diff options
Diffstat (limited to 'framework/java')
10 files changed, 427 insertions, 33 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 8398be1af4..2ed26a9f4d 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -3059,6 +3059,9 @@ public final class BluetoothAdapter { } else if (profile == BluetoothProfile.LE_AUDIO) { BluetoothLeAudio leAudio = new BluetoothLeAudio(context, listener, this); return true; + } else if (profile == BluetoothProfile.VOLUME_CONTROL) { + BluetoothVolumeControl vcs = new BluetoothVolumeControl(context, listener, this); + return true; } else { return false; } @@ -3151,6 +3154,11 @@ public final class BluetoothAdapter { case BluetoothProfile.LE_AUDIO: BluetoothLeAudio leAudio = (BluetoothLeAudio) proxy; leAudio.close(); + break; + case BluetoothProfile.VOLUME_CONTROL: + BluetoothVolumeControl vcs = (BluetoothVolumeControl) proxy; + vcs.close(); + break; } } diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index bbb550fd63..f68a8b28e9 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -1096,6 +1096,8 @@ public final class BluetoothDevice implements Parcelable, Attributable { /** Address is either resolvable, non-resolvable or static. */ public static final int ADDRESS_TYPE_RANDOM = 1; + private static final String NULL_MAC_ADDRESS = "00:00:00:00:00:00"; + /** * Lazy initialization. Guaranteed final after first object constructed, or * getService() called. @@ -1493,6 +1495,10 @@ public final class BluetoothDevice implements Parcelable, Attributable { Log.w(TAG, "BT not enabled, createBondOutOfBand failed"); return false; } + if (NULL_MAC_ADDRESS.equals(mAddress)) { + Log.e(TAG, "Unable to create bond, invalid address " + mAddress); + return false; + } try { return service.createBond( this, transport, remoteP192Data, remoteP256Data, mAttributionSource); diff --git a/framework/java/android/bluetooth/BluetoothGatt.java b/framework/java/android/bluetooth/BluetoothGatt.java index aea82102ca..a75dd59700 100644 --- a/framework/java/android/bluetooth/BluetoothGatt.java +++ b/framework/java/android/bluetooth/BluetoothGatt.java @@ -82,6 +82,9 @@ public final class BluetoothGatt implements BluetoothProfile { private static final int CONN_STATE_DISCONNECTING = 3; private static final int CONN_STATE_CLOSED = 4; + private static final int WRITE_CHARACTERISTIC_MAX_RETRIES = 5; + private static final int WRITE_CHARACTERISTIC_TIME_TO_WAIT = 1000; // milliseconds + private List<BluetoothGattService> mServices; /** A GATT operation completed successfully */ @@ -134,6 +137,27 @@ public final class BluetoothGatt implements BluetoothProfile { public static final int CONNECTION_PRIORITY_LOW_POWER = 2; /** + * A GATT writeCharacteristic request is started successfully. + * + * @hide + */ + public static final int GATT_WRITE_REQUEST_SUCCESS = 0; + + /** + * A GATT writeCharacteristic request failed to start. + * + * @hide + */ + public static final int GATT_WRITE_REQUEST_FAIL = 1; + + /** + * A GATT writeCharacteristic request is issued to a busy remote device. + * + * @hide + */ + public static final int GATT_WRITE_REQUEST_BUSY = 2; + + /** * No authentication required. * * @hide @@ -440,9 +464,19 @@ public final class BluetoothGatt implements BluetoothProfile { try { final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ? AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM; - mService.writeCharacteristic(mClientIf, address, handle, - characteristic.getWriteType(), authReq, - characteristic.getValue(), mAttributionSource); + int requestStatus = GATT_WRITE_REQUEST_FAIL; + for (int i = 0; i < WRITE_CHARACTERISTIC_MAX_RETRIES; i++) { + requestStatus = mService.writeCharacteristic(mClientIf, address, + handle, characteristic.getWriteType(), authReq, + characteristic.getValue(), mAttributionSource); + if (requestStatus != GATT_WRITE_REQUEST_BUSY) { + break; + } + try { + Thread.sleep(WRITE_CHARACTERISTIC_TIME_TO_WAIT); + } catch (InterruptedException e) { + } + } mAuthRetryState++; return; } catch (RemoteException e) { @@ -1190,7 +1224,9 @@ public final class BluetoothGatt implements BluetoothProfile { characteristic.getInstanceId(), AUTHENTICATION_NONE, mAttributionSource); } catch (RemoteException e) { Log.e(TAG, "", e); - mDeviceBusy = false; + synchronized (mDeviceBusyLock) { + mDeviceBusy = false; + } return false; } @@ -1226,7 +1262,9 @@ public final class BluetoothGatt implements BluetoothProfile { mAttributionSource); } catch (RemoteException e) { Log.e(TAG, "", e); - mDeviceBusy = false; + synchronized (mDeviceBusyLock) { + mDeviceBusy = false; + } return false; } @@ -1264,21 +1302,35 @@ public final class BluetoothGatt implements BluetoothProfile { if (device == null) return false; synchronized (mDeviceBusyLock) { - if (mDeviceBusy) return false; + if (mDeviceBusy) { + return false; + } mDeviceBusy = true; } + int requestStatus = GATT_WRITE_REQUEST_FAIL; try { - mService.writeCharacteristic(mClientIf, device.getAddress(), + for (int i = 0; i < WRITE_CHARACTERISTIC_MAX_RETRIES; i++) { + requestStatus = mService.writeCharacteristic(mClientIf, device.getAddress(), characteristic.getInstanceId(), characteristic.getWriteType(), AUTHENTICATION_NONE, characteristic.getValue(), mAttributionSource); + if (requestStatus != GATT_WRITE_REQUEST_BUSY) { + break; + } + try { + Thread.sleep(WRITE_CHARACTERISTIC_TIME_TO_WAIT); + } catch (InterruptedException e) { + } + } } catch (RemoteException e) { Log.e(TAG, "", e); - mDeviceBusy = false; + synchronized (mDeviceBusyLock) { + mDeviceBusy = false; + } return false; } - return true; + return requestStatus == GATT_WRITE_REQUEST_SUCCESS; } /** @@ -1317,7 +1369,9 @@ public final class BluetoothGatt implements BluetoothProfile { descriptor.getInstanceId(), AUTHENTICATION_NONE, mAttributionSource); } catch (RemoteException e) { Log.e(TAG, "", e); - mDeviceBusy = false; + synchronized (mDeviceBusyLock) { + mDeviceBusy = false; + } return false; } @@ -1359,7 +1413,9 @@ public final class BluetoothGatt implements BluetoothProfile { AUTHENTICATION_NONE, descriptor.getValue(), mAttributionSource); } catch (RemoteException e) { Log.e(TAG, "", e); - mDeviceBusy = false; + synchronized (mDeviceBusyLock) { + mDeviceBusy = false; + } return false; } @@ -1428,7 +1484,9 @@ public final class BluetoothGatt implements BluetoothProfile { mService.endReliableWrite(mClientIf, mDevice.getAddress(), true, mAttributionSource); } catch (RemoteException e) { Log.e(TAG, "", e); - mDeviceBusy = false; + synchronized (mDeviceBusyLock) { + mDeviceBusy = false; + } return false; } diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java index 9de27ff97f..c438dd34f8 100644 --- a/framework/java/android/bluetooth/BluetoothLeAudio.java +++ b/framework/java/android/bluetooth/BluetoothLeAudio.java @@ -356,7 +356,6 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { * earbud) * @param device LE Audio capable device * @return group id that this device currently belongs to - * @hide */ @RequiresLegacyBluetoothPermission @RequiresBluetoothConnectPermission diff --git a/framework/java/android/bluetooth/BluetoothProfile.java b/framework/java/android/bluetooth/BluetoothProfile.java index 161c843f03..83a272fce3 100644 --- a/framework/java/android/bluetooth/BluetoothProfile.java +++ b/framework/java/android/bluetooth/BluetoothProfile.java @@ -208,17 +208,24 @@ public interface BluetoothProfile { /** * LE Audio Device * - * @hide */ int LE_AUDIO = 22; /** + * Volume Control profile + * + * @hide + */ + @SystemApi + int VOLUME_CONTROL = 23; + + /** * Max profile ID. This value should be updated whenever a new profile is added to match * the largest value assigned to a profile. * * @hide */ - int MAX_PROFILE_ID = 22; + int MAX_PROFILE_ID = 23; /** * Default priority for devices that we try to auto-connect to and diff --git a/framework/java/android/bluetooth/BluetoothVolumeControl.java b/framework/java/android/bluetooth/BluetoothVolumeControl.java new file mode 100644 index 0000000000..678c11a59f --- /dev/null +++ b/framework/java/android/bluetooth/BluetoothVolumeControl.java @@ -0,0 +1,313 @@ +/* + * Copyright 2021 HIMSA II K/S - www.himsa.com. + * Represented by EHIMA - www.ehima.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.bluetooth; + +import android.Manifest; +import android.annotation.IntRange; +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.RequiresPermission; +import android.annotation.SdkConstant; +import android.annotation.SdkConstant.SdkConstantType; +import android.annotation.SuppressLint; +import android.annotation.SystemApi; +import android.bluetooth.annotations.RequiresBluetoothConnectPermission; +import android.compat.annotation.UnsupportedAppUsage; +import android.content.Attributable; +import android.content.AttributionSource; +import android.content.Context; +import android.os.Binder; +import android.os.IBinder; +import android.os.RemoteException; +import android.util.CloseGuard; +import android.util.Log; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class provides the public APIs to control the Bluetooth Volume Control service. + * + * <p>BluetoothVolumeControl is a proxy object for controlling the Bluetooth VC + * Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get + * the BluetoothVolumeControl proxy object. + * @hide + */ +@SystemApi +public final class BluetoothVolumeControl implements BluetoothProfile, AutoCloseable { + private static final String TAG = "BluetoothVolumeControl"; + private static final boolean DBG = true; + private static final boolean VDBG = false; + + private CloseGuard mCloseGuard; + + /** + * Intent used to broadcast the change in connection state of the Volume Control + * profile. + * + * <p>This intent will have 3 extras: + * <ul> + * <li> {@link #EXTRA_STATE} - The current state of the profile. </li> + * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li> + * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li> + * </ul> + * + * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of + * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING}, + * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}. + * + * @hide + */ + @SystemApi + @SuppressLint("ActionValue") + @RequiresBluetoothConnectPermission + @RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT) + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_CONNECTION_STATE_CHANGED = + "android.bluetooth.volume-control.profile.action.CONNECTION_STATE_CHANGED"; + + private BluetoothAdapter mAdapter; + private final AttributionSource mAttributionSource; + private final BluetoothProfileConnector<IBluetoothVolumeControl> mProfileConnector = + new BluetoothProfileConnector(this, BluetoothProfile.VOLUME_CONTROL, TAG, + IBluetoothVolumeControl.class.getName()) { + @Override + public IBluetoothVolumeControl getServiceInterface(IBinder service) { + return IBluetoothVolumeControl.Stub.asInterface(Binder.allowBlocking(service)); + } + }; + + /** + * Create a BluetoothVolumeControl proxy object for interacting with the local + * Bluetooth Volume Control service. + */ + /*package*/ BluetoothVolumeControl(Context context, ServiceListener listener, + BluetoothAdapter adapter) { + mAdapter = adapter; + mAttributionSource = adapter.getAttributionSource(); + mProfileConnector.connect(context, listener); + mCloseGuard = new CloseGuard(); + mCloseGuard.open("close"); + } + + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) + protected void finalize() { + if (mCloseGuard != null) { + mCloseGuard.warnIfOpen(); + } + close(); + } + + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) + public void close() { + mProfileConnector.disconnect(); + } + + private IBluetoothVolumeControl getService() { return mProfileConnector.getService(); } + + /** + * Get the list of connected devices. Currently at most one. + * + * @return list of connected devices + * + * @hide + */ + @SystemApi + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED, + }) + public @NonNull List<BluetoothDevice> getConnectedDevices() { + if (DBG) log("getConnectedDevices()"); + final IBluetoothVolumeControl service = getService(); + if (service != null && isEnabled()) { + try { + return Attributable.setAttributionSource( + service.getConnectedDevices(mAttributionSource), mAttributionSource); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return new ArrayList<BluetoothDevice>(); + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return new ArrayList<BluetoothDevice>(); + } + + /** + * Get the list of devices matching specified states. Currently at most one. + * + * @return list of matching devices + * + * @hide + */ + @RequiresBluetoothConnectPermission + @RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT) + public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { + if (DBG) log("getDevicesMatchingStates()"); + final IBluetoothVolumeControl service = getService(); + if (service != null && isEnabled()) { + try { + return Attributable.setAttributionSource( + service.getDevicesMatchingConnectionStates(states, mAttributionSource), + mAttributionSource); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return new ArrayList<BluetoothDevice>(); + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return new ArrayList<BluetoothDevice>(); + } + + /** + * Get connection state of device + * + * @return device connection state + * + * @hide + */ + @RequiresBluetoothConnectPermission + @RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT) + public int getConnectionState(BluetoothDevice device) { + if (DBG) log("getConnectionState(" + device + ")"); + final IBluetoothVolumeControl service = getService(); + if (service != null && isEnabled() && isValidDevice(device)) { + try { + return service.getConnectionState(device, mAttributionSource); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return BluetoothProfile.STATE_DISCONNECTED; + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return BluetoothProfile.STATE_DISCONNECTED; + } + + /** + * Tells remote device to set an absolute volume. + * + * @param volume Absolute volume to be set on remote device. + * Minimum value is 0 and maximum value is 255 + * @hide + */ + @SystemApi + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED, + }) + public void setVolume(@Nullable BluetoothDevice device, + @IntRange(from = 0, to = 255) int volume) { + if (DBG) + log("setVolume(" + volume + ")"); + final IBluetoothVolumeControl service = getService(); + try { + if (service != null && isEnabled()) { + service.setVolume(device, volume, mAttributionSource); + return; + } + if (service == null) + Log.w(TAG, "Proxy not attached to service"); + } catch (RemoteException e) { + Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); + } + } + + /** + * Set connection policy of the profile + * + * <p> The device should already be paired. + * Connection policy can be one of {@link #CONNECTION_POLICY_ALLOWED}, + * {@link #CONNECTION_POLICY_FORBIDDEN}, {@link #CONNECTION_POLICY_UNKNOWN} + * + * @param device Paired bluetooth device + * @param connectionPolicy is the connection policy to set to for this profile + * @return true if connectionPolicy is set, false on error + * @hide + */ + @SystemApi + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED, + }) + public boolean setConnectionPolicy(@NonNull BluetoothDevice device, + @ConnectionPolicy int connectionPolicy) { + if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")"); + final IBluetoothVolumeControl service = getService(); + if (service != null && isEnabled() && isValidDevice(device)) { + if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN + && connectionPolicy != BluetoothProfile.CONNECTION_POLICY_ALLOWED) { + return false; + } + try { + return service.setConnectionPolicy(device, connectionPolicy, mAttributionSource); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return false; + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return false; + } + + /** + * Get the connection policy of the profile. + * + * <p> The connection policy can be any of: + * {@link #CONNECTION_POLICY_ALLOWED}, {@link #CONNECTION_POLICY_FORBIDDEN}, + * {@link #CONNECTION_POLICY_UNKNOWN} + * + * @param device Bluetooth device + * @return connection policy of the device + * @hide + */ + @SystemApi + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED, + }) + public @ConnectionPolicy int getConnectionPolicy(@NonNull BluetoothDevice device) { + if (VDBG) log("getConnectionPolicy(" + device + ")"); + final IBluetoothVolumeControl service = getService(); + if (service != null && isEnabled() && isValidDevice(device)) { + try { + return service.getConnectionPolicy(device, mAttributionSource); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; + } + + private boolean isEnabled() { + return mAdapter.getState() == BluetoothAdapter.STATE_ON; + } + + private static boolean isValidDevice(@Nullable BluetoothDevice device) { + return device != null && BluetoothAdapter.checkBluetoothAddress(device.getAddress()); + } + + private static void log(String msg) { + Log.d(TAG, msg); + } +} diff --git a/framework/java/android/bluetooth/OobData.java b/framework/java/android/bluetooth/OobData.java index 4e5ede74ce..bb0b95649b 100644 --- a/framework/java/android/bluetooth/OobData.java +++ b/framework/java/android/bluetooth/OobData.java @@ -937,17 +937,18 @@ public final class OobData implements Parcelable { } @NonNull - private String toHexString(@NonNull int b) { + private String toHexString(int b) { return toHexString(new byte[] {(byte) b}); } @NonNull - private String toHexString(@NonNull byte b) { + private String toHexString(byte b) { return toHexString(new byte[] {b}); } @NonNull - private String toHexString(@NonNull byte[] array) { + private String toHexString(byte[] array) { + if (array == null) return "null"; StringBuilder builder = new StringBuilder(array.length * 2); for (byte b: array) { builder.append(String.format("%02x", b)); diff --git a/framework/java/android/bluetooth/le/BluetoothLeScanner.java b/framework/java/android/bluetooth/le/BluetoothLeScanner.java index 34aac8bfdb..ee173dbc4a 100644 --- a/framework/java/android/bluetooth/le/BluetoothLeScanner.java +++ b/framework/java/android/bluetooth/le/BluetoothLeScanner.java @@ -151,7 +151,7 @@ public final class BluetoothLeScanner { @RequiresPermission(android.Manifest.permission.BLUETOOTH_SCAN) public void startScan(List<ScanFilter> filters, ScanSettings settings, final ScanCallback callback) { - startScan(filters, settings, null, callback, /*callbackIntent=*/ null, null); + startScan(filters, settings, null, callback, /*callbackIntent=*/ null); } /** @@ -185,7 +185,7 @@ public final class BluetoothLeScanner { @NonNull PendingIntent callbackIntent) { return startScan(filters, settings != null ? settings : new ScanSettings.Builder().build(), - null, null, callbackIntent, null); + null, null, callbackIntent); } /** @@ -231,14 +231,13 @@ public final class BluetoothLeScanner { @SuppressLint("AndroidFrameworkRequiresPermission") public void startScanFromSource(List<ScanFilter> filters, ScanSettings settings, final WorkSource workSource, final ScanCallback callback) { - startScan(filters, settings, workSource, callback, null, null); + startScan(filters, settings, workSource, callback, null); } @RequiresPermission(android.Manifest.permission.BLUETOOTH_SCAN) private int startScan(List<ScanFilter> filters, ScanSettings settings, final WorkSource workSource, final ScanCallback callback, - final PendingIntent callbackIntent, - List<List<ResultStorageDescriptor>> resultStorages) { + final PendingIntent callbackIntent) { BluetoothLeUtils.checkAdapterStateOn(mBluetoothAdapter); if (callback == null && callbackIntent == null) { throw new IllegalArgumentException("callback is null"); @@ -274,7 +273,7 @@ public final class BluetoothLeScanner { } if (callback != null) { BleScanCallbackWrapper wrapper = new BleScanCallbackWrapper(gatt, filters, - settings, workSource, callback, resultStorages); + settings, workSource, callback); wrapper.startRegistration(); } else { try { @@ -357,8 +356,11 @@ public final class BluetoothLeScanner { /** * Start truncated scan. * + * @deprecated this is not used anywhere + * * @hide */ + @Deprecated @SystemApi @RequiresBluetoothScanPermission @RequiresPermission(android.Manifest.permission.BLUETOOTH_SCAN) @@ -366,13 +368,10 @@ public final class BluetoothLeScanner { final ScanCallback callback) { int filterSize = truncatedFilters.size(); List<ScanFilter> scanFilters = new ArrayList<ScanFilter>(filterSize); - List<List<ResultStorageDescriptor>> scanStorages = - new ArrayList<List<ResultStorageDescriptor>>(filterSize); for (TruncatedFilter filter : truncatedFilters) { scanFilters.add(filter.getFilter()); - scanStorages.add(filter.getStorageDescriptors()); } - startScan(scanFilters, settings, null, callback, null, scanStorages); + startScan(scanFilters, settings, null, callback, null); } /** @@ -397,7 +396,6 @@ public final class BluetoothLeScanner { private final WorkSource mWorkSource; private ScanSettings mSettings; private IBluetoothGatt mBluetoothGatt; - private List<List<ResultStorageDescriptor>> mResultStorages; // mLeHandle 0: not registered // -2: registration failed because app is scanning to frequently @@ -407,15 +405,13 @@ public final class BluetoothLeScanner { public BleScanCallbackWrapper(IBluetoothGatt bluetoothGatt, List<ScanFilter> filters, ScanSettings settings, - WorkSource workSource, ScanCallback scanCallback, - List<List<ResultStorageDescriptor>> resultStorages) { + WorkSource workSource, ScanCallback scanCallback) { mBluetoothGatt = bluetoothGatt; mFilters = filters; mSettings = settings; mWorkSource = workSource; mScanCallback = scanCallback; mScannerId = 0; - mResultStorages = resultStorages; } public void startRegistration() { @@ -493,7 +489,7 @@ public final class BluetoothLeScanner { } else { mScannerId = scannerId; mBluetoothGatt.startScan(mScannerId, mSettings, mFilters, - mResultStorages, mAttributionSource); + mAttributionSource); } } catch (RemoteException e) { Log.e(TAG, "fail to start le scan: " + e); diff --git a/framework/java/android/bluetooth/le/ResultStorageDescriptor.java b/framework/java/android/bluetooth/le/ResultStorageDescriptor.java index 796c815d69..f65048975d 100644 --- a/framework/java/android/bluetooth/le/ResultStorageDescriptor.java +++ b/framework/java/android/bluetooth/le/ResultStorageDescriptor.java @@ -23,8 +23,11 @@ import android.os.Parcelable; /** * Describes the way to store scan result. * + * @deprecated this is not used anywhere + * * @hide */ +@Deprecated @SystemApi public final class ResultStorageDescriptor implements Parcelable { private int mType; diff --git a/framework/java/android/bluetooth/le/TruncatedFilter.java b/framework/java/android/bluetooth/le/TruncatedFilter.java index 93f526bb9f..25925888a0 100644 --- a/framework/java/android/bluetooth/le/TruncatedFilter.java +++ b/framework/java/android/bluetooth/le/TruncatedFilter.java @@ -24,8 +24,11 @@ import java.util.List; /** * A special scan filter that lets the client decide how the scan record should be stored. * + * @deprecated this is not used anywhere + * * @hide */ +@Deprecated @SystemApi @SuppressLint("AndroidFrameworkBluetoothPermission") public final class TruncatedFilter { |