Allow the status bar disable flags to be used as View's system ui visibility fields.
Bug: 3363046 Change-Id: I50ba06ed9a4d2f5d0e0c807437aea9900f44fee9
This commit is contained in:
@@ -67,6 +67,7 @@ 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();
|
||||
@@ -141,25 +142,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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,6 +299,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,37 +459,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);
|
||||
}
|
||||
} else {
|
||||
if (tok == null) {
|
||||
tok = new DisableRecord();
|
||||
try {
|
||||
token.linkToDeath(tok, 0);
|
||||
}
|
||||
catch (RemoteException ex) {
|
||||
return; // give up
|
||||
}
|
||||
mDisableRecords.add(tok);
|
||||
}
|
||||
tok.what = what;
|
||||
tok.token = token;
|
||||
tok.pkg = pkg;
|
||||
}
|
||||
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);
|
||||
}
|
||||
catch (RemoteException ex) {
|
||||
return; // give up
|
||||
}
|
||||
mDisableRecords.add(tok);
|
||||
}
|
||||
tok.what = what;
|
||||
tok.token = token;
|
||||
tok.pkg = pkg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +528,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));
|
||||
|
||||
Reference in New Issue
Block a user