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

am: 02351ca3c4

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

Change-Id: I6782f3aec13d58139d760e3e2d13f7b3495b60f7
This commit is contained in:
Amith Yamasani
2016-05-24 21:59:37 +00:00
committed by android-build-merger
3 changed files with 34 additions and 7 deletions

View File

@@ -16867,6 +16867,13 @@ public final class ActivityManagerService extends ActivityManagerNative
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;
mBackupTarget = r;
mBackupAppName = app.packageName;

View File

@@ -258,6 +258,11 @@ public final class BroadcastQueue {
if (app.thread == null) {
throw new RemoteException();
}
if (app.inFullBackup) {
skipReceiverLocked(r);
return;
}
r.receiver = app.thread.asBinder();
r.curApp = app;
app.curReceiver = r;
@@ -341,13 +346,17 @@ public final class BroadcastQueue {
}
if (r != null) {
logBroadcastReceiverDiscardLocked(r);
finishReceiverLocked(r, r.resultCode, r.resultData,
r.resultExtras, r.resultAbort, false);
scheduleBroadcastsLocked();
skipReceiverLocked(r);
}
}
private void skipReceiverLocked(BroadcastRecord r) {
logBroadcastReceiverDiscardLocked(r);
finishReceiverLocked(r, r.resultCode, r.resultData,
r.resultExtras, r.resultAbort, false);
scheduleBroadcastsLocked();
}
public void scheduleBroadcastsLocked() {
if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Schedule broadcasts ["
+ mQueueName + "]: current="
@@ -641,9 +650,17 @@ public final class BroadcastQueue {
try {
if (DEBUG_BROADCAST_LIGHT) Slog.i(TAG_BROADCAST,
"Delivering to " + filter + " : " + r);
performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
new Intent(r.intent), r.resultCode, r.resultData,
r.resultExtras, r.ordered, r.initialSticky, r.userId);
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,
new Intent(r.intent), r.resultCode, r.resultData,
r.resultExtras, r.ordered, r.initialSticky, r.userId);
}
if (ordered) {
r.state = BroadcastRecord.CALL_DONE_RECEIVE;
}

View File

@@ -192,6 +192,9 @@ final class ProcessRecord {
// app that installed the package.
ComponentName errorReportReceiver;
// Process is currently hosting a backup agent for backup or restore
public boolean inFullBackup;
void dump(PrintWriter pw, String prefix) {
final long now = SystemClock.uptimeMillis();