Fix backup for users hit by erroneous backup disabling
am: 1975021d88
Change-Id: I4421e9642c2e89bf17535ef3212617d268c1c9d2
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index b3338ab..a605112 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -496,6 +496,12 @@
}
});
}
+ // STOPSHIP: Remove this code once all dogfood devices are fixed. See b/31754835
+ if (Intent.ACTION_BOOT_COMPLETED.equals(action) && !mOwners.hasDeviceOwner()
+ && !isBackupServiceEnabledInternal()) {
+ setBackupServiceEnabledInternal(true);
+ Slog.w(LOG_TAG, "Fix backup for device that is not in Device Owner mode.");
+ }
if (Intent.ACTION_USER_UNLOCKED.equals(action)
|| Intent.ACTION_USER_STARTED.equals(action)
|| KeyChain.ACTION_STORAGE_CHANGED.equals(action)) {
@@ -9319,12 +9325,15 @@
}
synchronized (this) {
getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- try {
- IBackupManager ibm = mInjector.getIBackupManager();
- return ibm != null && ibm.isBackupServiceActive(UserHandle.USER_SYSTEM);
- } catch (RemoteException e) {
- throw new IllegalStateException("Failed requesting backup service state.", e);
- }
+ return isBackupServiceEnabledInternal();
+ }
+ }
+ private boolean isBackupServiceEnabledInternal() {
+ try {
+ IBackupManager ibm = mInjector.getIBackupManager();
+ return ibm != null && ibm.isBackupServiceActive(UserHandle.USER_SYSTEM);
+ } catch (RemoteException e) {
+ throw new IllegalStateException("Failed requesting backup service state.", e);
}
}
}