Loading packages/CrashRecovery/aconfig/flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -31,3 +31,11 @@ flag { description: "Deletes flag and settings resets" bug: "333847376" } flag { name: "refactor_crashrecovery" namespace: "modularization" description: "Refactor required CrashRecovery code" bug: "289203818" is_fixed_read_only: true } services/core/java/com/android/server/am/ActivityManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.SIGNATURE_NO_MATCH; import static android.crashrecovery.flags.Flags.refactorCrashrecovery; import static android.net.ConnectivityManager.BLOCKED_REASON_NONE; import static android.os.FactoryTest.FACTORY_TEST_OFF; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; Loading Loading @@ -2322,7 +2323,9 @@ public class ActivityManagerService extends IActivityManager.Stub } else if (phase == PHASE_ACTIVITY_MANAGER_READY) { mService.startBroadcastObservers(); } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { if (!refactorCrashrecovery()) { mService.mPackageWatchdog.onPackagesReady(); } mService.scheduleHomeTimeout(); } } Loading services/core/java/com/android/server/crashrecovery/CrashRecoveryModule.java 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.crashrecovery; import android.content.Context; import com.android.server.PackageWatchdog; import com.android.server.RescueParty; import com.android.server.SystemService; /** This class encapsulate the lifecycle methods of CrashRecovery module. */ public class CrashRecoveryModule { private static final String TAG = "CrashRecoveryModule"; /** Lifecycle definition for CrashRecovery module. */ public static class Lifecycle extends SystemService { private Context mSystemContext; private PackageWatchdog mPackageWatchdog; public Lifecycle(Context context) { super(context); mSystemContext = context; mPackageWatchdog = PackageWatchdog.getInstance(context); } @Override public void onStart() { RescueParty.registerHealthObserver(mSystemContext); mPackageWatchdog.noteBoot(); } @Override public void onBootPhase(int phase) { if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { mPackageWatchdog.onPackagesReady(); } } } } services/core/java/com/android/server/crashrecovery/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,9 @@ "include-filter": "com.android.server.RescuePartyTest" } ] }, { "name": "CrashRecoveryModuleTests" } ] } No newline at end of file services/java/com/android/server/SystemServer.java +25 −13 Original line number Diff line number Diff line Loading @@ -381,6 +381,9 @@ public final class SystemServer implements Dumpable { + "OnDevicePersonalizationSystemService$Lifecycle"; private static final String UPDATABLE_DEVICE_CONFIG_SERVICE_CLASS = "com.android.server.deviceconfig.DeviceConfigInit$Lifecycle"; private static final String CRASHRECOVERY_MODULE_LIFECYCLE_CLASS = "com.android.server.crashrecovery.CrashRecoveryModule$Lifecycle"; /* * Implementation class names and jar locations for services in Loading Loading @@ -1196,6 +1199,7 @@ public final class SystemServer implements Dumpable { mSystemServiceManager.startService(RecoverySystemService.Lifecycle.class); t.traceEnd(); if (!Flags.refactorCrashrecovery()) { // Initialize RescueParty. RescueParty.registerHealthObserver(mSystemContext); if (!Flags.recoverabilityDetection()) { Loading @@ -1204,6 +1208,8 @@ public final class SystemServer implements Dumpable { // we're stuck in a runtime restart loop. PackageWatchdog.getInstance(mSystemContext).noteBoot(); } } // Manages LEDs and display backlight so we need it to bring up the display. t.traceBegin("StartLightsService"); Loading Loading @@ -2931,6 +2937,11 @@ public final class SystemServer implements Dumpable { mPackageManagerService.systemReady(); t.traceEnd(); if (Flags.refactorCrashrecovery()) { t.traceBegin("StartCrashRecoveryModule"); mSystemServiceManager.startService(CRASHRECOVERY_MODULE_LIFECYCLE_CLASS); t.traceEnd(); } else { if (Flags.recoverabilityDetection()) { // Now that we have the essential services needed for mitigations, register the boot // with package watchdog. Loading @@ -2938,6 +2949,7 @@ public final class SystemServer implements Dumpable { // runtime restart loop. PackageWatchdog.getInstance(mSystemContext).noteBoot(); } } t.traceBegin("MakeDisplayManagerServiceReady"); try { Loading Loading
packages/CrashRecovery/aconfig/flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -31,3 +31,11 @@ flag { description: "Deletes flag and settings resets" bug: "333847376" } flag { name: "refactor_crashrecovery" namespace: "modularization" description: "Refactor required CrashRecovery code" bug: "289203818" is_fixed_read_only: true }
services/core/java/com/android/server/am/ActivityManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.SIGNATURE_NO_MATCH; import static android.crashrecovery.flags.Flags.refactorCrashrecovery; import static android.net.ConnectivityManager.BLOCKED_REASON_NONE; import static android.os.FactoryTest.FACTORY_TEST_OFF; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; Loading Loading @@ -2322,7 +2323,9 @@ public class ActivityManagerService extends IActivityManager.Stub } else if (phase == PHASE_ACTIVITY_MANAGER_READY) { mService.startBroadcastObservers(); } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { if (!refactorCrashrecovery()) { mService.mPackageWatchdog.onPackagesReady(); } mService.scheduleHomeTimeout(); } } Loading
services/core/java/com/android/server/crashrecovery/CrashRecoveryModule.java 0 → 100644 +54 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.crashrecovery; import android.content.Context; import com.android.server.PackageWatchdog; import com.android.server.RescueParty; import com.android.server.SystemService; /** This class encapsulate the lifecycle methods of CrashRecovery module. */ public class CrashRecoveryModule { private static final String TAG = "CrashRecoveryModule"; /** Lifecycle definition for CrashRecovery module. */ public static class Lifecycle extends SystemService { private Context mSystemContext; private PackageWatchdog mPackageWatchdog; public Lifecycle(Context context) { super(context); mSystemContext = context; mPackageWatchdog = PackageWatchdog.getInstance(context); } @Override public void onStart() { RescueParty.registerHealthObserver(mSystemContext); mPackageWatchdog.noteBoot(); } @Override public void onBootPhase(int phase) { if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { mPackageWatchdog.onPackagesReady(); } } } }
services/core/java/com/android/server/crashrecovery/TEST_MAPPING +3 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,9 @@ "include-filter": "com.android.server.RescuePartyTest" } ] }, { "name": "CrashRecoveryModuleTests" } ] } No newline at end of file
services/java/com/android/server/SystemServer.java +25 −13 Original line number Diff line number Diff line Loading @@ -381,6 +381,9 @@ public final class SystemServer implements Dumpable { + "OnDevicePersonalizationSystemService$Lifecycle"; private static final String UPDATABLE_DEVICE_CONFIG_SERVICE_CLASS = "com.android.server.deviceconfig.DeviceConfigInit$Lifecycle"; private static final String CRASHRECOVERY_MODULE_LIFECYCLE_CLASS = "com.android.server.crashrecovery.CrashRecoveryModule$Lifecycle"; /* * Implementation class names and jar locations for services in Loading Loading @@ -1196,6 +1199,7 @@ public final class SystemServer implements Dumpable { mSystemServiceManager.startService(RecoverySystemService.Lifecycle.class); t.traceEnd(); if (!Flags.refactorCrashrecovery()) { // Initialize RescueParty. RescueParty.registerHealthObserver(mSystemContext); if (!Flags.recoverabilityDetection()) { Loading @@ -1204,6 +1208,8 @@ public final class SystemServer implements Dumpable { // we're stuck in a runtime restart loop. PackageWatchdog.getInstance(mSystemContext).noteBoot(); } } // Manages LEDs and display backlight so we need it to bring up the display. t.traceBegin("StartLightsService"); Loading Loading @@ -2931,6 +2937,11 @@ public final class SystemServer implements Dumpable { mPackageManagerService.systemReady(); t.traceEnd(); if (Flags.refactorCrashrecovery()) { t.traceBegin("StartCrashRecoveryModule"); mSystemServiceManager.startService(CRASHRECOVERY_MODULE_LIFECYCLE_CLASS); t.traceEnd(); } else { if (Flags.recoverabilityDetection()) { // Now that we have the essential services needed for mitigations, register the boot // with package watchdog. Loading @@ -2938,6 +2949,7 @@ public final class SystemServer implements Dumpable { // runtime restart loop. PackageWatchdog.getInstance(mSystemContext).noteBoot(); } } t.traceBegin("MakeDisplayManagerServiceReady"); try { Loading