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

Commit 33c78b3d authored by Jay Thomas Sullivan's avatar Jay Thomas Sullivan Committed by Jeff Sharkey
Browse files

Check permission BLUETOOTH_ADMIN -> BLUETOOTH_CONNECT

This updates all sendBroadcast and sendBroadcastAsUser calls inside the
Bluetooth project to use the BLUETOOTH_CONNECT permission instead of
BLUETOOTH_ADMIN.

Bug: 183203469
Test: atest AdapterServiceTest
Change-Id: I3572ec98b9791758479ffe44528833eeb6bb6dbe
parent 1bcd22cb
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -166,7 +166,6 @@ public class AdapterService extends Service {
    private String mSnoopLogSettingAtEnable = "empty";
    private String mDefaultSnoopLogSettingAtEnable = "empty";

    public static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
    public static final String BLUETOOTH_PRIVILEGED =
            android.Manifest.permission.BLUETOOTH_PRIVILEGED;
    static final String LOCAL_MAC_ADDRESS_PERM = android.Manifest.permission.LOCAL_MAC_ADDRESS;
+1 −1
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ final class BondStateMachine extends StateMachine {
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        // Workaround for Android Auto until pre-accepting pairing requests is added.
        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        mAdapterService.sendOrderedBroadcast(intent, AdapterService.BLUETOOTH_ADMIN_PERM);
        mAdapterService.sendOrderedBroadcast(intent, BLUETOOTH_CONNECT);
    }

    @VisibleForTesting
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth.btservice;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import android.app.ActivityManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
@@ -39,7 +41,6 @@ import com.android.bluetooth.Utils;
public abstract class ProfileService extends Service {
    private static final boolean DBG = false;

    public static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
    public static final String BLUETOOTH_PRIVILEGED =
            android.Manifest.permission.BLUETOOTH_PRIVILEGED;

@@ -142,7 +143,7 @@ public abstract class ProfileService extends Service {
            Log.d(mName, "onStartCommand()");
        }

        if (checkCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM)
        if (checkCallingOrSelfPermission(BLUETOOTH_CONNECT)
                != PackageManager.PERMISSION_GRANTED) {
            Log.e(mName, "Permission denied!");
            return PROFILE_SERVICE_MODE;
+1 −1
Original line number Diff line number Diff line
@@ -407,7 +407,7 @@ final class RemoteDevices {
        Intent intent = new Intent(BluetoothDevice.ACTION_UUID);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_UUID, prop == null ? null : prop.mUuids);
        sAdapterService.sendBroadcast(intent, AdapterService.BLUETOOTH_ADMIN_PERM);
        sAdapterService.sendBroadcast(intent, BLUETOOTH_CONNECT);

        //Remove the outstanding UUID request
        sSdpTracker.remove(device);
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth.hfp;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import android.bluetooth.BluetoothDevice;
import android.content.ContentResolver;
import android.content.Context;
@@ -86,7 +88,6 @@ public class AtPhonebook {

    // package and class name to which we send intent to check phone book access permission
    private final String mPairingPackage;
    private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;

    private final HashMap<String, PhonebookResult> mPhonebooks =
            new HashMap<String, PhonebookResult>(4);
@@ -643,7 +644,7 @@ public class AtPhonebook {
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, remoteDevice);
            // Leave EXTRA_PACKAGE_NAME and EXTRA_CLASS_NAME field empty.
            // BluetoothHandsfree's broadcast receiver is anonymous, cannot be targeted.
            mContext.sendOrderedBroadcast(intent, BLUETOOTH_ADMIN_PERM);
            mContext.sendOrderedBroadcast(intent, BLUETOOTH_CONNECT);
        }

        return permission;
Loading