summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-01-15 19:38:03 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-15 19:38:03 +0000
commitbbb98bee0e13e558034368f80f11b4b8d7c85336 (patch)
treea3c8b5cd550ef504c0a258b2d60ec108e41f738b
parentcf9dd94323e0bf4934281582a1851e60f1fa36ac (diff)
parentb175864bbf1d227566080be74aa4df74b1608731 (diff)
Merge "Return null when getting role holders of an unknown role."
-rw-r--r--services/core/java/com/android/server/role/RoleUserState.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/role/RoleUserState.java b/services/core/java/com/android/server/role/RoleUserState.java
index 69e144951154..02dcc4945664 100644
--- a/services/core/java/com/android/server/role/RoleUserState.java
+++ b/services/core/java/com/android/server/role/RoleUserState.java
@@ -193,14 +193,18 @@ public class RoleUserState {
*
* @param roleName the name of the role to query for
*
- * @return the set of role holders. {@code null} should not be returned and indicates an issue.
+ * @return the set of role holders, or {@code null} if and only if the role is not found
*/
@Nullable
public ArraySet<String> getRoleHolders(@NonNull String roleName) {
synchronized (mLock) {
throwIfDestroyedLocked();
- return new ArraySet<>(mRoles.get(roleName));
+ ArraySet<String> packageNames = mRoles.get(roleName);
+ if (packageNames == null) {
+ return null;
+ }
+ return new ArraySet<>(packageNames);
}
}
@@ -268,8 +272,7 @@ public class RoleUserState {
* @param roleName the name of the role to add the holder to
* @param packageName the package name of the new holder
*
- * @return {@code false} only if the set of role holders is null, which should not happen and
- * indicates an issue.
+ * @return {@code false} if and only if the role is not found
*/
@CheckResult
public boolean addRoleHolder(@NonNull String roleName, @NonNull String packageName) {
@@ -302,8 +305,7 @@ public class RoleUserState {
* @param roleName the name of the role to remove the holder from
* @param packageName the package name of the holder to remove
*
- * @return {@code false} only if the set of role holders is null, which should not happen and
- * indicates an issue.
+ * @return {@code false} if and only if the role is not found
*/
@CheckResult
public boolean removeRoleHolder(@NonNull String roleName, @NonNull String packageName) {