Loading cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +29 −0 Original line number Diff line number Diff line Loading @@ -195,10 +195,35 @@ public class Bmgr { return; } if ("scheduling".equals(op)) { setSchedulingEnabled(userId); return; } System.err.println("Unknown command"); showUsage(); } private void setSchedulingEnabled(int userId) { String arg = nextArg(); if (arg == null) { showUsage(); return; } try { boolean enable = Boolean.parseBoolean(arg); mBmgr.setFrameworkSchedulingEnabledForUser(userId, enable); System.out.println( "Backup scheduling is now " + (enable ? "enabled" : "disabled") + " for user " + userId); } catch (RemoteException e) { handleRemoteException(e); } } private void handleRemoteException(RemoteException e) { System.err.println(e.toString()); System.err.println(BMGR_NOT_RUNNING_ERR); Loading Loading @@ -944,6 +969,7 @@ public class Bmgr { System.err.println(" bmgr activate BOOL"); System.err.println(" bmgr activated"); System.err.println(" bmgr autorestore BOOL"); System.err.println(" bmgr scheduling BOOL"); System.err.println(""); System.err.println("The '--user' option specifies the user on which the operation is run."); System.err.println("It must be the first argument before the operation."); Loading Loading @@ -1021,6 +1047,9 @@ public class Bmgr { System.err.println(""); System.err.println("The 'autorestore' command enables or disables automatic restore when"); System.err.println("a new package is installed."); System.err.println(""); System.err.println("The 'scheduling' command enables or disables backup scheduling in the"); System.err.println("framework."); } private static class BackupMonitor extends IBackupManagerMonitor.Stub { Loading core/java/android/app/backup/BackupManager.java +27 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.app.backup; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; Loading @@ -38,8 +37,6 @@ import android.os.UserHandle; import android.util.Log; import android.util.Pair; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** Loading Loading @@ -409,6 +406,33 @@ public class BackupManager { } } /** * Enable/disable the framework backup scheduling entirely for the current user. When disabled, * no Key/Value or Full backup jobs will be scheduled by the Android framework. * * <p>Note: This does not disable backups: only their scheduling is affected and backups can * still be triggered manually. * * <p>Callers must hold the android.permission.BACKUP permission to use this method. * * @hide */ @RequiresPermission(allOf = {android.Manifest.permission.BACKUP, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true) public void setFrameworkSchedulingEnabled(boolean isEnabled) { checkServiceBinder(); if (sService == null) { Log.e(TAG, "setFrameworkSchedulingEnabled() couldn't connect"); return; } try { sService.setFrameworkSchedulingEnabledForUser(mContext.getUserId(), isEnabled); } catch (RemoteException e) { Log.e(TAG, "setFrameworkSchedulingEnabled() couldn't connect"); } } /** * Report whether the backup mechanism is currently enabled. * Loading core/java/android/app/backup/IBackupManager.aidl +16 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,22 @@ interface IBackupManager { */ void setBackupEnabledForUser(int userId, boolean isEnabled); /** * Enable/disable the framework backup scheduling entirely. When disabled, no Key/Value or Full * backup jobs will be scheduled by the Android framework. * * <p>Note: This does not disable backups: only their scheduling is affected and backups can * still be triggered manually. * * <p>Callers must hold the android.permission.BACKUP permission to use this method. If * {@code userId} is different from the calling user id, then the caller must additionally hold * the android.permission.INTERACT_ACROSS_USERS_FULL permission. * * @param userId The user for which backup scheduling should be enabled/disabled. */ void setFrameworkSchedulingEnabledForUser(int userId, boolean isEnabled); /** * {@link android.app.backup.IBackupManager.setBackupEnabledForUser} for the calling user id. */ Loading core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -8659,6 +8659,12 @@ public final class Settings { @Readable public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore"; /** * Controls whether framework backup scheduling is enabled. * @hide */ public static final String BACKUP_SCHEDULING_ENABLED = "backup_scheduling_enabled"; /** * Indicates whether settings backup has been fully provisioned. * Type: int ( 0 = unprovisioned, 1 = fully provisioned ) Loading packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -695,6 +695,7 @@ public class SettingsBackupTest { Settings.Secure.BACKUP_AUTO_RESTORE, Settings.Secure.BACKUP_ENABLED, Settings.Secure.BACKUP_PROVISIONED, Settings.Secure.BACKUP_SCHEDULING_ENABLED, Settings.Secure.BACKUP_TRANSPORT, Settings.Secure.CALL_SCREENING_DEFAULT_COMPONENT, Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED, // Candidate for backup? Loading Loading
cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +29 −0 Original line number Diff line number Diff line Loading @@ -195,10 +195,35 @@ public class Bmgr { return; } if ("scheduling".equals(op)) { setSchedulingEnabled(userId); return; } System.err.println("Unknown command"); showUsage(); } private void setSchedulingEnabled(int userId) { String arg = nextArg(); if (arg == null) { showUsage(); return; } try { boolean enable = Boolean.parseBoolean(arg); mBmgr.setFrameworkSchedulingEnabledForUser(userId, enable); System.out.println( "Backup scheduling is now " + (enable ? "enabled" : "disabled") + " for user " + userId); } catch (RemoteException e) { handleRemoteException(e); } } private void handleRemoteException(RemoteException e) { System.err.println(e.toString()); System.err.println(BMGR_NOT_RUNNING_ERR); Loading Loading @@ -944,6 +969,7 @@ public class Bmgr { System.err.println(" bmgr activate BOOL"); System.err.println(" bmgr activated"); System.err.println(" bmgr autorestore BOOL"); System.err.println(" bmgr scheduling BOOL"); System.err.println(""); System.err.println("The '--user' option specifies the user on which the operation is run."); System.err.println("It must be the first argument before the operation."); Loading Loading @@ -1021,6 +1047,9 @@ public class Bmgr { System.err.println(""); System.err.println("The 'autorestore' command enables or disables automatic restore when"); System.err.println("a new package is installed."); System.err.println(""); System.err.println("The 'scheduling' command enables or disables backup scheduling in the"); System.err.println("framework."); } private static class BackupMonitor extends IBackupManagerMonitor.Stub { Loading
core/java/android/app/backup/BackupManager.java +27 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.app.backup; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; Loading @@ -38,8 +37,6 @@ import android.os.UserHandle; import android.util.Log; import android.util.Pair; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; /** Loading Loading @@ -409,6 +406,33 @@ public class BackupManager { } } /** * Enable/disable the framework backup scheduling entirely for the current user. When disabled, * no Key/Value or Full backup jobs will be scheduled by the Android framework. * * <p>Note: This does not disable backups: only their scheduling is affected and backups can * still be triggered manually. * * <p>Callers must hold the android.permission.BACKUP permission to use this method. * * @hide */ @RequiresPermission(allOf = {android.Manifest.permission.BACKUP, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true) public void setFrameworkSchedulingEnabled(boolean isEnabled) { checkServiceBinder(); if (sService == null) { Log.e(TAG, "setFrameworkSchedulingEnabled() couldn't connect"); return; } try { sService.setFrameworkSchedulingEnabledForUser(mContext.getUserId(), isEnabled); } catch (RemoteException e) { Log.e(TAG, "setFrameworkSchedulingEnabled() couldn't connect"); } } /** * Report whether the backup mechanism is currently enabled. * Loading
core/java/android/app/backup/IBackupManager.aidl +16 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,22 @@ interface IBackupManager { */ void setBackupEnabledForUser(int userId, boolean isEnabled); /** * Enable/disable the framework backup scheduling entirely. When disabled, no Key/Value or Full * backup jobs will be scheduled by the Android framework. * * <p>Note: This does not disable backups: only their scheduling is affected and backups can * still be triggered manually. * * <p>Callers must hold the android.permission.BACKUP permission to use this method. If * {@code userId} is different from the calling user id, then the caller must additionally hold * the android.permission.INTERACT_ACROSS_USERS_FULL permission. * * @param userId The user for which backup scheduling should be enabled/disabled. */ void setFrameworkSchedulingEnabledForUser(int userId, boolean isEnabled); /** * {@link android.app.backup.IBackupManager.setBackupEnabledForUser} for the calling user id. */ Loading
core/java/android/provider/Settings.java +6 −0 Original line number Diff line number Diff line Loading @@ -8659,6 +8659,12 @@ public final class Settings { @Readable public static final String BACKUP_AUTO_RESTORE = "backup_auto_restore"; /** * Controls whether framework backup scheduling is enabled. * @hide */ public static final String BACKUP_SCHEDULING_ENABLED = "backup_scheduling_enabled"; /** * Indicates whether settings backup has been fully provisioned. * Type: int ( 0 = unprovisioned, 1 = fully provisioned ) Loading
packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -695,6 +695,7 @@ public class SettingsBackupTest { Settings.Secure.BACKUP_AUTO_RESTORE, Settings.Secure.BACKUP_ENABLED, Settings.Secure.BACKUP_PROVISIONED, Settings.Secure.BACKUP_SCHEDULING_ENABLED, Settings.Secure.BACKUP_TRANSPORT, Settings.Secure.CALL_SCREENING_DEFAULT_COMPONENT, Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED, // Candidate for backup? Loading