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

Commit 0d33ef9a authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Create systemapis to connect/disconnect all bt profiles

Bug: 143495377
Test: Manual
Change-Id: I80d816083ef568df319afddfd4557ef74d37d16f
parent 67bef6ab
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1239,7 +1239,9 @@ package android.bluetooth {
  public final class BluetoothAdapter {
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean addOnMetadataChangedListener(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.concurrent.Executor, @NonNull android.bluetooth.BluetoothAdapter.OnMetadataChangedListener);
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connectAllEnabledProfiles(@NonNull android.bluetooth.BluetoothDevice);
    method public boolean disableBLE();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean disconnectAllEnabledProfiles(@NonNull android.bluetooth.BluetoothDevice);
    method public boolean enableBLE();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean enableNoAutoConnect();
    method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean factoryReset();
+50 −0
Original line number Diff line number Diff line
@@ -1733,6 +1733,56 @@ public final class BluetoothAdapter {
        return false;
    }

    /**
     * Connects all enabled and supported bluetooth profiles between the local and remote device
     *
     * @param device is the remote device with which to connect these profiles
     * @return true if all profiles successfully connected, false if an error occurred
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
    public boolean connectAllEnabledProfiles(@NonNull BluetoothDevice device) {
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                return mService.connectAllEnabledProfiles(device);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        } finally {
            mServiceLock.readLock().unlock();
        }

        return false;
    }

    /**
     * Disconnects all enabled and supported bluetooth profiles between the local and remote device
     *
     * @param device is the remote device with which to disconnect these profiles
     * @return true if all profiles successfully disconnected, false if an error occurred
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
    public boolean disconnectAllEnabledProfiles(@NonNull BluetoothDevice device) {
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                return mService.disconnectAllEnabledProfiles(device);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        } finally {
            mServiceLock.readLock().unlock();
        }

        return false;
    }

    /**
     * Return true if the multi advertisement is supported by the chipset
     *