Loading cmds/bu/src/com/android/commands/bu/Backup.java +6 −1 Original line number Original line Diff line number Diff line Loading @@ -66,6 +66,7 @@ public final class Backup { boolean saveApks = false; boolean saveApks = false; boolean saveShared = false; boolean saveShared = false; boolean doEverything = false; boolean doEverything = false; boolean allIncludesSystem = true; String arg; String arg; while ((arg = nextArg()) != null) { while ((arg = nextArg()) != null) { Loading @@ -78,6 +79,10 @@ public final class Backup { saveShared = true; saveShared = true; } else if ("-noshared".equals(arg)) { } else if ("-noshared".equals(arg)) { saveShared = false; saveShared = false; } else if ("-system".equals(arg)) { allIncludesSystem = true; } else if ("-nosystem".equals(arg)) { allIncludesSystem = false; } else if ("-all".equals(arg)) { } else if ("-all".equals(arg)) { doEverything = true; doEverything = true; } else { } else { Loading @@ -102,7 +107,7 @@ public final class Backup { try { try { ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd); ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd); String[] packArray = new String[packages.size()]; String[] packArray = new String[packages.size()]; mBackupManager.fullBackup(fd, saveApks, saveShared, doEverything, mBackupManager.fullBackup(fd, saveApks, saveShared, doEverything, allIncludesSystem, packages.toArray(packArray)); packages.toArray(packArray)); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Unable to invoke backup manager for backup"); Log.e(TAG, "Unable to invoke backup manager for backup"); Loading core/java/android/app/backup/IBackupManager.aidl +5 −1 Original line number Original line Diff line number Diff line Loading @@ -157,11 +157,15 @@ interface IBackupManager { * @param allApps If <code>true</code>, the resulting tar stream will include all * @param allApps If <code>true</code>, the resulting tar stream will include all * installed applications' data, not just those named in the <code>packageNames</code> * installed applications' data, not just those named in the <code>packageNames</code> * parameter. * parameter. * @param allIncludesSystem If {@code true}, then {@code allApps} will be interpreted * as including packages pre-installed as part of the system. If {@code false}, * then setting {@code allApps} to {@code true} will mean only that all 3rd-party * applications will be included in the dataset. * @param packageNames The package names of the apps whose data (and optionally .apk files) * @param packageNames The package names of the apps whose data (and optionally .apk files) * are to be backed up. The <code>allApps</code> parameter supersedes this. * are to be backed up. The <code>allApps</code> parameter supersedes this. */ */ void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, boolean allApps, in String[] packageNames); boolean allApps, boolean allIncludesSystem, in String[] packageNames); /** /** * Restore device content from the data stream passed through the given socket. The * Restore device content from the data stream passed through the given socket. The Loading services/java/com/android/server/BackupManagerService.java +29 −10 Original line number Original line Diff line number Diff line Loading @@ -325,14 +325,16 @@ class BackupManagerService extends IBackupManager.Stub { public boolean includeApks; public boolean includeApks; public boolean includeShared; public boolean includeShared; public boolean allApps; public boolean allApps; public boolean includeSystem; public String[] packages; public String[] packages; FullBackupParams(ParcelFileDescriptor output, boolean saveApks, boolean saveShared, FullBackupParams(ParcelFileDescriptor output, boolean saveApks, boolean saveShared, boolean doAllApps, String[] pkgList) { boolean doAllApps, boolean doSystem, String[] pkgList) { fd = output; fd = output; includeApks = saveApks; includeApks = saveApks; includeShared = saveShared; includeShared = saveShared; allApps = doAllApps; allApps = doAllApps; includeSystem = doSystem; packages = pkgList; packages = pkgList; } } } } Loading Loading @@ -504,7 +506,7 @@ class BackupManagerService extends IBackupManager.Stub { PerformFullBackupTask task = new PerformFullBackupTask(params.fd, PerformFullBackupTask task = new PerformFullBackupTask(params.fd, params.observer, params.includeApks, params.observer, params.includeApks, params.includeShared, params.curPassword, params.encryptPassword, params.includeShared, params.curPassword, params.encryptPassword, params.allApps, params.packages, params.latch); params.allApps, params.includeSystem, params.packages, params.latch); (new Thread(task)).start(); (new Thread(task)).start(); break; break; } } Loading Loading @@ -2161,6 +2163,7 @@ class BackupManagerService extends IBackupManager.Stub { boolean mIncludeApks; boolean mIncludeApks; boolean mIncludeShared; boolean mIncludeShared; boolean mAllApps; boolean mAllApps; final boolean mIncludeSystem; String[] mPackages; String[] mPackages; String mCurrentPassword; String mCurrentPassword; String mEncryptPassword; String mEncryptPassword; Loading Loading @@ -2219,13 +2222,14 @@ class BackupManagerService extends IBackupManager.Stub { PerformFullBackupTask(ParcelFileDescriptor fd, IFullBackupRestoreObserver observer, PerformFullBackupTask(ParcelFileDescriptor fd, IFullBackupRestoreObserver observer, boolean includeApks, boolean includeShared, String curPassword, boolean includeApks, boolean includeShared, String curPassword, String encryptPassword, boolean doAllApps, String[] packages, String encryptPassword, boolean doAllApps, boolean doSystem, String[] packages, AtomicBoolean latch) { AtomicBoolean latch) { mOutputFile = fd; mOutputFile = fd; mObserver = observer; mObserver = observer; mIncludeApks = includeApks; mIncludeApks = includeApks; mIncludeShared = includeShared; mIncludeShared = includeShared; mAllApps = doAllApps; mAllApps = doAllApps; mIncludeSystem = doSystem; mPackages = packages; mPackages = packages; mCurrentPassword = curPassword; mCurrentPassword = curPassword; // when backing up, if there is a current backup password, we require that // when backing up, if there is a current backup password, we require that Loading @@ -2245,7 +2249,7 @@ class BackupManagerService extends IBackupManager.Stub { @Override @Override public void run() { public void run() { final List<PackageInfo> packagesToBackup; List<PackageInfo> packagesToBackup = new ArrayList<PackageInfo>(); Slog.i(TAG, "--- Performing full-dataset backup ---"); Slog.i(TAG, "--- Performing full-dataset backup ---"); sendStartBackup(); sendStartBackup(); Loading @@ -2254,8 +2258,23 @@ class BackupManagerService extends IBackupManager.Stub { if (mAllApps) { if (mAllApps) { packagesToBackup = mPackageManager.getInstalledPackages( packagesToBackup = mPackageManager.getInstalledPackages( PackageManager.GET_SIGNATURES); PackageManager.GET_SIGNATURES); // Exclude system apps if we've been asked to do so if (mIncludeSystem == false) { for (int i = 0; i < packagesToBackup.size(); ) { PackageInfo pkg = packagesToBackup.get(i); if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { packagesToBackup.remove(i); } else { } else { packagesToBackup = new ArrayList<PackageInfo>(); i++; } } } } // Now process the command line argument packages, if any. Note that explicitly- // named system-partition packages will be included even if includeSystem was // set to false. if (mPackages != null) { for (String pkgName : mPackages) { for (String pkgName : mPackages) { try { try { packagesToBackup.add(mPackageManager.getPackageInfo(pkgName, packagesToBackup.add(mPackageManager.getPackageInfo(pkgName, Loading @@ -2268,8 +2287,8 @@ class BackupManagerService extends IBackupManager.Stub { // Cull any packages that have indicated that backups are not permitted. // Cull any packages that have indicated that backups are not permitted. for (int i = 0; i < packagesToBackup.size(); ) { for (int i = 0; i < packagesToBackup.size(); ) { PackageInfo info = packagesToBackup.get(i); PackageInfo pkg = packagesToBackup.get(i); if ((info.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) == 0) { if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) == 0) { packagesToBackup.remove(i); packagesToBackup.remove(i); } else { } else { i++; i++; Loading Loading @@ -4781,7 +4800,7 @@ class BackupManagerService extends IBackupManager.Stub { // to the supplied file descriptor. This method is synchronous and does not return // to the supplied file descriptor. This method is synchronous and does not return // to the caller until the backup has been completed. // to the caller until the backup has been completed. public void fullBackup(ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, public void fullBackup(ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, boolean doAllApps, String[] pkgList) { boolean doAllApps, boolean includeSystem, String[] pkgList) { mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullBackup"); mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullBackup"); // Validate // Validate Loading Loading @@ -4811,7 +4830,7 @@ class BackupManagerService extends IBackupManager.Stub { Slog.i(TAG, "Beginning full backup..."); Slog.i(TAG, "Beginning full backup..."); FullBackupParams params = new FullBackupParams(fd, includeApks, includeShared, FullBackupParams params = new FullBackupParams(fd, includeApks, includeShared, doAllApps, pkgList); doAllApps, includeSystem, pkgList); final int token = generateToken(); final int token = generateToken(); synchronized (mFullConfirmations) { synchronized (mFullConfirmations) { mFullConfirmations.put(token, params); mFullConfirmations.put(token, params); Loading Loading
cmds/bu/src/com/android/commands/bu/Backup.java +6 −1 Original line number Original line Diff line number Diff line Loading @@ -66,6 +66,7 @@ public final class Backup { boolean saveApks = false; boolean saveApks = false; boolean saveShared = false; boolean saveShared = false; boolean doEverything = false; boolean doEverything = false; boolean allIncludesSystem = true; String arg; String arg; while ((arg = nextArg()) != null) { while ((arg = nextArg()) != null) { Loading @@ -78,6 +79,10 @@ public final class Backup { saveShared = true; saveShared = true; } else if ("-noshared".equals(arg)) { } else if ("-noshared".equals(arg)) { saveShared = false; saveShared = false; } else if ("-system".equals(arg)) { allIncludesSystem = true; } else if ("-nosystem".equals(arg)) { allIncludesSystem = false; } else if ("-all".equals(arg)) { } else if ("-all".equals(arg)) { doEverything = true; doEverything = true; } else { } else { Loading @@ -102,7 +107,7 @@ public final class Backup { try { try { ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd); ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd); String[] packArray = new String[packages.size()]; String[] packArray = new String[packages.size()]; mBackupManager.fullBackup(fd, saveApks, saveShared, doEverything, mBackupManager.fullBackup(fd, saveApks, saveShared, doEverything, allIncludesSystem, packages.toArray(packArray)); packages.toArray(packArray)); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Unable to invoke backup manager for backup"); Log.e(TAG, "Unable to invoke backup manager for backup"); Loading
core/java/android/app/backup/IBackupManager.aidl +5 −1 Original line number Original line Diff line number Diff line Loading @@ -157,11 +157,15 @@ interface IBackupManager { * @param allApps If <code>true</code>, the resulting tar stream will include all * @param allApps If <code>true</code>, the resulting tar stream will include all * installed applications' data, not just those named in the <code>packageNames</code> * installed applications' data, not just those named in the <code>packageNames</code> * parameter. * parameter. * @param allIncludesSystem If {@code true}, then {@code allApps} will be interpreted * as including packages pre-installed as part of the system. If {@code false}, * then setting {@code allApps} to {@code true} will mean only that all 3rd-party * applications will be included in the dataset. * @param packageNames The package names of the apps whose data (and optionally .apk files) * @param packageNames The package names of the apps whose data (and optionally .apk files) * are to be backed up. The <code>allApps</code> parameter supersedes this. * are to be backed up. The <code>allApps</code> parameter supersedes this. */ */ void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, boolean allApps, in String[] packageNames); boolean allApps, boolean allIncludesSystem, in String[] packageNames); /** /** * Restore device content from the data stream passed through the given socket. The * Restore device content from the data stream passed through the given socket. The Loading
services/java/com/android/server/BackupManagerService.java +29 −10 Original line number Original line Diff line number Diff line Loading @@ -325,14 +325,16 @@ class BackupManagerService extends IBackupManager.Stub { public boolean includeApks; public boolean includeApks; public boolean includeShared; public boolean includeShared; public boolean allApps; public boolean allApps; public boolean includeSystem; public String[] packages; public String[] packages; FullBackupParams(ParcelFileDescriptor output, boolean saveApks, boolean saveShared, FullBackupParams(ParcelFileDescriptor output, boolean saveApks, boolean saveShared, boolean doAllApps, String[] pkgList) { boolean doAllApps, boolean doSystem, String[] pkgList) { fd = output; fd = output; includeApks = saveApks; includeApks = saveApks; includeShared = saveShared; includeShared = saveShared; allApps = doAllApps; allApps = doAllApps; includeSystem = doSystem; packages = pkgList; packages = pkgList; } } } } Loading Loading @@ -504,7 +506,7 @@ class BackupManagerService extends IBackupManager.Stub { PerformFullBackupTask task = new PerformFullBackupTask(params.fd, PerformFullBackupTask task = new PerformFullBackupTask(params.fd, params.observer, params.includeApks, params.observer, params.includeApks, params.includeShared, params.curPassword, params.encryptPassword, params.includeShared, params.curPassword, params.encryptPassword, params.allApps, params.packages, params.latch); params.allApps, params.includeSystem, params.packages, params.latch); (new Thread(task)).start(); (new Thread(task)).start(); break; break; } } Loading Loading @@ -2161,6 +2163,7 @@ class BackupManagerService extends IBackupManager.Stub { boolean mIncludeApks; boolean mIncludeApks; boolean mIncludeShared; boolean mIncludeShared; boolean mAllApps; boolean mAllApps; final boolean mIncludeSystem; String[] mPackages; String[] mPackages; String mCurrentPassword; String mCurrentPassword; String mEncryptPassword; String mEncryptPassword; Loading Loading @@ -2219,13 +2222,14 @@ class BackupManagerService extends IBackupManager.Stub { PerformFullBackupTask(ParcelFileDescriptor fd, IFullBackupRestoreObserver observer, PerformFullBackupTask(ParcelFileDescriptor fd, IFullBackupRestoreObserver observer, boolean includeApks, boolean includeShared, String curPassword, boolean includeApks, boolean includeShared, String curPassword, String encryptPassword, boolean doAllApps, String[] packages, String encryptPassword, boolean doAllApps, boolean doSystem, String[] packages, AtomicBoolean latch) { AtomicBoolean latch) { mOutputFile = fd; mOutputFile = fd; mObserver = observer; mObserver = observer; mIncludeApks = includeApks; mIncludeApks = includeApks; mIncludeShared = includeShared; mIncludeShared = includeShared; mAllApps = doAllApps; mAllApps = doAllApps; mIncludeSystem = doSystem; mPackages = packages; mPackages = packages; mCurrentPassword = curPassword; mCurrentPassword = curPassword; // when backing up, if there is a current backup password, we require that // when backing up, if there is a current backup password, we require that Loading @@ -2245,7 +2249,7 @@ class BackupManagerService extends IBackupManager.Stub { @Override @Override public void run() { public void run() { final List<PackageInfo> packagesToBackup; List<PackageInfo> packagesToBackup = new ArrayList<PackageInfo>(); Slog.i(TAG, "--- Performing full-dataset backup ---"); Slog.i(TAG, "--- Performing full-dataset backup ---"); sendStartBackup(); sendStartBackup(); Loading @@ -2254,8 +2258,23 @@ class BackupManagerService extends IBackupManager.Stub { if (mAllApps) { if (mAllApps) { packagesToBackup = mPackageManager.getInstalledPackages( packagesToBackup = mPackageManager.getInstalledPackages( PackageManager.GET_SIGNATURES); PackageManager.GET_SIGNATURES); // Exclude system apps if we've been asked to do so if (mIncludeSystem == false) { for (int i = 0; i < packagesToBackup.size(); ) { PackageInfo pkg = packagesToBackup.get(i); if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { packagesToBackup.remove(i); } else { } else { packagesToBackup = new ArrayList<PackageInfo>(); i++; } } } } // Now process the command line argument packages, if any. Note that explicitly- // named system-partition packages will be included even if includeSystem was // set to false. if (mPackages != null) { for (String pkgName : mPackages) { for (String pkgName : mPackages) { try { try { packagesToBackup.add(mPackageManager.getPackageInfo(pkgName, packagesToBackup.add(mPackageManager.getPackageInfo(pkgName, Loading @@ -2268,8 +2287,8 @@ class BackupManagerService extends IBackupManager.Stub { // Cull any packages that have indicated that backups are not permitted. // Cull any packages that have indicated that backups are not permitted. for (int i = 0; i < packagesToBackup.size(); ) { for (int i = 0; i < packagesToBackup.size(); ) { PackageInfo info = packagesToBackup.get(i); PackageInfo pkg = packagesToBackup.get(i); if ((info.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) == 0) { if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) == 0) { packagesToBackup.remove(i); packagesToBackup.remove(i); } else { } else { i++; i++; Loading Loading @@ -4781,7 +4800,7 @@ class BackupManagerService extends IBackupManager.Stub { // to the supplied file descriptor. This method is synchronous and does not return // to the supplied file descriptor. This method is synchronous and does not return // to the caller until the backup has been completed. // to the caller until the backup has been completed. public void fullBackup(ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, public void fullBackup(ParcelFileDescriptor fd, boolean includeApks, boolean includeShared, boolean doAllApps, String[] pkgList) { boolean doAllApps, boolean includeSystem, String[] pkgList) { mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullBackup"); mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullBackup"); // Validate // Validate Loading Loading @@ -4811,7 +4830,7 @@ class BackupManagerService extends IBackupManager.Stub { Slog.i(TAG, "Beginning full backup..."); Slog.i(TAG, "Beginning full backup..."); FullBackupParams params = new FullBackupParams(fd, includeApks, includeShared, FullBackupParams params = new FullBackupParams(fd, includeApks, includeShared, doAllApps, pkgList); doAllApps, includeSystem, pkgList); final int token = generateToken(); final int token = generateToken(); synchronized (mFullConfirmations) { synchronized (mFullConfirmations) { mFullConfirmations.put(token, params); mFullConfirmations.put(token, params); Loading