From ad10affa4e6c4fdd3dd7c9088209dc27d668b872 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Thu, 16 Mar 2017 18:22:36 -0700 Subject: [PATCH] LE Maximum Advertising Data Length (1/4) Add ability to check maximum advertising data length. Bug: 30622771 Test: manual Change-Id: I281f7e9f294c40a47a67a22809cc753b6693f7c4 --- api/current.txt | 1 + api/system-current.txt | 1 + api/test-current.txt | 1 + .../android/bluetooth/BluetoothAdapter.java | 19 +++++++++++++++++++ core/java/android/bluetooth/IBluetooth.aidl | 1 + 5 files changed, 23 insertions(+) diff --git a/api/current.txt b/api/current.txt index 1aebd078a0dcb..3f4b73d57cc5a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6694,6 +6694,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 9c1cea7995b71..7241e9513f50b 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6992,6 +6992,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 e1419b217590b..98bf7a69afcb1 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -6703,6 +6703,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 c689da6ca7729..27640e78825eb 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(); /**