Merge changes from topics "bt-hfp-add-set-active-device-method", "bt-system-api-annotations"
am: 25259faa27
Change-Id: Ife08cbcb0490f55c81f239f96aef6e8e2a02e8d3
This commit is contained in:
@@ -615,6 +615,7 @@ package android.bluetooth {
|
|||||||
public final class BluetoothAdapter {
|
public final class BluetoothAdapter {
|
||||||
method public boolean disableBLE();
|
method public boolean disableBLE();
|
||||||
method public boolean enableBLE();
|
method public boolean enableBLE();
|
||||||
|
method public boolean enableNoAutoConnect();
|
||||||
method public boolean isBleScanAlwaysAvailable();
|
method public boolean isBleScanAlwaysAvailable();
|
||||||
method public boolean isLeEnabled();
|
method public boolean isLeEnabled();
|
||||||
field public static final java.lang.String ACTION_BLE_STATE_CHANGED = "android.bluetooth.adapter.action.BLE_STATE_CHANGED";
|
field public static final java.lang.String ACTION_BLE_STATE_CHANGED = "android.bluetooth.adapter.action.BLE_STATE_CHANGED";
|
||||||
@@ -622,8 +623,17 @@ package android.bluetooth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class BluetoothDevice implements android.os.Parcelable {
|
public final class BluetoothDevice implements android.os.Parcelable {
|
||||||
|
method public boolean cancelBondProcess();
|
||||||
method public boolean isConnected();
|
method public boolean isConnected();
|
||||||
method public boolean isEncrypted();
|
method public boolean isEncrypted();
|
||||||
|
method public boolean removeBond();
|
||||||
|
method public boolean setPhonebookAccessPermission(int);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class BluetoothHeadset implements android.bluetooth.BluetoothProfile {
|
||||||
|
method public boolean connect(android.bluetooth.BluetoothDevice);
|
||||||
|
method public boolean disconnect(android.bluetooth.BluetoothDevice);
|
||||||
|
method public boolean setPriority(android.bluetooth.BluetoothDevice, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2425,6 +2425,8 @@ public final class BluetoothAdapter {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
public boolean enableNoAutoConnect() {
|
public boolean enableNoAutoConnect() {
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
|
|||||||
@@ -1098,6 +1098,8 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* @return true on success, false on error
|
* @return true on success, false on error
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
public boolean cancelBondProcess() {
|
public boolean cancelBondProcess() {
|
||||||
final IBluetooth service = sService;
|
final IBluetooth service = sService;
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
@@ -1125,6 +1127,8 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* @return true on success, false on error
|
* @return true on success, false on error
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
public boolean removeBond() {
|
public boolean removeBond() {
|
||||||
final IBluetooth service = sService;
|
final IBluetooth service = sService;
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
@@ -1174,6 +1178,7 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH)
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
final IBluetooth service = sService;
|
final IBluetooth service = sService;
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
@@ -1197,6 +1202,7 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH)
|
||||||
public boolean isEncrypted() {
|
public boolean isEncrypted() {
|
||||||
final IBluetooth service = sService;
|
final IBluetooth service = sService;
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
@@ -1444,6 +1450,8 @@ public final class BluetoothDevice implements Parcelable {
|
|||||||
* @return Whether the value has been successfully set.
|
* @return Whether the value has been successfully set.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
|
||||||
public boolean setPhonebookAccessPermission(int value) {
|
public boolean setPhonebookAccessPermission(int value) {
|
||||||
final IBluetooth service = sService;
|
final IBluetooth service = sService;
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package android.bluetooth;
|
package android.bluetooth;
|
||||||
|
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SdkConstant;
|
import android.annotation.SdkConstant;
|
||||||
import android.annotation.SdkConstant.SdkConstantType;
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
@@ -91,6 +94,23 @@ public final class BluetoothHeadset implements BluetoothProfile {
|
|||||||
public static final String ACTION_AUDIO_STATE_CHANGED =
|
public static final String ACTION_AUDIO_STATE_CHANGED =
|
||||||
"android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED";
|
"android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intent used to broadcast the selection of a connected device as active.
|
||||||
|
*
|
||||||
|
* <p>This intent will have one extra:
|
||||||
|
* <ul>
|
||||||
|
* <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. It can
|
||||||
|
* be null if no device is active. </li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
|
||||||
|
* receive.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||||
|
public static final String ACTION_ACTIVE_DEVICE_CHANGED =
|
||||||
|
"android.bluetooth.headset.profile.action.ACTIVE_DEVICE_CHANGED";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intent used to broadcast that the headset has posted a
|
* Intent used to broadcast that the headset has posted a
|
||||||
@@ -416,6 +436,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
|
|||||||
* @return false on immediate error, true otherwise
|
* @return false on immediate error, true otherwise
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
public boolean connect(BluetoothDevice device) {
|
public boolean connect(BluetoothDevice device) {
|
||||||
if (DBG) log("connect(" + device + ")");
|
if (DBG) log("connect(" + device + ")");
|
||||||
final IBluetoothHeadset service = mService;
|
final IBluetoothHeadset service = mService;
|
||||||
@@ -456,6 +478,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
|
|||||||
* @return false on immediate error, true otherwise
|
* @return false on immediate error, true otherwise
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
public boolean disconnect(BluetoothDevice device) {
|
public boolean disconnect(BluetoothDevice device) {
|
||||||
if (DBG) log("disconnect(" + device + ")");
|
if (DBG) log("disconnect(" + device + ")");
|
||||||
final IBluetoothHeadset service = mService;
|
final IBluetoothHeadset service = mService;
|
||||||
@@ -543,6 +567,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
|
|||||||
* @return true if priority is set, false on error
|
* @return true if priority is set, false on error
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
public boolean setPriority(BluetoothDevice device, int priority) {
|
public boolean setPriority(BluetoothDevice device, int priority) {
|
||||||
if (DBG) log("setPriority(" + device + ", " + priority + ")");
|
if (DBG) log("setPriority(" + device + ", " + priority + ")");
|
||||||
final IBluetoothHeadset service = mService;
|
final IBluetoothHeadset service = mService;
|
||||||
@@ -974,6 +1000,76 @@ public final class BluetoothHeadset implements BluetoothProfile {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select a connected device as active.
|
||||||
|
*
|
||||||
|
* The active device selection is per profile. An active device's
|
||||||
|
* purpose is profile-specific. For example, in HFP and HSP profiles,
|
||||||
|
* it is the device used for phone call audio. If a remote device is not
|
||||||
|
* connected, it cannot be selected as active.
|
||||||
|
*
|
||||||
|
* <p> This API returns false in scenarios like the profile on the
|
||||||
|
* device is not connected or Bluetooth is not turned on.
|
||||||
|
* When this API returns true, it is guaranteed that the
|
||||||
|
* {@link #ACTION_ACTIVE_DEVICE_CHANGED} intent will be broadcasted
|
||||||
|
* with the active device.
|
||||||
|
*
|
||||||
|
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* @param device Remote Bluetooth Device, could be null if phone call audio should not be
|
||||||
|
* streamed to a headset
|
||||||
|
* @return false on immediate error, true otherwise
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN)
|
||||||
|
public boolean setActiveDevice(@Nullable BluetoothDevice device) {
|
||||||
|
if (DBG) {
|
||||||
|
Log.d(TAG, "setActiveDevice: " + device);
|
||||||
|
}
|
||||||
|
final IBluetoothHeadset service = mService;
|
||||||
|
if (service != null && isEnabled() && (device == null || isValidDevice(device))) {
|
||||||
|
try {
|
||||||
|
return service.setActiveDevice(device);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(new Throwable()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (service == null) {
|
||||||
|
Log.w(TAG, "Proxy not attached to service");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the connected device that is active.
|
||||||
|
*
|
||||||
|
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* @return the connected device that is active or null if no device
|
||||||
|
* is active.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.BLUETOOTH)
|
||||||
|
public BluetoothDevice getActiveDevice() {
|
||||||
|
if (VDBG) {
|
||||||
|
Log.d(TAG, "getActiveDevice");
|
||||||
|
}
|
||||||
|
final IBluetoothHeadset service = mService;
|
||||||
|
if (service != null && isEnabled()) {
|
||||||
|
try {
|
||||||
|
return service.getActiveDevice();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(new Throwable()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (service == null) {
|
||||||
|
Log.w(TAG, "Proxy not attached to service");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if in-band ringing is supported for this platform.
|
* check if in-band ringing is supported for this platform.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -158,6 +158,8 @@
|
|||||||
android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" />
|
android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" />
|
||||||
<protected-broadcast
|
<protected-broadcast
|
||||||
android:name="android.bluetooth.headset.action.HF_INDICATORS_VALUE_CHANGED" />
|
android:name="android.bluetooth.headset.action.HF_INDICATORS_VALUE_CHANGED" />
|
||||||
|
<protected-broadcast
|
||||||
|
android:name="android.bluetooth.headset.profile.action.ACTIVE_DEVICE_CHANGED" />
|
||||||
<protected-broadcast
|
<protected-broadcast
|
||||||
android:name="android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED" />
|
android:name="android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED" />
|
||||||
<protected-broadcast
|
<protected-broadcast
|
||||||
|
|||||||
Reference in New Issue
Block a user