Reuse DeathRecipient object for StatusBarManagerService

With each SystemUI crash don't create new DeathRecipient
Object during registration of Status Bar

BUG: 111051603
Test: manual -Device booted up and running
Change-Id: Ie9219400c87722cd9e9fc13f106a052d692400ea
This commit is contained in:
Gopal Krishna Shukla
2018-06-29 18:20:36 +05:30
committed by Shibin George
parent 73200d9ac9
commit e5c8379d81

View File

@@ -77,6 +77,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
private int mDisabled2 = 0;
private final Object mLock = new Object();
private final DeathRecipient mDeathRecipient = new DeathRecipient();
// encompasses lights-out mode and other flags defined on View
private int mSystemUiVisibility = 0;
private int mFullscreenStackSysUiVisibility;
@@ -90,6 +91,23 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
private IBinder mImeToken = null;
private int mCurrentUserId;
private class DeathRecipient implements IBinder.DeathRecipient {
public void binderDied() {
mBar.asBinder().unlinkToDeath(this,0);
mBar = null;
notifyBarAttachChanged();
}
public void linkToDeath() {
try {
mBar.asBinder().linkToDeath(mDeathRecipient,0);
} catch (RemoteException e) {
Slog.e(TAG,"Unable to register Death Recipient for status bar", e);
}
}
}
private class DisableRecord implements IBinder.DeathRecipient {
int userId;
String pkg;
@@ -713,16 +731,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
Slog.i(TAG, "registerStatusBar bar=" + bar);
mBar = bar;
try {
mBar.asBinder().linkToDeath(new DeathRecipient() {
@Override
public void binderDied() {
mBar = null;
notifyBarAttachChanged();
}
}, 0);
} catch (RemoteException e) {
}
mDeathRecipient.linkToDeath();
notifyBarAttachChanged();
synchronized (mIcons) {
for (String slot : mIcons.keySet()) {