Check the return value of RoR preparation/clear
The corresponding functions already has a boolean return value in the reboot escrow manager. So expose the return value to the recovery system. Test: build, check return value of request Change-Id: I056956075868ab62ba6a43259242c4521c1c1bfe
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -3467,11 +3467,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
|
||||
@@ -3480,12 +3481,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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user