diff --git a/api/current.txt b/api/current.txt index f9cfc68ba4336..74953c234c5de 100644 --- a/api/current.txt +++ b/api/current.txt @@ -7122,6 +7122,7 @@ package android.bluetooth { method public android.bluetooth.le.BluetoothLeScanner getBluetoothLeScanner(); method public java.util.Set getBondedDevices(); method public static synchronized android.bluetooth.BluetoothAdapter getDefaultAdapter(); + method public int getLeMaximumAdvertisingDataLength(); method public java.lang.String getName(); method public android.bluetooth.le.PeriodicAdvertisingManager getPeriodicAdvertisingManager(); method public int getProfileConnectionState(int); diff --git a/api/system-current.txt b/api/system-current.txt index 839bde3aa28c8..7fc18d06df465 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -7591,6 +7591,7 @@ package android.bluetooth { method public android.bluetooth.le.BluetoothLeScanner getBluetoothLeScanner(); method public java.util.Set getBondedDevices(); method public static synchronized android.bluetooth.BluetoothAdapter getDefaultAdapter(); + method public int getLeMaximumAdvertisingDataLength(); method public java.lang.String getName(); method public android.bluetooth.le.PeriodicAdvertisingManager getPeriodicAdvertisingManager(); method public int getProfileConnectionState(int); diff --git a/api/test-current.txt b/api/test-current.txt index 6bfdafec283d3..670217029ddb8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -7149,6 +7149,7 @@ package android.bluetooth { method public android.bluetooth.le.BluetoothLeScanner getBluetoothLeScanner(); method public java.util.Set getBondedDevices(); method public static synchronized android.bluetooth.BluetoothAdapter getDefaultAdapter(); + method public int getLeMaximumAdvertisingDataLength(); method public java.lang.String getName(); method public android.bluetooth.le.PeriodicAdvertisingManager getPeriodicAdvertisingManager(); method public int getProfileConnectionState(int); diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 488511b49b881..4e1e42da4fe72 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1482,6 +1482,25 @@ public final class BluetoothAdapter { return false; } + /** + * Return the maximum LE advertising data length, + * if LE Extended Advertising feature is supported. + * + * @return the maximum LE advertising data length. + */ + public int getLeMaximumAdvertisingDataLength() { + if (!getLeAccess()) return 0; + try { + mServiceLock.readLock().lock(); + if (mService != null) return mService.getLeMaximumAdvertisingDataLength(); + } catch (RemoteException e) { + Log.e(TAG, "failed to get getLeMaximumAdvertisingDataLength, error: ", e); + } finally { + mServiceLock.readLock().unlock(); + } + return 0; + } + /** * Return true if hardware has entries available for matching beacons * diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index 76ca554e5984b..b33781729b628 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -108,6 +108,7 @@ interface IBluetooth boolean isLeCodedPhySupported(); boolean isLeExtendedAdvertisingSupported(); boolean isLePeriodicAdvertisingSupported(); + int getLeMaximumAdvertisingDataLength(); BluetoothActivityEnergyInfo reportActivityInfo(); /**