@@ -799,6 +799,28 @@ private void runOrQueueCallback(final Runnable cb) {
799799 * error
800800 */
801801 private boolean registerApp (BluetoothGattCallback callback , Handler handler ) {
802+ return registerApp (callback , handler , false );
803+ }
804+
805+ /**
806+ * Register an application callback to start using GATT.
807+ *
808+ * <p>This is an asynchronous call. The callback {@link BluetoothGattCallback#onAppRegistered}
809+ * is used to notify success or failure if the function returns true.
810+ *
811+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
812+ *
813+ * @param callback GATT callback handler that will receive asynchronous callbacks.
814+ * @param eattSupport specifies whether client app needs EATT channel for client operations.
815+ * If both local and remote devices support EATT and local app asks for EATT, GATT client
816+ * operations will be performed using EATT channel.
817+ * If either local or remote device doesn't support EATT but local App asks for EATT, GATT
818+ * client operations will be performed using unenhanced ATT channel.
819+ * @return If true, the callback will be called to notify success or failure, false on immediate
820+ * error
821+ * @hide
822+ */
823+ private boolean registerApp (BluetoothGattCallback callback , Handler handler , boolean eattSupport ) {
802824 if (DBG ) Log .d (TAG , "registerApp()" );
803825 if (mService == null ) return false ;
804826
@@ -808,7 +830,7 @@ private boolean registerApp(BluetoothGattCallback callback, Handler handler) {
808830 if (DBG ) Log .d (TAG , "registerApp() - UUID=" + uuid );
809831
810832 try {
811- mService .registerClient (new ParcelUuid (uuid ), mBluetoothGattCallback );
833+ mService .registerClient (new ParcelUuid (uuid ), mBluetoothGattCallback , eattSupport );
812834 } catch (RemoteException e ) {
813835 Log .e (TAG , "" , e );
814836 return false ;
@@ -859,9 +881,45 @@ private void unregisterApp() {
859881 @ UnsupportedAppUsage
860882 /*package*/ boolean connect (Boolean autoConnect , BluetoothGattCallback callback ,
861883 Handler handler ) {
884+ return connect (autoConnect , callback , handler , false );
885+ }
886+
887+ /**
888+ * Initiate a connection to a Bluetooth GATT capable device.
889+ *
890+ * <p>The connection may not be established right away, but will be
891+ * completed when the remote device is available. A
892+ * {@link BluetoothGattCallback#onConnectionStateChange} callback will be
893+ * invoked when the connection state changes as a result of this function.
894+ *
895+ * <p>The autoConnect parameter determines whether to actively connect to
896+ * the remote device, or rather passively scan and finalize the connection
897+ * when the remote device is in range/available. Generally, the first ever
898+ * connection to a device should be direct (autoConnect set to false) and
899+ * subsequent connections to known devices should be invoked with the
900+ * autoConnect parameter set to true.
901+ *
902+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
903+ *
904+ * @param device Remote device to connect to
905+ * @param autoConnect Whether to directly connect to the remote device (false) or to
906+ * automatically connect as soon as the remote device becomes available (true).
907+ * @param eattSupport specifies whether client app needs EATT channel for client operations.
908+ * If both local and remote devices support EATT and local app asks for EATT, GATT client
909+ * operations will be performed using EATT channel.
910+ * If either local or remote device doesn't support EATT but local App asks for EATT, GATT
911+ * client operations will be performed using unenhanced ATT channel.
912+ * @return true, if the connection attempt was initiated successfully
913+ *
914+ * @hide
915+ */
916+ @ UnsupportedAppUsage
917+ /*package*/ boolean connect (Boolean autoConnect , BluetoothGattCallback callback ,
918+ Handler handler , boolean eattSupport ) {
862919 if (DBG ) {
863920 Log .d (TAG ,
864- "connect() - device: " + mDevice .getAddress () + ", auto: " + autoConnect );
921+ "connect() - device: " + mDevice .getAddress () + ", auto: " + autoConnect
922+ + ", eattSupport: " + eattSupport );
865923 }
866924 synchronized (mStateLock ) {
867925 if (mConnState != CONN_STATE_IDLE ) {
@@ -872,7 +930,7 @@ private void unregisterApp() {
872930
873931 mAutoConnect = autoConnect ;
874932
875- if (!registerApp (callback , handler )) {
933+ if (!registerApp (callback , handler , eattSupport )) {
876934 synchronized (mStateLock ) {
877935 mConnState = CONN_STATE_IDLE ;
878936 }
0 commit comments