Loading core/java/android/bluetooth/BluetoothAdapter.java +8 −8 Original line number Diff line number Diff line Loading @@ -38,12 +38,14 @@ import android.bluetooth.le.ScanRecord; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.compat.annotation.UnsupportedAppUsage; import android.content.AttributionSource; import android.content.Context; import android.os.BatteryStats; import android.os.Binder; import android.os.Build; import android.os.IBinder; import android.os.ParcelUuid; import android.os.Process; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; Loading Loading @@ -853,8 +855,8 @@ public final class BluetoothAdapter { } synchronized (mLock) { if (sBluetoothLeScanner == null) { sBluetoothLeScanner = new BluetoothLeScanner(mManagerService, getOpPackageName(), getAttributionTag()); sBluetoothLeScanner = new BluetoothLeScanner(mManagerService, getAttributionSource()); } } return sBluetoothLeScanner; Loading Loading @@ -1664,13 +1666,11 @@ public final class BluetoothAdapter { return ActivityThread.currentOpPackageName(); } private String getAttributionTag() { // Workaround for legacy API for getting a BluetoothAdapter not // passing a context private AttributionSource getAttributionSource() { if (mContext != null) { return mContext.getAttributionTag(); return mContext.getAttributionSource(); } return null; return new AttributionSource(Process.myUid(), ActivityThread.currentOpPackageName(), null); } /** Loading Loading @@ -1710,7 +1710,7 @@ public final class BluetoothAdapter { try { mServiceLock.readLock().lock(); if (mService != null) { return mService.startDiscovery(getOpPackageName(), getAttributionTag()); return mService.startDiscovery(getAttributionSource()); } } catch (RemoteException e) { Log.e(TAG, "", e); Loading core/java/android/bluetooth/le/BluetoothLeScanner.java +7 −10 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothGatt; import android.bluetooth.IBluetoothGatt; import android.bluetooth.IBluetoothManager; import android.content.AttributionSource; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -82,9 +83,7 @@ public final class BluetoothLeScanner { private final Handler mHandler; private BluetoothAdapter mBluetoothAdapter; private final Map<ScanCallback, BleScanCallbackWrapper> mLeScanClients; private final String mOpPackageName; private final String mFeatureId; private final AttributionSource mAttributionSource; /** * Use {@link BluetoothAdapter#getBluetoothLeScanner()} instead. Loading @@ -95,13 +94,12 @@ public final class BluetoothLeScanner { * @hide */ public BluetoothLeScanner(IBluetoothManager bluetoothManager, @NonNull String opPackageName, @Nullable String featureId) { @NonNull AttributionSource attributionSource) { mBluetoothManager = bluetoothManager; mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mHandler = new Handler(Looper.getMainLooper()); mLeScanClients = new HashMap<ScanCallback, BleScanCallbackWrapper>(); mOpPackageName = opPackageName; mFeatureId = featureId; mAttributionSource = attributionSource; } /** Loading Loading @@ -256,8 +254,7 @@ public final class BluetoothLeScanner { wrapper.startRegistration(); } else { try { gatt.startScanForIntent(callbackIntent, settings, filters, mOpPackageName, mFeatureId); gatt.startScanForIntent(callbackIntent, settings, filters, mAttributionSource); } catch (RemoteException e) { return ScanCallback.SCAN_FAILED_INTERNAL_ERROR; } Loading Loading @@ -298,7 +295,7 @@ public final class BluetoothLeScanner { IBluetoothGatt gatt; try { gatt = mBluetoothManager.getBluetoothGatt(); gatt.stopScanForIntent(callbackIntent, mOpPackageName); gatt.stopScanForIntent(callbackIntent); } catch (RemoteException e) { } } Loading Loading @@ -458,7 +455,7 @@ public final class BluetoothLeScanner { } else { mScannerId = scannerId; mBluetoothGatt.startScan(mScannerId, mSettings, mFilters, mResultStorages, mOpPackageName, mFeatureId); mResultStorages, mAttributionSource); } } catch (RemoteException e) { Log.e(TAG, "fail to start le scan: " + e); Loading Loading
core/java/android/bluetooth/BluetoothAdapter.java +8 −8 Original line number Diff line number Diff line Loading @@ -38,12 +38,14 @@ import android.bluetooth.le.ScanRecord; import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanSettings; import android.compat.annotation.UnsupportedAppUsage; import android.content.AttributionSource; import android.content.Context; import android.os.BatteryStats; import android.os.Binder; import android.os.Build; import android.os.IBinder; import android.os.ParcelUuid; import android.os.Process; import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ServiceManager; Loading Loading @@ -853,8 +855,8 @@ public final class BluetoothAdapter { } synchronized (mLock) { if (sBluetoothLeScanner == null) { sBluetoothLeScanner = new BluetoothLeScanner(mManagerService, getOpPackageName(), getAttributionTag()); sBluetoothLeScanner = new BluetoothLeScanner(mManagerService, getAttributionSource()); } } return sBluetoothLeScanner; Loading Loading @@ -1664,13 +1666,11 @@ public final class BluetoothAdapter { return ActivityThread.currentOpPackageName(); } private String getAttributionTag() { // Workaround for legacy API for getting a BluetoothAdapter not // passing a context private AttributionSource getAttributionSource() { if (mContext != null) { return mContext.getAttributionTag(); return mContext.getAttributionSource(); } return null; return new AttributionSource(Process.myUid(), ActivityThread.currentOpPackageName(), null); } /** Loading Loading @@ -1710,7 +1710,7 @@ public final class BluetoothAdapter { try { mServiceLock.readLock().lock(); if (mService != null) { return mService.startDiscovery(getOpPackageName(), getAttributionTag()); return mService.startDiscovery(getAttributionSource()); } } catch (RemoteException e) { Log.e(TAG, "", e); Loading
core/java/android/bluetooth/le/BluetoothLeScanner.java +7 −10 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothGatt; import android.bluetooth.IBluetoothGatt; import android.bluetooth.IBluetoothManager; import android.content.AttributionSource; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -82,9 +83,7 @@ public final class BluetoothLeScanner { private final Handler mHandler; private BluetoothAdapter mBluetoothAdapter; private final Map<ScanCallback, BleScanCallbackWrapper> mLeScanClients; private final String mOpPackageName; private final String mFeatureId; private final AttributionSource mAttributionSource; /** * Use {@link BluetoothAdapter#getBluetoothLeScanner()} instead. Loading @@ -95,13 +94,12 @@ public final class BluetoothLeScanner { * @hide */ public BluetoothLeScanner(IBluetoothManager bluetoothManager, @NonNull String opPackageName, @Nullable String featureId) { @NonNull AttributionSource attributionSource) { mBluetoothManager = bluetoothManager; mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mHandler = new Handler(Looper.getMainLooper()); mLeScanClients = new HashMap<ScanCallback, BleScanCallbackWrapper>(); mOpPackageName = opPackageName; mFeatureId = featureId; mAttributionSource = attributionSource; } /** Loading Loading @@ -256,8 +254,7 @@ public final class BluetoothLeScanner { wrapper.startRegistration(); } else { try { gatt.startScanForIntent(callbackIntent, settings, filters, mOpPackageName, mFeatureId); gatt.startScanForIntent(callbackIntent, settings, filters, mAttributionSource); } catch (RemoteException e) { return ScanCallback.SCAN_FAILED_INTERNAL_ERROR; } Loading Loading @@ -298,7 +295,7 @@ public final class BluetoothLeScanner { IBluetoothGatt gatt; try { gatt = mBluetoothManager.getBluetoothGatt(); gatt.stopScanForIntent(callbackIntent, mOpPackageName); gatt.stopScanForIntent(callbackIntent); } catch (RemoteException e) { } } Loading Loading @@ -458,7 +455,7 @@ public final class BluetoothLeScanner { } else { mScannerId = scannerId; mBluetoothGatt.startScan(mScannerId, mSettings, mFilters, mResultStorages, mOpPackageName, mFeatureId); mResultStorages, mAttributionSource); } } catch (RemoteException e) { Log.e(TAG, "fail to start le scan: " + e); Loading