diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 7d039ef221d7f..e5df278f2cc1d 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -288,7 +288,8 @@ public class AccountManager {
}
/**
- * Account visibility was not set.
+ * Account visibility was not set. Default visibility value will be used.
+ * See {@link #PACKAGE_NAME_KEY_LEGACY_VISIBLE}, {@link #PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE}
*/
public static final int VISIBILITY_UNDEFINED = 0;
@@ -919,7 +920,14 @@ public class AccountManager {
* Package name must match installed application, or be equal to
* {@link #PACKAGE_NAME_KEY_LEGACY_VISIBLE} or {@link #PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE}.
*
- * See {@link #getAccountVisibility} for possible values.
+ * Possible visibility values:
+ *
+ * - {@link #VISIBILITY_UNDEFINED}
+ * - {@link #VISIBILITY_VISIBLE}
+ * - {@link #VISIBILITY_USER_MANAGED_VISIBLE}
+ * - {@link #VISIBILITY_NOT_VISIBLE}
+ *
- {@link #VISIBILITY_USER_MANAGED_NOT_VISIBLE}
+ *
*
* This method requires the caller to have a signature match with the authenticator that owns
* the specified account.
@@ -944,7 +952,6 @@ public class AccountManager {
/**
* Get visibility of certain account for given application. Possible returned values are:
*
- * - {@link #VISIBILITY_UNDEFINED}
* - {@link #VISIBILITY_VISIBLE}
* - {@link #VISIBILITY_USER_MANAGED_VISIBLE}
* - {@link #VISIBILITY_NOT_VISIBLE}
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index be5cbfce79997..5b480d0b7430b 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -481,8 +481,13 @@ public class AccountManagerService
managedTypes.add(accountType);
}
- return getAccountsAndVisibilityForPackage(packageName, managedTypes, callingUid,
- getUserAccounts(UserHandle.getUserId(callingUid)));
+ long identityToken = clearCallingIdentity();
+ try {
+ return getAccountsAndVisibilityForPackage(packageName, managedTypes, callingUid,
+ getUserAccounts(UserHandle.getUserId(callingUid)));
+ } finally {
+ restoreCallingIdentity(identityToken);
+ }
}
/*
@@ -560,7 +565,7 @@ public class AccountManagerService
a.type);
throw new SecurityException(msg);
}
- return getAccountVisibility(a, packageName,
+ return resolveAccountVisibility(a, packageName,
getUserAccounts(UserHandle.getUserId(callingUid)));
}