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

Commit a66590ed authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Provide address and name in BT Hot off state.

Clients need this before BT is turned on.
Todo: If BT "hot" feature is off, read from system properties.

Change-Id: I266c2d4731cacde7a53c65e3d5fb43a2cbe29481
parent f5fb6c8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -194,7 +194,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
    }
    }


    private synchronized void onBluetoothEnable() {
    private synchronized void onBluetoothEnable() {
        String devices = mBluetoothService.getProperty("Devices");
        String devices = mBluetoothService.getProperty("Devices", true);
        if (devices != null) {
        if (devices != null) {
            String [] paths = devices.split(",");
            String [] paths = devices.split(",");
            for (String path: paths) {
            for (String path: paths) {
+20 −11
Original line number Original line Diff line number Diff line
@@ -798,8 +798,15 @@ public class BluetoothService extends IBluetooth.Stub {
        return true;
        return true;
    }
    }


    /*package*/ synchronized String getProperty(String name) {
    /*package*/ synchronized String getProperty(String name, boolean checkState) {
        // If checkState is false, check if the event loop is running.
        // before making the call to Bluez
        if (checkState) {
            if (!isEnabledInternal()) return null;
            if (!isEnabledInternal()) return null;
        } else if (!mEventLoop.isEventLoopRunning()) {
            return null;
        }

        return mAdapterProperties.getProperty(name);
        return mAdapterProperties.getProperty(name);
    }
    }


@@ -825,17 +832,19 @@ public class BluetoothService extends IBluetooth.Stub {


    public synchronized String getAddress() {
    public synchronized String getAddress() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return getProperty("Address");
        // Don't check state since we want to provide address, even if BT is off
        return getProperty("Address", false);
    }
    }


    public synchronized String getName() {
    public synchronized String getName() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        return getProperty("Name");
        // Don't check state since we want to provide name, even if BT is off
        return getProperty("Name", false);
    }
    }


    public synchronized ParcelUuid[] getUuids() {
    public synchronized ParcelUuid[] getUuids() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        String value =  getProperty("UUIDs");
        String value =  getProperty("UUIDs", true);
        if (value == null) return null;
        if (value == null) return null;
        return convertStringToParcelUuid(value);
        return convertStringToParcelUuid(value);
    }
    }
@@ -915,7 +924,7 @@ public class BluetoothService extends IBluetooth.Stub {
     */
     */
    public synchronized int getDiscoverableTimeout() {
    public synchronized int getDiscoverableTimeout() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        String timeout = getProperty("DiscoverableTimeout");
        String timeout = getProperty("DiscoverableTimeout", true);
        if (timeout != null)
        if (timeout != null)
           return Integer.valueOf(timeout);
           return Integer.valueOf(timeout);
        else
        else
@@ -927,8 +936,8 @@ public class BluetoothService extends IBluetooth.Stub {
        if (!isEnabledInternal())
        if (!isEnabledInternal())
            return BluetoothAdapter.SCAN_MODE_NONE;
            return BluetoothAdapter.SCAN_MODE_NONE;


        boolean pairable = getProperty("Pairable").equals("true");
        boolean pairable = getProperty("Pairable", true).equals("true");
        boolean discoverable = getProperty("Discoverable").equals("true");
        boolean discoverable = getProperty("Discoverable", true).equals("true");
        return bluezStringToScanMode (pairable, discoverable);
        return bluezStringToScanMode (pairable, discoverable);
    }
    }


@@ -951,7 +960,7 @@ public class BluetoothService extends IBluetooth.Stub {
    public synchronized boolean isDiscovering() {
    public synchronized boolean isDiscovering() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");


        String discoveringProperty = mAdapterProperties.getProperty("Discovering");
        String discoveringProperty = getProperty("Discovering", false);
        if (discoveringProperty == null) {
        if (discoveringProperty == null) {
            return false;
            return false;
        }
        }
@@ -2341,7 +2350,7 @@ public class BluetoothService extends IBluetooth.Stub {


    synchronized String[] getKnownDevices() {
    synchronized String[] getKnownDevices() {
        String[] bonds = null;
        String[] bonds = null;
        String val = getProperty("Devices");
        String val = getProperty("Devices", true);
        if (val != null) {
        if (val != null) {
            bonds = val.split(",");
            bonds = val.split(",");
        }
        }
@@ -2350,7 +2359,7 @@ public class BluetoothService extends IBluetooth.Stub {


    private void initProfileState() {
    private void initProfileState() {
        String[] bonds = null;
        String[] bonds = null;
        String val = mAdapterProperties.getProperty("Devices");
        String val = getProperty("Devices", false);
        if (val != null) {
        if (val != null) {
            bonds = val.split(",");
            bonds = val.split(",");
        }
        }