diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java index bbb31e6a0..d06d9ba58 100644 --- a/src/com/android/bluetooth/gatt/GattService.java +++ b/src/com/android/bluetooth/gatt/GattService.java @@ -95,7 +95,8 @@ import java.util.function.Predicate; * @hide */ public class GattService extends ProfileService { - private static final boolean DBG = GattServiceConfig.DBG; + //private static final boolean DBG = GattServiceConfig.DBG; + private static final boolean DBG = true; private static final boolean VDBG = GattServiceConfig.VDBG; private static final String TAG = GattServiceConfig.TAG_PREFIX + "GattService"; private static final String UUID_SUFFIX = "-0000-1000-8000-00805f9b34fb"; @@ -249,6 +250,7 @@ public class GattService extends ProfileService { "BRM_SA02", "BOS_KR01" }; + boolean bSendLEConnectionUpdate = false; /* vas added end*/ /** @@ -270,6 +272,7 @@ public class GattService extends ProfileService { if (DBG) { Log.d(TAG, "start()"); } + Log.d(TAG, "start()"); mExposureNotificationPackage = getString(R.string.exposure_notification_package); Settings.Global.putInt( getContentResolver(), "bluetooth_sanitized_exposure_notification_supported", 1); @@ -297,6 +300,7 @@ public class GattService extends ProfileService { if (DBG) { Log.d(TAG, "stop()"); } + Log.d(TAG, "stop()"); setGattService(null); mScannerMap.clear(); mClientMap.clear(); @@ -312,6 +316,7 @@ public class GattService extends ProfileService { if (mPeriodicScanManager != null) { mPeriodicScanManager.cleanup(); } + bSendLEConnectionUpdate = false; return true; } @@ -822,6 +827,7 @@ public class GattService extends ProfileService { if (service == null) { return; } + Log.d(TAG,"JERRY 1 send leConnectionUpdate for " + address); service.leConnectionUpdate(clientIf, address, minConnectionInterval, maxConnectionInterval, peripheralLatency, supervisionTimeout, minConnectionEventLen, @@ -1356,7 +1362,7 @@ public class GattService extends ProfileService { void onConnected(int clientIf, int connId, int status, String address) throws RemoteException { if (DBG) { Log.d(TAG, "onConnected() - clientIf=" + clientIf + ", connId=" + connId + ", address=" - + address); + + address + ", satus=" + status); } if (status == 0) { @@ -1367,24 +1373,38 @@ public class GattService extends ProfileService { app.callback.onClientConnectionState(status, clientIf, (status == BluetoothGatt.GATT_SUCCESS), address); + Log.d(TAG,"JERRY app.name " + app.name); /* vas added start*/ BluetoothDevice device = getAnonymousDevice(address); - if((device != null) /*&& (app.name.indexOf("android.uid.system") != -1)*/ ){ + if((device != null) && (app.name.indexOf("android.uid.system") != -1) ){ String name = device.getName(); // BOS_KR01 + Log.d(TAG,"JERRY device.name " + name); Log.e(TAG, " name: " + name); for (String devName : RTK_DEVICES) { if (name.indexOf(devName) != -1) { Log.e(TAG, "onClientConnected() connId=" + connId + " send connection update"); if (name.contains("BOS_KR01")){ - leConnectionUpdate(clientIf, address, 8, 8, 133, 1000, 0, 8, getAttributionSource()); /* 8*1.25 = 10ms, 133, 10s supervision timeout, min_ce 0, max_ce 8 */ + if(!bSendLEConnectionUpdate) { + bSendLEConnectionUpdate = true; + Log.d(TAG,"send leConnectionUpdate for BOS_KR01"); + leConnectionUpdate(clientIf, address, 8, 8, 133, 1000, 0, 8, getAttributionSource()); /* 8*1.25 = 10ms, 133, 10s supervision timeout, min_ce 0, max_ce 8 */ + } Log.e(TAG, "BOS_KR01"); } else if (name.contains("BRM_SA02")){ - leConnectionUpdate(clientIf, address, 9, 9, 266, 1000, 0, 8, getAttributionSource()); + if(!bSendLEConnectionUpdate) { + bSendLEConnectionUpdate = true; + Log.d(TAG,"send leConnectionUpdate for BRM_SA02"); + leConnectionUpdate(clientIf, address, 9, 9, 266, 1000, 0, 8, getAttributionSource()); + } Log.e(TAG, "BRM_SA02"); } else { - leConnectionUpdate(clientIf, address, 9, 9, 133, 1000, 0, 8, getAttributionSource()); /* 9*1.25 = 11.25ms, 133, 10s supervision timeout, min_ce 0, max_ce 8 */ + if(!bSendLEConnectionUpdate) { + bSendLEConnectionUpdate = true; + Log.d(TAG,"JERRY 2 send leConnectionUpdate for " + name); + leConnectionUpdate(clientIf, address, 9, 9, 133, 1000, 0, 8, getAttributionSource()); /* 9*1.25 = 11.25ms, 133, 10s supervision timeout, min_ce 0, max_ce 8 */ + } } } } @@ -1400,12 +1420,21 @@ public class GattService extends ProfileService { "onDisconnected() - clientIf=" + clientIf + ", connId=" + connId + ", address=" + address); } + Log.d(TAG,"onDisconnected() - clientIf=" + clientIf + ", connId=" + connId + ", address="+ address); mClientMap.removeConnection(clientIf, connId); ClientMap.App app = mClientMap.getById(clientIf); if (app != null) { app.callback.onClientConnectionState(status, clientIf, false, address); } + + BluetoothDevice device = getAnonymousDevice(address); + if(device != null) { + if(!device.isConnected()) { + Log.d(TAG,"set bSendLEConnectionUpdate to false"); + bSendLEConnectionUpdate = false; + } + } } void onClientPhyUpdate(int connId, int txPhy, int rxPhy, int status) throws RemoteException { @@ -3130,6 +3159,7 @@ public class GattService extends ProfileService { } + Log.d(TAG,"JERRY 0 send leConnectionUpdate for " + address); gattConnectionParameterUpdateNative(clientIf, address, minInterval, maxInterval, peripheralLatency, supervisionTimeout, minConnectionEventLen, maxConnectionEventLen);