From e7287a0791b7398a540c18894972908683456283 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Fri, 7 Sep 2012 18:32:12 -0700 Subject: [PATCH] Sanity-check existence of restore agent When a restore dataset includes data for an app that used to have a backup agent, but does not in the currently-installed version, we were merrily trying to bring up the agent for restore anyway, and crashing. Now we don't do that; we check whether there's actually going to be an agent to handle the data before doing any of the heavy work. Bug 7130695 Change-Id: I0a38c2a8bb51d4a140a72d22896fa58d98ebaa02 --- .../com/android/server/BackupManagerService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 955ea23ff0c41..1d40f4f427f9e 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -4401,6 +4401,18 @@ class BackupManagerService extends IBackupManager.Stub { return; } + if (packageInfo.applicationInfo.backupAgentName == null + || "".equals(packageInfo.applicationInfo.backupAgentName)) { + if (DEBUG) { + Slog.i(TAG, "Data exists for package " + packageName + + " but app has no agent; skipping"); + } + EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, packageName, + "Package has no agent"); + executeNextState(RestoreState.RUNNING_QUEUE); + return; + } + if (metaInfo.versionCode > packageInfo.versionCode) { // Data is from a "newer" version of the app than we have currently // installed. If the app has not declared that it is prepared to