Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity"

This commit is contained in:
Lucas Lin 2021-01-07 04:32:54 +00:00 • committed by Gerrit Code Review
commit 8971ccf93e

View file

@ -1833,30 +1833,42 @@ public class ConnectivityManager {
mCallback = new ISocketKeepaliveCallback.Stub() {
@Override
public void onStarted(int slot) {
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> {
mSlot = slot;
callback.onStarted();
}));
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
mSlot = slot;
callback.onStarted();
});
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override
public void onStopped() {
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> {
mSlot = null;
callback.onStopped();
}));
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
mSlot = null;
callback.onStopped();
});
} finally {
Binder.restoreCallingIdentity(token);
}
mExecutor.shutdown();
}
@Override
public void onError(int error) {
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> {
mSlot = null;
callback.onError(error);
}));
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
mSlot = null;
callback.onError(error);
});
} finally {
Binder.restoreCallingIdentity(token);
}
mExecutor.shutdown();
}