Loading cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +32 −42 Original line number Original line Diff line number Diff line Loading @@ -64,6 +64,10 @@ public class Bmgr { private static final String BMGR_NOT_RUNNING_ERR = private static final String BMGR_NOT_RUNNING_ERR = "Error: Could not access the Backup Manager. Is the system running?"; "Error: Could not access the Backup Manager. Is the system running?"; private static final String BMGR_NOT_ACTIVATED_FOR_USER = "Error: Backup Manager is not activated for user "; private static final String BMGR_ERR_NO_RESTORESESSION_FOR_USER = "Error: Could not get restore session for user "; private static final String TRANSPORT_NOT_RUNNING_ERR = private static final String TRANSPORT_NOT_RUNNING_ERR = "Error: Could not access the backup transport. Is the system running?"; "Error: Could not access the backup transport. Is the system running?"; private static final String PM_NOT_RUNNING_ERR = private static final String PM_NOT_RUNNING_ERR = Loading Loading @@ -190,15 +194,19 @@ public class Bmgr { showUsage(); showUsage(); } } boolean isBackupActive(@UserIdInt int userId) { private void handleRemoteException(RemoteException e) { System.err.println(e.toString()); System.err.println(BMGR_NOT_RUNNING_ERR); } private boolean isBackupActive(@UserIdInt int userId) { try { try { if (!mBmgr.isBackupServiceActive(userId)) { if (!mBmgr.isBackupServiceActive(userId)) { System.err.println(BMGR_NOT_RUNNING_ERR); System.err.println(BMGR_NOT_ACTIVATED_FOR_USER + userId); return false; return false; } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); return false; return false; } } Loading @@ -214,8 +222,7 @@ public class Bmgr { System.out.println("Backup Manager currently " System.out.println("Backup Manager currently " + activatedToString(mBmgr.isBackupServiceActive(userId))); + activatedToString(mBmgr.isBackupServiceActive(userId))); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -230,8 +237,7 @@ public class Bmgr { System.out.println("Backup Manager currently " System.out.println("Backup Manager currently " + enableToString(isEnabled)); + enableToString(isEnabled)); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -250,8 +256,7 @@ public class Bmgr { showUsage(); showUsage(); return; return; } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -259,8 +264,7 @@ public class Bmgr { try { try { mBmgr.backupNowForUser(userId); mBmgr.backupNowForUser(userId); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -274,8 +278,7 @@ public class Bmgr { try { try { mBmgr.dataChangedForUser(userId, pkg); mBmgr.dataChangedForUser(userId, pkg); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -292,8 +295,7 @@ public class Bmgr { mBmgr.fullTransportBackupForUser( mBmgr.fullTransportBackupForUser( userId, allPkgs.toArray(new String[allPkgs.size()])); userId, allPkgs.toArray(new String[allPkgs.size()])); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } } } Loading Loading @@ -421,8 +423,7 @@ public class Bmgr { try { try { filteredPackages = mBmgr.filterAppsEligibleForBackupForUser(userId, packages); filteredPackages = mBmgr.filterAppsEligibleForBackupForUser(userId, packages); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } backupNowPackages(userId, Arrays.asList(filteredPackages), nonIncrementalBackup, backupNowPackages(userId, Arrays.asList(filteredPackages), nonIncrementalBackup, monitorState); monitorState); Loading Loading @@ -455,8 +456,7 @@ public class Bmgr { System.err.println("Unable to run backup"); System.err.println("Unable to run backup"); } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -506,8 +506,7 @@ public class Bmgr { try { try { mBmgr.cancelBackupsForUser(userId); mBmgr.cancelBackupsForUser(userId); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } return; return; } } Loading Loading @@ -537,8 +536,7 @@ public class Bmgr { } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -569,8 +567,7 @@ public class Bmgr { } } }); }); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); return; return; } } Loading Loading @@ -598,8 +595,7 @@ public class Bmgr { mBmgr.clearBackupDataForUser(userId, transport, pkg); mBmgr.clearBackupDataForUser(userId, transport, pkg); System.out.println("Wiped backup data for " + pkg + " on " + transport); System.out.println("Wiped backup data for " + pkg + " on " + transport); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -632,8 +628,7 @@ public class Bmgr { observer.waitForCompletion(30*1000L); observer.waitForCompletion(30*1000L); System.out.println("Initialization result: " + observer.result); System.out.println("Initialization result: " + observer.result); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -648,7 +643,7 @@ public class Bmgr { try { try { mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); if (mRestore == null) { if (mRestore == null) { System.err.println(BMGR_NOT_RUNNING_ERR); System.err.println(BMGR_ERR_NO_RESTORESESSION_FOR_USER + userId); return; return; } } Loading @@ -658,8 +653,7 @@ public class Bmgr { mRestore.endRestoreSession(); mRestore.endRestoreSession(); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -686,8 +680,7 @@ public class Bmgr { System.out.println(pad + t); System.out.println(pad + t); } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -805,7 +798,7 @@ public class Bmgr { boolean didRestore = false; boolean didRestore = false; mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); if (mRestore == null) { if (mRestore == null) { System.err.println(BMGR_NOT_RUNNING_ERR); System.err.println(BMGR_ERR_NO_RESTORESESSION_FOR_USER + userId); return; return; } } RestoreSet[] sets = null; RestoreSet[] sets = null; Loading Loading @@ -851,8 +844,7 @@ public class Bmgr { System.out.println("done"); System.out.println("done"); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -865,8 +857,7 @@ public class Bmgr { } } } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -886,8 +877,7 @@ public class Bmgr { + " for user " + " for user " + userId); + userId); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading
cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +32 −42 Original line number Original line Diff line number Diff line Loading @@ -64,6 +64,10 @@ public class Bmgr { private static final String BMGR_NOT_RUNNING_ERR = private static final String BMGR_NOT_RUNNING_ERR = "Error: Could not access the Backup Manager. Is the system running?"; "Error: Could not access the Backup Manager. Is the system running?"; private static final String BMGR_NOT_ACTIVATED_FOR_USER = "Error: Backup Manager is not activated for user "; private static final String BMGR_ERR_NO_RESTORESESSION_FOR_USER = "Error: Could not get restore session for user "; private static final String TRANSPORT_NOT_RUNNING_ERR = private static final String TRANSPORT_NOT_RUNNING_ERR = "Error: Could not access the backup transport. Is the system running?"; "Error: Could not access the backup transport. Is the system running?"; private static final String PM_NOT_RUNNING_ERR = private static final String PM_NOT_RUNNING_ERR = Loading Loading @@ -190,15 +194,19 @@ public class Bmgr { showUsage(); showUsage(); } } boolean isBackupActive(@UserIdInt int userId) { private void handleRemoteException(RemoteException e) { System.err.println(e.toString()); System.err.println(BMGR_NOT_RUNNING_ERR); } private boolean isBackupActive(@UserIdInt int userId) { try { try { if (!mBmgr.isBackupServiceActive(userId)) { if (!mBmgr.isBackupServiceActive(userId)) { System.err.println(BMGR_NOT_RUNNING_ERR); System.err.println(BMGR_NOT_ACTIVATED_FOR_USER + userId); return false; return false; } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); return false; return false; } } Loading @@ -214,8 +222,7 @@ public class Bmgr { System.out.println("Backup Manager currently " System.out.println("Backup Manager currently " + activatedToString(mBmgr.isBackupServiceActive(userId))); + activatedToString(mBmgr.isBackupServiceActive(userId))); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -230,8 +237,7 @@ public class Bmgr { System.out.println("Backup Manager currently " System.out.println("Backup Manager currently " + enableToString(isEnabled)); + enableToString(isEnabled)); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -250,8 +256,7 @@ public class Bmgr { showUsage(); showUsage(); return; return; } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -259,8 +264,7 @@ public class Bmgr { try { try { mBmgr.backupNowForUser(userId); mBmgr.backupNowForUser(userId); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -274,8 +278,7 @@ public class Bmgr { try { try { mBmgr.dataChangedForUser(userId, pkg); mBmgr.dataChangedForUser(userId, pkg); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -292,8 +295,7 @@ public class Bmgr { mBmgr.fullTransportBackupForUser( mBmgr.fullTransportBackupForUser( userId, allPkgs.toArray(new String[allPkgs.size()])); userId, allPkgs.toArray(new String[allPkgs.size()])); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } } } Loading Loading @@ -421,8 +423,7 @@ public class Bmgr { try { try { filteredPackages = mBmgr.filterAppsEligibleForBackupForUser(userId, packages); filteredPackages = mBmgr.filterAppsEligibleForBackupForUser(userId, packages); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } backupNowPackages(userId, Arrays.asList(filteredPackages), nonIncrementalBackup, backupNowPackages(userId, Arrays.asList(filteredPackages), nonIncrementalBackup, monitorState); monitorState); Loading Loading @@ -455,8 +456,7 @@ public class Bmgr { System.err.println("Unable to run backup"); System.err.println("Unable to run backup"); } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -506,8 +506,7 @@ public class Bmgr { try { try { mBmgr.cancelBackupsForUser(userId); mBmgr.cancelBackupsForUser(userId); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } return; return; } } Loading Loading @@ -537,8 +536,7 @@ public class Bmgr { } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -569,8 +567,7 @@ public class Bmgr { } } }); }); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); return; return; } } Loading Loading @@ -598,8 +595,7 @@ public class Bmgr { mBmgr.clearBackupDataForUser(userId, transport, pkg); mBmgr.clearBackupDataForUser(userId, transport, pkg); System.out.println("Wiped backup data for " + pkg + " on " + transport); System.out.println("Wiped backup data for " + pkg + " on " + transport); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -632,8 +628,7 @@ public class Bmgr { observer.waitForCompletion(30*1000L); observer.waitForCompletion(30*1000L); System.out.println("Initialization result: " + observer.result); System.out.println("Initialization result: " + observer.result); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -648,7 +643,7 @@ public class Bmgr { try { try { mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); if (mRestore == null) { if (mRestore == null) { System.err.println(BMGR_NOT_RUNNING_ERR); System.err.println(BMGR_ERR_NO_RESTORESESSION_FOR_USER + userId); return; return; } } Loading @@ -658,8 +653,7 @@ public class Bmgr { mRestore.endRestoreSession(); mRestore.endRestoreSession(); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -686,8 +680,7 @@ public class Bmgr { System.out.println(pad + t); System.out.println(pad + t); } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading Loading @@ -805,7 +798,7 @@ public class Bmgr { boolean didRestore = false; boolean didRestore = false; mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null); if (mRestore == null) { if (mRestore == null) { System.err.println(BMGR_NOT_RUNNING_ERR); System.err.println(BMGR_ERR_NO_RESTORESESSION_FOR_USER + userId); return; return; } } RestoreSet[] sets = null; RestoreSet[] sets = null; Loading Loading @@ -851,8 +844,7 @@ public class Bmgr { System.out.println("done"); System.out.println("done"); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -865,8 +857,7 @@ public class Bmgr { } } } } } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading @@ -886,8 +877,7 @@ public class Bmgr { + " for user " + " for user " + userId); + userId); } catch (RemoteException e) { } catch (RemoteException e) { System.err.println(e.toString()); handleRemoteException(e); System.err.println(BMGR_NOT_RUNNING_ERR); } } } } Loading