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

Commit f5f5eb69 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android Build Coastguard Worker
Browse files

Don't send BOOT_COMPLETED to app in restricted backup mode

If the app is being started for a backup or restore operation,
don't send it the BOOT_COMPLETED broadcasts even if currently
in the package STOPPED state. This prevents some apps from
crashing because they don't properly handle getting broadcasts
during a backup or restore.

Bug: 362516211
Test: Install a previously backed up app and ensure restore works
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a2e386b3555a25df7e3405ec1269f2ac4b2a9dfc)
Merged-In: Iddb40c1398f49dd72cbcb730b9cfb48aaca98e2c
Change-Id: Iddb40c1398f49dd72cbcb730b9cfb48aaca98e2c
parent 1f120455
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -4898,7 +4898,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (!mConstants.mEnableWaitForFinishAttachApplication) {
                finishAttachApplicationInner(startSeq, callingUid, pid);
            }
            maybeSendBootCompletedLocked(app);
            maybeSendBootCompletedLocked(app, isRestrictedBackupMode);
        } catch (Exception e) {
            // We need kill the process group here. (b/148588589)
            Slog.wtf(TAG, "Exception thrown during bind of " + app, e);
@@ -5143,7 +5143,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     * Send LOCKED_BOOT_COMPLETED and BOOT_COMPLETED to the package explicitly when unstopped,
     * or when the package first starts in private space
     */
    private void maybeSendBootCompletedLocked(ProcessRecord app) {
    private void maybeSendBootCompletedLocked(ProcessRecord app, boolean isRestrictedBackupMode) {
        boolean sendBroadcast = false;
        if (android.os.Flags.allowPrivateProfile()
                && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
@@ -5169,6 +5169,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                    RESTRICTION_REASON_USAGE, "unknown", RESTRICTION_SOURCE_USER, 0L);
        }
        // Don't send BOOT_COMPLETED if currently in restricted backup mode
        if (isRestrictedBackupMode) return;
        if (!sendBroadcast) {
            if (!android.content.pm.Flags.stayStopped()) return;
            // Nothing to do if it wasn't previously stopped