Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a26fe4d2 authored by Poompatai Puntitpong's avatar Poompatai Puntitpong
Browse files

Modify permissions checking for multi-user scenarios

Test: m com.android.btservices
Bug: 360274428
Flag: EXEMPT only affect devices with HSUM enabled
Change-Id: I45d8bd5bb52b2840205febf78f03740518cec354
parent 252970e5
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -821,11 +821,17 @@ public final class Utils {
            UserHandle uh = um.getProfileParent(callingUser);
            int parentUser = (uh != null) ? uh.getIdentifier() : USER_HANDLE_NULL.getIdentifier();

            // In HSUM mode, UserHandle.SYSTEM is only for System and the human users will use other
            // ids
            boolean isSystemUserInHsumMode =
                    um.isHeadlessSystemUserMode() && callingUser.equals(UserHandle.SYSTEM);

            // Always allow SystemUI/System access.
            return (sForegroundUserId == callingUser.getIdentifier())
                    || (sForegroundUserId == parentUser)
                    || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid))
                    || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid));
                    || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid))
                    || (isSystemUserInHsumMode);
        } catch (Exception ex) {
            Log.e(TAG, "checkCallerAllowManagedProfiles: Exception ex=" + ex);
            return false;