Skip to content

Commit 13451a2

Browse files
author
John Spurlock
committed
Status bar: Keep disabled state per user.
Bug:7165607 Change-Id: If6f7a41c2516996612aef5e013dd0d2bd23f9084
1 parent 135e5fb commit 13451a2

File tree

3 files changed

+46
-16
lines changed

3 files changed

+46
-16
lines changed

core/java/com/android/internal/statusbar/IStatusBarService.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface IStatusBarService
3333
void topAppWindowChanged(boolean menuVisible);
3434
void setImeWindowStatus(in IBinder token, int vis, int backDisposition);
3535
void expandSettingsPanel();
36+
void setCurrentUser(int newUserId);
3637

3738
// ---- Methods below are for use by the status bar policy services ----
3839
// You need the STATUS_BAR_SERVICE permission

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4298,6 +4298,13 @@ public void setCurrentUserLw(int newUserId) {
42984298
if (mKeyguardMediator != null) {
42994299
mKeyguardMediator.setCurrentUser(newUserId);
43004300
}
4301+
if (mStatusBarService != null) {
4302+
try {
4303+
mStatusBarService.setCurrentUser(newUserId);
4304+
} catch (RemoteException e) {
4305+
// oh well
4306+
}
4307+
}
43014308
}
43024309

43034310
@Override

services/java/com/android/server/StatusBarManagerService.java

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub
6464
= new HashMap<IBinder,StatusBarNotification>();
6565

6666
// for disabling the status bar
67-
ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
67+
final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
6868
IBinder mSysUiVisToken = new Binder();
6969
int mDisabled = 0;
7070

@@ -75,15 +75,17 @@ public class StatusBarManagerService extends IStatusBarService.Stub
7575
int mImeWindowVis = 0;
7676
int mImeBackDisposition;
7777
IBinder mImeToken = null;
78+
int mCurrentUserId;
7879

7980
private class DisableRecord implements IBinder.DeathRecipient {
81+
int userId;
8082
String pkg;
8183
int what;
8284
IBinder token;
8385

8486
public void binderDied() {
8587
Slog.i(TAG, "binder died for pkg=" + pkg);
86-
disable(0, token, pkg);
88+
disableInternal(userId, 0, token, pkg);
8789
token.unlinkToDeath(this, 0);
8890
}
8991
}
@@ -151,20 +153,24 @@ public void expandSettingsPanel() {
151153
}
152154

153155
public void disable(int what, IBinder token, String pkg) {
156+
disableInternal(mCurrentUserId, what, token, pkg);
157+
}
158+
159+
private void disableInternal(int userId, int what, IBinder token, String pkg) {
154160
enforceStatusBar();
155161

156162
synchronized (mLock) {
157-
disableLocked(what, token, pkg);
163+
disableLocked(userId, what, token, pkg);
158164
}
159165
}
160166

161-
private void disableLocked(int what, IBinder token, String pkg) {
167+
private void disableLocked(int userId, int what, IBinder token, String pkg) {
162168
// It's important that the the callback and the call to mBar get done
163169
// in the same order when multiple threads are calling this function
164170
// so they are paired correctly. The messages on the handler will be
165171
// handled in the order they were enqueued, but will be outside the lock.
166-
manageDisableListLocked(what, token, pkg);
167-
final int net = gatherDisableActionsLocked();
172+
manageDisableListLocked(userId, what, token, pkg);
173+
final int net = gatherDisableActionsLocked(userId);
168174
if (net != mDisabled) {
169175
mDisabled = net;
170176
mHandler.post(new Runnable() {
@@ -312,7 +318,10 @@ public void setSystemUiVisibility(int vis, int mask) {
312318

313319
synchronized (mLock) {
314320
updateUiVisibilityLocked(vis, mask);
315-
disableLocked(vis & StatusBarManager.DISABLE_MASK, mSysUiVisToken,
321+
disableLocked(
322+
mCurrentUserId,
323+
vis & StatusBarManager.DISABLE_MASK,
324+
mSysUiVisToken,
316325
"WindowManager.LayoutParams");
317326
}
318327
}
@@ -382,6 +391,12 @@ public void cancelPreloadRecentApps() {
382391
}
383392
}
384393

394+
@Override
395+
public void setCurrentUser(int newUserId) {
396+
if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId);
397+
mCurrentUserId = newUserId;
398+
}
399+
385400
private void enforceStatusBar() {
386401
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
387402
"StatusBarManagerService");
@@ -417,7 +432,7 @@ public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
417432
}
418433
}
419434
synchronized (mLock) {
420-
switches[0] = gatherDisableActionsLocked();
435+
switches[0] = gatherDisableActionsLocked(mCurrentUserId);
421436
switches[1] = mSystemUiVisibility;
422437
switches[2] = mMenuVisible ? 1 : 0;
423438
switches[3] = mImeWindowVis;
@@ -518,9 +533,10 @@ public void removeNotification(IBinder key) {
518533
// ================================================================================
519534

520535
// lock on mDisableRecords
521-
void manageDisableListLocked(int what, IBinder token, String pkg) {
536+
void manageDisableListLocked(int userId, int what, IBinder token, String pkg) {
522537
if (SPEW) {
523-
Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
538+
Slog.d(TAG, "manageDisableList userId=" + userId
539+
+ " what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
524540
}
525541
// update the list
526542
final int N = mDisableRecords.size();
@@ -541,6 +557,7 @@ void manageDisableListLocked(int what, IBinder token, String pkg) {
541557
} else {
542558
if (tok == null) {
543559
tok = new DisableRecord();
560+
tok.userId = userId;
544561
try {
545562
token.linkToDeath(tok, 0);
546563
}
@@ -556,12 +573,15 @@ void manageDisableListLocked(int what, IBinder token, String pkg) {
556573
}
557574

558575
// lock on mDisableRecords
559-
int gatherDisableActionsLocked() {
576+
int gatherDisableActionsLocked(int userId) {
560577
final int N = mDisableRecords.size();
561578
// gather the new net flags
562579
int net = 0;
563580
for (int i=0; i<N; i++) {
564-
net |= mDisableRecords.get(i).what;
581+
final DisableRecord rec = mDisableRecords.get(i);
582+
if (rec.userId == userId) {
583+
net |= rec.what;
584+
}
565585
}
566586
return net;
567587
}
@@ -593,13 +613,15 @@ protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
593613
}
594614

595615
synchronized (mLock) {
616+
pw.println(" mDisabled=0x" + Integer.toHexString(mDisabled));
596617
final int N = mDisableRecords.size();
597-
pw.println(" mDisableRecords.size=" + N
598-
+ " mDisabled=0x" + Integer.toHexString(mDisabled));
618+
pw.println(" mDisableRecords.size=" + N);
599619
for (int i=0; i<N; i++) {
600620
DisableRecord tok = mDisableRecords.get(i);
601-
pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
602-
+ " pkg=" + tok.pkg + " token=" + tok.token);
621+
pw.println(" [" + i + "] userId=" + tok.userId
622+
+ " what=0x" + Integer.toHexString(tok.what)
623+
+ " pkg=" + tok.pkg
624+
+ " token=" + tok.token);
603625
}
604626
}
605627
}

0 commit comments

Comments
 (0)