Fix bug in UserManager#getUserName

Fixed incorrect permission check in getUserName

Fixes: 181814864
Test: Settings no longer crash when switching accounts
Change-Id: Ic41da942c2e493cae5c29693bec5f7ecec885226
This commit is contained in:
kholoud mohamed
2021-03-04 10:53:43 +00:00
parent cf82f60caf
commit c34a63817b

View File

@@ -1544,7 +1544,7 @@ public class UserManagerService extends IUserManager.Stub {
public String getUserName() {
final int callingUid = Binder.getCallingUid();
if (!hasManageOrCreateUsersPermission()
|| hasPermissionGranted(
&& !hasPermissionGranted(
android.Manifest.permission.GET_ACCOUNTS_PRIVILEGED, callingUid)) {
throw new SecurityException("You need MANAGE_USERS or CREATE_USERS or "
+ "GET_ACCOUNTS_PRIVILEGED permissions to: get user name");