Loading core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +14 −5 Original line number Diff line number Diff line Loading @@ -237,8 +237,8 @@ public final class BluetoothLeAdvertiser { private final IBluetoothGatt mBluetoothGatt; // mClientIf 0: not registered // -1: scan stopped // >0: registered and scan started // -1: advertise stopped or registration timeout // >0: registered and advertising started private int mClientIf; private boolean mIsAdvertising = false; Loading Loading @@ -268,6 +268,10 @@ public final class BluetoothLeAdvertiser { if (mClientIf > 0 && mIsAdvertising) { mLeAdvertisers.put(mAdvertiseCallback, this); } else if (mClientIf <= 0) { // Registration timeout, reset mClientIf to -1 so no subsequent operations can // proceed. if (mClientIf == 0) mClientIf = -1; // Post internal error if registration failed. postStartFailure(mAdvertiseCallback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); Loading Loading @@ -308,10 +312,15 @@ public final class BluetoothLeAdvertiser { Log.d(TAG, "onClientRegistered() - status=" + status + " clientIf=" + clientIf); synchronized (this) { if (status == BluetoothGatt.GATT_SUCCESS) { mClientIf = clientIf; try { if (mClientIf == -1) { // Registration succeeds after timeout, unregister client. mBluetoothGatt.unregisterClient(clientIf); } else { mClientIf = clientIf; mBluetoothGatt.startMultiAdvertising(mClientIf, mAdvertisement, mScanResponse, mSettings); } return; } catch (RemoteException e) { Log.e(TAG, "failed to start advertising", e); Loading core/java/android/bluetooth/le/BluetoothLeScanner.java +14 −11 Original line number Diff line number Diff line Loading @@ -278,7 +278,7 @@ public final class BluetoothLeScanner { private List<List<ResultStorageDescriptor>> mResultStorages; // mLeHandle 0: not registered // -1: scan stopped // -1: scan stopped or registration failed // > 0: registered and scan started private int mClientIf; Loading Loading @@ -310,6 +310,9 @@ public final class BluetoothLeScanner { if (mClientIf > 0) { mLeScanClients.put(mScanCallback, this); } else { // Registration timed out or got exception, reset clientIf to -1 so no // subsequent operations can proceed. if (mClientIf == 0) mClientIf = -1; postCallbackError(mScanCallback, ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED); } Loading Loading @@ -352,19 +355,19 @@ public final class BluetoothLeScanner { @Override public void onClientRegistered(int status, int clientIf) { Log.d(TAG, "onClientRegistered() - status=" + status + " clientIf=" + clientIf); " clientIf=" + clientIf + " mClientIf=" + mClientIf); synchronized (this) { if (mClientIf == -1) { if (DBG) Log.d(TAG, "onClientRegistered LE scan canceled"); } if (status == BluetoothGatt.GATT_SUCCESS) { mClientIf = clientIf; try { if (mClientIf == -1) { // Registration succeeds after timeout, unregister client. mBluetoothGatt.unregisterClient(clientIf); } else { mClientIf = clientIf; mBluetoothGatt.startScan(mClientIf, false, mSettings, mFilters, mWorkSource, mResultStorages, ActivityThread.currentOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "fail to start le scan: " + e); mClientIf = -1; Loading Loading
core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +14 −5 Original line number Diff line number Diff line Loading @@ -237,8 +237,8 @@ public final class BluetoothLeAdvertiser { private final IBluetoothGatt mBluetoothGatt; // mClientIf 0: not registered // -1: scan stopped // >0: registered and scan started // -1: advertise stopped or registration timeout // >0: registered and advertising started private int mClientIf; private boolean mIsAdvertising = false; Loading Loading @@ -268,6 +268,10 @@ public final class BluetoothLeAdvertiser { if (mClientIf > 0 && mIsAdvertising) { mLeAdvertisers.put(mAdvertiseCallback, this); } else if (mClientIf <= 0) { // Registration timeout, reset mClientIf to -1 so no subsequent operations can // proceed. if (mClientIf == 0) mClientIf = -1; // Post internal error if registration failed. postStartFailure(mAdvertiseCallback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); Loading Loading @@ -308,10 +312,15 @@ public final class BluetoothLeAdvertiser { Log.d(TAG, "onClientRegistered() - status=" + status + " clientIf=" + clientIf); synchronized (this) { if (status == BluetoothGatt.GATT_SUCCESS) { mClientIf = clientIf; try { if (mClientIf == -1) { // Registration succeeds after timeout, unregister client. mBluetoothGatt.unregisterClient(clientIf); } else { mClientIf = clientIf; mBluetoothGatt.startMultiAdvertising(mClientIf, mAdvertisement, mScanResponse, mSettings); } return; } catch (RemoteException e) { Log.e(TAG, "failed to start advertising", e); Loading
core/java/android/bluetooth/le/BluetoothLeScanner.java +14 −11 Original line number Diff line number Diff line Loading @@ -278,7 +278,7 @@ public final class BluetoothLeScanner { private List<List<ResultStorageDescriptor>> mResultStorages; // mLeHandle 0: not registered // -1: scan stopped // -1: scan stopped or registration failed // > 0: registered and scan started private int mClientIf; Loading Loading @@ -310,6 +310,9 @@ public final class BluetoothLeScanner { if (mClientIf > 0) { mLeScanClients.put(mScanCallback, this); } else { // Registration timed out or got exception, reset clientIf to -1 so no // subsequent operations can proceed. if (mClientIf == 0) mClientIf = -1; postCallbackError(mScanCallback, ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED); } Loading Loading @@ -352,19 +355,19 @@ public final class BluetoothLeScanner { @Override public void onClientRegistered(int status, int clientIf) { Log.d(TAG, "onClientRegistered() - status=" + status + " clientIf=" + clientIf); " clientIf=" + clientIf + " mClientIf=" + mClientIf); synchronized (this) { if (mClientIf == -1) { if (DBG) Log.d(TAG, "onClientRegistered LE scan canceled"); } if (status == BluetoothGatt.GATT_SUCCESS) { mClientIf = clientIf; try { if (mClientIf == -1) { // Registration succeeds after timeout, unregister client. mBluetoothGatt.unregisterClient(clientIf); } else { mClientIf = clientIf; mBluetoothGatt.startScan(mClientIf, false, mSettings, mFilters, mWorkSource, mResultStorages, ActivityThread.currentOpPackageName()); } } catch (RemoteException e) { Log.e(TAG, "fail to start le scan: " + e); mClientIf = -1; Loading