diff options
author | Joe LaPenna <jlapenna@google.com> | 2015-02-24 00:37:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-24 00:37:15 +0000 |
commit | c0c395162ff14b83694158663470ad60e065d9a9 (patch) | |
tree | 4f85f84611d7b2638d8d2b404bba892e2bb19645 /core/java/android/view | |
parent | 8f022fd323063f9cebb481be650db40cf5e486f3 (diff) | |
parent | c2932a1be3e320679034212698aff376d5104dbe (diff) | |
download | frameworks_base-c0c395162ff14b83694158663470ad60e065d9a9.zip frameworks_base-c0c395162ff14b83694158663470ad60e065d9a9.tar.gz frameworks_base-c0c395162ff14b83694158663470ad60e065d9a9.tar.bz2 |
Merge "Hold a wake lock while dozing when display updates are pending." into lmp-mr1-modular-dev
Diffstat (limited to 'core/java/android/view')
-rw-r--r-- | core/java/android/view/IWindowSession.aidl | 15 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 16 |
2 files changed, 31 insertions, 0 deletions
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..90c2bd1 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -47,6 +47,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; +import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; @@ -831,6 +832,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 +863,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 +1050,7 @@ public final class ViewRootImpl implements ViewParent, scheduleConsumeBatchedInput(); } notifyRendererOfFramePending(); + pokeDrawLockIfNeeded(); } } |