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

Commit 2a5f608e authored by Casper Bonde's avatar Casper Bonde Committed by Andre Eisenbach
Browse files

Add support for Bluetooth Sim Access Profile (2/4)

Change-Id: I6c634aa38d31a7b5a98c9089840557257fd58209
parent d055adbe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ LOCAL_SRC_FILES += \
	core/java/android/bluetooth/IBluetoothManagerCallback.aidl \
	core/java/android/bluetooth/IBluetoothPbap.aidl \
	core/java/android/bluetooth/IBluetoothMap.aidl \
	core/java/android/bluetooth/IBluetoothSap.aidl \
	core/java/android/bluetooth/IBluetoothStateChangeCallback.aidl \
	core/java/android/bluetooth/IBluetoothHeadsetClient.aidl \
	core/java/android/bluetooth/IBluetoothGatt.aidl \
+20 −0
Original line number Diff line number Diff line
@@ -6951,6 +6951,7 @@ package android.bluetooth {
    field public static final int GATT_SERVER = 8; // 0x8
    field public static final int HEADSET = 1; // 0x1
    field public static final int HEALTH = 3; // 0x3
    field public static final int SAP = 10; // 0xa
    field public static final int STATE_CONNECTED = 2; // 0x2
    field public static final int STATE_CONNECTING = 1; // 0x1
    field public static final int STATE_DISCONNECTED = 0; // 0x0
@@ -6962,6 +6963,25 @@ package android.bluetooth {
    method public abstract void onServiceDisconnected(int);
  }
  public final class BluetoothSap implements android.bluetooth.BluetoothProfile {
    method public synchronized void close();
    method public boolean connect(android.bluetooth.BluetoothDevice);
    method public boolean disconnect(android.bluetooth.BluetoothDevice);
    method public android.bluetooth.BluetoothDevice getClient();
    method public java.util.List<android.bluetooth.BluetoothDevice> getConnectedDevices();
    method public int getConnectionState(android.bluetooth.BluetoothDevice);
    method public java.util.List<android.bluetooth.BluetoothDevice> getDevicesMatchingConnectionStates(int[]);
    method public int getPriority(android.bluetooth.BluetoothDevice);
    method public int getState();
    method public boolean isConnected(android.bluetooth.BluetoothDevice);
    method public boolean setPriority(android.bluetooth.BluetoothDevice, int);
    field public static final java.lang.String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.sap.profile.action.CONNECTION_STATE_CHANGED";
    field public static final int RESULT_CANCELED = 2; // 0x2
    field public static final int RESULT_FAILURE = 0; // 0x0
    field public static final int RESULT_SUCCESS = 1; // 0x1
    field public static final int STATE_ERROR = -1; // 0xffffffff
  }
  public final class BluetoothServerSocket implements java.io.Closeable {
    method public android.bluetooth.BluetoothSocket accept() throws java.io.IOException;
    method public android.bluetooth.BluetoothSocket accept(int) throws java.io.IOException;
+20 −0
Original line number Diff line number Diff line
@@ -7142,6 +7142,7 @@ package android.bluetooth {
    field public static final int GATT_SERVER = 8; // 0x8
    field public static final int HEADSET = 1; // 0x1
    field public static final int HEALTH = 3; // 0x3
    field public static final int SAP = 10; // 0xa
    field public static final int STATE_CONNECTED = 2; // 0x2
    field public static final int STATE_CONNECTING = 1; // 0x1
    field public static final int STATE_DISCONNECTED = 0; // 0x0
@@ -7153,6 +7154,25 @@ package android.bluetooth {
    method public abstract void onServiceDisconnected(int);
  }
  public final class BluetoothSap implements android.bluetooth.BluetoothProfile {
    method public synchronized void close();
    method public boolean connect(android.bluetooth.BluetoothDevice);
    method public boolean disconnect(android.bluetooth.BluetoothDevice);
    method public android.bluetooth.BluetoothDevice getClient();
    method public java.util.List<android.bluetooth.BluetoothDevice> getConnectedDevices();
    method public int getConnectionState(android.bluetooth.BluetoothDevice);
    method public java.util.List<android.bluetooth.BluetoothDevice> getDevicesMatchingConnectionStates(int[]);
    method public int getPriority(android.bluetooth.BluetoothDevice);
    method public int getState();
    method public boolean isConnected(android.bluetooth.BluetoothDevice);
    method public boolean setPriority(android.bluetooth.BluetoothDevice, int);
    field public static final java.lang.String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.sap.profile.action.CONNECTION_STATE_CHANGED";
    field public static final int RESULT_CANCELED = 2; // 0x2
    field public static final int RESULT_FAILURE = 0; // 0x0
    field public static final int RESULT_SUCCESS = 1; // 0x1
    field public static final int STATE_ERROR = -1; // 0xffffffff
  }
  public final class BluetoothServerSocket implements java.io.Closeable {
    method public android.bluetooth.BluetoothSocket accept() throws java.io.IOException;
    method public android.bluetooth.BluetoothSocket accept(int) throws java.io.IOException;
+7 −0
Original line number Diff line number Diff line
@@ -1743,6 +1743,9 @@ public final class BluetoothAdapter {
        } else if (profile == BluetoothProfile.HEADSET_CLIENT) {
            BluetoothHeadsetClient headsetClient = new BluetoothHeadsetClient(context, listener);
            return true;
        } else if (profile == BluetoothProfile.SAP) {
            BluetoothSap sap = new BluetoothSap(context, listener);
            return true;
        } else {
            return false;
        }
@@ -1807,6 +1810,10 @@ public final class BluetoothAdapter {
                BluetoothHeadsetClient headsetClient = (BluetoothHeadsetClient)proxy;
                headsetClient.close();
                break;
            case BluetoothProfile.SAP:
                BluetoothSap sap = (BluetoothSap)proxy;
                sap.close();
                break;
        }
    }

+41 −0
Original line number Diff line number Diff line
@@ -382,6 +382,9 @@ public final class BluetoothDevice implements Parcelable {
    /**@hide*/
    public static final int REQUEST_TYPE_MESSAGE_ACCESS = 3;

    /**@hide*/
    public static final int REQUEST_TYPE_SIM_ACCESS = 4;

    /**
     * Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REQUEST} intents,
     * Contains package name to return reply intent to.
@@ -1269,6 +1272,44 @@ public final class BluetoothDevice implements Parcelable {
        return false;
    }

    /**
     * Requires {@link android.Manifest.permission#BLUETOOTH}.
     * @return Whether the Sim access is allowed to this device. Can be
     *         {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
     * @hide
     */
    public int getSimAccessPermission() {
        if (sService == null) {
            return ACCESS_UNKNOWN;
        }
        try {
            return sService.getSimAccessPermission(this);
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        }
        return ACCESS_UNKNOWN;
    }

    /**
     * Sets whether the Sim access is allowed to this device.
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
     * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or
     *              {@link #ACCESS_REJECTED}.
     * @return Whether the value has been successfully set.
     * @hide
     */
    public boolean setSimAccessPermission(int value) {
        if (sService == null) {
            return false;
        }
        try {
            return sService.setSimAccessPermission(this, value);
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        }
        return false;
    }    
    
    /**
     * Create an RFCOMM {@link BluetoothSocket} ready to start a secure
     * outgoing connection to this remote device on given channel.
Loading