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

Commit 4f17bc4a authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Update permission enforcement for BluetoothPan System APIs to enforce...

Merge "Update permission enforcement for BluetoothPan System APIs to enforce the BLUETOOTH_PRIVILEGED permission" am: 726f4986 am: 37734678

Change-Id: I9b4857f6daed915c119427faca5d612f4abeee36
parents be4f1245 37734678
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -347,6 +347,8 @@ public class PanService extends ProfileService {
    }
    }


    public int getConnectionState(BluetoothDevice device) {
    public int getConnectionState(BluetoothDevice device) {
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        BluetoothPanDevice panDevice = mPanDevices.get(device);
        BluetoothPanDevice panDevice = mPanDevices.get(device);
        if (panDevice == null) {
        if (panDevice == null) {
            return BluetoothPan.STATE_DISCONNECTED;
            return BluetoothPan.STATE_DISCONNECTED;
@@ -370,7 +372,8 @@ public class PanService extends ProfileService {


    public boolean isTetheringOn() {
    public boolean isTetheringOn() {
        // TODO(BT) have a variable marking the on/off state
        // TODO(BT) have a variable marking the on/off state
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        return mTetherOn;
        return mTetherOn;
    }
    }


@@ -378,7 +381,8 @@ public class PanService extends ProfileService {
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "setBluetoothTethering: " + value + ", mTetherOn: " + mTetherOn);
            Log.d(TAG, "setBluetoothTethering: " + value + ", mTetherOn: " + mTetherOn);
        }
        }
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        final Context context = getBaseContext();
        final Context context = getBaseContext();


        ConnectivityManager.enforceTetherChangePermission(context, pkgName);
        ConnectivityManager.enforceTetherChangePermission(context, pkgName);
@@ -413,7 +417,8 @@ public class PanService extends ProfileService {
     * @return true if connectionPolicy is set, false on error
     * @return true if connectionPolicy is set, false on error
     */
     */
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
        }
@@ -448,7 +453,8 @@ public class PanService extends ProfileService {
    }
    }


    public List<BluetoothDevice> getConnectedDevices() {
    public List<BluetoothDevice> getConnectedDevices() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        List<BluetoothDevice> devices =
        List<BluetoothDevice> devices =
                getDevicesMatchingConnectionStates(new int[]{BluetoothProfile.STATE_CONNECTED});
                getDevicesMatchingConnectionStates(new int[]{BluetoothProfile.STATE_CONNECTED});
        return devices;
        return devices;