diff options
Diffstat (limited to 'core/java')
4 files changed, 74 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 74d85c3..e062fa8 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1752,6 +1752,10 @@ public final class BluetoothAdapter { public void onReadRemoteRssi(String address, int rssi, int status) { // no op } + + public void onListen(int status) { + // no op + } } } diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index 1ad7bf2..a8c310b 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -553,6 +553,14 @@ public final class BluetoothGatt implements BluetoothProfile { Log.w(TAG, "Unhandled exception in callback", ex); } } + + /** + * Listen command status callback + * @hide + */ + public void onListen(int status) { + if (DBG) Log.d(TAG, "onListen() - status=" + status); + } }; /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device) { @@ -685,6 +693,63 @@ public final class BluetoothGatt implements BluetoothProfile { return true; } + /** + * Starts or stops sending of advertisement packages to listen for connection + * requests from a central devices. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param start Start or stop advertising + */ + /*package*/ void listen(boolean start) { + if (DBG) Log.d(TAG, "listen() - start: " + start); + if (mService == null || mClientIf == 0) return; + + try { + mService.clientListen(mClientIf, start); + } catch (RemoteException e) { + Log.e(TAG,"",e); + } + } + + /** + * Sets the advertising data contained in the adv. response packet. + * + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. + * + * @param advData true to set adv. data, false to set scan response + * @param includeName Inlucde the name in the adv. response + * @param includeTxPower Include TX power value + * @param minInterval Minimum desired scan interval (optional) + * @param maxInterval Maximum desired scan interval (optional) + * @param appearance The appearance flags for the device (optional) + * @param manufacturerData Manufacturer specific data including company ID (optional) + */ + /*package*/ void setAdvData(boolean advData, boolean includeName, boolean includeTxPower, + Integer minInterval, Integer maxInterval, + Integer appearance, Byte[] manufacturerData) { + if (DBG) Log.d(TAG, "setAdvData()"); + if (mService == null || mClientIf == 0) return; + + byte[] data = new byte[0]; + if (manufacturerData != null) { + data = new byte[manufacturerData.length]; + for(int i = 0; i != manufacturerData.length; ++i) { + data[i] = manufacturerData[i]; + } + } + + try { + mService.setAdvData(mClientIf, !advData, + includeName, includeTxPower, + minInterval != null ? minInterval : 0, + maxInterval != null ? maxInterval : 0, + appearance != null ? appearance : 0, data); + } catch (RemoteException e) { + Log.e(TAG,"",e); + } + } + /** * Disconnects an established connection, or cancels a connection attempt * currently in progress. diff --git a/core/java/android/bluetooth/IBluetoothGatt.aidl b/core/java/android/bluetooth/IBluetoothGatt.aidl index b58b847..df393db 100644 --- a/core/java/android/bluetooth/IBluetoothGatt.aidl +++ b/core/java/android/bluetooth/IBluetoothGatt.aidl @@ -37,6 +37,10 @@ interface IBluetoothGatt { void unregisterClient(in int clientIf); void clientConnect(in int clientIf, in String address, in boolean isDirect); void clientDisconnect(in int clientIf, in String address); + void clientListen(in int clientIf, in boolean start); + void setAdvData(in int clientIf, in boolean setScanRsp, in boolean inclName, + in boolean inclTxPower, in int minInterval, in int maxInterval, + in int appearance, in byte[] manufacturerData); void refreshDevice(in int clientIf, in String address); void discoverServices(in int clientIf, in String address); void readCharacteristic(in int clientIf, in String address, in int srvcType, diff --git a/core/java/android/bluetooth/IBluetoothGattCallback.aidl b/core/java/android/bluetooth/IBluetoothGattCallback.aidl index e3563fc..60c297b 100644 --- a/core/java/android/bluetooth/IBluetoothGattCallback.aidl +++ b/core/java/android/bluetooth/IBluetoothGattCallback.aidl @@ -63,4 +63,5 @@ interface IBluetoothGattCallback { in int charInstId, in ParcelUuid charUuid, in byte[] value); void onReadRemoteRssi(in String address, in int rssi, in int status); + void onListen(in int status); } |