diff options
Diffstat (limited to 'services/backup/java/com/android/server')
-rw-r--r-- | services/backup/java/com/android/server/backup/BackupManagerService.java | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 30d90af..3e57d31 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -2231,10 +2231,10 @@ public class BackupManagerService { // fire off a backup agent, blocking until it attaches or times out IBackupAgent bindToAgentSynchronous(ApplicationInfo app, int mode) { IBackupAgent agent = null; - synchronized(mAgentConnectLock) { - mConnecting = true; - mConnectedAgent = null; - try { + try { + synchronized(mAgentConnectLock) { + mConnecting = true; + mConnectedAgent = null; if (mActivityManager.bindBackupAgent(app, mode)) { Slog.d(TAG, "awaiting agent for " + app); @@ -2248,7 +2248,6 @@ public class BackupManagerService { } catch (InterruptedException e) { // just bail Slog.w(TAG, "Interrupted: " + e); - mActivityManager.clearPendingBackup(); return null; } } @@ -2256,14 +2255,22 @@ public class BackupManagerService { // if we timed out with no connect, abort and move on if (mConnecting == true) { Slog.w(TAG, "Timeout waiting for agent " + app); - mActivityManager.clearPendingBackup(); return null; } if (DEBUG) Slog.i(TAG, "got agent " + mConnectedAgent); agent = mConnectedAgent; } - } catch (RemoteException e) { + } + } catch (RemoteException e) { // can't happen - ActivityManager is local + } finally { + // failed to bind backup agent, clear pending backup + if (agent == null) { + try { + mActivityManager.clearPendingBackup(); + } catch (RemoteException e) { + // can't happen - ActivityManager is local + } } } return agent; @@ -2944,6 +2951,12 @@ public class BackupManagerService { final String pkgName = mCurrentPackage.packageName; final long filepos = mBackupDataName.length(); + if (mBackupData == null) { + failAgent(mAgentBinder, "Backup data was null: " + mBackupDataName); + addBackupTrace("backup data was null: " + mBackupDataName); + agentErrorCleanup(); + return; + } FileDescriptor fd = mBackupData.getFileDescriptor(); try { // If it's a 3rd party app, see whether they wrote any protected keys @@ -7948,6 +7961,11 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF } int toCopy = result; while (toCopy > 0) { + if (!mEngine.isRunning() && RestoreEngine.SUCCESS != mEngine.getResult()) { + Slog.e(TAG, "RestoreEngine fail"); + // throw IOException to abandon this package's restore + throw new IOException(); + } int n = transportIn.read(buffer, 0, toCopy); engineOut.write(buffer, 0, n); toCopy -= n; |