| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 19 | import android.app.ActivityManagerNative; |
| 20 | import android.app.IActivityManager; |
| 21 | import android.app.IApplicationThread; |
| 22 | import android.app.IBackupAgent; |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 23 | import android.content.BroadcastReceiver; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 26 | import android.content.IntentFilter; |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 27 | import android.content.pm.ApplicationInfo; |
| Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame] | 28 | import android.content.pm.PackageInfo; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 29 | import android.content.pm.PackageManager; |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 30 | import android.content.pm.PackageManager.NameNotFoundException; |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 31 | import android.net.Uri; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 32 | import android.os.Binder; |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 33 | import android.os.Bundle; |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 34 | import android.os.Environment; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 35 | import android.os.Handler; |
| 36 | import android.os.IBinder; |
| 37 | import android.os.Message; |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 38 | import android.os.ParcelFileDescriptor; |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 39 | import android.os.Process; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 40 | import android.os.RemoteException; |
| 41 | import android.util.Log; |
| 42 | import android.util.SparseArray; |
| 43 | |
| 44 | import android.backup.IBackupManager; |
| Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 45 | import android.backup.IRestoreSession; |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 46 | import android.backup.BackupManager; |
| Christopher Tate | 9b3905c | 2009-06-08 15:24:01 -0700 | [diff] [blame^] | 47 | import android.backup.RestoreSet; |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 48 | |
| 49 | import com.android.internal.backup.AdbTransport; |
| 50 | import com.android.internal.backup.GoogleTransport; |
| 51 | import com.android.internal.backup.IBackupTransport; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 52 | |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 53 | import java.io.File; |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 54 | import java.io.FileDescriptor; |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 55 | import java.io.FileNotFoundException; |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 56 | import java.io.PrintWriter; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 57 | import java.lang.String; |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 58 | import java.util.ArrayList; |
| 59 | import java.util.HashMap; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 60 | import java.util.HashSet; |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 61 | import java.util.Iterator; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 62 | import java.util.List; |
| 63 | |
| 64 | class BackupManagerService extends IBackupManager.Stub { |
| 65 | private static final String TAG = "BackupManagerService"; |
| 66 | private static final boolean DEBUG = true; |
| 67 | |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 68 | private static final long COLLECTION_INTERVAL = 1000; |
| 69 | //private static final long COLLECTION_INTERVAL = 3 * 60 * 1000; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 70 | |
| 71 | private static final int MSG_RUN_BACKUP = 1; |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 72 | private static final int MSG_RUN_FULL_BACKUP = 2; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 73 | |
| 74 | private Context mContext; |
| 75 | private PackageManager mPackageManager; |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 76 | private final IActivityManager mActivityManager; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 77 | private final BackupHandler mBackupHandler = new BackupHandler(); |
| 78 | // map UIDs to the set of backup client services within that UID's app set |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 79 | private SparseArray<HashSet<ApplicationInfo>> mBackupParticipants |
| 80 | = new SparseArray<HashSet<ApplicationInfo>>(); |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 81 | // set of backup services that have pending changes |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 82 | private class BackupRequest { |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 83 | public ApplicationInfo appInfo; |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 84 | public boolean fullBackup; |
| 85 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 86 | BackupRequest(ApplicationInfo app, boolean isFull) { |
| 87 | appInfo = app; |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 88 | fullBackup = isFull; |
| 89 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 90 | |
| 91 | public String toString() { |
| 92 | return "BackupRequest{app=" + appInfo + " full=" + fullBackup + "}"; |
| 93 | } |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 94 | } |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 95 | // Backups that we haven't started yet. |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 96 | private HashMap<ApplicationInfo,BackupRequest> mPendingBackups |
| 97 | = new HashMap<ApplicationInfo,BackupRequest>(); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 98 | // Backups that we have started. These are separate to prevent starvation |
| 99 | // if an app keeps re-enqueuing itself. |
| 100 | private ArrayList<BackupRequest> mBackupQueue; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 101 | private final Object mQueueLock = new Object(); |
| 102 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 103 | // The thread performing the sequence of queued backups binds to each app's agent |
| 104 | // in succession. Bind notifications are asynchronously delivered through the |
| 105 | // Activity Manager; use this lock object to signal when a requested binding has |
| 106 | // completed. |
| 107 | private final Object mAgentConnectLock = new Object(); |
| 108 | private IBackupAgent mConnectedAgent; |
| 109 | private volatile boolean mConnecting; |
| 110 | |
| 111 | private int mTransportId; |
| 112 | |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 113 | private File mStateDir; |
| Christopher Tate | f417247 | 2009-05-05 15:50:03 -0700 | [diff] [blame] | 114 | private File mDataDir; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 115 | |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 116 | public BackupManagerService(Context context) { |
| 117 | mContext = context; |
| 118 | mPackageManager = context.getPackageManager(); |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 119 | mActivityManager = ActivityManagerNative.getDefault(); |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 120 | |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 121 | // Set up our bookkeeping |
| Christopher Tate | f417247 | 2009-05-05 15:50:03 -0700 | [diff] [blame] | 122 | mStateDir = new File(Environment.getDataDirectory(), "backup"); |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 123 | mStateDir.mkdirs(); |
| Christopher Tate | f417247 | 2009-05-05 15:50:03 -0700 | [diff] [blame] | 124 | mDataDir = Environment.getDownloadCacheDirectory(); |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 125 | mTransportId = BackupManager.TRANSPORT_GOOGLE; |
| Christopher Tate | 22b8787 | 2009-05-04 16:41:53 -0700 | [diff] [blame] | 126 | |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 127 | // Build our mapping of uid to backup client services |
| 128 | synchronized (mBackupParticipants) { |
| 129 | addPackageParticipantsLocked(null); |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 132 | // Register for broadcasts about package install, etc., so we can |
| 133 | // update the provider list. |
| 134 | IntentFilter filter = new IntentFilter(); |
| 135 | filter.addAction(Intent.ACTION_PACKAGE_ADDED); |
| 136 | filter.addAction(Intent.ACTION_PACKAGE_REMOVED); |
| 137 | filter.addDataScheme("package"); |
| 138 | mContext.registerReceiver(mBroadcastReceiver, filter); |
| 139 | } |
| 140 | |
| 141 | // ----- Track installation/removal of packages ----- |
| 142 | BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 143 | public void onReceive(Context context, Intent intent) { |
| 144 | if (DEBUG) Log.d(TAG, "Received broadcast " + intent); |
| 145 | |
| 146 | Uri uri = intent.getData(); |
| 147 | if (uri == null) { |
| 148 | return; |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 149 | } |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 150 | String pkgName = uri.getSchemeSpecificPart(); |
| 151 | if (pkgName == null) { |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | String action = intent.getAction(); |
| 156 | if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { |
| 157 | synchronized (mBackupParticipants) { |
| 158 | Bundle extras = intent.getExtras(); |
| 159 | if (extras != null && extras.getBoolean(Intent.EXTRA_REPLACING, false)) { |
| 160 | // The package was just upgraded |
| 161 | updatePackageParticipantsLocked(pkgName); |
| 162 | } else { |
| 163 | // The package was just added |
| 164 | addPackageParticipantsLocked(pkgName); |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) { |
| 169 | Bundle extras = intent.getExtras(); |
| 170 | if (extras != null && extras.getBoolean(Intent.EXTRA_REPLACING, false)) { |
| 171 | // The package is being updated. We'll receive a PACKAGE_ADDED shortly. |
| 172 | } else { |
| 173 | synchronized (mBackupParticipants) { |
| 174 | removePackageParticipantsLocked(pkgName); |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | }; |
| 180 | |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 181 | // ----- Run the actual backup process asynchronously ----- |
| 182 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 183 | private class BackupHandler extends Handler { |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 184 | public void handleMessage(Message msg) { |
| 185 | |
| 186 | switch (msg.what) { |
| 187 | case MSG_RUN_BACKUP: |
| 188 | // snapshot the pending-backup set and work on that |
| 189 | synchronized (mQueueLock) { |
| Joe Onorato | d2110db | 2009-05-19 13:41:21 -0700 | [diff] [blame] | 190 | if (mBackupQueue == null) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 191 | mBackupQueue = new ArrayList<BackupRequest>(); |
| Joe Onorato | d2110db | 2009-05-19 13:41:21 -0700 | [diff] [blame] | 192 | for (BackupRequest b: mPendingBackups.values()) { |
| 193 | mBackupQueue.add(b); |
| 194 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 195 | mPendingBackups = new HashMap<ApplicationInfo,BackupRequest>(); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 196 | } |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 197 | // !!! TODO: start a new backup-queue journal file too |
| 198 | // WARNING: If we crash after this line, anything in mPendingBackups will |
| 199 | // be lost. FIX THIS. |
| 200 | } |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 201 | (new PerformBackupThread(mTransportId, mBackupQueue)).run(); |
| 202 | break; |
| 203 | |
| 204 | case MSG_RUN_FULL_BACKUP: |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 205 | break; |
| 206 | } |
| 207 | } |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 208 | } |
| 209 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 210 | void processOneBackup(BackupRequest request, IBackupAgent agent, IBackupTransport transport) { |
| 211 | final String packageName = request.appInfo.packageName; |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 212 | Log.d(TAG, "processOneBackup doBackup() on " + packageName); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 213 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 214 | try { |
| Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame] | 215 | // Look up the package info & signatures. This is first so that if it |
| 216 | // throws an exception, there's no file setup yet that would need to |
| 217 | // be unraveled. |
| 218 | PackageInfo packInfo = mPackageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); |
| 219 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 220 | // !!! TODO: get the state file dir from the transport |
| 221 | File savedStateName = new File(mStateDir, packageName); |
| 222 | File backupDataName = new File(mDataDir, packageName + ".data"); |
| 223 | File newStateName = new File(mStateDir, packageName + ".new"); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 224 | |
| 225 | // In a full backup, we pass a null ParcelFileDescriptor as |
| 226 | // the saved-state "file" |
| 227 | ParcelFileDescriptor savedState = (request.fullBackup) ? null |
| 228 | : ParcelFileDescriptor.open(savedStateName, |
| 229 | ParcelFileDescriptor.MODE_READ_ONLY | |
| 230 | ParcelFileDescriptor.MODE_CREATE); |
| 231 | |
| 232 | backupDataName.delete(); |
| 233 | ParcelFileDescriptor backupData = |
| 234 | ParcelFileDescriptor.open(backupDataName, |
| 235 | ParcelFileDescriptor.MODE_READ_WRITE | |
| 236 | ParcelFileDescriptor.MODE_CREATE); |
| 237 | |
| 238 | newStateName.delete(); |
| 239 | ParcelFileDescriptor newState = |
| 240 | ParcelFileDescriptor.open(newStateName, |
| 241 | ParcelFileDescriptor.MODE_READ_WRITE | |
| 242 | ParcelFileDescriptor.MODE_CREATE); |
| 243 | |
| 244 | // Run the target's backup pass |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 245 | boolean success = false; |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 246 | try { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 247 | agent.doBackup(savedState, backupData, newState); |
| 248 | success = true; |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 249 | } finally { |
| 250 | if (savedState != null) { |
| 251 | savedState.close(); |
| 252 | } |
| 253 | backupData.close(); |
| 254 | newState.close(); |
| 255 | } |
| 256 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 257 | // Now propagate the newly-backed-up data to the transport |
| 258 | if (success) { |
| Christopher Tate | 1885b37 | 2009-06-04 15:00:33 -0700 | [diff] [blame] | 259 | if (DEBUG) Log.v(TAG, "doBackup() success; calling transport"); |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 260 | backupData = |
| 261 | ParcelFileDescriptor.open(backupDataName, ParcelFileDescriptor.MODE_READ_ONLY); |
| Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame] | 262 | int error = transport.performBackup(packInfo, backupData); |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 263 | |
| 264 | // !!! TODO: After successful transport, delete the now-stale data |
| 265 | // and juggle the files so that next time the new state is passed |
| 266 | //backupDataName.delete(); |
| 267 | newStateName.renameTo(savedStateName); |
| 268 | } |
| Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame] | 269 | } catch (NameNotFoundException e) { |
| 270 | Log.e(TAG, "Package not found on backup: " + packageName); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 271 | } catch (FileNotFoundException fnf) { |
| Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame] | 272 | Log.w(TAG, "File not found on backup: "); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 273 | fnf.printStackTrace(); |
| 274 | } catch (RemoteException e) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 275 | Log.d(TAG, "Remote target " + request.appInfo.packageName + " threw during backup:"); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 276 | e.printStackTrace(); |
| 277 | } catch (Exception e) { |
| 278 | Log.w(TAG, "Final exception guard in backup: "); |
| 279 | e.printStackTrace(); |
| 280 | } |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 281 | } |
| 282 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 283 | // Add the backup agents in the given package to our set of known backup participants. |
| 284 | // If 'packageName' is null, adds all backup agents in the whole system. |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 285 | void addPackageParticipantsLocked(String packageName) { |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 286 | // Look for apps that define the android:backupAgent attribute |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 287 | if (DEBUG) Log.v(TAG, "addPackageParticipantsLocked: " + packageName); |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 288 | List<ApplicationInfo> targetApps = allAgentApps(); |
| 289 | addPackageParticipantsLockedInner(packageName, targetApps); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 292 | private void addPackageParticipantsLockedInner(String packageName, |
| 293 | List<ApplicationInfo> targetApps) { |
| 294 | if (DEBUG) { |
| 295 | Log.v(TAG, "Adding " + targetApps.size() + " backup participants:"); |
| 296 | for (ApplicationInfo a : targetApps) { |
| 297 | Log.v(TAG, " " + a + " agent=" + a.backupAgentName); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | for (ApplicationInfo app : targetApps) { |
| 302 | if (packageName == null || app.packageName.equals(packageName)) { |
| 303 | int uid = app.uid; |
| 304 | HashSet<ApplicationInfo> set = mBackupParticipants.get(uid); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 305 | if (set == null) { |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 306 | set = new HashSet<ApplicationInfo>(); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 307 | mBackupParticipants.put(uid, set); |
| 308 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 309 | set.add(app); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 310 | } |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 314 | // Remove the given package's backup services from our known active set. If |
| 315 | // 'packageName' is null, *all* backup services will be removed. |
| 316 | void removePackageParticipantsLocked(String packageName) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 317 | if (DEBUG) Log.v(TAG, "removePackageParticipantsLocked: " + packageName); |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 318 | List<ApplicationInfo> allApps = null; |
| 319 | if (packageName != null) { |
| 320 | allApps = new ArrayList<ApplicationInfo>(); |
| 321 | try { |
| 322 | ApplicationInfo app = mPackageManager.getApplicationInfo(packageName, 0); |
| 323 | allApps.add(app); |
| 324 | } catch (Exception e) { |
| 325 | // just skip it |
| 326 | } |
| 327 | } else { |
| 328 | // all apps with agents |
| 329 | allApps = allAgentApps(); |
| 330 | } |
| 331 | removePackageParticipantsLockedInner(packageName, allApps); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 334 | private void removePackageParticipantsLockedInner(String packageName, |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 335 | List<ApplicationInfo> agents) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 336 | if (DEBUG) { |
| 337 | Log.v(TAG, "removePackageParticipantsLockedInner (" + packageName |
| 338 | + ") removing " + agents.size() + " entries"); |
| 339 | for (ApplicationInfo a : agents) { |
| 340 | Log.v(TAG, " - " + a); |
| 341 | } |
| 342 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 343 | for (ApplicationInfo app : agents) { |
| 344 | if (packageName == null || app.packageName.equals(packageName)) { |
| 345 | int uid = app.uid; |
| 346 | HashSet<ApplicationInfo> set = mBackupParticipants.get(uid); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 347 | if (set != null) { |
| Christopher Tate | cd4ff2e | 2009-06-05 13:57:54 -0700 | [diff] [blame] | 348 | // Find the existing entry with the same package name, and remove it. |
| 349 | // We can't just remove(app) because the instances are different. |
| 350 | for (ApplicationInfo entry: set) { |
| 351 | if (entry.packageName.equals(app.packageName)) { |
| 352 | set.remove(entry); |
| 353 | break; |
| 354 | } |
| 355 | } |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 356 | if (set.size() == 0) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 357 | mBackupParticipants.delete(uid); } |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 363 | // Returns the set of all applications that define an android:backupAgent attribute |
| 364 | private List<ApplicationInfo> allAgentApps() { |
| 365 | List<ApplicationInfo> allApps = mPackageManager.getInstalledApplications(0); |
| 366 | int N = allApps.size(); |
| 367 | if (N > 0) { |
| 368 | for (int a = N-1; a >= 0; a--) { |
| 369 | ApplicationInfo app = allApps.get(a); |
| 370 | if (app.backupAgentName == null) { |
| 371 | allApps.remove(a); |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | return allApps; |
| 376 | } |
| 377 | |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 378 | // Reset the given package's known backup participants. Unlike add/remove, the update |
| 379 | // action cannot be passed a null package name. |
| 380 | void updatePackageParticipantsLocked(String packageName) { |
| 381 | if (packageName == null) { |
| 382 | Log.e(TAG, "updatePackageParticipants called with null package name"); |
| 383 | return; |
| 384 | } |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 385 | if (DEBUG) Log.v(TAG, "updatePackageParticipantsLocked: " + packageName); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 386 | |
| 387 | // brute force but small code size |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 388 | List<ApplicationInfo> allApps = allAgentApps(); |
| 389 | removePackageParticipantsLockedInner(packageName, allApps); |
| 390 | addPackageParticipantsLockedInner(packageName, allApps); |
| Christopher Tate | 3799bc2 | 2009-05-06 16:13:56 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 393 | // Instantiate the given transport |
| 394 | private IBackupTransport createTransport(int transportID) { |
| 395 | IBackupTransport transport = null; |
| 396 | switch (transportID) { |
| 397 | case BackupManager.TRANSPORT_ADB: |
| 398 | if (DEBUG) Log.v(TAG, "Initializing adb transport"); |
| 399 | transport = new AdbTransport(); |
| 400 | break; |
| 401 | |
| 402 | case BackupManager.TRANSPORT_GOOGLE: |
| 403 | if (DEBUG) Log.v(TAG, "Initializing Google transport"); |
| 404 | //!!! TODO: stand up the google backup transport for real here |
| 405 | transport = new GoogleTransport(); |
| 406 | break; |
| 407 | |
| 408 | default: |
| 409 | Log.e(TAG, "creating unknown transport " + transportID); |
| 410 | } |
| 411 | return transport; |
| 412 | } |
| 413 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 414 | // ----- Back up a set of applications via a worker thread ----- |
| 415 | |
| 416 | class PerformBackupThread extends Thread { |
| 417 | private static final String TAG = "PerformBackupThread"; |
| 418 | int mTransport; |
| 419 | ArrayList<BackupRequest> mQueue; |
| 420 | |
| 421 | public PerformBackupThread(int transportId, ArrayList<BackupRequest> queue) { |
| 422 | mTransport = transportId; |
| 423 | mQueue = queue; |
| 424 | } |
| 425 | |
| 426 | @Override |
| 427 | public void run() { |
| 428 | /* |
| 429 | * 1. start up the current transport |
| 430 | * 2. for each item in the queue: |
| 431 | * 2a. bind the agent [wait for async attach] |
| 432 | * 2b. set up the files and call doBackup() |
| 433 | * 2c. unbind the agent |
| 434 | * 3. tear down the transport |
| 435 | * 4. done! |
| 436 | */ |
| 437 | if (DEBUG) Log.v(TAG, "Beginning backup of " + mQueue.size() + " targets"); |
| 438 | |
| 439 | // stand up the current transport |
| Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 440 | IBackupTransport transport = createTransport(mTransport); |
| 441 | if (transport == null) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 442 | return; |
| 443 | } |
| 444 | |
| 445 | // The transport is up and running; now run all the backups in our queue |
| 446 | doQueuedBackups(transport); |
| 447 | |
| 448 | // Finally, tear down the transport |
| 449 | try { |
| 450 | transport.endSession(); |
| 451 | } catch (Exception e) { |
| 452 | Log.e(TAG, "Error ending transport"); |
| 453 | e.printStackTrace(); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | private void doQueuedBackups(IBackupTransport transport) { |
| 458 | for (BackupRequest request : mQueue) { |
| 459 | Log.d(TAG, "starting agent for " + request); |
| 460 | // !!! TODO: need to handle the restore case? |
| 461 | |
| 462 | IBackupAgent agent = null; |
| 463 | int mode = (request.fullBackup) |
| 464 | ? IApplicationThread.BACKUP_MODE_FULL |
| 465 | : IApplicationThread.BACKUP_MODE_INCREMENTAL; |
| 466 | try { |
| 467 | synchronized(mAgentConnectLock) { |
| 468 | mConnecting = true; |
| 469 | mConnectedAgent = null; |
| 470 | if (mActivityManager.bindBackupAgent(request.appInfo, mode)) { |
| 471 | Log.d(TAG, "awaiting agent for " + request); |
| 472 | |
| 473 | // success; wait for the agent to arrive |
| 474 | while (mConnecting && mConnectedAgent == null) { |
| 475 | try { |
| 476 | mAgentConnectLock.wait(10000); |
| 477 | } catch (InterruptedException e) { |
| 478 | // just retry |
| 479 | continue; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | // if we timed out with no connect, abort and move on |
| 484 | if (mConnecting == true) { |
| 485 | Log.w(TAG, "Timeout waiting for agent " + request); |
| 486 | continue; |
| 487 | } |
| 488 | agent = mConnectedAgent; |
| 489 | } |
| 490 | } |
| 491 | } catch (RemoteException e) { |
| 492 | // can't happen; activity manager is local |
| 493 | } catch (SecurityException ex) { |
| 494 | // Try for the next one. |
| 495 | Log.d(TAG, "error in bind", ex); |
| 496 | } |
| 497 | |
| 498 | // successful bind? run the backup for this agent |
| 499 | if (agent != null) { |
| 500 | processOneBackup(request, agent, transport); |
| 501 | } |
| 502 | |
| 503 | // send the unbind even on timeout, just in case |
| 504 | try { |
| 505 | mActivityManager.unbindBackupAgent(request.appInfo); |
| 506 | } catch (RemoteException e) { |
| 507 | // can't happen |
| 508 | } |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 513 | // ----- IBackupManager binder interface ----- |
| 514 | |
| Christopher Tate | a8bf815 | 2009-04-30 11:36:21 -0700 | [diff] [blame] | 515 | public void dataChanged(String packageName) throws RemoteException { |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 516 | // Record that we need a backup pass for the caller. Since multiple callers |
| 517 | // may share a uid, we need to note all candidates within that uid and schedule |
| 518 | // a backup pass for each of them. |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 519 | |
| 520 | Log.d(TAG, "dataChanged packageName=" + packageName); |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 521 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 522 | HashSet<ApplicationInfo> targets = mBackupParticipants.get(Binder.getCallingUid()); |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 523 | if (targets != null) { |
| 524 | synchronized (mQueueLock) { |
| 525 | // Note that this client has made data changes that need to be backed up |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 526 | for (ApplicationInfo app : targets) { |
| Christopher Tate | a8bf815 | 2009-04-30 11:36:21 -0700 | [diff] [blame] | 527 | // validate the caller-supplied package name against the known set of |
| 528 | // packages associated with this uid |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 529 | if (app.packageName.equals(packageName)) { |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 530 | // Add the caller to the set of pending backups. If there is |
| 531 | // one already there, then overwrite it, but no harm done. |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 532 | BackupRequest req = new BackupRequest(app, false); |
| 533 | mPendingBackups.put(app, req); |
| Joe Onorato | 8ad0281 | 2009-05-13 01:41:44 -0400 | [diff] [blame] | 534 | // !!! TODO: write to the pending-backup journal file in case of crash |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 538 | if (DEBUG) { |
| 539 | int numKeys = mPendingBackups.size(); |
| 540 | Log.d(TAG, "Scheduling backup for " + numKeys + " participants:"); |
| 541 | for (BackupRequest b : mPendingBackups.values()) { |
| 542 | Log.d(TAG, " + " + b + " agent=" + b.appInfo.backupAgentName); |
| 543 | } |
| 544 | } |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 545 | // Schedule a backup pass in a few minutes. As backup-eligible data |
| 546 | // keeps changing, continue to defer the backup pass until things |
| 547 | // settle down, to avoid extra overhead. |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 548 | mBackupHandler.removeMessages(MSG_RUN_BACKUP); |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 549 | mBackupHandler.sendEmptyMessageDelayed(MSG_RUN_BACKUP, COLLECTION_INTERVAL); |
| 550 | } |
| 551 | } |
| 552 | } |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 553 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 554 | // Schedule a backup pass for a given package. This method will schedule a |
| 555 | // full backup even for apps that do not declare an android:backupAgent, so |
| 556 | // use with care. |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 557 | public void scheduleFullBackup(String packageName) throws RemoteException { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 558 | mContext.enforceCallingPermission("android.permission.BACKUP", "scheduleFullBackup"); |
| 559 | |
| 560 | if (DEBUG) Log.v(TAG, "Scheduling immediate full backup for " + packageName); |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 561 | synchronized (mQueueLock) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 562 | try { |
| 563 | ApplicationInfo app = mPackageManager.getApplicationInfo(packageName, 0); |
| 564 | mPendingBackups.put(app, new BackupRequest(app, true)); |
| 565 | mBackupHandler.sendEmptyMessage(MSG_RUN_FULL_BACKUP); |
| 566 | } catch (NameNotFoundException e) { |
| 567 | Log.w(TAG, "Could not find app for " + packageName + " to schedule full backup"); |
| Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 568 | } |
| 569 | } |
| 570 | } |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 571 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 572 | // Select which transport to use for the next backup operation |
| 573 | public int selectBackupTransport(int transportId) { |
| 574 | mContext.enforceCallingPermission("android.permission.BACKUP", "selectBackupTransport"); |
| 575 | |
| 576 | int prevTransport = mTransportId; |
| 577 | mTransportId = transportId; |
| 578 | return prevTransport; |
| 579 | } |
| 580 | |
| 581 | // Callback: a requested backup agent has been instantiated. This should only |
| 582 | // be called from the Activity Manager. |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 583 | public void agentConnected(String packageName, IBinder agentBinder) { |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 584 | synchronized(mAgentConnectLock) { |
| 585 | if (Binder.getCallingUid() == Process.SYSTEM_UID) { |
| 586 | Log.d(TAG, "agentConnected pkg=" + packageName + " agent=" + agentBinder); |
| 587 | IBackupAgent agent = IBackupAgent.Stub.asInterface(agentBinder); |
| 588 | mConnectedAgent = agent; |
| 589 | mConnecting = false; |
| 590 | } else { |
| 591 | Log.w(TAG, "Non-system process uid=" + Binder.getCallingUid() |
| 592 | + " claiming agent connected"); |
| 593 | } |
| 594 | mAgentConnectLock.notifyAll(); |
| 595 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | // Callback: a backup agent has failed to come up, or has unexpectedly quit. |
| 599 | // If the agent failed to come up in the first place, the agentBinder argument |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 600 | // will be null. This should only be called from the Activity Manager. |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 601 | public void agentDisconnected(String packageName) { |
| 602 | // TODO: handle backup being interrupted |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 603 | synchronized(mAgentConnectLock) { |
| 604 | if (Binder.getCallingUid() == Process.SYSTEM_UID) { |
| 605 | mConnectedAgent = null; |
| 606 | mConnecting = false; |
| 607 | } else { |
| 608 | Log.w(TAG, "Non-system process uid=" + Binder.getCallingUid() |
| 609 | + " claiming agent disconnected"); |
| 610 | } |
| 611 | mAgentConnectLock.notifyAll(); |
| 612 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 613 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 614 | |
| Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 615 | // Hand off a restore session |
| 616 | public IRestoreSession beginRestoreSession(int transportID) { |
| 617 | mContext.enforceCallingPermission("android.permission.BACKUP", "beginRestoreSession"); |
| 618 | return null; |
| 619 | } |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 620 | |
| Christopher Tate | 9b3905c | 2009-06-08 15:24:01 -0700 | [diff] [blame^] | 621 | // ----- Restore session ----- |
| 622 | |
| 623 | class RestoreSession extends IRestoreSession.Stub { |
| 624 | private IBackupTransport mRestoreTransport = null; |
| 625 | RestoreSet[] mRestoreSets = null; |
| 626 | |
| 627 | RestoreSession(int transportID) { |
| 628 | mRestoreTransport = createTransport(transportID); |
| 629 | } |
| 630 | |
| 631 | // --- Binder interface --- |
| 632 | public RestoreSet[] getAvailableRestoreSets() throws android.os.RemoteException { |
| 633 | synchronized(this) { |
| 634 | if (mRestoreSets == null) { |
| 635 | mRestoreSets = mRestoreTransport.getAvailableRestoreSets(); |
| 636 | } |
| 637 | return mRestoreSets; |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | public int performRestore(int token) throws android.os.RemoteException { |
| 642 | return -1; |
| 643 | } |
| 644 | |
| 645 | public void endRestoreSession() throws android.os.RemoteException { |
| 646 | mRestoreTransport.endSession(); |
| 647 | mRestoreTransport = null; |
| 648 | } |
| 649 | } |
| 650 | |
| Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 651 | |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 652 | @Override |
| 653 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 654 | synchronized (mQueueLock) { |
| 655 | int N = mBackupParticipants.size(); |
| 656 | pw.println("Participants:"); |
| 657 | for (int i=0; i<N; i++) { |
| 658 | int uid = mBackupParticipants.keyAt(i); |
| 659 | pw.print(" uid: "); |
| 660 | pw.println(uid); |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 661 | HashSet<ApplicationInfo> participants = mBackupParticipants.valueAt(i); |
| 662 | for (ApplicationInfo app: participants) { |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 663 | pw.print(" "); |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 664 | pw.println(app.toString()); |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 665 | } |
| 666 | } |
| Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 667 | pw.println("Pending:"); |
| 668 | Iterator<BackupRequest> br = mPendingBackups.values().iterator(); |
| 669 | while (br.hasNext()) { |
| 670 | pw.print(" "); |
| 671 | pw.println(br); |
| 672 | } |
| Joe Onorato | b1a7ffe | 2009-05-06 18:06:21 -0700 | [diff] [blame] | 673 | } |
| 674 | } |
| Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 675 | } |