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

Commit f021abe2 authored by Grace Cheng's avatar Grace Cheng
Browse files

Synchronize SecureLockDeviceStatusListener broadcast

Adds lock to synchronize SecureLockDeviceStatusListener access

Flag: android.security.secure_lock_device
Fixes: 435285250
Test: N/A bug fix
Bug: 401645997
Change-Id: I36f25ea250b534d54517d944eaea582ca143adbd
parent f2f7fd6a
Loading
Loading
Loading
Loading
+36 −32
Original line number Original line Diff line number Diff line
@@ -97,6 +97,7 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
    @Nullable private final FaceManager mFaceManager;
    @Nullable private final FaceManager mFaceManager;
    @Nullable private final FingerprintManager mFingerprintManager;
    @Nullable private final FingerprintManager mFingerprintManager;
    private final PowerManager mPowerManager;
    private final PowerManager mPowerManager;
    @NonNull private final Object mSecureLockDeviceStatusListenerLock = new Object();
    @NonNull private final SecureLockDeviceStore mStore;
    @NonNull private final SecureLockDeviceStore mStore;
    private final RemoteCallbackList<ISecureLockDeviceStatusListener>
    private final RemoteCallbackList<ISecureLockDeviceStatusListener>
            mSecureLockDeviceStatusListeners = new RemoteCallbackList<>();
            mSecureLockDeviceStatusListeners = new RemoteCallbackList<>();
@@ -553,6 +554,7 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
     *               update. Only listeners registered to this userId will be notified.s
     *               update. Only listeners registered to this userId will be notified.s
     */
     */
    private void notifySecureLockDeviceAvailabilityForUser(int userId) {
    private void notifySecureLockDeviceAvailabilityForUser(int userId) {
        synchronized (mSecureLockDeviceStatusListenerLock) {
            final int count = mSecureLockDeviceStatusListeners.beginBroadcast();
            final int count = mSecureLockDeviceStatusListeners.beginBroadcast();
            try {
            try {
                for (int i = 0; i < count; i++) {
                for (int i = 0; i < count; i++) {
@@ -577,13 +579,14 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
                                + secureLockDeviceAvailability);
                                + secureLockDeviceAvailability);
                    }
                    }
                    try {
                    try {
                    listener.onSecureLockDeviceAvailableStatusChanged(secureLockDeviceAvailability);
                        listener.onSecureLockDeviceAvailableStatusChanged(
                                secureLockDeviceAvailability);
                    } catch (RemoteException e) {
                    } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to notify listener " + listener.asBinder() + " for "
                        Slog.e(TAG, "Failed to notify listener " + listener.asBinder()
                            + "user " + userId + ", RemoteException thrown: ", e);
                                + " for user " + userId + ", RemoteException thrown: ", e);
                    } catch (Exception e) {
                    } catch (Exception e) {
                    Slog.e(TAG, "Exception thrown by listener " + listener.asBinder() + " for "
                        Slog.e(TAG, "Exception thrown by listener " + listener.asBinder()
                            + "user " + userId + " during callback: ", e);
                                + " for user " + userId + " during callback: ", e);
                        mSecureLockDeviceStatusListeners.unregister(listener);
                        mSecureLockDeviceStatusListeners.unregister(listener);
                    }
                    }
                }
                }
@@ -591,6 +594,7 @@ public class SecureLockDeviceService extends SecureLockDeviceServiceInternal {
                mSecureLockDeviceStatusListeners.finishBroadcast();
                mSecureLockDeviceStatusListeners.finishBroadcast();
            }
            }
        }
        }
    }


    /**
    /**
     * @see AuthenticationPolicyManager#setSecureLockDeviceTestStatus(boolean)
     * @see AuthenticationPolicyManager#setSecureLockDeviceTestStatus(boolean)