Loading core/java/android/bluetooth/BluetoothAdapter.java +0 −22 Original line number Original line Diff line number Diff line Loading @@ -580,10 +580,6 @@ public final class BluetoothAdapter { */ */ public BluetoothLeAdvertiser getBluetoothLeAdvertiser() { public BluetoothLeAdvertiser getBluetoothLeAdvertiser() { if (!getLeAccess()) return null; if (!getLeAccess()) return null; if (!isMultipleAdvertisementSupported() && !isPeripheralModeSupported()) { Log.e(TAG, "Bluetooth LE advertising not supported"); return null; } synchronized(mLock) { synchronized(mLock) { if (sBluetoothLeAdvertiser == null) { if (sBluetoothLeAdvertiser == null) { sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService); sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService); Loading Loading @@ -1332,24 +1328,6 @@ public final class BluetoothAdapter { } } } } /** * Returns whether peripheral mode is supported. * * @hide */ public boolean isPeripheralModeSupported() { if (getState() != STATE_ON) return false; try { mServiceLock.readLock().lock(); if (mService != null) return mService.isPeripheralModeSupported(); } catch (RemoteException e) { Log.e(TAG, "failed to get peripheral mode capability: ", e); } finally { mServiceLock.readLock().unlock(); } return false; } /** /** * Return true if offloaded filters are supported * Return true if offloaded filters are supported * * Loading core/java/android/bluetooth/IBluetooth.aidl +0 −1 Original line number Original line Diff line number Diff line Loading @@ -100,7 +100,6 @@ interface IBluetooth boolean factoryReset(); boolean factoryReset(); boolean isMultiAdvertisementSupported(); boolean isMultiAdvertisementSupported(); boolean isPeripheralModeSupported(); boolean isOffloadedFilteringSupported(); boolean isOffloadedFilteringSupported(); boolean isOffloadedScanBatchingSupported(); boolean isOffloadedScanBatchingSupported(); boolean isActivityAndEnergyReportingSupported(); boolean isActivityAndEnergyReportingSupported(); Loading core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +12 −18 Original line number Original line Diff line number Diff line Loading @@ -111,12 +111,6 @@ public final class BluetoothLeAdvertiser { if (callback == null) { if (callback == null) { throw new IllegalArgumentException("callback cannot be null"); throw new IllegalArgumentException("callback cannot be null"); } } if (!mBluetoothAdapter.isMultipleAdvertisementSupported() && !mBluetoothAdapter.isPeripheralModeSupported()) { postStartFailure(callback, AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED); return; } boolean isConnectable = settings.isConnectable(); boolean isConnectable = settings.isConnectable(); if (totalBytes(advertiseData, isConnectable) > MAX_ADVERTISING_DATA_BYTES || if (totalBytes(advertiseData, isConnectable) > MAX_ADVERTISING_DATA_BYTES || totalBytes(scanResponse, false) > MAX_ADVERTISING_DATA_BYTES) { totalBytes(scanResponse, false) > MAX_ADVERTISING_DATA_BYTES) { Loading Loading @@ -236,9 +230,9 @@ public final class BluetoothLeAdvertiser { private final AdvertiseSettings mSettings; private final AdvertiseSettings mSettings; private final IBluetoothGatt mBluetoothGatt; private final IBluetoothGatt mBluetoothGatt; // mAdvertiserId 0: not registered // mAdvertiserId -1: not registered // -1: advertise stopped or registration timeout // -2: advertise stopped or registration timeout // >0: registered and advertising started // >=0: registered and advertising started private int mAdvertiserId; private int mAdvertiserId; private boolean mIsAdvertising = false; private boolean mIsAdvertising = false; Loading @@ -251,12 +245,12 @@ public final class BluetoothLeAdvertiser { mScanResponse = scanResponse; mScanResponse = scanResponse; mSettings = settings; mSettings = settings; mBluetoothGatt = bluetoothGatt; mBluetoothGatt = bluetoothGatt; mAdvertiserId = 0; mAdvertiserId = -1; } } public void startRegisteration() { public void startRegisteration() { synchronized (this) { synchronized (this) { if (mAdvertiserId == -1) return; if (mAdvertiserId == -2) return; try { try { mBluetoothGatt.registerAdvertiser(this); mBluetoothGatt.registerAdvertiser(this); Loading @@ -264,13 +258,13 @@ public final class BluetoothLeAdvertiser { } catch (InterruptedException | RemoteException e) { } catch (InterruptedException | RemoteException e) { Log.e(TAG, "Failed to start registeration", e); Log.e(TAG, "Failed to start registeration", e); } } if (mAdvertiserId > 0 && mIsAdvertising) { if (mAdvertiserId >= 0 && mIsAdvertising) { mLeAdvertisers.put(mAdvertiseCallback, this); mLeAdvertisers.put(mAdvertiseCallback, this); } else if (mAdvertiserId <= 0) { } else if (mAdvertiserId < 0) { // Registration timeout, reset mClientIf to -1 so no subsequent operations can // Registration timeout, reset mClientIf to -1 so no subsequent operations can // proceed. // proceed. if (mAdvertiserId == 0) mAdvertiserId = -1; if (mAdvertiserId == 0) mAdvertiserId = -2; // Post internal error if registration failed. // Post internal error if registration failed. postStartFailure(mAdvertiseCallback, postStartFailure(mAdvertiseCallback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); Loading @@ -278,7 +272,7 @@ public final class BluetoothLeAdvertiser { // Unregister application if it's already registered but advertise failed. // Unregister application if it's already registered but advertise failed. try { try { mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mAdvertiserId = -1; mAdvertiserId = -2; } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "remote exception when unregistering", e); Log.e(TAG, "remote exception when unregistering", e); } } Loading Loading @@ -312,7 +306,7 @@ public final class BluetoothLeAdvertiser { synchronized (this) { synchronized (this) { if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) { try { try { if (mAdvertiserId == -1) { if (mAdvertiserId == -2) { // Registration succeeds after timeout, unregister advertiser. // Registration succeeds after timeout, unregister advertiser. mBluetoothGatt.unregisterAdvertiser(advertiserId); mBluetoothGatt.unregisterAdvertiser(advertiserId); } else { } else { Loading @@ -326,7 +320,7 @@ public final class BluetoothLeAdvertiser { } } } } // Registration failed. // Registration failed. mAdvertiserId = -1; mAdvertiserId = -2; notifyAll(); notifyAll(); } } } } Loading @@ -348,7 +342,7 @@ public final class BluetoothLeAdvertiser { // unregister advertiser for stop. // unregister advertiser for stop. try { try { mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mAdvertiserId = -1; mAdvertiserId = -2; mIsAdvertising = false; mIsAdvertising = false; mLeAdvertisers.remove(mAdvertiseCallback); mLeAdvertisers.remove(mAdvertiseCallback); } catch (RemoteException e) { } catch (RemoteException e) { Loading Loading
core/java/android/bluetooth/BluetoothAdapter.java +0 −22 Original line number Original line Diff line number Diff line Loading @@ -580,10 +580,6 @@ public final class BluetoothAdapter { */ */ public BluetoothLeAdvertiser getBluetoothLeAdvertiser() { public BluetoothLeAdvertiser getBluetoothLeAdvertiser() { if (!getLeAccess()) return null; if (!getLeAccess()) return null; if (!isMultipleAdvertisementSupported() && !isPeripheralModeSupported()) { Log.e(TAG, "Bluetooth LE advertising not supported"); return null; } synchronized(mLock) { synchronized(mLock) { if (sBluetoothLeAdvertiser == null) { if (sBluetoothLeAdvertiser == null) { sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService); sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService); Loading Loading @@ -1332,24 +1328,6 @@ public final class BluetoothAdapter { } } } } /** * Returns whether peripheral mode is supported. * * @hide */ public boolean isPeripheralModeSupported() { if (getState() != STATE_ON) return false; try { mServiceLock.readLock().lock(); if (mService != null) return mService.isPeripheralModeSupported(); } catch (RemoteException e) { Log.e(TAG, "failed to get peripheral mode capability: ", e); } finally { mServiceLock.readLock().unlock(); } return false; } /** /** * Return true if offloaded filters are supported * Return true if offloaded filters are supported * * Loading
core/java/android/bluetooth/IBluetooth.aidl +0 −1 Original line number Original line Diff line number Diff line Loading @@ -100,7 +100,6 @@ interface IBluetooth boolean factoryReset(); boolean factoryReset(); boolean isMultiAdvertisementSupported(); boolean isMultiAdvertisementSupported(); boolean isPeripheralModeSupported(); boolean isOffloadedFilteringSupported(); boolean isOffloadedFilteringSupported(); boolean isOffloadedScanBatchingSupported(); boolean isOffloadedScanBatchingSupported(); boolean isActivityAndEnergyReportingSupported(); boolean isActivityAndEnergyReportingSupported(); Loading
core/java/android/bluetooth/le/BluetoothLeAdvertiser.java +12 −18 Original line number Original line Diff line number Diff line Loading @@ -111,12 +111,6 @@ public final class BluetoothLeAdvertiser { if (callback == null) { if (callback == null) { throw new IllegalArgumentException("callback cannot be null"); throw new IllegalArgumentException("callback cannot be null"); } } if (!mBluetoothAdapter.isMultipleAdvertisementSupported() && !mBluetoothAdapter.isPeripheralModeSupported()) { postStartFailure(callback, AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED); return; } boolean isConnectable = settings.isConnectable(); boolean isConnectable = settings.isConnectable(); if (totalBytes(advertiseData, isConnectable) > MAX_ADVERTISING_DATA_BYTES || if (totalBytes(advertiseData, isConnectable) > MAX_ADVERTISING_DATA_BYTES || totalBytes(scanResponse, false) > MAX_ADVERTISING_DATA_BYTES) { totalBytes(scanResponse, false) > MAX_ADVERTISING_DATA_BYTES) { Loading Loading @@ -236,9 +230,9 @@ public final class BluetoothLeAdvertiser { private final AdvertiseSettings mSettings; private final AdvertiseSettings mSettings; private final IBluetoothGatt mBluetoothGatt; private final IBluetoothGatt mBluetoothGatt; // mAdvertiserId 0: not registered // mAdvertiserId -1: not registered // -1: advertise stopped or registration timeout // -2: advertise stopped or registration timeout // >0: registered and advertising started // >=0: registered and advertising started private int mAdvertiserId; private int mAdvertiserId; private boolean mIsAdvertising = false; private boolean mIsAdvertising = false; Loading @@ -251,12 +245,12 @@ public final class BluetoothLeAdvertiser { mScanResponse = scanResponse; mScanResponse = scanResponse; mSettings = settings; mSettings = settings; mBluetoothGatt = bluetoothGatt; mBluetoothGatt = bluetoothGatt; mAdvertiserId = 0; mAdvertiserId = -1; } } public void startRegisteration() { public void startRegisteration() { synchronized (this) { synchronized (this) { if (mAdvertiserId == -1) return; if (mAdvertiserId == -2) return; try { try { mBluetoothGatt.registerAdvertiser(this); mBluetoothGatt.registerAdvertiser(this); Loading @@ -264,13 +258,13 @@ public final class BluetoothLeAdvertiser { } catch (InterruptedException | RemoteException e) { } catch (InterruptedException | RemoteException e) { Log.e(TAG, "Failed to start registeration", e); Log.e(TAG, "Failed to start registeration", e); } } if (mAdvertiserId > 0 && mIsAdvertising) { if (mAdvertiserId >= 0 && mIsAdvertising) { mLeAdvertisers.put(mAdvertiseCallback, this); mLeAdvertisers.put(mAdvertiseCallback, this); } else if (mAdvertiserId <= 0) { } else if (mAdvertiserId < 0) { // Registration timeout, reset mClientIf to -1 so no subsequent operations can // Registration timeout, reset mClientIf to -1 so no subsequent operations can // proceed. // proceed. if (mAdvertiserId == 0) mAdvertiserId = -1; if (mAdvertiserId == 0) mAdvertiserId = -2; // Post internal error if registration failed. // Post internal error if registration failed. postStartFailure(mAdvertiseCallback, postStartFailure(mAdvertiseCallback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR); Loading @@ -278,7 +272,7 @@ public final class BluetoothLeAdvertiser { // Unregister application if it's already registered but advertise failed. // Unregister application if it's already registered but advertise failed. try { try { mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mAdvertiserId = -1; mAdvertiserId = -2; } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "remote exception when unregistering", e); Log.e(TAG, "remote exception when unregistering", e); } } Loading Loading @@ -312,7 +306,7 @@ public final class BluetoothLeAdvertiser { synchronized (this) { synchronized (this) { if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) { try { try { if (mAdvertiserId == -1) { if (mAdvertiserId == -2) { // Registration succeeds after timeout, unregister advertiser. // Registration succeeds after timeout, unregister advertiser. mBluetoothGatt.unregisterAdvertiser(advertiserId); mBluetoothGatt.unregisterAdvertiser(advertiserId); } else { } else { Loading @@ -326,7 +320,7 @@ public final class BluetoothLeAdvertiser { } } } } // Registration failed. // Registration failed. mAdvertiserId = -1; mAdvertiserId = -2; notifyAll(); notifyAll(); } } } } Loading @@ -348,7 +342,7 @@ public final class BluetoothLeAdvertiser { // unregister advertiser for stop. // unregister advertiser for stop. try { try { mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mBluetoothGatt.unregisterAdvertiser(mAdvertiserId); mAdvertiserId = -1; mAdvertiserId = -2; mIsAdvertising = false; mIsAdvertising = false; mLeAdvertisers.remove(mAdvertiseCallback); mLeAdvertisers.remove(mAdvertiseCallback); } catch (RemoteException e) { } catch (RemoteException e) { Loading