Merge "Fix potential for dead binders when calling callbacks" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
74983c1214
@@ -567,7 +567,13 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private void notifyAllPolicyListenersLocked() {
|
private void notifyAllPolicyListenersLocked() {
|
||||||
for (final PolicyListenerBinderDeath policyListener : mRegisteredPolicyListeners.values()) {
|
for (final PolicyListenerBinderDeath policyListener : mRegisteredPolicyListeners.values()) {
|
||||||
Binder.withCleanCallingIdentity(() -> policyListener.mListener.onPolicyChanged());
|
Binder.withCleanCallingIdentity(() -> {
|
||||||
|
try {
|
||||||
|
policyListener.mListener.onPolicyChanged();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
logDbg("VcnStatusCallback threw on VCN status change", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,8 +582,13 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
@NonNull ParcelUuid subGroup, @VcnStatusCode int statusCode) {
|
@NonNull ParcelUuid subGroup, @VcnStatusCode int statusCode) {
|
||||||
for (final VcnStatusCallbackInfo cbInfo : mRegisteredStatusCallbacks.values()) {
|
for (final VcnStatusCallbackInfo cbInfo : mRegisteredStatusCallbacks.values()) {
|
||||||
if (isCallbackPermissioned(cbInfo, subGroup)) {
|
if (isCallbackPermissioned(cbInfo, subGroup)) {
|
||||||
Binder.withCleanCallingIdentity(
|
Binder.withCleanCallingIdentity(() -> {
|
||||||
() -> cbInfo.mCallback.onVcnStatusChanged(statusCode));
|
try {
|
||||||
|
cbInfo.mCallback.onVcnStatusChanged(statusCode);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
logDbg("VcnStatusCallback threw on VCN status change", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1250,13 +1261,17 @@ public class VcnManagementService extends IVcnManagementService.Stub {
|
|||||||
// Notify all registered StatusCallbacks for this subGroup
|
// Notify all registered StatusCallbacks for this subGroup
|
||||||
for (VcnStatusCallbackInfo cbInfo : mRegisteredStatusCallbacks.values()) {
|
for (VcnStatusCallbackInfo cbInfo : mRegisteredStatusCallbacks.values()) {
|
||||||
if (isCallbackPermissioned(cbInfo, mSubGroup)) {
|
if (isCallbackPermissioned(cbInfo, mSubGroup)) {
|
||||||
Binder.withCleanCallingIdentity(
|
Binder.withCleanCallingIdentity(() -> {
|
||||||
() ->
|
try {
|
||||||
cbInfo.mCallback.onGatewayConnectionError(
|
cbInfo.mCallback.onGatewayConnectionError(
|
||||||
gatewayConnectionName,
|
gatewayConnectionName,
|
||||||
errorCode,
|
errorCode,
|
||||||
exceptionClass,
|
exceptionClass,
|
||||||
exceptionMessage));
|
exceptionMessage);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
logDbg("VcnStatusCallback threw on VCN status change", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user