Merge "Additional callback on binder's death." into sc-dev

This commit is contained in:
Alex Buynytskyy
2021-02-25 08:42:16 +00:00
committed by Android (Google) Code Review

View File

@@ -171,7 +171,7 @@ public class DataLoaderManagerService extends SystemService {
}
}
private class DataLoaderServiceConnection implements ServiceConnection {
private class DataLoaderServiceConnection implements ServiceConnection, IBinder.DeathRecipient {
final int mId;
final IDataLoaderStatusListener mListener;
IDataLoader mDataLoader;
@@ -194,6 +194,13 @@ public class DataLoaderManagerService extends SystemService {
mContext.unbindService(this);
return;
}
try {
service.linkToDeath(this, /*flags=*/0);
} catch (RemoteException e) {
Slog.e(TAG, "Failed to link to DataLoader's death: " + mId, e);
onBindingDied(className);
return;
}
callListener(IDataLoaderStatusListener.DATA_LOADER_BOUND);
}
@@ -218,6 +225,13 @@ public class DataLoaderManagerService extends SystemService {
destroy();
}
@Override
public void binderDied() {
Slog.i(TAG, "DataLoader " + mId + " died");
callListener(IDataLoaderStatusListener.DATA_LOADER_DESTROYED);
destroy();
}
IDataLoader getDataLoader() {
return mDataLoader;
}