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

Commit cfab9a00 authored by Tianjie Xu's avatar Tianjie Xu Committed by Automerger Merge Worker
Browse files

Merge changes I296c1011,I05695607 am: 58deb1cf am: c9674eec am: 676422f2

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

Change-Id: If10475c3af8fc72442dbc8c2933b1f6561c87174
parents 0fd3637f 676422f2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public abstract class LockSettingsInternal {
     * #setRebootEscrowListener}, then {@link #armRebootEscrow()} should be called before
     * rebooting to apply the update.
     */
    public abstract void prepareRebootEscrow();
    public abstract boolean prepareRebootEscrow();

    /**
     * Registers a listener for when the RebootEscrow HAL has stored its data needed for rebooting
@@ -124,7 +124,7 @@ public abstract class LockSettingsInternal {
    /**
     * Requests that any data needed for rebooting is cleared from the RebootEscrow HAL.
     */
    public abstract void clearRebootEscrow();
    public abstract boolean clearRebootEscrow();

    /**
     * Should be called immediately before rebooting for an update. This depends on {@link
+6 −4
Original line number Diff line number Diff line
@@ -3637,11 +3637,12 @@ public class LockSettingsService extends ILockSettings.Stub {
        }

        @Override
        public void prepareRebootEscrow() {
        public boolean prepareRebootEscrow() {
            if (!mRebootEscrowManager.prepareRebootEscrow()) {
                return;
                return false;
            }
            mStrongAuth.requireStrongAuth(STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE, USER_ALL);
            return true;
        }

        @Override
@@ -3650,12 +3651,13 @@ public class LockSettingsService extends ILockSettings.Stub {
        }

        @Override
        public void clearRebootEscrow() {
        public boolean clearRebootEscrow() {
            if (!mRebootEscrowManager.clearRebootEscrow()) {
                return;
                return false;
            }
            mStrongAuth.noLongerRequireStrongAuth(STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE,
                    USER_ALL);
            return true;
        }

        @Override
+13 −8
Original line number Diff line number Diff line
@@ -554,11 +554,15 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
            case ROR_NEED_PREPARATION:
                final long origId = Binder.clearCallingIdentity();
                try {
                    mInjector.getLockSettingsService().prepareRebootEscrow();
                    boolean result = mInjector.getLockSettingsService().prepareRebootEscrow();
                    // Clear the RoR preparation state if lock settings reports an failure.
                    if (!result) {
                        clearRoRPreparationState();
                    }
                    return result;
                } finally {
                    Binder.restoreCallingIdentity(origId);
                }
                return true;
            default:
                throw new IllegalStateException("Unsupported action type on new request " + action);
        }
@@ -670,11 +674,10 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
            case ROR_REQUESTED_NEED_CLEAR:
                final long origId = Binder.clearCallingIdentity();
                try {
                    mInjector.getLockSettingsService().clearRebootEscrow();
                    return mInjector.getLockSettingsService().clearRebootEscrow();
                } finally {
                    Binder.restoreCallingIdentity(origId);
                }
                return true;
            default:
                throw new IllegalStateException("Unsupported action type on clear " + action);
        }
@@ -820,6 +823,11 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
                lskfCapturedCount);
    }

    private synchronized void clearRoRPreparationState() {
        mCallerPendingRequest.clear();
        mCallerPreparedForReboot.clear();
    }

    private void clearRoRPreparationStateOnRebootFailure(RebootPreparationError escrowError) {
        if (!FATAL_ARM_ESCROW_ERRORS.contains(escrowError.mProviderErrorCode)) {
            return;
@@ -827,10 +835,7 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo

        Slog.w(TAG, "Clearing resume on reboot states for all clients on arm escrow error: "
                + escrowError.mProviderErrorCode);
        synchronized (this) {
            mCallerPendingRequest.clear();
            mCallerPreparedForReboot.clear();
        }
        clearRoRPreparationState();
    }

    private @ResumeOnRebootRebootErrorCode int rebootWithLskfImpl(String packageName, String reason,
+10 −1
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ public class RecoverySystemServiceTest {
        mUncryptUpdateFileWriter = mock(FileWriter.class);
        mLockSettingsInternal = mock(LockSettingsInternal.class);

        doReturn(true).when(mLockSettingsInternal).prepareRebootEscrow();
        doReturn(true).when(mLockSettingsInternal).clearRebootEscrow();
        doReturn(LockSettingsInternal.ARM_REBOOT_ERROR_NONE).when(mLockSettingsInternal)
                .armRebootEscrow();

@@ -254,7 +256,6 @@ public class RecoverySystemServiceTest {
                + RecoverySystemService.REQUEST_LSKF_TIMESTAMP_PREF_SUFFIX), eq(100_000L));
    }


    @Test
    public void requestLskf_success() throws Exception {
        IntentSender intentSender = mock(IntentSender.class);
@@ -298,6 +299,14 @@ public class RecoverySystemServiceTest {
                anyInt(), anyInt(), anyInt());
    }

    @Test
    public void requestLskf_lockSettingsError() throws Exception {
        IntentSender intentSender = mock(IntentSender.class);

        doReturn(false).when(mLockSettingsInternal).prepareRebootEscrow();
        assertFalse(mRecoverySystemService.requestLskf(FAKE_OTA_PACKAGE_NAME, intentSender));
    }

    @Test
    public void isLskfCaptured_requestedButNotPrepared() throws Exception {
        IntentSender intentSender = mock(IntentSender.class);
+15 −0
Original line number Diff line number Diff line
{
    "presubmit": [
        {
            "name": "FrameworksServicesTests",
            "options": [
                {
                    "include-filter": "com.android.server.recoverysystem."
                },
                {
                    "exclude-annotation": "android.platform.test.annotations.FlakyTest"
                }
            ]
        }
    ]
}
 No newline at end of file