diff options
Diffstat (limited to 'framework/java/android/bluetooth/le/AdvertisingSet.java')
-rw-r--r-- | framework/java/android/bluetooth/le/AdvertisingSet.java | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/framework/java/android/bluetooth/le/AdvertisingSet.java b/framework/java/android/bluetooth/le/AdvertisingSet.java index 1bc211cb83..1df35e1e38 100644 --- a/framework/java/android/bluetooth/le/AdvertisingSet.java +++ b/framework/java/android/bluetooth/le/AdvertisingSet.java @@ -19,7 +19,6 @@ package android.bluetooth.le; import android.bluetooth.BluetoothAdapter; import android.bluetooth.IBluetoothGatt; import android.bluetooth.IBluetoothManager; -import android.bluetooth.le.IAdvertisingSetCallback; import android.os.RemoteException; import android.util.Log; @@ -37,23 +36,23 @@ import android.util.Log; public final class AdvertisingSet { private static final String TAG = "AdvertisingSet"; - private final IBluetoothGatt gatt; - private int advertiserId; + private final IBluetoothGatt mGatt; + private int mAdvertiserId; /* package */ AdvertisingSet(int advertiserId, - IBluetoothManager bluetoothManager) { - this.advertiserId = advertiserId; + IBluetoothManager bluetoothManager) { + mAdvertiserId = advertiserId; try { - this.gatt = bluetoothManager.getBluetoothGatt(); + mGatt = bluetoothManager.getBluetoothGatt(); } catch (RemoteException e) { - Log.e(TAG, "Failed to get Bluetooth gatt - ", e); - throw new IllegalStateException("Failed to get Bluetooth"); + Log.e(TAG, "Failed to get Bluetooth gatt - ", e); + throw new IllegalStateException("Failed to get Bluetooth"); } } /* package */ void setAdvertiserId(int advertiserId) { - this.advertiserId = advertiserId; + mAdvertiserId = advertiserId; } /** @@ -63,18 +62,17 @@ public final class AdvertisingSet { * Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} * * @param enable whether the advertising should be enabled (true), or disabled (false) - * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to - * 65535 (655,350 ms) + * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535 + * (655,350 ms) * @param maxExtendedAdvertisingEvents maximum number of extended advertising events the - * controller shall attempt to send prior to terminating the extended - * advertising, even if the duration has not expired. Valid range is - * from 1 to 255. + * controller shall attempt to send prior to terminating the extended advertising, even if the + * duration has not expired. Valid range is from 1 to 255. */ public void enableAdvertising(boolean enable, int duration, int maxExtendedAdvertisingEvents) { try { - gatt.enableAdvertisingSet(this.advertiserId, enable, duration, - maxExtendedAdvertisingEvents); + mGatt.enableAdvertisingSet(mAdvertiserId, enable, duration, + maxExtendedAdvertisingEvents); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -87,15 +85,14 @@ public final class AdvertisingSet { * <p> * Advertising data must be empty if non-legacy scannable advertising is used. * - * @param advertiseData Advertisement data to be broadcasted. Size must not exceed - * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the - * advertisement is connectable, three bytes will be added for flags. If the - * update takes place when the advertising set is enabled, the data can be - * maximum 251 bytes long. + * @param advertiseData Advertisement data to be broadcasted. Size must not exceed {@link + * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the advertisement is connectable, + * three bytes will be added for flags. If the update takes place when the advertising set is + * enabled, the data can be maximum 251 bytes long. */ public void setAdvertisingData(AdvertiseData advertiseData) { try { - gatt.setAdvertisingData(this.advertiserId, advertiseData); + mGatt.setAdvertisingData(mAdvertiserId, advertiseData); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -107,13 +104,12 @@ public final class AdvertisingSet { * is delivered through {@code callback.onScanResponseDataSet()}. * * @param scanResponse Scan response associated with the advertisement data. Size must not - * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the - * update takes place when the advertising set is enabled, the data can be - * maximum 251 bytes long. + * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the update takes place + * when the advertising set is enabled, the data can be maximum 251 bytes long. */ public void setScanResponseData(AdvertiseData scanResponse) { try { - gatt.setScanResponseData(this.advertiserId, scanResponse); + mGatt.setScanResponseData(mAdvertiserId, scanResponse); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -128,7 +124,7 @@ public final class AdvertisingSet { */ public void setAdvertisingParameters(AdvertisingSetParameters parameters) { try { - gatt.setAdvertisingParameters(this.advertiserId, parameters); + mGatt.setAdvertisingParameters(mAdvertiserId, parameters); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -141,7 +137,7 @@ public final class AdvertisingSet { */ public void setPeriodicAdvertisingParameters(PeriodicAdvertisingParameters parameters) { try { - gatt.setPeriodicAdvertisingParameters(this.advertiserId, parameters); + mGatt.setPeriodicAdvertisingParameters(mAdvertiserId, parameters); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -153,14 +149,13 @@ public final class AdvertisingSet { * immediately, the operation status is delivered through * {@code callback.onPeriodicAdvertisingDataSet()}. * - * @param periodicData Periodic advertising data. Size must not exceed - * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the - * update takes place when the periodic advertising is enabled for this set, - * the data can be maximum 251 bytes long. + * @param periodicData Periodic advertising data. Size must not exceed {@link + * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the update takes place when the + * periodic advertising is enabled for this set, the data can be maximum 251 bytes long. */ public void setPeriodicAdvertisingData(AdvertiseData periodicData) { try { - gatt.setPeriodicAdvertisingData(this.advertiserId, periodicData); + mGatt.setPeriodicAdvertisingData(mAdvertiserId, periodicData); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -170,11 +165,12 @@ public final class AdvertisingSet { * Used to enable/disable periodic advertising. This method returns immediately, the operation * status is delivered through {@code callback.onPeriodicAdvertisingEnable()}. * - * @param enable whether the periodic advertising should be enabled (true), or disabled (false). + * @param enable whether the periodic advertising should be enabled (true), or disabled + * (false). */ public void setPeriodicAdvertisingEnabled(boolean enable) { try { - gatt.setPeriodicAdvertisingEnable(this.advertiserId, enable); + mGatt.setPeriodicAdvertisingEnable(mAdvertiserId, enable); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -186,11 +182,12 @@ public final class AdvertisingSet { * should ever use it. * * This method requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} permission. + * * @hide */ - public void getOwnAddress(){ + public void getOwnAddress() { try { - gatt.getOwnAddress(this.advertiserId); + mGatt.getOwnAddress(mAdvertiserId); } catch (RemoteException e) { Log.e(TAG, "remote exception - ", e); } @@ -201,7 +198,7 @@ public final class AdvertisingSet { * * @hide */ - public int getAdvertiserId(){ - return advertiserId; + public int getAdvertiserId() { + return mAdvertiserId; } -}
\ No newline at end of file +} |