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

Commit 02351ca3 authored by Amith Yamasani's avatar Amith Yamasani Committed by android-build-merger
Browse files

Merge "Don\'t deliver broadcast to apps that are being backed up" into nyc-dev am: fc2a7ce7

am: b475c89a

* commit 'b475c89a':
  Don't deliver broadcast to apps that are being backed up

Change-Id: I7ced9d068f89f0f0854f3afa89ff8260774bbf8c
parents d68e7a3d b475c89a
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -16863,6 +16863,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                return false;
                return false;
            }
            }
            // If the app is a regular app (uid >= 10000) and not the system server or phone
            // process, etc, then mark it as being in full backup so that certain calls to the
            // process can be blocked. This is not reset to false anywhere because we kill the
            // process after the full backup is done and the ProcessRecord will vaporize anyway.
            if (UserHandle.isApp(app.uid) && backupMode == IApplicationThread.BACKUP_MODE_FULL) {
                proc.inFullBackup = true;
            }
            r.app = proc;
            r.app = proc;
            mBackupTarget = r;
            mBackupTarget = r;
            mBackupAppName = app.packageName;
            mBackupAppName = app.packageName;
+24 −7
Original line number Original line Diff line number Diff line
@@ -258,6 +258,11 @@ public final class BroadcastQueue {
        if (app.thread == null) {
        if (app.thread == null) {
            throw new RemoteException();
            throw new RemoteException();
        }
        }
        if (app.inFullBackup) {
            skipReceiverLocked(r);
            return;
        }

        r.receiver = app.thread.asBinder();
        r.receiver = app.thread.asBinder();
        r.curApp = app;
        r.curApp = app;
        app.curReceiver = r;
        app.curReceiver = r;
@@ -341,12 +346,16 @@ public final class BroadcastQueue {
        }
        }


        if (r != null) {
        if (r != null) {
            skipReceiverLocked(r);
        }
    }

    private void skipReceiverLocked(BroadcastRecord r) {
        logBroadcastReceiverDiscardLocked(r);
        logBroadcastReceiverDiscardLocked(r);
        finishReceiverLocked(r, r.resultCode, r.resultData,
        finishReceiverLocked(r, r.resultCode, r.resultData,
                r.resultExtras, r.resultAbort, false);
                r.resultExtras, r.resultAbort, false);
        scheduleBroadcastsLocked();
        scheduleBroadcastsLocked();
    }
    }
    }


    public void scheduleBroadcastsLocked() {
    public void scheduleBroadcastsLocked() {
        if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Schedule broadcasts ["
        if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Schedule broadcasts ["
@@ -641,9 +650,17 @@ public final class BroadcastQueue {
        try {
        try {
            if (DEBUG_BROADCAST_LIGHT) Slog.i(TAG_BROADCAST,
            if (DEBUG_BROADCAST_LIGHT) Slog.i(TAG_BROADCAST,
                    "Delivering to " + filter + " : " + r);
                    "Delivering to " + filter + " : " + r);
            if (filter.receiverList.app != null && filter.receiverList.app.inFullBackup) {
                // Skip delivery if full backup in progress
                // If it's an ordered broadcast, we need to continue to the next receiver.
                if (ordered) {
                    skipReceiverLocked(r);
                }
            } else {
                performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
                performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
                        new Intent(r.intent), r.resultCode, r.resultData,
                        new Intent(r.intent), r.resultCode, r.resultData,
                        r.resultExtras, r.ordered, r.initialSticky, r.userId);
                        r.resultExtras, r.ordered, r.initialSticky, r.userId);
            }
            if (ordered) {
            if (ordered) {
                r.state = BroadcastRecord.CALL_DONE_RECEIVE;
                r.state = BroadcastRecord.CALL_DONE_RECEIVE;
            }
            }
+3 −0
Original line number Original line Diff line number Diff line
@@ -192,6 +192,9 @@ final class ProcessRecord {
    // app that installed the package.
    // app that installed the package.
    ComponentName errorReportReceiver;
    ComponentName errorReportReceiver;


    // Process is currently hosting a backup agent for backup or restore
    public boolean inFullBackup;

    void dump(PrintWriter pw, String prefix) {
    void dump(PrintWriter pw, String prefix) {
        final long now = SystemClock.uptimeMillis();
        final long now = SystemClock.uptimeMillis();