1a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski/*
2a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Copyright (C) 2017 The Android Open Source Project
3a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski *
4a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Licensed under the Apache License, Version 2.0 (the "License");
5a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * you may not use this file except in compliance with the License.
6a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * You may obtain a copy of the License at
7a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski *
8a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski *      http://www.apache.org/licenses/LICENSE-2.0
9a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski *
10a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Unless required by applicable law or agreed to in writing, software
11a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * distributed under the License is distributed on an "AS IS" BASIS,
12a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * See the License for the specific language governing permissions and
14a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * limitations under the License.
15a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */
16a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
17a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskipackage android.bluetooth.le;
18a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
19d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowskiimport android.bluetooth.BluetoothAdapter;
20a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.bluetooth.IBluetoothGatt;
21a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.bluetooth.IBluetoothManager;
22a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.bluetooth.le.IAdvertisingSetCallback;
23a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.os.RemoteException;
24a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.util.Log;
25a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
26a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski/**
27a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * This class provides a way to control single Bluetooth LE advertising instance.
28a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * <p>
29a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * To get an instance of {@link AdvertisingSet}, call the
30a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * {@link BluetoothLeAdvertiser#startAdvertisingSet} method.
31a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * <p>
32a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * <b>Note:</b> Most of the methods here require {@link android.Manifest.permission#BLUETOOTH_ADMIN}
33a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * permission.
34a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski *
35a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @see AdvertiseData
36a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */
37a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskipublic final class AdvertisingSet {
38a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    private static final String TAG = "AdvertisingSet";
39a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
40a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    private final IBluetoothGatt gatt;
41a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    private int advertiserId;
42a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
43a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /* package */ AdvertisingSet(int advertiserId,
44a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski                                 IBluetoothManager bluetoothManager) {
45a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        this.advertiserId = advertiserId;
46a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
47a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
48a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski          this.gatt = bluetoothManager.getBluetoothGatt();
49a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
50a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski          Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
51a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski          throw new IllegalStateException("Failed to get Bluetooth");
52a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
53a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
54a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
55a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /* package */ void setAdvertiserId(int advertiserId) {
56a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski      this.advertiserId = advertiserId;
57a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
58a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
59a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
60a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Enables Advertising. This method returns immediately, the operation status is
61d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * delivered through {@code callback.onAdvertisingEnabled()}.
62a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * <p>
63a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
64a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     *
65d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * @param enable whether the advertising should be enabled (true), or disabled (false)
66260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski     * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to
67260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski     *                     65535 (655,350 ms)
68260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski     * @param maxExtendedAdvertisingEvents maximum number of extended advertising events the
69260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski     *                     controller shall attempt to send prior to terminating the extended
70260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski     *                     advertising, even if the duration has not expired. Valid range is
71260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski     *                     from 1 to 255.
72a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
73260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski    public void enableAdvertising(boolean enable, int duration,
74260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski            int maxExtendedAdvertisingEvents) {
75a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
76260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski            gatt.enableAdvertisingSet(this.advertiserId, enable, duration,
77260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski                                      maxExtendedAdvertisingEvents);
78a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
79a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
80a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
81a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
82a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
83a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
84a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Set/update data being Advertised. Make sure that data doesn't exceed the size limit for
85a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * specified AdvertisingSetParameters. This method returns immediately, the operation status is
86a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * delivered through {@code callback.onAdvertisingDataSet()}.
87a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * <p>
88a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Advertising data must be empty if non-legacy scannable advertising is used.
89d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *
90d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * @param advertiseData Advertisement data to be broadcasted. Size must not exceed
91d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
92d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     advertisement is connectable, three bytes will be added for flags. If the
93d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     update takes place when the advertising set is enabled, the data can be
94d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     maximum 251 bytes long.
95a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
96d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski    public void setAdvertisingData(AdvertiseData advertiseData) {
97a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
98d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski            gatt.setAdvertisingData(this.advertiserId, advertiseData);
99a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
100a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
101a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
102a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
103a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
104a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
105a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Set/update scan response data. Make sure that data doesn't exceed the size limit for
106a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * specified AdvertisingSetParameters. This method returns immediately, the operation status
107a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * is delivered through {@code callback.onScanResponseDataSet()}.
108d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *
109d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * @param scanResponse Scan response associated with the advertisement data. Size must not
110d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
111d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     update takes place when the advertising set is enabled, the data can be
112d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     maximum 251 bytes long.
113a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
114d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski    public void setScanResponseData(AdvertiseData scanResponse) {
115a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
116d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski            gatt.setScanResponseData(this.advertiserId, scanResponse);
117a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
118a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
119a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
120a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
121a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
122a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
123a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Update advertising parameters associated with this AdvertisingSet. Must be called when
124a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * advertising is not active. This method returns immediately, the operation status is delivered
125a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * through {@code callback.onAdvertisingParametersUpdated}.
126d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *
127d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * @param parameters advertising set parameters.
128a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
129a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    public void setAdvertisingParameters(AdvertisingSetParameters parameters) {
130a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
131a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            gatt.setAdvertisingParameters(this.advertiserId, parameters);
132a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
133a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
134a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
135a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
136a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
137a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
138a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Update periodic advertising parameters associated with this set. Must be called when
139a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * periodic advertising is not enabled. This method returns immediately, the operation
140a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * status is delivered through {@code callback.onPeriodicAdvertisingParametersUpdated()}.
141a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
142a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    public void setPeriodicAdvertisingParameters(PeriodicAdvertisingParameters parameters) {
143a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
144a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            gatt.setPeriodicAdvertisingParameters(this.advertiserId, parameters);
145a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
146a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
147a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
148a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
149a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
150a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
151a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Used to set periodic advertising data, must be called after setPeriodicAdvertisingParameters,
152a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * or after advertising was started with periodic advertising data set. This method returns
153a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * immediately, the operation status is delivered through
154a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * {@code callback.onPeriodicAdvertisingDataSet()}.
155d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *
156d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * @param periodicData Periodic advertising data. Size must not exceed
157d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
158d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     update takes place when the periodic advertising is enabled for this set,
159d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *                     the data can be maximum 251 bytes long.
160a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
161d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski    public void setPeriodicAdvertisingData(AdvertiseData periodicData) {
162a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
163d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski            gatt.setPeriodicAdvertisingData(this.advertiserId, periodicData);
164a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
165a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
166a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
167a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
168a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
169a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
170a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * Used to enable/disable periodic advertising. This method returns immediately, the operation
171a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * status is delivered through {@code callback.onPeriodicAdvertisingEnable()}.
172d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     *
173d89e4ba357be2b592b0c5407f82adcb42fa3292bJakub Pawlowski     * @param enable whether the periodic advertising should be enabled (true), or disabled (false).
174a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
17517100948f9562905e458975752f0abe042be31e5Jakub Pawlowski    public void setPeriodicAdvertisingEnabled(boolean enable) {
176a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        try {
1776a55da90184fcc6e8f4bb9ebb01662b4925f6094Jakub Pawlowski            gatt.setPeriodicAdvertisingEnable(this.advertiserId, enable);
178a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        } catch (RemoteException e) {
179a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
180a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski        }
181a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
182a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski
183a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    /**
184348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     * Returns address associated with this advertising set.
185348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     * This method is exposed only for Bluetooth PTS tests, no app or system service
186348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     * should ever use it.
187348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     *
188348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     * This method requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} permission.
189348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     * @hide
190348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     */
191348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski    public void getOwnAddress(){
192348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski        try {
193348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski            gatt.getOwnAddress(this.advertiserId);
194348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski        } catch (RemoteException e) {
195348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski            Log.e(TAG, "remote exception - ", e);
196348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski        }
197348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski    }
198348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski
199348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski    /**
200348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski     * Returns advertiserId associated with this advertising set.
201a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     *
202a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     * @hide
203a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski     */
204a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    public int getAdvertiserId(){
205a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski      return advertiserId;
206a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski    }
207a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski}