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

Commit 9ef032b0 authored by Zach Johnson's avatar Zach Johnson
Browse files

Pass package name as part of startDiscovery

Test: manual
Bug: 118347252
Change-Id: Icbc2e7e756b16ffd181924b586a0292c2bf32ec5
parent b759a578
Loading
Loading
Loading
Loading
+19 −1
Original line number Original line Diff line number Diff line
@@ -643,6 +643,7 @@ public final class BluetoothAdapter {
    private final IBluetoothManager mManagerService;
    private final IBluetoothManager mManagerService;
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private IBluetooth mService;
    private IBluetooth mService;
    private Context mContext;
    private final ReentrantReadWriteLock mServiceLock = new ReentrantReadWriteLock();
    private final ReentrantReadWriteLock mServiceLock = new ReentrantReadWriteLock();


    private final Object mLock = new Object();
    private final Object mLock = new Object();
@@ -1540,6 +1541,23 @@ public final class BluetoothAdapter {
        return -1;
        return -1;
    }
    }


    /**
     * Set the context for this BluetoothAdapter (only called from BluetoothManager)
     * @hide
     */
    public void setContext(Context context) {
        mContext = context;
    }

    private String getOpPackageName() {
        // Workaround for legacy API for getting a BluetoothAdapter not
        // passing a context
        if (mContext != null) {
            return mContext.getOpPackageName();
        }
        return ActivityThread.currentOpPackageName();
    }

    /**
    /**
     * Start the remote device discovery process.
     * Start the remote device discovery process.
     * <p>The discovery process usually involves an inquiry scan of about 12
     * <p>The discovery process usually involves an inquiry scan of about 12
@@ -1577,7 +1595,7 @@ public final class BluetoothAdapter {
        try {
        try {
            mServiceLock.readLock().lock();
            mServiceLock.readLock().lock();
            if (mService != null) {
            if (mService != null) {
                return mService.startDiscovery();
                return mService.startDiscovery(getOpPackageName());
            }
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
            Log.e(TAG, "", e);
+1 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,7 @@ public final class BluetoothManager {
        }
        }
        // Legacy api - getDefaultAdapter does not take in the context
        // Legacy api - getDefaultAdapter does not take in the context
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mAdapter.setContext(context);
    }
    }


    /**
    /**