diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ActivityView.java | 96 | ||||
| -rw-r--r-- | core/java/android/app/IActivityContainer.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/app/WallpaperManager.java | 41 | ||||
| -rw-r--r-- | core/java/android/bluetooth/IBluetooth.aidl | 4 | ||||
| -rw-r--r-- | core/java/android/hardware/Sensor.java | 23 | ||||
| -rw-r--r-- | core/java/android/hardware/SensorManager.java | 3 | ||||
| -rw-r--r-- | core/java/android/hardware/display/DisplayManagerInternal.java | 13 | ||||
| -rw-r--r-- | core/java/android/net/SSLCertificateSocketFactory.java | 2 | ||||
| -rw-r--r-- | core/java/android/net/http/HttpsConnection.java | 2 | ||||
| -rw-r--r-- | core/java/android/os/PowerManager.java | 36 | ||||
| -rw-r--r-- | core/java/android/provider/Settings.java | 1 | ||||
| -rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 39 | ||||
| -rw-r--r-- | core/java/android/view/IWindowSession.aidl | 15 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 34 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 15 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 15 |
16 files changed, 234 insertions, 107 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index 94ea2c5..fecaf6f 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -16,6 +16,8 @@ package android.app; +import static android.app.ActivityManager.START_CANCELED; + import android.content.Context; import android.content.ContextWrapper; import android.content.IIntentSender; @@ -23,6 +25,7 @@ import android.content.Intent; import android.content.IntentSender; import android.graphics.SurfaceTexture; import android.os.IBinder; +import android.os.OperationCanceledException; import android.os.RemoteException; import android.util.AttributeSet; import android.util.DisplayMetrics; @@ -55,10 +58,6 @@ public class ActivityView extends ViewGroup { private int mLastVisibility; private ActivityViewCallback mActivityViewCallback; - // Only one IIntentSender or Intent may be queued at a time. Most recent one wins. - IIntentSender mQueuedPendingIntent; - Intent mQueuedIntent; - public ActivityView(Context context) { this(context, null); } @@ -167,14 +166,13 @@ public class ActivityView extends ViewGroup { if (mActivityContainer == null) { throw new IllegalStateException("Attempt to call startActivity after release"); } + if (mSurface == null) { + throw new IllegalStateException("Surface not yet created."); + } if (DEBUG) Log.v(TAG, "startActivity(): intent=" + intent + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); - if (mSurface != null) { - mActivityContainer.startActivity(intent); - } else { - mActivityContainer.checkEmbeddedAllowed(intent); - mQueuedIntent = intent; - mQueuedPendingIntent = null; + if (mActivityContainer.startActivity(intent) == START_CANCELED) { + throw new OperationCanceledException(); } } @@ -182,15 +180,14 @@ public class ActivityView extends ViewGroup { if (mActivityContainer == null) { throw new IllegalStateException("Attempt to call startActivity after release"); } + if (mSurface == null) { + throw new IllegalStateException("Surface not yet created."); + } if (DEBUG) Log.v(TAG, "startActivityIntentSender(): intentSender=" + intentSender + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); final IIntentSender iIntentSender = intentSender.getTarget(); - if (mSurface != null) { - mActivityContainer.startActivityIntentSender(iIntentSender); - } else { - mActivityContainer.checkEmbeddedAllowedIntentSender(iIntentSender); - mQueuedPendingIntent = iIntentSender; - mQueuedIntent = null; + if (mActivityContainer.startActivityIntentSender(iIntentSender) == START_CANCELED) { + throw new OperationCanceledException(); } } @@ -198,15 +195,14 @@ public class ActivityView extends ViewGroup { if (mActivityContainer == null) { throw new IllegalStateException("Attempt to call startActivity after release"); } + if (mSurface == null) { + throw new IllegalStateException("Surface not yet created."); + } if (DEBUG) Log.v(TAG, "startActivityPendingIntent(): PendingIntent=" + pendingIntent + " " + (isAttachedToDisplay() ? "" : "not") + " attached"); final IIntentSender iIntentSender = pendingIntent.getTarget(); - if (mSurface != null) { - mActivityContainer.startActivityIntentSender(iIntentSender); - } else { - mActivityContainer.checkEmbeddedAllowedIntentSender(iIntentSender); - mQueuedPendingIntent = iIntentSender; - mQueuedIntent = null; + if (mActivityContainer.startActivityIntentSender(iIntentSender) == START_CANCELED) { + throw new OperationCanceledException(); } } @@ -243,26 +239,24 @@ public class ActivityView extends ViewGroup { mSurface = null; throw new RuntimeException("ActivityView: Unable to create ActivityContainer. " + e); } - - if (DEBUG) Log.v(TAG, "attachToSurfaceWhenReady: " + (mQueuedIntent != null || - mQueuedPendingIntent != null ? "" : "no") + " queued intent"); - if (mQueuedIntent != null) { - mActivityContainer.startActivity(mQueuedIntent); - mQueuedIntent = null; - } else if (mQueuedPendingIntent != null) { - mActivityContainer.startActivityIntentSender(mQueuedPendingIntent); - mQueuedPendingIntent = null; - } } /** * Set the callback to use to report certain state changes. - * @param callback The callback to report events to. + * + * Note: If the surface has been created prior to this call being made, then + * ActivityViewCallback.onSurfaceAvailable will be called from within setCallback. + * + * @param callback The callback to report events to. * * @see ActivityViewCallback */ public void setCallback(ActivityViewCallback callback) { mActivityViewCallback = callback; + + if (mSurface != null) { + mActivityViewCallback.onSurfaceAvailable(this); + } } public static abstract class ActivityViewCallback { @@ -272,6 +266,16 @@ public class ActivityView extends ViewGroup { * have at most one callback registered. */ public abstract void onAllActivitiesComplete(ActivityView view); + /** + * Called when the surface is ready to be drawn to. Calling startActivity prior to this + * callback will result in an IllegalStateException. + */ + public abstract void onSurfaceAvailable(ActivityView view); + /** + * Called when the surface has been removed. Calling startActivity after this callback + * will result in an IllegalStateException. + */ + public abstract void onSurfaceDestroyed(ActivityView view); } private class ActivityViewSurfaceTextureListener implements SurfaceTextureListener { @@ -286,6 +290,9 @@ public class ActivityView extends ViewGroup { mWidth = width; mHeight = height; attachToSurfaceWhenReady(); + if (mActivityViewCallback != null) { + mActivityViewCallback.onSurfaceAvailable(ActivityView.this); + } } @Override @@ -311,6 +318,9 @@ public class ActivityView extends ViewGroup { throw new RuntimeException( "ActivityView: Unable to set surface of ActivityContainer. " + e); } + if (mActivityViewCallback != null) { + mActivityViewCallback.onSurfaceDestroyed(ActivityView.this); + } return true; } @@ -325,7 +335,7 @@ public class ActivityView extends ViewGroup { private final WeakReference<ActivityView> mActivityViewWeakReference; ActivityContainerCallback(ActivityView activityView) { - mActivityViewWeakReference = new WeakReference<ActivityView>(activityView); + mActivityViewWeakReference = new WeakReference<>(activityView); } @Override @@ -391,24 +401,6 @@ public class ActivityView extends ViewGroup { } } - void checkEmbeddedAllowed(Intent intent) { - try { - mIActivityContainer.checkEmbeddedAllowed(intent); - } catch (RemoteException e) { - throw new RuntimeException( - "ActivityView: Unable to startActivity from Intent. " + e); - } - } - - void checkEmbeddedAllowedIntentSender(IIntentSender intentSender) { - try { - mIActivityContainer.checkEmbeddedAllowedIntentSender(intentSender); - } catch (RemoteException e) { - throw new RuntimeException( - "ActivityView: Unable to startActivity from IntentSender. " + e); - } - } - int getDisplayId() { try { return mIActivityContainer.getDisplayId(); diff --git a/core/java/android/app/IActivityContainer.aidl b/core/java/android/app/IActivityContainer.aidl index 52884f7..cc3b10c 100644 --- a/core/java/android/app/IActivityContainer.aidl +++ b/core/java/android/app/IActivityContainer.aidl @@ -29,8 +29,6 @@ interface IActivityContainer { void setSurface(in Surface surface, int width, int height, int density); int startActivity(in Intent intent); int startActivityIntentSender(in IIntentSender intentSender); - void checkEmbeddedAllowed(in Intent intent); - void checkEmbeddedAllowedIntentSender(in IIntentSender intentSender); int getDisplayId(); boolean injectEvent(in InputEvent event); void release(); diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index 8bfe6d3..90d84ee 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -994,6 +994,47 @@ public class WallpaperManager { } /** + * Clear the wallpaper. + * + * @hide + */ + @SystemApi + public void clearWallpaper() { + if (sGlobals.mService == null) { + Log.w(TAG, "WallpaperService not running"); + return; + } + try { + sGlobals.mService.clearWallpaper(); + } catch (RemoteException e) { + // Ignore + } + } + + /** + * Set the live wallpaper. + * + * This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT + * permission. + * + * @hide + */ + @SystemApi + public boolean setWallpaperComponent(ComponentName name) { + if (sGlobals.mService == null) { + Log.w(TAG, "WallpaperService not running"); + return false; + } + try { + sGlobals.mService.setWallpaperComponent(name); + return true; + } catch (RemoteException e) { + // Ignore + } + return false; + } + + /** * Set the position of the current wallpaper within any larger space, when * that wallpaper is visible behind the given window. The X and Y offsets * are floating point numbers ranging from 0 to 1, representing where the diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index dabb1ce..c6f238e 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -99,6 +99,6 @@ interface IBluetooth void getActivityEnergyInfoFromController(); BluetoothActivityEnergyInfo reportActivityInfo(); - // for dumpsys support - String dump(); + // For dumpsys support + void dump(in ParcelFileDescriptor fd); } diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java index cf6a779..fa5e9d2 100644 --- a/core/java/android/hardware/Sensor.java +++ b/core/java/android/hardware/Sensor.java @@ -18,6 +18,7 @@ package android.hardware; import android.os.Build; +import android.annotation.SystemApi; /** * Class representing a sensor. Use {@link SensorManager#getSensorList} to get @@ -511,6 +512,27 @@ public final class Sensor { */ public static final String STRING_TYPE_PICK_UP_GESTURE = "android.sensor.pick_up_gesture"; + /** + * A constant describing a wrist tilt gesture sensor. + * + * A sensor of this type triggers when the device face is tilted towards the user. + * The only allowed return value is 1.0. + * This sensor remains active until disabled. + * + * @hide This sensor is expected to only be used by the system ui + */ + @SystemApi + public static final int TYPE_WRIST_TILT_GESTURE = 26; + + /** + * A constant string describing a wrist tilt gesture sensor. + * + * @hide This sensor is expected to only be used by the system ui + * @see #TYPE_WRIST_TILT_GESTURE + */ + @SystemApi + public static final String STRING_TYPE_WRIST_TILT_GESTURE = "android.sensor.wrist_tilt_gesture"; + /** * A constant describing all sensor types. */ @@ -591,6 +613,7 @@ public final class Sensor { 1, // SENSOR_TYPE_WAKE_GESTURE 1, // SENSOR_TYPE_GLANCE_GESTURE 1, // SENSOR_TYPE_PICK_UP_GESTURE + 1, // SENSOR_TYPE_WRIST_TILT_GESTURE }; /** diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java index e4e5a8c..34b895b 100644 --- a/core/java/android/hardware/SensorManager.java +++ b/core/java/android/hardware/SensorManager.java @@ -451,7 +451,8 @@ public abstract class SensorManager { // non_wake-up version. if (type == Sensor.TYPE_PROXIMITY || type == Sensor.TYPE_SIGNIFICANT_MOTION || type == Sensor.TYPE_TILT_DETECTOR || type == Sensor.TYPE_WAKE_GESTURE || - type == Sensor.TYPE_GLANCE_GESTURE || type == Sensor.TYPE_PICK_UP_GESTURE) { + type == Sensor.TYPE_GLANCE_GESTURE || type == Sensor.TYPE_PICK_UP_GESTURE || + type == Sensor.TYPE_WRIST_TILT_GESTURE) { wakeUpSensor = true; } diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java index bb162153..adab9be 100644 --- a/core/java/android/hardware/display/DisplayManagerInternal.java +++ b/core/java/android/hardware/display/DisplayManagerInternal.java @@ -132,6 +132,19 @@ public abstract class DisplayManagerInternal { float requestedRefreshRate, boolean inTraversal); /** + * Applies an offset to the contents of a display, for example to avoid burn-in. + * <p> + * TODO: Technically this should be associated with a physical rather than logical + * display but this is good enough for now. + * </p> + * + * @param displayId The logical display id to update. + * @param x The X offset by which to shift the contents of the display. + * @param y The Y offset by which to shift the contents of the display. + */ + public abstract void setDisplayOffsets(int displayId, int x, int y); + + /** * Describes the requested power state of the display. * * This object is intended to describe the general characteristics of the diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java index c15e6e5..6654577 100644 --- a/core/java/android/net/SSLCertificateSocketFactory.java +++ b/core/java/android/net/SSLCertificateSocketFactory.java @@ -208,7 +208,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { private SSLSocketFactory makeSocketFactory( KeyManager[] keyManagers, TrustManager[] trustManagers) { try { - OpenSSLContextImpl sslContext = new OpenSSLContextImpl(); + OpenSSLContextImpl sslContext = OpenSSLContextImpl.getPreferred(); sslContext.engineInit(keyManagers, trustManagers, null); sslContext.engineGetClientSessionContext().setPersistentCache(mSessionCache); return sslContext.engineGetSocketFactory(); diff --git a/core/java/android/net/http/HttpsConnection.java b/core/java/android/net/http/HttpsConnection.java index 6bf01e2..a8674de 100644 --- a/core/java/android/net/http/HttpsConnection.java +++ b/core/java/android/net/http/HttpsConnection.java @@ -79,7 +79,7 @@ public class HttpsConnection extends Connection { cache = FileClientSessionCache.usingDirectory(sessionDir); } - OpenSSLContextImpl sslContext = new OpenSSLContextImpl(); + OpenSSLContextImpl sslContext = OpenSSLContextImpl.getPreferred(); // here, trust managers is a single trust-all manager TrustManager[] trustManagers = new TrustManager[] { diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 8307d9b..de970cb 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -205,6 +205,20 @@ public final class PowerManager { public static final int DOZE_WAKE_LOCK = 0x00000040; /** + * Wake lock level: Keep the device awake enough to allow drawing to occur. + * <p> + * This is used by the window manager to allow applications to draw while the + * system is dozing. It currently has no effect unless the power manager is in + * the dozing state. + * </p><p> + * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission. + * </p> + * + * {@hide} + */ + public static final int DRAW_WAKE_LOCK = 0x00000080; + + /** * Mask for the wake lock level component of a combined wake lock level and flags integer. * * @hide @@ -350,6 +364,12 @@ public final class PowerManager { public static final int GO_TO_SLEEP_REASON_HDMI = 5; /** + * Go to sleep reason code: Going to sleep due to the sleep button being pressed. + * @hide + */ + public static final int GO_TO_SLEEP_REASON_SLEEP_BUTTON = 6; + + /** * Go to sleep flag: Skip dozing state and directly go to full sleep. * @hide */ @@ -489,6 +509,7 @@ public final class PowerManager { case FULL_WAKE_LOCK: case PROXIMITY_SCREEN_OFF_WAKE_LOCK: case DOZE_WAKE_LOCK: + case DRAW_WAKE_LOCK: break; default: throw new IllegalArgumentException("Must specify a valid wake lock level."); @@ -835,6 +856,21 @@ public final class PowerManager { } /** + * Turn off the device. + * + * @param confirm If true, shows a shutdown confirmation dialog. + * @param wait If true, this call waits for the shutdown to complete and does not return. + * + * @hide + */ + public void shutdown(boolean confirm, boolean wait) { + try { + mService.shutdown(confirm, wait); + } catch (RemoteException e) { + } + } + + /** * Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes. * This broadcast is only sent to registered receivers. */ diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 838686a..92349338 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5101,6 +5101,7 @@ public final class Settings { * Whether Theater Mode is on. * {@hide} */ + @SystemApi public static final String THEATER_MODE_ON = "theater_mode_on"; /** diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 9496b53..d46b6f5 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -17,15 +17,12 @@ package android.service.wallpaper; import android.content.res.TypedArray; -import android.os.Build; import android.os.SystemProperties; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.ViewRootImpl; import android.view.WindowInsets; import com.android.internal.R; import com.android.internal.os.HandlerCaller; +import com.android.internal.util.ScreenShapeHelper; import com.android.internal.view.BaseIWindow; import com.android.internal.view.BaseSurfaceHolder; @@ -64,8 +61,6 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; -import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; - /** * A wallpaper service is responsible for showing a live wallpaper behind * applications that would like to sit on top of it. This service object @@ -160,7 +155,7 @@ public abstract class WallpaperService extends Service { WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS; int mCurWindowFlags = mWindowFlags; int mCurWindowPrivateFlags = mWindowPrivateFlags; - TypedValue mOutsetBottom; + int mOutsetBottomPx; final Rect mVisibleInsets = new Rect(); final Rect mWinFrame = new Rect(); final Rect mOverscanInsets = new Rect(); @@ -173,8 +168,6 @@ public abstract class WallpaperService extends Service { final Rect mFinalStableInsets = new Rect(); final Configuration mConfiguration = new Configuration(); - private boolean mIsEmulator; - private boolean mIsCircularEmulator; private boolean mWindowIsRound; final WindowManager.LayoutParams mLayout @@ -639,23 +632,13 @@ public abstract class WallpaperService extends Service { final Display display = windowService.getDefaultDisplay(); final boolean shouldUseBottomOutset = display.getDisplayId() == Display.DEFAULT_DISPLAY; - if (shouldUseBottomOutset && windowStyle.hasValue( - R.styleable.Window_windowOutsetBottom)) { - if (mOutsetBottom == null) mOutsetBottom = new TypedValue(); - windowStyle.getValue(R.styleable.Window_windowOutsetBottom, - mOutsetBottom); - } else { - mOutsetBottom = null; + if (shouldUseBottomOutset) { + mOutsetBottomPx = ScreenShapeHelper.getWindowOutsetBottomPx( + getResources().getDisplayMetrics(), windowStyle); } - mWindowIsRound = getResources().getBoolean( - com.android.internal.R.bool.config_windowIsRound); + mWindowIsRound = ScreenShapeHelper.getWindowIsRound(getResources()); windowStyle.recycle(); - // detect emulator - mIsEmulator = Build.HARDWARE.contains("goldfish"); - mIsCircularEmulator = SystemProperties.getBoolean( - ViewRootImpl.PROPERTY_EMULATOR_CIRCULAR, false); - // Add window mLayout.type = mIWallpaperEngine.mWindowType; mLayout.gravity = Gravity.START|Gravity.TOP; @@ -785,18 +768,14 @@ public abstract class WallpaperService extends Service { mDispatchedOverscanInsets.set(mOverscanInsets); mDispatchedContentInsets.set(mContentInsets); mDispatchedStableInsets.set(mStableInsets); - final boolean isRound = (mIsEmulator && mIsCircularEmulator) - || mWindowIsRound; mFinalSystemInsets.set(mDispatchedOverscanInsets); mFinalStableInsets.set(mDispatchedStableInsets); - if (mOutsetBottom != null) { - final DisplayMetrics metrics = getResources().getDisplayMetrics(); + if (mOutsetBottomPx != 0) { mFinalSystemInsets.bottom = - ( (int) mOutsetBottom.getDimension(metrics) ) - + mIWallpaperEngine.mDisplayPadding.bottom; + mIWallpaperEngine.mDisplayPadding.bottom + mOutsetBottomPx; } WindowInsets insets = new WindowInsets(mFinalSystemInsets, - null, mFinalStableInsets, isRound); + null, mFinalStableInsets, mWindowIsRound); onApplyWindowInsets(insets); } diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index 7b13e84..63e1a85 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -197,4 +197,19 @@ interface IWindowSession { void onRectangleOnScreenRequested(IBinder token, in Rect rectangle); IWindowId getWindowId(IBinder window); + + /** + * When the system is dozing in a low-power partially suspended state, pokes a short + * lived wake lock and ensures that the display is ready to accept the next frame + * of content drawn in the window. + * + * This mechanism is bound to the window rather than to the display manager or the + * power manager so that the system can ensure that the window is actually visible + * and prevent runaway applications from draining the battery. This is similar to how + * FLAG_KEEP_SCREEN_ON works. + * + * This method is synchronous because it may need to acquire a wake lock before returning. + * The assumption is that this method will be called rather infrequently. + */ + void pokeDrawLock(IBinder window); } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index e4d82b1..113ad8d 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -40,7 +40,6 @@ import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; import android.media.AudioManager; import android.os.Binder; -import android.os.Build; import android.os.Bundle; import android.os.Debug; import android.os.Handler; @@ -77,6 +76,7 @@ import android.widget.Scroller; import com.android.internal.R; import com.android.internal.os.SomeArgs; import com.android.internal.policy.PolicyManager; +import com.android.internal.util.ScreenShapeHelper; import com.android.internal.view.BaseSurfaceHolder; import com.android.internal.view.RootViewSurfaceTaker; @@ -120,8 +120,10 @@ public final class ViewRootImpl implements ViewParent, private static final String PROPERTY_PROFILE_RENDERING = "viewroot.profile_rendering"; private static final String PROPERTY_MEDIA_DISABLED = "config.disable_media"; - // property used by emulator to determine display shape + // properties used by emulator to determine display shape public static final String PROPERTY_EMULATOR_CIRCULAR = "ro.emulator.circular"; + public static final String PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX = + "ro.emu.win_outset_bottom_px"; /** * Maximum time we allow the user to roll the trackball enough to generate @@ -332,8 +334,6 @@ public final class ViewRootImpl implements ViewParent, /** Set to true once doDie() has been called. */ private boolean mRemoved; - private boolean mIsEmulator; - private boolean mIsCircularEmulator; private final boolean mWindowIsRound; /** @@ -390,8 +390,7 @@ public final class ViewRootImpl implements ViewParent, mChoreographer = Choreographer.getInstance(); mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE); loadSystemProperties(); - mWindowIsRound = context.getResources().getBoolean( - com.android.internal.R.bool.config_windowIsRound); + mWindowIsRound = ScreenShapeHelper.getWindowIsRound(context.getResources()); } public static void addFirstDrawHandler(Runnable callback) { @@ -831,6 +830,7 @@ public final class ViewRootImpl implements ViewParent, final int newDisplayState = mDisplay.getState(); if (oldDisplayState != newDisplayState) { mAttachInfo.mDisplayState = newDisplayState; + pokeDrawLockIfNeeded(); if (oldDisplayState != Display.STATE_UNKNOWN) { final int oldScreenState = toViewScreenState(oldDisplayState); final int newScreenState = toViewScreenState(newDisplayState); @@ -861,6 +861,19 @@ public final class ViewRootImpl implements ViewParent, } }; + void pokeDrawLockIfNeeded() { + final int displayState = mAttachInfo.mDisplayState; + if (mView != null && mAdded && mTraversalScheduled + && (displayState == Display.STATE_DOZE + || displayState == Display.STATE_DOZE_SUSPEND)) { + try { + mWindowSession.pokeDrawLock(mWindow); + } catch (RemoteException ex) { + // System server died, oh well. + } + } + } + @Override public void requestFitSystemWindows() { checkThread(); @@ -1035,6 +1048,7 @@ public final class ViewRootImpl implements ViewParent, scheduleConsumeBatchedInput(); } notifyRendererOfFramePending(); + pokeDrawLockIfNeeded(); } } @@ -1208,10 +1222,9 @@ public final class ViewRootImpl implements ViewParent, void dispatchApplyInsets(View host) { mDispatchContentInsets.set(mAttachInfo.mContentInsets); mDispatchStableInsets.set(mAttachInfo.mStableInsets); - final boolean isRound = (mIsEmulator && mIsCircularEmulator) || mWindowIsRound; host.dispatchApplyWindowInsets(new WindowInsets( mDispatchContentInsets, null /* windowDecorInsets */, - mDispatchStableInsets, isRound)); + mDispatchStableInsets, mWindowIsRound)); } private void performTraversals() { @@ -5555,11 +5568,6 @@ public final class ViewRootImpl implements ViewParent, mHandler.sendEmptyMessageDelayed(MSG_INVALIDATE_WORLD, 200); } } - - // detect emulator - mIsEmulator = Build.HARDWARE.contains("goldfish"); - mIsCircularEmulator = - SystemProperties.getBoolean(PROPERTY_EMULATOR_CIRCULAR, false); } }); } diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 094a8a1..84434f7 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -16,6 +16,7 @@ package android.view; +import android.annotation.SystemApi; import android.app.Presentation; import android.content.Context; import android.content.pm.ActivityInfo; @@ -1590,7 +1591,19 @@ public interface WindowManager extends ViewManager { public final CharSequence getTitle() { return mTitle; } - + + /** @hide */ + @SystemApi + public final void setUserActivityTimeout(long timeout) { + userActivityTimeout = timeout; + } + + /** @hide */ + @SystemApi + public final long getUserActivityTimeout() { + return userActivityTimeout; + } + public int describeContents() { return 0; } diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 94f3e7a..780ca99 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -17,6 +17,7 @@ package android.view; import android.annotation.IntDef; +import android.annotation.SystemApi; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.CompatibilityInfo; @@ -105,6 +106,13 @@ public interface WindowManagerPolicy { public final static String EXTRA_HDMI_PLUGGED_STATE = "state"; /** + * Set to {@code true} when intent was invoked from pressing the home key. + * @hide + */ + @SystemApi + public static final String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY"; + + /** * Pass this event to the user / app. To be returned from * {@link #interceptKeyBeforeQueueing}. */ @@ -901,13 +909,12 @@ public interface WindowManagerPolicy { /** * Called following layout of all window to apply policy to each window. - * + * * @param win The window being positioned. - * @param attrs The LayoutParams of the window. - * @param attached For sub-windows, the window it is attached to. Otherwise null. + * @param attrs The LayoutParams of the window. */ public void applyPostLayoutPolicyLw(WindowState win, - WindowManager.LayoutParams attrs, WindowState attached); + WindowManager.LayoutParams attrs); /** * Called following layout of all windows and after policy has been applied |
