Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be749b6f authored by Benedict Wong's avatar Benedict Wong Committed by Automerger Merge Worker
Browse files

Merge "Fix potential for dead binders when calling callbacks" am: bb0d4256...

Merge "Fix potential for dead binders when calling callbacks" am: bb0d4256 am: 551b9f8d am: 14f479cc

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1969041

Change-Id: Iae87d0d571e8d4668bafc778642aa4639bb0fbbc
parents 0ff22a28 14f479cc
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -539,7 +539,13 @@ public class VcnManagementService extends IVcnManagementService.Stub {
    @GuardedBy("mLock")
    private void notifyAllPolicyListenersLocked() {
        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);
                }
            });
        }
    }

@@ -548,8 +554,13 @@ public class VcnManagementService extends IVcnManagementService.Stub {
            @NonNull ParcelUuid subGroup, @VcnStatusCode int statusCode) {
        for (final VcnStatusCallbackInfo cbInfo : mRegisteredStatusCallbacks.values()) {
            if (isCallbackPermissioned(cbInfo, subGroup)) {
                Binder.withCleanCallingIdentity(
                        () -> cbInfo.mCallback.onVcnStatusChanged(statusCode));
                Binder.withCleanCallingIdentity(() -> {
                    try {
                        cbInfo.mCallback.onVcnStatusChanged(statusCode);
                    } catch (RemoteException e) {
                        logDbg("VcnStatusCallback threw on VCN status change", e);
                    }
                });
            }
        }
    }
@@ -1222,13 +1233,17 @@ public class VcnManagementService extends IVcnManagementService.Stub {
                // Notify all registered StatusCallbacks for this subGroup
                for (VcnStatusCallbackInfo cbInfo : mRegisteredStatusCallbacks.values()) {
                    if (isCallbackPermissioned(cbInfo, mSubGroup)) {
                        Binder.withCleanCallingIdentity(
                                () ->
                        Binder.withCleanCallingIdentity(() -> {
                            try {
                                cbInfo.mCallback.onGatewayConnectionError(
                                        gatewayConnectionName,
                                        errorCode,
                                        exceptionClass,
                                                exceptionMessage));
                                        exceptionMessage);
                            } catch (RemoteException e) {
                                logDbg("VcnStatusCallback threw on VCN status change", e);
                            }
                        });
                    }
                }
            }