summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kumar Prasad <quic_amitpras@quicinc.com>2023-01-23 16:15:04 +0530
committerAmit Prasad <quic_amitpras@quicinc.com>2023-02-03 10:07:10 +0000
commit9292ebc23ba0501d57c81d9c22fd3672fdcc0a9f (patch)
tree9d55a76e9f00f20952f209f29cc67f97401b2733
parent9ff8dea1a67bd82e3fffdf7829deee11ceaffe5d (diff)
Frameworks: Set and Get AFH map support
CRs-Fixed: 3396190 Change-Id: Ifd4db2975742f30312468c6c04fcd3fb97daafda
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java55
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java39
2 files changed, 94 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index ea6fddbfac73..23fa0e29e166 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -1592,6 +1592,61 @@ public final class BluetoothAdapter {
}
/**
+ * Sets the AFH map for BT Adapter
+ *
+ * Allows the Host to specify a channel classification based on its “local information”.
+ *
+ * @param afhMap
+ * @return true if Afh map is set, false on error
+ * @hide
+ */
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED,
+ })
+ public boolean setAfhChannelMap(int transport, int len, @NonNull byte[] afhMap) {
+ if (getState() != STATE_ON) return false;
+ try {
+ mServiceLock.readLock().lock();
+ if (mService != null) return mService.setAfhChannelMap(transport, len, afhMap, mAttributionSource);
+ } catch (RemoteException e) {
+ Log.e(TAG, e.getMessage(), e);
+ } finally {
+ mServiceLock.readLock().unlock();
+ }
+ return false;
+ }
+
+ /**
+ * Reads the AFH channel map
+ *
+ * <p>command returns the values for the AFH_Mode and AFH_Channel_Map
+ * for the specified Bluetooth device .
+ *
+ * @param BluetoothDevice
+ * @return true if command success, false on error
+ * @hide
+ */
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED,
+ })
+ public boolean getAfhChannelMap(@NonNull BluetoothDevice device, int transport) {
+ if (getState() != STATE_ON) return false;
+ try {
+ mServiceLock.readLock().lock();
+ if (mService != null) return mService.getAfhChannelMap(device, transport, mAttributionSource);
+ } catch (RemoteException e) {
+ Log.e(TAG, e.getMessage(), e);
+ } finally {
+ mServiceLock.readLock().unlock();
+ }
+ return false;
+ }
+
+ /**
* Get the current Bluetooth scan mode of the local Bluetooth adapter.
* <p>The Bluetooth scan mode determines if the local adapter is
* connectable and/or discoverable from remote Bluetooth devices.
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index d0baece08935..e37d64d99886 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -157,6 +157,45 @@ public final class BluetoothDevice implements Parcelable, Attributable {
"android.bluetooth.device.action.FOUND";
/**
+ * Broadcast Action: Indicates the Bluetooth current AFH map
+ * <p>Always contains the extra fields {@link #EXTRA_AFH_MAP},
+ * {@link #EXTRA_TRANSPORT}.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+ * @hide
+ **/
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_AFH_MAP = "android.bluetooth.action.AFH_MAP";
+
+ /**
+ * Broadcast Action: Indicates the Bluetooth current AFH map status
+ * <p>Always contains the extra fields {@link #EXTRA_STATUS},
+ * {@link #EXTRA_TRANSPORT}.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+ * @hide
+ **/
+ @RequiresLegacyBluetoothPermission
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_AFH_MAP_STATUS = "android.bluetooth.action.AFH_MAP_STATUS";
+
+ /**
+ * Used as an int extra field in {@link #ACTION_GET_AFH_MAP}
+ *@hide
+ **/
+ public static final String EXTRA_TRANSPORT = "android.bluetooth.extra.TRANSPORT";
+
+ /**
+ * Used as an byte array extra field for Afh map in {@link #ACTION_GET_AFH_MAP}
+ *@hide
+ **/
+ public static final String EXTRA_AFH_MAP = "android.bluetooth.extra.AFH_MAP";
+
+ /**
+ * Used as an int extra field for Afh mode in {@link #ACTION_GET_AFH_MAP}
+ *@hide
+ **/
+ public static final String EXTRA_AFH_MODE = "android.bluetooth.extra.AFH_MODE";
+
+ /**
* Broadcast Action: Bluetooth class of a remote device has changed.
* <p>Always contains the extra fields {@link #EXTRA_DEVICE} and {@link
* #EXTRA_CLASS}.