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

Commit be605ebf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check isDeviceLocked instead of isKeyguardLocked" into main

parents 627b8968 ee4e1c14
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -71,14 +71,14 @@ public final class ComputerControlSession implements AutoCloseable {
    public static final int ERROR_SESSION_LIMIT_REACHED = 1;

    /**
     * Error code indicating that a new session cannot be created because the lock screen (also
     * known as Keyguard) is showing.
     * Error code indicating that a new session cannot be created because the device is currently
     * locked.
     *
     * <p>This is a transient error and the session creation request can be retried later.</p>
     *
     * @see android.app.KeyguardManager#isKeyguardLocked()
     * @see android.app.KeyguardManager#isDeviceLocked()
     */
    public static final int ERROR_KEYGUARD_LOCKED = 2;
    public static final int ERROR_DEVICE_LOCKED = 2;

    /**
     * Error code indicating that the user did not approve the creation of a new session.
@@ -89,7 +89,7 @@ public final class ComputerControlSession implements AutoCloseable {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "ERROR_", value = {
            ERROR_SESSION_LIMIT_REACHED,
            ERROR_KEYGUARD_LOCKED,
            ERROR_DEVICE_LOCKED,
            ERROR_PERMISSION_DENIED})
    @Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
    public @interface SessionCreationError {
+2 −2
Original line number Diff line number Diff line
@@ -197,9 +197,9 @@ public class ComputerControlSessionProcessor {
    private boolean checkSessionCreationPreconditionsLocked(
            @NonNull ComputerControlSessionParams params,
            @NonNull IComputerControlSessionCallback callback) {
        if (mKeyguardManager.isKeyguardLocked()) {
        if (mKeyguardManager.isDeviceLocked()) {
            dispatchSessionCreationFailed(callback, params,
                    ComputerControlSession.ERROR_KEYGUARD_LOCKED);
                    ComputerControlSession.ERROR_DEVICE_LOCKED);
            return false;
        }
        if (mSessions.size() >= MAXIMUM_CONCURRENT_SESSIONS) {
+2 −2
Original line number Diff line number Diff line
@@ -133,12 +133,12 @@ public class ComputerControlSessionProcessorTest {

    @Test
    public void keyguardLocked_sessionNotCreated() throws Exception {
        when(mKeyguardManager.isKeyguardLocked()).thenReturn(true);
        when(mKeyguardManager.isDeviceLocked()).thenReturn(true);

        mProcessor.processNewSessionRequest(AttributionSource.myAttributionSource(),
                mParams, mComputerControlSessionCallback);
        verify(mComputerControlSessionCallback, timeout(CALLBACK_TIMEOUT_MS))
                .onSessionCreationFailed(ComputerControlSession.ERROR_KEYGUARD_LOCKED);
                .onSessionCreationFailed(ComputerControlSession.ERROR_DEVICE_LOCKED);
    }

    @Test