Merge changes I296c1011,I05695607
* changes: Add RecoverySystemServiceTest to presubmit Check the return value of RoR preparation/clear
This commit is contained in:
@@ -110,7 +110,7 @@ public abstract class LockSettingsInternal {
|
|||||||
* #setRebootEscrowListener}, then {@link #armRebootEscrow()} should be called before
|
* #setRebootEscrowListener}, then {@link #armRebootEscrow()} should be called before
|
||||||
* rebooting to apply the update.
|
* 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
|
* 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.
|
* 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
|
* Should be called immediately before rebooting for an update. This depends on {@link
|
||||||
|
|||||||
@@ -3467,11 +3467,12 @@ public class LockSettingsService extends ILockSettings.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareRebootEscrow() {
|
public boolean prepareRebootEscrow() {
|
||||||
if (!mRebootEscrowManager.prepareRebootEscrow()) {
|
if (!mRebootEscrowManager.prepareRebootEscrow()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
mStrongAuth.requireStrongAuth(STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE, USER_ALL);
|
mStrongAuth.requireStrongAuth(STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE, USER_ALL);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -3480,12 +3481,13 @@ public class LockSettingsService extends ILockSettings.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearRebootEscrow() {
|
public boolean clearRebootEscrow() {
|
||||||
if (!mRebootEscrowManager.clearRebootEscrow()) {
|
if (!mRebootEscrowManager.clearRebootEscrow()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
mStrongAuth.noLongerRequireStrongAuth(STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE,
|
mStrongAuth.noLongerRequireStrongAuth(STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE,
|
||||||
USER_ALL);
|
USER_ALL);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -554,11 +554,15 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
case ROR_NEED_PREPARATION:
|
case ROR_NEED_PREPARATION:
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
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 {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unsupported action type on new request " + action);
|
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:
|
case ROR_REQUESTED_NEED_CLEAR:
|
||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mInjector.getLockSettingsService().clearRebootEscrow();
|
return mInjector.getLockSettingsService().clearRebootEscrow();
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unsupported action type on clear " + action);
|
throw new IllegalStateException("Unsupported action type on clear " + action);
|
||||||
}
|
}
|
||||||
@@ -820,6 +823,11 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
lskfCapturedCount);
|
lskfCapturedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized void clearRoRPreparationState() {
|
||||||
|
mCallerPendingRequest.clear();
|
||||||
|
mCallerPreparedForReboot.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void clearRoRPreparationStateOnRebootFailure(RebootPreparationError escrowError) {
|
private void clearRoRPreparationStateOnRebootFailure(RebootPreparationError escrowError) {
|
||||||
if (!FATAL_ARM_ESCROW_ERRORS.contains(escrowError.mProviderErrorCode)) {
|
if (!FATAL_ARM_ESCROW_ERRORS.contains(escrowError.mProviderErrorCode)) {
|
||||||
return;
|
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: "
|
Slog.w(TAG, "Clearing resume on reboot states for all clients on arm escrow error: "
|
||||||
+ escrowError.mProviderErrorCode);
|
+ escrowError.mProviderErrorCode);
|
||||||
synchronized (this) {
|
clearRoRPreparationState();
|
||||||
mCallerPendingRequest.clear();
|
|
||||||
mCallerPreparedForReboot.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private @ResumeOnRebootRebootErrorCode int rebootWithLskfImpl(String packageName, String reason,
|
private @ResumeOnRebootRebootErrorCode int rebootWithLskfImpl(String packageName, String reason,
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ public class RecoverySystemServiceTest {
|
|||||||
mUncryptUpdateFileWriter = mock(FileWriter.class);
|
mUncryptUpdateFileWriter = mock(FileWriter.class);
|
||||||
mLockSettingsInternal = mock(LockSettingsInternal.class);
|
mLockSettingsInternal = mock(LockSettingsInternal.class);
|
||||||
|
|
||||||
|
doReturn(true).when(mLockSettingsInternal).prepareRebootEscrow();
|
||||||
|
doReturn(true).when(mLockSettingsInternal).clearRebootEscrow();
|
||||||
doReturn(LockSettingsInternal.ARM_REBOOT_ERROR_NONE).when(mLockSettingsInternal)
|
doReturn(LockSettingsInternal.ARM_REBOOT_ERROR_NONE).when(mLockSettingsInternal)
|
||||||
.armRebootEscrow();
|
.armRebootEscrow();
|
||||||
|
|
||||||
@@ -254,7 +256,6 @@ public class RecoverySystemServiceTest {
|
|||||||
+ RecoverySystemService.REQUEST_LSKF_TIMESTAMP_PREF_SUFFIX), eq(100_000L));
|
+ RecoverySystemService.REQUEST_LSKF_TIMESTAMP_PREF_SUFFIX), eq(100_000L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestLskf_success() throws Exception {
|
public void requestLskf_success() throws Exception {
|
||||||
IntentSender intentSender = mock(IntentSender.class);
|
IntentSender intentSender = mock(IntentSender.class);
|
||||||
@@ -298,6 +299,14 @@ public class RecoverySystemServiceTest {
|
|||||||
anyInt(), anyInt(), anyInt());
|
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
|
@Test
|
||||||
public void isLskfCaptured_requestedButNotPrepared() throws Exception {
|
public void isLskfCaptured_requestedButNotPrepared() throws Exception {
|
||||||
IntentSender intentSender = mock(IntentSender.class);
|
IntentSender intentSender = mock(IntentSender.class);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"presubmit": [
|
||||||
|
{
|
||||||
|
"name": "FrameworksServicesTests",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"include-filter": "com.android.server.recoverysystem."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exclude-annotation": "android.platform.test.annotations.FlakyTest"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user