Loading framework/java/android/bluetooth/BluetoothAdapter.java +8 −0 Original line number Diff line number Diff line Loading @@ -2026,5 +2026,13 @@ public final class BluetoothAdapter { } } } /** * Callback reporting LE ATT MTU. * @hide */ public void onConfigureMTU(String address, int mtu, int status) { // no op } } } framework/java/android/bluetooth/BluetoothGatt.java +47 −0 Original line number Diff line number Diff line Loading @@ -562,6 +562,23 @@ public final class BluetoothGatt implements BluetoothProfile { if (DBG) Log.d(TAG, "onAdvertiseStateChange() - state = " + state + " status=" + status); } /** * Callback invoked when the MTU for a given connection changes * @hide */ public void onConfigureMTU(String address, int mtu, int status) { if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address + " mtu=" + mtu + " status=" + status); if (!address.equals(mDevice.getAddress())) { return; } try { mCallback.onConfigureMTU(BluetoothGatt.this, mtu, status); } catch (Exception ex) { Log.w(TAG, "Unhandled exception in callback", ex); } } }; /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device) { Loading Loading @@ -1147,6 +1164,36 @@ public final class BluetoothGatt implements BluetoothProfile { return true; } /** * Configure the MTU used for a given connection. * * <p>When performing a write request operation (write without response), * the data sent is truncated to the MTU size. This function may be used * to request a larget MTU size to be able to send more data at once. * * <p>A {@link BluetoothGattCallback#onConfigureMTU} callback will indicate * whether this operation was successful. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. * * @return true, if the new MTU value has been requested successfully * @hide */ public boolean configureMTU(int mtu) { if (DBG) Log.d(TAG, "configureMTU() - device: " + mDevice.getAddress() + " mtu: " + mtu); if (mService == null || mClientIf == 0) return false; try { mService.configureMTU(mClientIf, mDevice.getAddress(), mtu); } catch (RemoteException e) { Log.e(TAG,"",e); return false; } return true; } /** * Not supported - please use {@link BluetoothManager#getConnectedDevices(int)} * with {@link BluetoothProfile#GATT} as argument Loading framework/java/android/bluetooth/BluetoothGattCallback.java +15 −0 Original line number Diff line number Diff line Loading @@ -138,4 +138,19 @@ public abstract class BluetoothGattCallback { */ public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { } /** * Callback indicating the MTU for a given device connection has changed. * * This callback is triggered in response to the * {@link BluetoothGatt#configureMTU} function, or in response to a connection * event. * * @param gatt GATT client invoked {@link BluetoothGatt#configureMTU} * @param mtu The new MTU size * @param status {@link BluetoothGatt#GATT_SUCCESS} if the MTU has been changed successfully * @hide */ public void onConfigureMTU(BluetoothGatt gatt, int mtu, int status) { } } framework/java/android/bluetooth/IBluetoothGatt.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ interface IBluetoothGatt { void beginReliableWrite(in int clientIf, in String address); void endReliableWrite(in int clientIf, in String address, in boolean execute); void readRemoteRssi(in int clientIf, in String address); void configureMTU(in int clientIf, in String address, in int mtu); void registerServer(in ParcelUuid appId, in IBluetoothGattServerCallback callback); void unregisterServer(in int serverIf); Loading framework/java/android/bluetooth/IBluetoothGattCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,5 @@ interface IBluetoothGattCallback { in byte[] value); void onReadRemoteRssi(in String address, in int rssi, in int status); oneway void onAdvertiseStateChange(in int advertiseState, in int status); void onConfigureMTU(in String address, in int mtu, in int status); } Loading
framework/java/android/bluetooth/BluetoothAdapter.java +8 −0 Original line number Diff line number Diff line Loading @@ -2026,5 +2026,13 @@ public final class BluetoothAdapter { } } } /** * Callback reporting LE ATT MTU. * @hide */ public void onConfigureMTU(String address, int mtu, int status) { // no op } } }
framework/java/android/bluetooth/BluetoothGatt.java +47 −0 Original line number Diff line number Diff line Loading @@ -562,6 +562,23 @@ public final class BluetoothGatt implements BluetoothProfile { if (DBG) Log.d(TAG, "onAdvertiseStateChange() - state = " + state + " status=" + status); } /** * Callback invoked when the MTU for a given connection changes * @hide */ public void onConfigureMTU(String address, int mtu, int status) { if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address + " mtu=" + mtu + " status=" + status); if (!address.equals(mDevice.getAddress())) { return; } try { mCallback.onConfigureMTU(BluetoothGatt.this, mtu, status); } catch (Exception ex) { Log.w(TAG, "Unhandled exception in callback", ex); } } }; /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device) { Loading Loading @@ -1147,6 +1164,36 @@ public final class BluetoothGatt implements BluetoothProfile { return true; } /** * Configure the MTU used for a given connection. * * <p>When performing a write request operation (write without response), * the data sent is truncated to the MTU size. This function may be used * to request a larget MTU size to be able to send more data at once. * * <p>A {@link BluetoothGattCallback#onConfigureMTU} callback will indicate * whether this operation was successful. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. * * @return true, if the new MTU value has been requested successfully * @hide */ public boolean configureMTU(int mtu) { if (DBG) Log.d(TAG, "configureMTU() - device: " + mDevice.getAddress() + " mtu: " + mtu); if (mService == null || mClientIf == 0) return false; try { mService.configureMTU(mClientIf, mDevice.getAddress(), mtu); } catch (RemoteException e) { Log.e(TAG,"",e); return false; } return true; } /** * Not supported - please use {@link BluetoothManager#getConnectedDevices(int)} * with {@link BluetoothProfile#GATT} as argument Loading
framework/java/android/bluetooth/BluetoothGattCallback.java +15 −0 Original line number Diff line number Diff line Loading @@ -138,4 +138,19 @@ public abstract class BluetoothGattCallback { */ public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) { } /** * Callback indicating the MTU for a given device connection has changed. * * This callback is triggered in response to the * {@link BluetoothGatt#configureMTU} function, or in response to a connection * event. * * @param gatt GATT client invoked {@link BluetoothGatt#configureMTU} * @param mtu The new MTU size * @param status {@link BluetoothGatt#GATT_SUCCESS} if the MTU has been changed successfully * @hide */ public void onConfigureMTU(BluetoothGatt gatt, int mtu, int status) { } }
framework/java/android/bluetooth/IBluetoothGatt.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ interface IBluetoothGatt { void beginReliableWrite(in int clientIf, in String address); void endReliableWrite(in int clientIf, in String address, in boolean execute); void readRemoteRssi(in int clientIf, in String address); void configureMTU(in int clientIf, in String address, in int mtu); void registerServer(in ParcelUuid appId, in IBluetoothGattServerCallback callback); void unregisterServer(in int serverIf); Loading
framework/java/android/bluetooth/IBluetoothGattCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -64,4 +64,5 @@ interface IBluetoothGattCallback { in byte[] value); void onReadRemoteRssi(in String address, in int rssi, in int status); oneway void onAdvertiseStateChange(in int advertiseState, in int status); void onConfigureMTU(in String address, in int mtu, in int status); }