diff options
| author | 2013-05-13 12:46:41 -0400 | |
|---|---|---|
| committer | 2013-05-13 17:24:24 -0400 | |
| commit | 04db1762fb75a3938dda34537626c41c8e97d9c5 (patch) | |
| tree | 7efffabc21e457dda69d42cd0e9f9e12b8f05482 | |
| parent | 155d965ab099601bb6646f3b7006f411b64ea601 (diff) | |
Window manager cleanup.
Specifically:
- Fix policy vs wm lock management issues.
- Share runnable to avoid allocation.
- Remove unused noop runnable.
- Make sure to handle status bar = null case.
- Fix javadoc typo.
Bug: 8890313
Change-Id: I242eaef8e946025f6885d6dba3225722fb0ca7ce
3 files changed, 35 insertions, 30 deletions
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index b9f9e8056ef1..6a35f20ef53f 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -420,6 +420,11 @@ public interface WindowManagerPolicy { public void shutdown(boolean confirm); public void rebootSafeMode(boolean confirm); + + /** + * Return the window manager lock needed to correctly call "Lw" methods. + */ + public Object getWindowManagerLock(); } /** Window has been added to the screen. */ diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 08fb48f96ee2..1fab35f2252a 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -114,7 +114,7 @@ import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; * WindowManagerPolicy implementation for the Android phone UI. This * introduces a new method suffix, Lp, for an internal lock of the * PhoneWindowManager. This is used to protect some internal state, and - * can be acquired with either thw Lw and Li lock held, so has the restrictions + * can be acquired with either the Lw and Li lock held, so has the restrictions * of both of those when held. */ public class PhoneWindowManager implements WindowManagerPolicy { @@ -921,18 +921,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { new SystemGestures.Callbacks() { @Override public void onSwipeFromTop() { - showHideybars(mStatusBar); + if (mStatusBar != null) { + requestHideybars(mStatusBar); + } } @Override public void onSwipeFromBottom() { - if (mNavigationBarOnBottom) { - showHideybars(mNavigationBar); + if (mNavigationBar != null && mNavigationBarOnBottom) { + requestHideybars(mNavigationBar); } } @Override public void onSwipeFromRight() { - if (!mNavigationBarOnBottom) { - showHideybars(mNavigationBar); + if (mNavigationBar != null && !mNavigationBarOnBottom) { + requestHideybars(mNavigationBar); } } @Override @@ -2436,13 +2438,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - /** - * A delayed callback use to determine when it is okay to re-allow applications - * to use certain system UI flags. This is used to prevent applications from - * spamming system UI changes that prevent the navigation bar from being shown. - */ - final Runnable mAllowSystemUiDelay = new Runnable() { - @Override public void run() { + private final Runnable mClearHideNavigationFlag = new Runnable() { + @Override + public void run() { + synchronized (mWindowManagerFuncs.getWindowManagerLock()) { + // Clear flags. + mForceClearedSystemUiFlags &= + ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + } + mWindowManagerFuncs.reevaluateStatusBarVisibility(); } }; @@ -2466,7 +2470,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { // When the user taps down, we re-show the nav bar. boolean changed = false; - synchronized (mLock) { + synchronized (mWindowManagerFuncs.getWindowManagerLock()) { // Any user activity always causes us to show the // navigation controls, if they had been hidden. // We also clear the low profile and only content @@ -2488,16 +2492,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mForceClearedSystemUiFlags != newVal) { mForceClearedSystemUiFlags = newVal; changed = true; - mHandler.postDelayed(new Runnable() { - @Override public void run() { - synchronized (mLock) { - // Clear flags. - mForceClearedSystemUiFlags &= - ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - } - mWindowManagerFuncs.reevaluateStatusBarVisibility(); - } - }, 1000); + mHandler.postDelayed(mClearHideNavigationFlag, 1000); } } if (changed) { @@ -2521,7 +2516,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public int adjustSystemUiVisibilityLw(int visibility) { - if (mStatusHideybar == HIDEYBAR_SHOWING && + if (mStatusBar != null && mStatusHideybar == HIDEYBAR_SHOWING && 0 == (visibility & View.STATUS_BAR_OVERLAY)) { mStatusHideybar = HIDEYBAR_HIDING; mStatusBar.hideLw(true); @@ -4134,7 +4129,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // force a re-application of focused window sysui visibility. // the window may never have been shown for this user // e.g. the keyguard when going through the new-user setup flow - synchronized(mLock) { + synchronized (mWindowManagerFuncs.getWindowManagerLock()) { mLastSystemUiFlags = 0; updateSystemUiVisibilityLw(); } @@ -4142,8 +4137,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }; - private void showHideybars(WindowState swipeTarget) { - synchronized(mLock) { + private void requestHideybars(WindowState swipeTarget) { + synchronized (mWindowManagerFuncs.getWindowManagerLock()) { boolean sb = checkShowHideybar("status", mStatusHideybar, mStatusBar); boolean nb = checkShowHideybar("navigation", mNavigationHideybar, mNavigationBar); if (sb || nb) { @@ -5056,9 +5051,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { || (hideStatusBarSysui && overlayAllowed) || statusBarHasFocus; - if (!statusHideyAllowed) { + if (mStatusBar == null || !statusHideyAllowed) { mStatusHideybar = HIDEYBAR_NONE; - if (hideStatusBarSysui) { + if (mStatusBar != null && hideStatusBarSysui) { // clear the clearable flags instead int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; if (newVal != mResettingSystemUiFlags) { diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 1c26dc33b285..da1336bb370d 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -10855,4 +10855,9 @@ public class WindowManagerService extends IWindowManager.Stub displayContent.updateDisplayInfo(); } } + + @Override + public Object getWindowManagerLock() { + return mWindowMap; + } } |