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

Commit 3fbb87f9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Checks the service is supported before binding the service"

parents 1a753ddc 29b0d287
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -129,13 +129,27 @@ public abstract class BluetoothProfileConnector<T> {
            if (mService == null) {
                logDebug("Binding service...");
                mCloseGuard.open("doUnbind");

                List<Integer> mSupportedProfileList =
                        BluetoothAdapter.getDefaultAdapter().getSupportedProfiles();

                if (!mSupportedProfileList.contains(mProfileId)) {
                    logDebug("Skip binding " + mProfileName + " service due to not supported");
                    return false;
                }

                try {
                    Intent intent = new Intent(mServiceName);
                    ComponentName comp = resolveSystemService(intent, mContext.getPackageManager());
                    intent.setComponent(comp);
                    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
                    if (comp == null) {
                        logError("Component is null");
                        return false;
                    }
                    if (!mContext.bindServiceAsUser(intent, mConnection, 0,
                            USER_HANDLE_CURRENT_OR_SELF)) {
                        logError("Could not bind to Bluetooth Service with " + intent);
                        mContext.unbindService(mConnection);
                        return false;
                    }
                } catch (SecurityException se) {