In AccountManagerService, don't crash if there's no dpm.
BUG:31015735
Change-Id: I0857008576c11857f52cdc2233fd3e3566e62268
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 53e6a55..ef0f1ee 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -3420,7 +3420,9 @@
final DevicePolicyManagerInternal dpmi =
LocalServices.getService(DevicePolicyManagerInternal.class);
Intent intent = null;
- if (errorCode == AccountManager.ERROR_CODE_USER_RESTRICTED) {
+ if (dpmi == null) {
+ intent = getDefaultCantAddAccountIntent(errorCode);
+ } else if (errorCode == AccountManager.ERROR_CODE_USER_RESTRICTED) {
intent = dpmi.createUserRestrictionSupportIntent(userId,
UserManager.DISALLOW_MODIFY_ACCOUNTS);
} else if (errorCode == AccountManager.ERROR_CODE_MANAGEMENT_DISABLED_FOR_ACCOUNT_TYPE) {