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

Commit 93583a80 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update caller check to support multiple users in bluetooth utils" am: 49ab6c45

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1326391

Change-Id: Ibdcb573f1a93cb75a9a2496146787d6d10f43cf8
parents f616cec1 49ab6c45
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -334,8 +334,9 @@ public final class Utils {
    public static boolean checkCaller() {
    public static boolean checkCaller() {
        int callingUser = UserHandle.getCallingUserId();
        int callingUser = UserHandle.getCallingUserId();
        int callingUid = Binder.getCallingUid();
        int callingUid = Binder.getCallingUid();
        return (sForegroundUserId == callingUser) || (sSystemUiUid == callingUid)
        return (sForegroundUserId == callingUser)
                || (Process.SYSTEM_UID == callingUid);
                || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid))
                || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid));
    }
    }


    public static boolean checkCallerAllowManagedProfiles(Context mContext) {
    public static boolean checkCallerAllowManagedProfiles(Context mContext) {
@@ -354,7 +355,8 @@ public final class Utils {


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