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

Commit 0f6b4e23 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Cleanup mRearDisplayPresentationController if SecurityException caught

If a SecurityException occurs when invoking
DeviceStateManager#requestState (e.g. if not the caller is not
in foreground, or if it does not have the required permissions),
we should first clean up our local state before re-throwing the
SecurityException to the caller. Otherwise, subsequent attempts
to startRearDisplayPresentationSession will always fail.

Bug: 270671994
Test: atest ExtensionRearDisplayPresentationKeyguardTest
Change-Id: Ie102b03b722f018dc093ef9ab8c5c41b141a5bd0
parent 50f9e8ba
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -342,11 +342,22 @@ public class WindowAreaComponentImpl implements WindowAreaComponent,
                            mRearDisplayPresentationController);
                            mRearDisplayPresentationController);
            DeviceStateRequest concurrentDisplayStateRequest = DeviceStateRequest.newBuilder(
            DeviceStateRequest concurrentDisplayStateRequest = DeviceStateRequest.newBuilder(
                    mConcurrentDisplayState).build();
                    mConcurrentDisplayState).build();

            try {
                mDeviceStateManager.requestState(
                mDeviceStateManager.requestState(
                        concurrentDisplayStateRequest,
                        concurrentDisplayStateRequest,
                        mExecutor,
                        mExecutor,
                        deviceStateCallback
                        deviceStateCallback
                );
                );
            } catch (SecurityException e) {
                // If a SecurityException occurs when invoking DeviceStateManager#requestState
                // (e.g. if the caller is not in the foreground, or if it does not have the required
                // permissions), we should first clean up our local state before re-throwing the
                // SecurityException to the caller. Otherwise, subsequent attempts to
                // startRearDisplayPresentationSession will always fail.
                mRearDisplayPresentationController = null;
                throw e;
            }
        }
        }
    }
    }