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

Commit 76c641c3 authored by William Escande's avatar William Escande
Browse files

SystemServer: ClearIdentity before binding

Bug: 290732757
Test: m service-bluetooth | no-op change from a logical aspect
Flag: EXEMPT, to allow onboarding in 24Q1
Change-Id: I62f2143b990b6fb80f82a20c25d86e371a6e8075
parent 533f65d3
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1359,9 +1359,20 @@ class BluetoothManagerService {
                psc =
                        new ProfileServiceConnections(
                                new Intent(PROFILE_TO_SERVICE_NAME.get(bluetoothProfile)));

                // TODO: b/291815510 or b/288450479 - Remove clearCallingIdentity
                // bindService is using bindServiceAsUser that require permission to interact
                // across users.
                // Because this method is called on the binderThread, we need to clear identity
                // before attempting to bind
                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    if (!psc.bindService(DEFAULT_REBIND_COUNT)) {
                        return false;
                    }
                } finally {
                    Binder.restoreCallingIdentity(callingIdentity);
                }

                mProfileServices.put(bluetoothProfile, psc);
            }