Loading core/java/android/app/admin/DevicePolicyManager.java +5 −16 Original line number Diff line number Diff line Loading @@ -9518,18 +9518,12 @@ public class DevicePolicyManager { } /** * Allows the device owner or profile owner to enable or disable the backup service. * Allows the device owner to enable or disable the backup service. * * <p> Each user has its own backup service which manages the backup and restore mechanisms in * that user. Disabling the backup service will prevent data from being backed up or restored. * <p> Backup service manages all backup and restore mechanisms on the device. Setting this to * false will prevent data from being backed up or restored. * * <p> Device owner calls this API to control backup services across all users on the device. * Profile owner can use this API to enable or disable the profile's backup service. However, * for a managed profile its backup functionality is only enabled if both the device owner * and the profile owner have enabled the backup service. * * <p> By default, backup service is disabled on a device with device owner, and within a * managed profile. * <p> Backup service is off by default when device owner is present. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param enabled {@code true} to enable the backup service, {@code false} to disable it. Loading @@ -9545,12 +9539,7 @@ public class DevicePolicyManager { } /** * Return whether the backup service is enabled by the device owner or profile owner for the * current user, as previously set by {@link #setBackupServiceEnabled(ComponentName, boolean)}. * * <p> Whether the backup functionality is actually enabled or not depends on settings from both * the current user and the device owner, please see * {@link #setBackupServiceEnabled(ComponentName, boolean)} for details. * Return whether the backup service is enabled by the device owner. * * <p> Backup service manages all backup and restore mechanisms on the device. * Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +31 −30 Original line number Diff line number Diff line Loading @@ -7667,7 +7667,18 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } // Shutting down backup manager service permanently. toggleBackupServiceActive(UserHandle.USER_SYSTEM, /* makeActive= */ false); long ident = mInjector.binderClearCallingIdentity(); try { if (mInjector.getIBackupManager() != null) { mInjector.getIBackupManager() .setBackupServiceActive(UserHandle.USER_SYSTEM, false); } } catch (RemoteException e) { throw new IllegalStateException("Failed deactivating backup service.", e); } finally { mInjector.binderRestoreCallingIdentity(ident); } if (isAdb()) { // Log device owner provisioning was started using adb. MetricsLogger.action(mContext, PROVISIONING_ENTRY_POINT_ADB, LOG_TAG_DEVICE_OWNER); Loading Loading @@ -7695,7 +7706,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { saveUserRestrictionsLocked(userId); } long ident = mInjector.binderClearCallingIdentity(); ident = mInjector.binderClearCallingIdentity(); try { // TODO Send to system too? sendOwnerChangedBroadcast(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED, userId); Loading Loading @@ -7952,9 +7963,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { .write(); } // Shutting down backup manager service permanently. toggleBackupServiceActive(userHandle, /* makeActive= */ false); mOwners.setProfileOwner(who, ownerName, userHandle); mOwners.writeProfileOwner(userHandle); Slog.i(LOG_TAG, "Profile owner set: " + who + " on user " + userHandle); Loading @@ -7978,24 +7986,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } private void toggleBackupServiceActive(int userId, boolean makeActive) { // Shutting down backup manager service permanently. enforceUserUnlocked(userId); long ident = mInjector.binderClearCallingIdentity(); try { if (mInjector.getIBackupManager() != null) { mInjector.getIBackupManager() .setBackupServiceActive(userId, makeActive); } } catch (RemoteException e) { throw new IllegalStateException("Failed deactivating backup service.", e); } finally { mInjector.binderRestoreCallingIdentity(ident); } } @Override public void clearProfileOwner(ComponentName who) { if (!mHasFeature) { Loading Loading @@ -12748,9 +12738,22 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return; } Preconditions.checkNotNull(admin); enforceProfileOrDeviceOwner(admin); int userId = mInjector.userHandleGetCallingUserId(); toggleBackupServiceActive(userId, enabled); synchronized (getLockObject()) { getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); } final long ident = mInjector.binderClearCallingIdentity(); try { IBackupManager ibm = mInjector.getIBackupManager(); if (ibm != null) { ibm.setBackupServiceActive(UserHandle.USER_SYSTEM, enabled); } } catch (RemoteException e) { throw new IllegalStateException( "Failed " + (enabled ? "" : "de") + "activating backup service.", e); } finally { mInjector.binderRestoreCallingIdentity(ident); } } @Override Loading @@ -12759,13 +12762,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { if (!mHasFeature) { return true; } enforceProfileOrDeviceOwner(admin); synchronized (getLockObject()) { try { getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); IBackupManager ibm = mInjector.getIBackupManager(); return ibm != null && ibm.isBackupServiceActive( mInjector.userHandleGetCallingUserId()); return ibm != null && ibm.isBackupServiceActive(UserHandle.USER_SYSTEM); } catch (RemoteException e) { throw new IllegalStateException("Failed requesting backup service state.", e); } Loading
core/java/android/app/admin/DevicePolicyManager.java +5 −16 Original line number Diff line number Diff line Loading @@ -9518,18 +9518,12 @@ public class DevicePolicyManager { } /** * Allows the device owner or profile owner to enable or disable the backup service. * Allows the device owner to enable or disable the backup service. * * <p> Each user has its own backup service which manages the backup and restore mechanisms in * that user. Disabling the backup service will prevent data from being backed up or restored. * <p> Backup service manages all backup and restore mechanisms on the device. Setting this to * false will prevent data from being backed up or restored. * * <p> Device owner calls this API to control backup services across all users on the device. * Profile owner can use this API to enable or disable the profile's backup service. However, * for a managed profile its backup functionality is only enabled if both the device owner * and the profile owner have enabled the backup service. * * <p> By default, backup service is disabled on a device with device owner, and within a * managed profile. * <p> Backup service is off by default when device owner is present. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param enabled {@code true} to enable the backup service, {@code false} to disable it. Loading @@ -9545,12 +9539,7 @@ public class DevicePolicyManager { } /** * Return whether the backup service is enabled by the device owner or profile owner for the * current user, as previously set by {@link #setBackupServiceEnabled(ComponentName, boolean)}. * * <p> Whether the backup functionality is actually enabled or not depends on settings from both * the current user and the device owner, please see * {@link #setBackupServiceEnabled(ComponentName, boolean)} for details. * Return whether the backup service is enabled by the device owner. * * <p> Backup service manages all backup and restore mechanisms on the device. * Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +31 −30 Original line number Diff line number Diff line Loading @@ -7667,7 +7667,18 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } // Shutting down backup manager service permanently. toggleBackupServiceActive(UserHandle.USER_SYSTEM, /* makeActive= */ false); long ident = mInjector.binderClearCallingIdentity(); try { if (mInjector.getIBackupManager() != null) { mInjector.getIBackupManager() .setBackupServiceActive(UserHandle.USER_SYSTEM, false); } } catch (RemoteException e) { throw new IllegalStateException("Failed deactivating backup service.", e); } finally { mInjector.binderRestoreCallingIdentity(ident); } if (isAdb()) { // Log device owner provisioning was started using adb. MetricsLogger.action(mContext, PROVISIONING_ENTRY_POINT_ADB, LOG_TAG_DEVICE_OWNER); Loading Loading @@ -7695,7 +7706,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { saveUserRestrictionsLocked(userId); } long ident = mInjector.binderClearCallingIdentity(); ident = mInjector.binderClearCallingIdentity(); try { // TODO Send to system too? sendOwnerChangedBroadcast(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED, userId); Loading Loading @@ -7952,9 +7963,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { .write(); } // Shutting down backup manager service permanently. toggleBackupServiceActive(userHandle, /* makeActive= */ false); mOwners.setProfileOwner(who, ownerName, userHandle); mOwners.writeProfileOwner(userHandle); Slog.i(LOG_TAG, "Profile owner set: " + who + " on user " + userHandle); Loading @@ -7978,24 +7986,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } private void toggleBackupServiceActive(int userId, boolean makeActive) { // Shutting down backup manager service permanently. enforceUserUnlocked(userId); long ident = mInjector.binderClearCallingIdentity(); try { if (mInjector.getIBackupManager() != null) { mInjector.getIBackupManager() .setBackupServiceActive(userId, makeActive); } } catch (RemoteException e) { throw new IllegalStateException("Failed deactivating backup service.", e); } finally { mInjector.binderRestoreCallingIdentity(ident); } } @Override public void clearProfileOwner(ComponentName who) { if (!mHasFeature) { Loading Loading @@ -12748,9 +12738,22 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return; } Preconditions.checkNotNull(admin); enforceProfileOrDeviceOwner(admin); int userId = mInjector.userHandleGetCallingUserId(); toggleBackupServiceActive(userId, enabled); synchronized (getLockObject()) { getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); } final long ident = mInjector.binderClearCallingIdentity(); try { IBackupManager ibm = mInjector.getIBackupManager(); if (ibm != null) { ibm.setBackupServiceActive(UserHandle.USER_SYSTEM, enabled); } } catch (RemoteException e) { throw new IllegalStateException( "Failed " + (enabled ? "" : "de") + "activating backup service.", e); } finally { mInjector.binderRestoreCallingIdentity(ident); } } @Override Loading @@ -12759,13 +12762,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { if (!mHasFeature) { return true; } enforceProfileOrDeviceOwner(admin); synchronized (getLockObject()) { try { getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); IBackupManager ibm = mInjector.getIBackupManager(); return ibm != null && ibm.isBackupServiceActive( mInjector.userHandleGetCallingUserId()); return ibm != null && ibm.isBackupServiceActive(UserHandle.USER_SYSTEM); } catch (RemoteException e) { throw new IllegalStateException("Failed requesting backup service state.", e); }