Loading services/core/java/com/android/server/RescueParty.java +12 −8 Original line number Diff line number Diff line Loading @@ -494,10 +494,10 @@ public class RescueParty { private static void executeRescueLevelInternalOld(Context context, int level, @Nullable String failedPackage) throws Exception { if (level <= LEVEL_RESET_SETTINGS_TRUSTED_DEFAULTS) { // Disabling flag resets on master branch for trunk stable launch. // TODO(b/287618292): Re-enable them after the trunk stable is launched and we // figured out a way to reset flags without interfering with trunk development. // Note: DeviceConfig reset is disabled currently and would be enabled using the flag, // after we have figured out a way to reset flags without interfering with trunk // development. TODO: b/287618292 For enabling flag resets. if (!Flags.allowRescuePartyFlagResets() && level <= LEVEL_RESET_SETTINGS_TRUSTED_DEFAULTS) { return; } Loading Loading @@ -572,12 +572,16 @@ public class RescueParty { level, levelToString(level)); switch (level) { case RESCUE_LEVEL_SCOPED_DEVICE_CONFIG_RESET: // Temporary disable deviceConfig reset // resetDeviceConfig(context, /*isScoped=*/true, failedPackage); // Enable deviceConfig reset behind flag if (Flags.allowRescuePartyFlagResets()) { resetDeviceConfig(context, /*isScoped=*/true, failedPackage); } break; case RESCUE_LEVEL_ALL_DEVICE_CONFIG_RESET: // Temporary disable deviceConfig reset // resetDeviceConfig(context, /*isScoped=*/false, failedPackage); // Enable deviceConfig reset behind flag if (Flags.allowRescuePartyFlagResets()) { resetDeviceConfig(context, /*isScoped=*/false, failedPackage); } break; case RESCUE_LEVEL_WARM_REBOOT: executeWarmReboot(context, level, failedPackage); Loading services/tests/mockingservicestests/src/com/android/server/RescuePartyTest.java +29 −10 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; import static com.android.server.RescueParty.DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN; import static com.android.server.RescueParty.LEVEL_FACTORY_RESET; import static com.android.server.RescueParty.RESCUE_LEVEL_FACTORY_RESET; Loading Loading @@ -103,8 +104,6 @@ public class RescuePartyTest { private static final String PROP_DISABLE_FACTORY_RESET_FLAG = "persist.device_config.configuration.disable_rescue_party_factory_reset"; private static final int THROTTLING_DURATION_MIN = 10; @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); Loading Loading @@ -228,6 +227,9 @@ public class RescuePartyTest { setCrashRecoveryPropRescueBootCount(0); SystemProperties.set(RescueParty.PROP_ENABLE_RESCUE, Boolean.toString(true)); SystemProperties.set(PROP_DEVICE_CONFIG_DISABLE_FLAG, Boolean.toString(false)); // enable flag resets for tests mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_RESCUE_PARTY_FLAG_RESETS); } @After Loading Loading @@ -312,6 +314,9 @@ public class RescuePartyTest { @Test public void testPersistentAppCrashDetectionWithExecutionForAllRescueLevels() { // this is old test where the flag needs to be disabled mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); noteAppCrash(1, true); verifySettingsResets(Settings.RESET_MODE_UNTRUSTED_DEFAULTS, /*resetNamespaces=*/ null, Loading Loading @@ -378,6 +383,9 @@ public class RescuePartyTest { @Test public void testNonPersistentAppOnlyPerformsFlagResets() { // this is old test where the flag needs to be disabled mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); noteAppCrash(1, false); verifySettingsResets(Settings.RESET_MODE_UNTRUSTED_DEFAULTS, /*resetNamespaces=*/ null, Loading Loading @@ -628,7 +636,8 @@ public class RescuePartyTest { public void testThrottlingOnBootFailures() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 1; i <= LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -641,7 +650,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 1; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -653,7 +663,8 @@ public class RescuePartyTest { public void testThrottlingOnAppCrash() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 0; i <= LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading @@ -666,7 +677,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 0; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading @@ -678,7 +690,8 @@ public class RescuePartyTest { public void testNotThrottlingAfterTimeoutOnBootFailures() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 1; i <= LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -691,7 +704,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 1; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -703,7 +717,8 @@ public class RescuePartyTest { public void testNotThrottlingAfterTimeoutOnAppCrash() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 0; i <= LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading @@ -716,7 +731,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 0; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading Loading @@ -794,6 +810,9 @@ public class RescuePartyTest { @Test public void testHealthCheckLevels() { // this is old test where the flag needs to be disabled mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); RescuePartyObserver observer = RescuePartyObserver.getInstance(mMockContext); // Ensure that no action is taken for cases where the failure reason is unknown Loading Loading
services/core/java/com/android/server/RescueParty.java +12 −8 Original line number Diff line number Diff line Loading @@ -494,10 +494,10 @@ public class RescueParty { private static void executeRescueLevelInternalOld(Context context, int level, @Nullable String failedPackage) throws Exception { if (level <= LEVEL_RESET_SETTINGS_TRUSTED_DEFAULTS) { // Disabling flag resets on master branch for trunk stable launch. // TODO(b/287618292): Re-enable them after the trunk stable is launched and we // figured out a way to reset flags without interfering with trunk development. // Note: DeviceConfig reset is disabled currently and would be enabled using the flag, // after we have figured out a way to reset flags without interfering with trunk // development. TODO: b/287618292 For enabling flag resets. if (!Flags.allowRescuePartyFlagResets() && level <= LEVEL_RESET_SETTINGS_TRUSTED_DEFAULTS) { return; } Loading Loading @@ -572,12 +572,16 @@ public class RescueParty { level, levelToString(level)); switch (level) { case RESCUE_LEVEL_SCOPED_DEVICE_CONFIG_RESET: // Temporary disable deviceConfig reset // resetDeviceConfig(context, /*isScoped=*/true, failedPackage); // Enable deviceConfig reset behind flag if (Flags.allowRescuePartyFlagResets()) { resetDeviceConfig(context, /*isScoped=*/true, failedPackage); } break; case RESCUE_LEVEL_ALL_DEVICE_CONFIG_RESET: // Temporary disable deviceConfig reset // resetDeviceConfig(context, /*isScoped=*/false, failedPackage); // Enable deviceConfig reset behind flag if (Flags.allowRescuePartyFlagResets()) { resetDeviceConfig(context, /*isScoped=*/false, failedPackage); } break; case RESCUE_LEVEL_WARM_REBOOT: executeWarmReboot(context, level, failedPackage); Loading
services/tests/mockingservicestests/src/com/android/server/RescuePartyTest.java +29 −10 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; import static com.android.server.RescueParty.DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN; import static com.android.server.RescueParty.LEVEL_FACTORY_RESET; import static com.android.server.RescueParty.RESCUE_LEVEL_FACTORY_RESET; Loading Loading @@ -103,8 +104,6 @@ public class RescuePartyTest { private static final String PROP_DISABLE_FACTORY_RESET_FLAG = "persist.device_config.configuration.disable_rescue_party_factory_reset"; private static final int THROTTLING_DURATION_MIN = 10; @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); Loading Loading @@ -228,6 +227,9 @@ public class RescuePartyTest { setCrashRecoveryPropRescueBootCount(0); SystemProperties.set(RescueParty.PROP_ENABLE_RESCUE, Boolean.toString(true)); SystemProperties.set(PROP_DEVICE_CONFIG_DISABLE_FLAG, Boolean.toString(false)); // enable flag resets for tests mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_RESCUE_PARTY_FLAG_RESETS); } @After Loading Loading @@ -312,6 +314,9 @@ public class RescuePartyTest { @Test public void testPersistentAppCrashDetectionWithExecutionForAllRescueLevels() { // this is old test where the flag needs to be disabled mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); noteAppCrash(1, true); verifySettingsResets(Settings.RESET_MODE_UNTRUSTED_DEFAULTS, /*resetNamespaces=*/ null, Loading Loading @@ -378,6 +383,9 @@ public class RescuePartyTest { @Test public void testNonPersistentAppOnlyPerformsFlagResets() { // this is old test where the flag needs to be disabled mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); noteAppCrash(1, false); verifySettingsResets(Settings.RESET_MODE_UNTRUSTED_DEFAULTS, /*resetNamespaces=*/ null, Loading Loading @@ -628,7 +636,8 @@ public class RescuePartyTest { public void testThrottlingOnBootFailures() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 1; i <= LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -641,7 +650,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 1; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -653,7 +663,8 @@ public class RescuePartyTest { public void testThrottlingOnAppCrash() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 0; i <= LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading @@ -666,7 +677,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long beforeTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN - 1); long beforeTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN - 1); setCrashRecoveryPropLastFactoryReset(beforeTimeout); for (int i = 0; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading @@ -678,7 +690,8 @@ public class RescuePartyTest { public void testNotThrottlingAfterTimeoutOnBootFailures() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 1; i <= LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -691,7 +704,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 1; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteBoot(i); Loading @@ -703,7 +717,8 @@ public class RescuePartyTest { public void testNotThrottlingAfterTimeoutOnAppCrash() { setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 0; i <= LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading @@ -716,7 +731,8 @@ public class RescuePartyTest { mSetFlagsRule.enableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); setCrashRecoveryPropAttemptingReboot(false); long now = System.currentTimeMillis(); long afterTimeout = now - TimeUnit.MINUTES.toMillis(THROTTLING_DURATION_MIN + 1); long afterTimeout = now - TimeUnit.MINUTES.toMillis( DEFAULT_FACTORY_RESET_THROTTLE_DURATION_MIN + 1); setCrashRecoveryPropLastFactoryReset(afterTimeout); for (int i = 0; i <= RESCUE_LEVEL_FACTORY_RESET; i++) { noteAppCrash(i + 1, true); Loading Loading @@ -794,6 +810,9 @@ public class RescuePartyTest { @Test public void testHealthCheckLevels() { // this is old test where the flag needs to be disabled mSetFlagsRule.disableFlags(Flags.FLAG_RECOVERABILITY_DETECTION); RescuePartyObserver observer = RescuePartyObserver.getInstance(mMockContext); // Ensure that no action is taken for cases where the failure reason is unknown Loading