diff options
Diffstat (limited to 'core/java/android/bluetooth/BluetoothGatt.java')
-rw-r--r-- | core/java/android/bluetooth/BluetoothGatt.java | 65 |
1 files changed, 65 insertions, 0 deletions
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. |