diff options
author | Joe Onorato <joeo@google.com> | 2011-01-23 17:53:23 -0800 |
---|---|---|
committer | Joe Onorato <joeo@google.com> | 2011-01-23 19:22:52 -0800 |
commit | 664644d9e012aa2a28ac96f305b1ce6499ec8806 (patch) | |
tree | d8db43b09de516fefd82adf4fc4ec22417dda648 /policy | |
parent | fac86056b285bf59c1c3e774f1cb9f6de0be59ba (diff) | |
download | frameworks_base-664644d9e012aa2a28ac96f305b1ce6499ec8806.zip frameworks_base-664644d9e012aa2a28ac96f305b1ce6499ec8806.tar.gz frameworks_base-664644d9e012aa2a28ac96f305b1ce6499ec8806.tar.bz2 |
visibility ("lights out") API.
1. Views may setSystemUiVisibility() to recommend that
the system chrome (status bar or other UI) show or hide
itself. (This functionality was previously available only
via the FLAG_FULLSCREEN window flag for some SystemUI
implementations.)
2. Views may register a OnSystemUiVisibilityChangedListener
on a view, and find out when the system UI actually
appears or disappears, allowing apps to coordinate the
appearance of their own UI if desired.
Bug: 3241144
Change-Id: Ia1758d94099182d49a1e3688ea2738ae4995b829
Diffstat (limited to 'policy')
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 747242f..5567dfe 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -34,6 +34,7 @@ import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.PixelFormat; import android.graphics.Rect; +import android.os.Binder; import android.os.Build; import android.os.Handler; import android.os.IBinder; @@ -270,7 +271,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mPointerLocationMode = 0; PointerLocationView mPointerLocationView = null; InputChannel mPointerLocationInputChannel; - + + // The last window we were told about in focusChanged. + WindowState mFocusedWindow; + private final InputHandler mPointerLocationInputHandler = new BaseInputHandler() { @Override public void handleMotion(MotionEvent event, InputQueue.FinishedCallback finishedCallback) { @@ -1953,7 +1957,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { mKeyguardMediator.setHidden(false); } } - + + updateSystemUiVisibility(); + // update since mAllowLockscreenWhenOn might have changed updateLockScreenTimeout(); return changes; @@ -1993,6 +1999,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { return true; } + public void focusChanged(WindowState lastFocus, WindowState newFocus) { + mFocusedWindow = newFocus; + updateSystemUiVisibility(); + } + /** {@inheritDoc} */ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { // lid changed state @@ -2836,6 +2847,34 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mScreenOn; } + private void updateSystemUiVisibility() { + // If there is no window focused, there will be nobody to handle the events + // anyway, so just hang on in whatever state we're in until things settle down. + if (mFocusedWindow != null) { + final int visibility = mFocusedWindow.getAttrs().systemUiVisibility; + mHandler.post(new Runnable() { + public void run() { + if (mStatusBarService == null) { + mStatusBarService = IStatusBarService.Stub.asInterface( + ServiceManager.getService("statusbar")); + } + if (mStatusBarService != null) { + // need to assume status bar privileges to invoke lights on + long origId = Binder.clearCallingIdentity(); + try { + mStatusBarService.setSystemUiVisibility(visibility); + } catch (RemoteException e) { + // not much to be done + mStatusBarService = null; + } finally { + Binder.restoreCallingIdentity(origId); + } + } + } + }); + } + } + public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) { pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); pw.print(" mSystemRead="); pw.println(mSystemReady); |