Merge changes from topic "update_profile_api" am: dced19175b am: e035a12367

Change-Id: Iaa111d4a20144a0a555bc617c3e7db86d09cb21a
This commit is contained in:
Automerger Merge Worker
2020-02-07 03:11:48 +00:00
3 changed files with 22 additions and 9 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settingslib.bluetooth; package com.android.settingslib.bluetooth;
import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_AUDIO;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
@@ -45,6 +46,7 @@ public class A2dpProfile implements LocalBluetoothProfile {
private boolean mIsProfileReady; private boolean mIsProfileReady;
private final CachedBluetoothDeviceManager mDeviceManager; private final CachedBluetoothDeviceManager mDeviceManager;
private final BluetoothAdapter mBluetoothAdapter;
static final ParcelUuid[] SINK_UUIDS = { static final ParcelUuid[] SINK_UUIDS = {
BluetoothUuid.A2DP_SINK, BluetoothUuid.A2DP_SINK,
@@ -99,7 +101,8 @@ public class A2dpProfile implements LocalBluetoothProfile {
mContext = context; mContext = context;
mDeviceManager = deviceManager; mDeviceManager = deviceManager;
mProfileManager = profileManager; mProfileManager = profileManager;
BluetoothAdapter.getDefaultAdapter().getProfileProxy(context, new A2dpServiceListener(), mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.getProfileProxy(context, new A2dpServiceListener(),
BluetoothProfile.A2DP); BluetoothProfile.A2DP);
} }
@@ -158,8 +161,10 @@ public class A2dpProfile implements LocalBluetoothProfile {
} }
public boolean setActiveDevice(BluetoothDevice device) { public boolean setActiveDevice(BluetoothDevice device) {
if (mService == null) return false; if (mBluetoothAdapter == null) {
return mService.setActiveDevice(device); return false;
}
return mBluetoothAdapter.setActiveDevice(device, ACTIVE_DEVICE_AUDIO);
} }
public BluetoothDevice getActiveDevice() { public BluetoothDevice getActiveDevice() {

View File

@@ -16,6 +16,7 @@
package com.android.settingslib.bluetooth; package com.android.settingslib.bluetooth;
import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_PHONE_CALL;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
@@ -45,6 +46,7 @@ public class HeadsetProfile implements LocalBluetoothProfile {
private final CachedBluetoothDeviceManager mDeviceManager; private final CachedBluetoothDeviceManager mDeviceManager;
private final LocalBluetoothProfileManager mProfileManager; private final LocalBluetoothProfileManager mProfileManager;
private final BluetoothAdapter mBluetoothAdapter;
static final ParcelUuid[] UUIDS = { static final ParcelUuid[] UUIDS = {
BluetoothUuid.HSP, BluetoothUuid.HSP,
@@ -99,7 +101,8 @@ public class HeadsetProfile implements LocalBluetoothProfile {
LocalBluetoothProfileManager profileManager) { LocalBluetoothProfileManager profileManager) {
mDeviceManager = deviceManager; mDeviceManager = deviceManager;
mProfileManager = profileManager; mProfileManager = profileManager;
BluetoothAdapter.getDefaultAdapter().getProfileProxy(context, new HeadsetServiceListener(), mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.getProfileProxy(context, new HeadsetServiceListener(),
BluetoothProfile.HEADSET); BluetoothProfile.HEADSET);
} }
@@ -119,10 +122,10 @@ public class HeadsetProfile implements LocalBluetoothProfile {
} }
public boolean setActiveDevice(BluetoothDevice device) { public boolean setActiveDevice(BluetoothDevice device) {
if (mService == null) { if (mBluetoothAdapter == null) {
return false; return false;
} }
return mService.setActiveDevice(device); return mBluetoothAdapter.setActiveDevice(device, ACTIVE_DEVICE_PHONE_CALL);
} }
public BluetoothDevice getActiveDevice() { public BluetoothDevice getActiveDevice() {

View File

@@ -16,6 +16,7 @@
package com.android.settingslib.bluetooth; package com.android.settingslib.bluetooth;
import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_ALL;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED;
import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
@@ -45,6 +46,7 @@ public class HearingAidProfile implements LocalBluetoothProfile {
static final String NAME = "HearingAid"; static final String NAME = "HearingAid";
private final LocalBluetoothProfileManager mProfileManager; private final LocalBluetoothProfileManager mProfileManager;
private final BluetoothAdapter mBluetoothAdapter;
// Order of this profile in device profiles list // Order of this profile in device profiles list
private static final int ORDINAL = 1; private static final int ORDINAL = 1;
@@ -97,7 +99,8 @@ public class HearingAidProfile implements LocalBluetoothProfile {
mContext = context; mContext = context;
mDeviceManager = deviceManager; mDeviceManager = deviceManager;
mProfileManager = profileManager; mProfileManager = profileManager;
BluetoothAdapter.getDefaultAdapter().getProfileProxy(context, mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.getProfileProxy(context,
new HearingAidServiceListener(), BluetoothProfile.HEARING_AID); new HearingAidServiceListener(), BluetoothProfile.HEARING_AID);
} }
@@ -156,8 +159,10 @@ public class HearingAidProfile implements LocalBluetoothProfile {
} }
public boolean setActiveDevice(BluetoothDevice device) { public boolean setActiveDevice(BluetoothDevice device) {
if (mService == null) return false; if (mBluetoothAdapter == null) {
return mService.setActiveDevice(device); return false;
}
return mBluetoothAdapter.setActiveDevice(device, ACTIVE_DEVICE_ALL);
} }
public List<BluetoothDevice> getActiveDevices() { public List<BluetoothDevice> getActiveDevices() {