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

Commit be082153 authored by Pradeep Panigrahi's avatar Pradeep Panigrahi Committed by Steve Kondik
Browse files

Bluetooth: Add trust device feature.

Add set trust feature where the remote device is marked
as a trusted device for subsequent connection.

CRs-fixed: 523135

Conflicts:
        core/java/android/bluetooth/BluetoothDevice.java

Change-Id: I9bde4d7dfe07d9d63b58a661ed2413f45501bd7b
parent 330d1e02
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -972,6 +972,46 @@ public final class BluetoothDevice implements Parcelable {
        return null;
    }

    /**
     * Get trust state of a remote device.
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
     * @return true/false
     * @hide
     */
    public boolean getTrustState() {
        if (sService == null) {
            Log.e(TAG, "BT not enabled. Cannot get Remote Device Alias");
            return false;
        }

        try {
            return sService.getRemoteTrust(this);
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        }
        return false;
    }

    /**
     * Set trust state for a remote device.
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
     * @param value the trust state value (true or false)
     * @return true/false
     * @hide
     */
    public boolean setTrust(boolean trustValue) {
        if (sService == null) {
            Log.e(TAG, "BT not enabled. Cannot set Remote Device name");
            return false;
        }
        try {
            return sService.setRemoteTrust(this, trustValue);
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        }
        return false;
    }

    /**
     * Returns the supported features (UUIDs) of the remote device.
     *
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ interface IBluetooth
    int getRemoteType(in BluetoothDevice device);
    String getRemoteAlias(in BluetoothDevice device);
    boolean setRemoteAlias(in BluetoothDevice device, in String name);
    boolean setRemoteTrust(in BluetoothDevice device, in boolean value);
    boolean getRemoteTrust(in BluetoothDevice device);
    int getRemoteClass(in BluetoothDevice device);
    ParcelUuid[] getRemoteUuids(in BluetoothDevice device);
    boolean fetchRemoteUuids(in BluetoothDevice device);