Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58867e83 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7263361 from 2cf7f6dacfd682b6dceefa012bd91ddd5ec0df6f to sc-release

Change-Id: I7fa3a80327f15bcc7e64a18e5a88156111aec796
parents 18249afe 5131226e
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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);
    }

    /**
@@ -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);
+7 −10
Original line number Diff line number Diff line
@@ -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;
@@ -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.
@@ -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;
    }

    /**
@@ -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;
                }
@@ -298,7 +295,7 @@ public final class BluetoothLeScanner {
        IBluetoothGatt gatt;
        try {
            gatt = mBluetoothManager.getBluetoothGatt();
            gatt.stopScanForIntent(callbackIntent, mOpPackageName);
            gatt.stopScanForIntent(callbackIntent);
        } catch (RemoteException e) {
        }
    }
@@ -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);