Check if records is inited before removing items

The record might already be removed and the records array set to null
when the binder dies, hence handle the scenario.

Bug: 28512952
Change-Id: Id21b03b6d14d1dc8cb792ee4ec0519287a289a33
This commit is contained in:
Philip P. Moltmann
2016-04-28 14:54:35 -07:00
parent 383189f494
commit 640918f911

View File

@@ -555,7 +555,11 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
new PrintJobStateChangeListenerRecord(listener, appId) {
@Override
public void onBinderDied() {
mPrintJobStateChangeListenerRecords.remove(this);
synchronized (mLock) {
if (mPrintJobStateChangeListenerRecords != null) {
mPrintJobStateChangeListenerRecords.remove(this);
}
}
}
});
}
@@ -639,7 +643,11 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
new ListenerRecord<IRecommendationsChangeListener>(listener) {
@Override
public void onBinderDied() {
mPrintServiceRecommendationsChangeListenerRecords.remove(this);
synchronized (mLock) {
if (mPrintServiceRecommendationsChangeListenerRecords != null) {
mPrintServiceRecommendationsChangeListenerRecords.remove(this);
}
}
}
});
}