summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-06-11 18:35:41 -0700
committerDianne Hackborn <hackbod@google.com>2012-06-11 18:35:41 -0700
commit9d0908919a65a4f3158a8fc50aaf320dfed36278 (patch)
treeb7d76e038cf66ff28138cfc214ad5a05f514f539 /core/java/android/view/ViewRootImpl.java
parentf9d80b6b940540b5d7be22ae310e047fcd2472a8 (diff)
Fix issue #6634325: View.setKeepScreenOn and...
...MediaPlayer.setScreenOnWhilePlaying seem broken We need to correctly clear the keep screen on flag when the view hierarchy request is gone... and to do that, we need to keep the actual state of the flag requested by the app. Also when the app changes its state, we need to compute the proper value based on both the app request and any requests in the view hierarchy. Bug: 6634325 Change-Id: I060e9a34a10faffbaa77c06098cf21298bb4969f
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7eeb6d0c648f..cdc51d1bb40d 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -229,6 +229,7 @@ public final class ViewRootImpl implements ViewParent,
boolean mWindowsAnimating;
boolean mIsDrawing;
int mLastSystemUiVisibility;
+ int mClientWindowLayoutFlags;
// Pool of queued input events.
private static final int MAX_QUEUED_INPUT_EVENT_POOL_SIZE = 10;
@@ -485,6 +486,8 @@ public final class ViewRootImpl implements ViewParent,
mFallbackEventHandler.setView(view);
mWindowAttributes.copyFrom(attrs);
attrs = mWindowAttributes;
+ // Keep track of the actual window flags supplied by the client.
+ mClientWindowLayoutFlags = attrs.flags;
setAccessibilityFocusedHost(null);
@@ -760,6 +763,8 @@ public final class ViewRootImpl implements ViewParent,
void setLayoutParams(WindowManager.LayoutParams attrs, boolean newView) {
synchronized (this) {
int oldSoftInputMode = mWindowAttributes.softInputMode;
+ // Keep track of the actual window flags supplied by the client.
+ mClientWindowLayoutFlags = attrs.flags;
// preserve compatible window flag if exists.
int compatibleWindowFlag =
mWindowAttributes.flags & WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
@@ -768,7 +773,9 @@ public final class ViewRootImpl implements ViewParent,
attrs.subtreeSystemUiVisibility = mWindowAttributes.subtreeSystemUiVisibility;
mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
mWindowAttributes.flags |= compatibleWindowFlag;
-
+
+ applyKeepScreenOnFlag(mWindowAttributes);
+
if (newView) {
mSoftInputMode = attrs.softInputMode;
requestLayout();
@@ -1000,6 +1007,18 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ private void applyKeepScreenOnFlag(WindowManager.LayoutParams params) {
+ // Update window's global keep screen on flag: if a view has requested
+ // that the screen be kept on, then it is always set; otherwise, it is
+ // set to whatever the client last requested for the global state.
+ if (mAttachInfo.mKeepScreenOn) {
+ params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ } else {
+ params.flags = (params.flags&~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
+ | (mClientWindowLayoutFlags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+ }
+
private boolean collectViewAttributes() {
final View.AttachInfo attachInfo = mAttachInfo;
if (attachInfo.mRecomputeGlobalAttributes) {
@@ -1017,9 +1036,7 @@ public final class ViewRootImpl implements ViewParent,
|| attachInfo.mSystemUiVisibility != oldVis
|| attachInfo.mHasSystemUiListeners != oldHasSystemUiListeners) {
WindowManager.LayoutParams params = mWindowAttributes;
- if (attachInfo.mKeepScreenOn) {
- params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
- }
+ applyKeepScreenOnFlag(params);
params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
mView.dispatchWindowSystemUiVisiblityChanged(attachInfo.mSystemUiVisibility);