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

Commit c5f3ad2d authored by William Escande's avatar William Escande Committed by Etienne Ruffieux
Browse files

HeadsetService: extend check to allow dual app

It looks like the AttributionSource plumbing CL wrongly replaced the
`checkCallerAllowManagedProfiles` with `checkCallerIsSystemOrActiveUser`
instead of `checkCallerIsSystemOrActiveOrManagedUser`
(in packages/apps/Bluetooth/+/438d26339b29fb7d68fa99fa6c06aea9aa9f0431)

This is specific to headset service as the other service are usually not
loaded in dual apps

Test: Manual reproduction by partner
Bug: 243638912
Bug: 260325902
Ignore-AOSP-First: Cherry-pick
Merged-In: Id72d8e6d3155709a3fa76630b2cc33f6a49e08ad
Change-Id: Id72d8e6d3155709a3fa76630b2cc33f6a49e08ad
parent 553e5bb9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -617,7 +617,7 @@ public final class Utils {
        return false;
    }

    public static boolean checkCallerIsSystemOrActiveUser() {
    private static boolean checkCallerIsSystemOrActiveUser() {
        int callingUid = Binder.getCallingUid();
        UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid);

@@ -638,7 +638,7 @@ public final class Utils {
        return checkCallerIsSystemOrActiveUser(tag + "." + method + "()");
    }

    public static boolean checkCallerIsSystemOrActiveOrManagedUser(Context context) {
    private static boolean checkCallerIsSystemOrActiveOrManagedUser(Context context) {
        if (context == null) {
            return checkCallerIsSystemOrActiveUser();
        }
+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ public class HeadsetService extends ProfileService {

        @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
        private HeadsetService getService(AttributionSource source) {
            if (!Utils.checkCallerIsSystemOrActiveUser(TAG)
            if (!Utils.checkCallerIsSystemOrActiveOrManagedUser(mService, TAG)
                    || !Utils.checkServiceAvailable(mService, TAG)
                    || !Utils.checkConnectPermissionForDataDelivery(mService, source, TAG)) {
                return null;