Loading api/system-current.txt +10 −0 Original line number Diff line number Diff line Loading @@ -615,6 +615,7 @@ package android.bluetooth { public final class BluetoothAdapter { method public boolean disableBLE(); method public boolean enableBLE(); method public boolean enableNoAutoConnect(); method public boolean isBleScanAlwaysAvailable(); method public boolean isLeEnabled(); field public static final java.lang.String ACTION_BLE_STATE_CHANGED = "android.bluetooth.adapter.action.BLE_STATE_CHANGED"; Loading @@ -622,8 +623,17 @@ package android.bluetooth { } public final class BluetoothDevice implements android.os.Parcelable { method public boolean cancelBondProcess(); method public boolean isConnected(); 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); } } Loading core/java/android/bluetooth/BluetoothAdapter.java +2 −0 Original line number Diff line number Diff line Loading @@ -2425,6 +2425,8 @@ public final class BluetoothAdapter { * * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean enableNoAutoConnect() { if (isEnabled()) { if (DBG) { Loading core/java/android/bluetooth/BluetoothDevice.java +8 −0 Original line number Diff line number Diff line Loading @@ -1098,6 +1098,8 @@ public final class BluetoothDevice implements Parcelable { * @return true on success, false on error * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean cancelBondProcess() { final IBluetooth service = sService; if (service == null) { Loading Loading @@ -1125,6 +1127,8 @@ public final class BluetoothDevice implements Parcelable { * @return true on success, false on error * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean removeBond() { final IBluetooth service = sService; if (service == null) { Loading Loading @@ -1174,6 +1178,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isConnected() { final IBluetooth service = sService; if (service == null) { Loading @@ -1197,6 +1202,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted() { final IBluetooth service = sService; if (service == null) { Loading Loading @@ -1444,6 +1450,8 @@ public final class BluetoothDevice implements Parcelable { * @return Whether the value has been successfully set. * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int value) { final IBluetooth service = sService; if (service == null) { Loading core/java/android/bluetooth/BluetoothHeadset.java +96 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,11 @@ package android.bluetooth; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; import android.os.Binder; Loading Loading @@ -91,6 +94,23 @@ public final class BluetoothHeadset implements BluetoothProfile { public static final String 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 Loading Loading @@ -416,6 +436,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return false on immediate error, true otherwise * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); final IBluetoothHeadset service = mService; Loading Loading @@ -456,6 +478,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return false on immediate error, true otherwise * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); final IBluetoothHeadset service = mService; Loading Loading @@ -543,6 +567,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return true if priority is set, false on error * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPriority(BluetoothDevice device, int priority) { if (DBG) log("setPriority(" + device + ", " + priority + ")"); final IBluetoothHeadset service = mService; Loading Loading @@ -974,6 +1000,76 @@ public final class BluetoothHeadset implements BluetoothProfile { 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. * Loading core/res/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,8 @@ android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" /> <protected-broadcast android:name="android.bluetooth.headset.action.HF_INDICATORS_VALUE_CHANGED" /> <protected-broadcast android:name="android.bluetooth.headset.profile.action.ACTIVE_DEVICE_CHANGED" /> <protected-broadcast android:name="android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED" /> <protected-broadcast Loading Loading
api/system-current.txt +10 −0 Original line number Diff line number Diff line Loading @@ -615,6 +615,7 @@ package android.bluetooth { public final class BluetoothAdapter { method public boolean disableBLE(); method public boolean enableBLE(); method public boolean enableNoAutoConnect(); method public boolean isBleScanAlwaysAvailable(); method public boolean isLeEnabled(); field public static final java.lang.String ACTION_BLE_STATE_CHANGED = "android.bluetooth.adapter.action.BLE_STATE_CHANGED"; Loading @@ -622,8 +623,17 @@ package android.bluetooth { } public final class BluetoothDevice implements android.os.Parcelable { method public boolean cancelBondProcess(); method public boolean isConnected(); 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); } } Loading
core/java/android/bluetooth/BluetoothAdapter.java +2 −0 Original line number Diff line number Diff line Loading @@ -2425,6 +2425,8 @@ public final class BluetoothAdapter { * * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean enableNoAutoConnect() { if (isEnabled()) { if (DBG) { Loading
core/java/android/bluetooth/BluetoothDevice.java +8 −0 Original line number Diff line number Diff line Loading @@ -1098,6 +1098,8 @@ public final class BluetoothDevice implements Parcelable { * @return true on success, false on error * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean cancelBondProcess() { final IBluetooth service = sService; if (service == null) { Loading Loading @@ -1125,6 +1127,8 @@ public final class BluetoothDevice implements Parcelable { * @return true on success, false on error * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean removeBond() { final IBluetooth service = sService; if (service == null) { Loading Loading @@ -1174,6 +1178,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isConnected() { final IBluetooth service = sService; if (service == null) { Loading @@ -1197,6 +1202,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted() { final IBluetooth service = sService; if (service == null) { Loading Loading @@ -1444,6 +1450,8 @@ public final class BluetoothDevice implements Parcelable { * @return Whether the value has been successfully set. * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int value) { final IBluetooth service = sService; if (service == null) { Loading
core/java/android/bluetooth/BluetoothHeadset.java +96 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,11 @@ package android.bluetooth; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; import android.os.Binder; Loading Loading @@ -91,6 +94,23 @@ public final class BluetoothHeadset implements BluetoothProfile { public static final String 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 Loading Loading @@ -416,6 +436,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return false on immediate error, true otherwise * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); final IBluetoothHeadset service = mService; Loading Loading @@ -456,6 +478,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return false on immediate error, true otherwise * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); final IBluetoothHeadset service = mService; Loading Loading @@ -543,6 +567,8 @@ public final class BluetoothHeadset implements BluetoothProfile { * @return true if priority is set, false on error * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPriority(BluetoothDevice device, int priority) { if (DBG) log("setPriority(" + device + ", " + priority + ")"); final IBluetoothHeadset service = mService; Loading Loading @@ -974,6 +1000,76 @@ public final class BluetoothHeadset implements BluetoothProfile { 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. * Loading
core/res/AndroidManifest.xml +2 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,8 @@ android:name="android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT" /> <protected-broadcast android:name="android.bluetooth.headset.action.HF_INDICATORS_VALUE_CHANGED" /> <protected-broadcast android:name="android.bluetooth.headset.profile.action.ACTIVE_DEVICE_CHANGED" /> <protected-broadcast android:name="android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED" /> <protected-broadcast Loading