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

Commit 7f96b92d authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by android-build-merger
Browse files

Merge "Added internal API getMaxConnectedAudioDevices()" am: 719f0113

am: 4cc2c65f

Change-Id: I3e248970180efee8f65c967b9d5ce1c86ee04a50
parents a3d3b52b 4cc2c65f
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.ParcelUuid;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.Log;
import android.util.Pair;
@@ -53,6 +54,10 @@ class AdapterProperties {
    private static final boolean VDBG = false;
    private static final String TAG = "BluetoothAdapterProperties";

    private static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
            "persist.bluetooth.maxconnectedaudiodevices";
    static final int MIN_CONNECTED_AUDIO_DEVICES = 1;

    private static final long DEFAULT_DISCOVERY_TIMEOUT_MS = 12800;
    private static final int BD_ADDR_LEN = 6; // in bytes

@@ -71,6 +76,7 @@ class AdapterProperties {

    private volatile int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED;
    private volatile int mState = BluetoothAdapter.STATE_OFF;
    private int mMaxConnectedAudioDevices = 1;

    private AdapterService mService;
    private boolean mDiscovering;
@@ -164,6 +170,9 @@ class AdapterProperties {
        mProfileConnectionState.clear();
        mRemoteDevices = remoteDevices;

        mMaxConnectedAudioDevices = SystemProperties.getInt(
                MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, MIN_CONNECTED_AUDIO_DEVICES);

        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED);
@@ -397,6 +406,13 @@ class AdapterProperties {
        return mTotNumOfTrackableAdv;
    }

    /**
     * @return the maximum number of connected audio devices
     */
    int getMaxConnectedAudioDevices() {
        return mMaxConnectedAudioDevices;
    }

    /**
     * @return the mBondedDevices
     */
+16 −0
Original line number Diff line number Diff line
@@ -1497,6 +1497,16 @@ public class AdapterService extends Service {
            return service.getBatteryLevel(device);
        }

        @Override
        public int getMaxConnectedAudioDevices() {
            // don't check caller, may be called from system UI
            AdapterService service = getService();
            if (service == null) {
                return AdapterProperties.MIN_CONNECTED_AUDIO_DEVICES;
            }
            return service.getMaxConnectedAudioDevices();
        }

        @Override
        public boolean factoryReset() {
            AdapterService service = getService();
@@ -2010,6 +2020,12 @@ public class AdapterService extends Service {
        return deviceProp.getBatteryLevel();
    }

    int getMaxConnectedAudioDevices() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");

        return mAdapterProperties.getMaxConnectedAudioDevices();
    }

    boolean setPin(BluetoothDevice device, boolean accept, int len, byte[] pinCode) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);