* commit 'db3b01a5bfbf5e190bf6116b71e27971c3b5816b': Status bar: Keep disabled state per user.
This commit is contained in:
@@ -33,6 +33,7 @@ interface IStatusBarService
|
||||
void topAppWindowChanged(boolean menuVisible);
|
||||
void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
|
||||
void expandSettingsPanel();
|
||||
void setCurrentUser(int newUserId);
|
||||
|
||||
// ---- Methods below are for use by the status bar policy services ----
|
||||
// You need the STATUS_BAR_SERVICE permission
|
||||
|
||||
@@ -4298,6 +4298,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
if (mKeyguardMediator != null) {
|
||||
mKeyguardMediator.setCurrentUser(newUserId);
|
||||
}
|
||||
if (mStatusBarService != null) {
|
||||
try {
|
||||
mStatusBarService.setCurrentUser(newUserId);
|
||||
} catch (RemoteException e) {
|
||||
// oh well
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,7 +64,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
= new HashMap<IBinder,StatusBarNotification>();
|
||||
|
||||
// for disabling the status bar
|
||||
ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
|
||||
final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
|
||||
IBinder mSysUiVisToken = new Binder();
|
||||
int mDisabled = 0;
|
||||
|
||||
@@ -75,15 +75,17 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
int mImeWindowVis = 0;
|
||||
int mImeBackDisposition;
|
||||
IBinder mImeToken = null;
|
||||
int mCurrentUserId;
|
||||
|
||||
private class DisableRecord implements IBinder.DeathRecipient {
|
||||
int userId;
|
||||
String pkg;
|
||||
int what;
|
||||
IBinder token;
|
||||
|
||||
public void binderDied() {
|
||||
Slog.i(TAG, "binder died for pkg=" + pkg);
|
||||
disable(0, token, pkg);
|
||||
disableInternal(userId, 0, token, pkg);
|
||||
token.unlinkToDeath(this, 0);
|
||||
}
|
||||
}
|
||||
@@ -151,20 +153,24 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
|
||||
public void disable(int what, IBinder token, String pkg) {
|
||||
disableInternal(mCurrentUserId, what, token, pkg);
|
||||
}
|
||||
|
||||
private void disableInternal(int userId, int what, IBinder token, String pkg) {
|
||||
enforceStatusBar();
|
||||
|
||||
synchronized (mLock) {
|
||||
disableLocked(what, token, pkg);
|
||||
disableLocked(userId, what, token, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
private void disableLocked(int what, IBinder token, String pkg) {
|
||||
private void disableLocked(int userId, 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.
|
||||
manageDisableListLocked(what, token, pkg);
|
||||
final int net = gatherDisableActionsLocked();
|
||||
manageDisableListLocked(userId, what, token, pkg);
|
||||
final int net = gatherDisableActionsLocked(userId);
|
||||
if (net != mDisabled) {
|
||||
mDisabled = net;
|
||||
mHandler.post(new Runnable() {
|
||||
@@ -312,7 +318,10 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
|
||||
synchronized (mLock) {
|
||||
updateUiVisibilityLocked(vis, mask);
|
||||
disableLocked(vis & StatusBarManager.DISABLE_MASK, mSysUiVisToken,
|
||||
disableLocked(
|
||||
mCurrentUserId,
|
||||
vis & StatusBarManager.DISABLE_MASK,
|
||||
mSysUiVisToken,
|
||||
"WindowManager.LayoutParams");
|
||||
}
|
||||
}
|
||||
@@ -382,6 +391,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentUser(int newUserId) {
|
||||
if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId);
|
||||
mCurrentUserId = newUserId;
|
||||
}
|
||||
|
||||
private void enforceStatusBar() {
|
||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
|
||||
"StatusBarManagerService");
|
||||
@@ -417,7 +432,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
}
|
||||
synchronized (mLock) {
|
||||
switches[0] = gatherDisableActionsLocked();
|
||||
switches[0] = gatherDisableActionsLocked(mCurrentUserId);
|
||||
switches[1] = mSystemUiVisibility;
|
||||
switches[2] = mMenuVisible ? 1 : 0;
|
||||
switches[3] = mImeWindowVis;
|
||||
@@ -518,9 +533,10 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
// ================================================================================
|
||||
|
||||
// lock on mDisableRecords
|
||||
void manageDisableListLocked(int what, IBinder token, String pkg) {
|
||||
void manageDisableListLocked(int userId, int what, IBinder token, String pkg) {
|
||||
if (SPEW) {
|
||||
Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
|
||||
Slog.d(TAG, "manageDisableList userId=" + userId
|
||||
+ " what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
|
||||
}
|
||||
// update the list
|
||||
final int N = mDisableRecords.size();
|
||||
@@ -541,6 +557,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
} else {
|
||||
if (tok == null) {
|
||||
tok = new DisableRecord();
|
||||
tok.userId = userId;
|
||||
try {
|
||||
token.linkToDeath(tok, 0);
|
||||
}
|
||||
@@ -556,12 +573,15 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
|
||||
// lock on mDisableRecords
|
||||
int gatherDisableActionsLocked() {
|
||||
int gatherDisableActionsLocked(int userId) {
|
||||
final int N = mDisableRecords.size();
|
||||
// gather the new net flags
|
||||
int net = 0;
|
||||
for (int i=0; i<N; i++) {
|
||||
net |= mDisableRecords.get(i).what;
|
||||
final DisableRecord rec = mDisableRecords.get(i);
|
||||
if (rec.userId == userId) {
|
||||
net |= rec.what;
|
||||
}
|
||||
}
|
||||
return net;
|
||||
}
|
||||
@@ -593,13 +613,15 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
||||
}
|
||||
|
||||
synchronized (mLock) {
|
||||
pw.println(" mDisabled=0x" + Integer.toHexString(mDisabled));
|
||||
final int N = mDisableRecords.size();
|
||||
pw.println(" mDisableRecords.size=" + N
|
||||
+ " mDisabled=0x" + Integer.toHexString(mDisabled));
|
||||
pw.println(" mDisableRecords.size=" + N);
|
||||
for (int i=0; i<N; i++) {
|
||||
DisableRecord tok = mDisableRecords.get(i);
|
||||
pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
|
||||
+ " pkg=" + tok.pkg + " token=" + tok.token);
|
||||
pw.println(" [" + i + "] userId=" + tok.userId
|
||||
+ " what=0x" + Integer.toHexString(tok.what)
|
||||
+ " pkg=" + tok.pkg
|
||||
+ " token=" + tok.token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user