diff options
Diffstat (limited to 'services/java/com/android/server/StatusBarManagerService.java')
| -rw-r--r-- | services/java/com/android/server/StatusBarManagerService.java | 147 |
1 files changed, 92 insertions, 55 deletions
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index bdaa3b0..5ada77b 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -53,11 +53,13 @@ import java.util.Map; * if they are local, that they just enqueue messages to not deadlock. */ public class StatusBarManagerService extends IStatusBarService.Stub + implements WindowManagerService.OnHardKeyboardStatusChangeListener { static final String TAG = "StatusBarManagerService"; static final boolean SPEW = false; final Context mContext; + final WindowManagerService mWindowManager; Handler mHandler = new Handler(); NotificationCallbacks mNotificationCallbacks; volatile IStatusBar mBar; @@ -67,14 +69,16 @@ public class StatusBarManagerService extends IStatusBarService.Stub // for disabling the status bar ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>(); + IBinder mSysUiVisToken = new Binder(); int mDisabled = 0; Object mLock = new Object(); // We usually call it lights out mode, but double negatives are annoying boolean mLightsOn = true; boolean mMenuVisible = false; - boolean mIMEButtonVisible = false; - IBinder mIMEToken = null; + int mImeWindowVis = 0; + int mImeBackDisposition; + IBinder mImeToken = null; private class DisableRecord implements IBinder.DeathRecipient { String pkg; @@ -101,8 +105,10 @@ public class StatusBarManagerService extends IStatusBarService.Stub /** * Construct the service, add the status bar view to the window manager */ - public StatusBarManagerService(Context context) { + public StatusBarManagerService(Context context, WindowManagerService windowManager) { mContext = context; + mWindowManager = windowManager; + mWindowManager.setOnHardKeyboardStatusChangeListener(this); final Resources res = context.getResources(); mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons)); @@ -140,25 +146,29 @@ public class StatusBarManagerService extends IStatusBarService.Stub public void disable(int what, IBinder token, String pkg) { enforceStatusBar(); + synchronized (mLock) { + disableLocked(what, token, pkg); + } + } + + private void disableLocked(int what, IBinder token, String pkg) { // It's important that the the callback and the call to mBar get done // in the same order when multiple threads are calling this function // so they are paired correctly. The messages on the handler will be // handled in the order they were enqueued, but will be outside the lock. - synchronized (mDisableRecords) { - manageDisableListLocked(what, token, pkg); - final int net = gatherDisableActionsLocked(); - if (net != mDisabled) { - mDisabled = net; - mHandler.post(new Runnable() { - public void run() { - mNotificationCallbacks.onSetDisabled(net); - } - }); - if (mBar != null) { - try { - mBar.disable(net); - } catch (RemoteException ex) { + manageDisableListLocked(what, token, pkg); + final int net = gatherDisableActionsLocked(); + if (net != mDisabled) { + mDisabled = net; + mHandler.post(new Runnable() { + public void run() { + mNotificationCallbacks.onSetDisabled(net); } + }); + if (mBar != null) { + try { + mBar.disable(net); + } catch (RemoteException ex) { } } } @@ -259,22 +269,25 @@ public class StatusBarManagerService extends IStatusBarService.Stub } } - public void setIMEButtonVisible(final IBinder token, final boolean visible) { + public void setImeWindowStatus(final IBinder token, final int vis, final int backDisposition) { enforceStatusBar(); - if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button"); + if (SPEW) { + Slog.d(TAG, "swetImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition); + } synchronized(mLock) { - // In case of IME change, we need to call up setIMEButtonVisible() regardless of - // mIMEButtonVisible because mIMEButtonVisible may not have been set to false when the + // In case of IME change, we need to call up setImeWindowStatus() regardless of + // mImeWindowVis because mImeWindowVis may not have been set to false when the // previous IME was destroyed. - mIMEButtonVisible = visible; - mIMEToken = token; + mImeWindowVis = vis; + mImeBackDisposition = backDisposition; + mImeToken = token; mHandler.post(new Runnable() { public void run() { if (mBar != null) { try { - mBar.setIMEButtonVisible(token, visible); + mBar.setImeWindowStatus(token, vis, backDisposition); } catch (RemoteException ex) { } } @@ -290,6 +303,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub synchronized (mLock) { final boolean lightsOn = (vis & View.STATUS_BAR_HIDDEN) == 0; updateLightsOnLocked(lightsOn); + disableLocked(vis & StatusBarManager.DISABLE_MASK, mSysUiVisToken, + "WindowManager.LayoutParams"); } } @@ -309,6 +324,28 @@ public class StatusBarManagerService extends IStatusBarService.Stub } } + public void setHardKeyboardEnabled(final boolean enabled) { + mHandler.post(new Runnable() { + public void run() { + mWindowManager.setHardKeyboardEnabled(enabled); + } + }); + } + + @Override + public void onHardKeyboardStatusChange(final boolean available, final boolean enabled) { + mHandler.post(new Runnable() { + public void run() { + if (mBar != null) { + try { + mBar.setHardKeyboardStatus(available, enabled); + } catch (RemoteException ex) { + } + } + } + }); + } + private void enforceStatusBar() { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR, "StatusBarManagerService"); @@ -324,7 +361,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub "StatusBarManagerService"); } - // ================================================================================ // Callbacks from the status bar service. // ================================================================================ @@ -348,9 +384,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub switches[0] = gatherDisableActionsLocked(); switches[1] = mLightsOn ? 1 : 0; switches[2] = mMenuVisible ? 1 : 0; - switches[3] = mIMEButtonVisible ? 1 : 0; - binders.add(mIMEToken); + switches[3] = mImeWindowVis; + switches[4] = mImeBackDisposition; + binders.add(mImeToken); } + switches[5] = mWindowManager.isHardKeyboardAvailable() ? 1 : 0; + switches[6] = mWindowManager.isHardKeyboardEnabled() ? 1 : 0; } /** @@ -447,37 +486,35 @@ public class StatusBarManagerService extends IStatusBarService.Stub Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg); } // update the list - synchronized (mDisableRecords) { - final int N = mDisableRecords.size(); - DisableRecord tok = null; - int i; - for (i=0; i<N; i++) { - DisableRecord t = mDisableRecords.get(i); - if (t.token == token) { - tok = t; - break; - } + final int N = mDisableRecords.size(); + DisableRecord tok = null; + int i; + for (i=0; i<N; i++) { + DisableRecord t = mDisableRecords.get(i); + if (t.token == token) { + tok = t; + break; + } + } + if (what == 0 || !token.isBinderAlive()) { + if (tok != null) { + mDisableRecords.remove(i); + tok.token.unlinkToDeath(tok, 0); } - if (what == 0 || !token.isBinderAlive()) { - if (tok != null) { - mDisableRecords.remove(i); - tok.token.unlinkToDeath(tok, 0); + } else { + if (tok == null) { + tok = new DisableRecord(); + try { + token.linkToDeath(tok, 0); } - } else { - if (tok == null) { - tok = new DisableRecord(); - try { - token.linkToDeath(tok, 0); - } - catch (RemoteException ex) { - return; // give up - } - mDisableRecords.add(tok); + catch (RemoteException ex) { + return; // give up } - tok.what = what; - tok.token = token; - tok.pkg = pkg; + mDisableRecords.add(tok); } + tok.what = what; + tok.token = token; + tok.pkg = pkg; } } @@ -518,7 +555,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub } } - synchronized (mDisableRecords) { + synchronized (mLock) { final int N = mDisableRecords.size(); pw.println(" mDisableRecords.size=" + N + " mDisabled=0x" + Integer.toHexString(mDisabled)); |
