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

Commit a5ca41e9 authored by Matthew Xie's avatar Matthew Xie Committed by Android Git Automerger
Browse files

am a4f5c425: am 2b9af44e: am 6da97a24: Merge "Check the bluetooth state for...

am a4f5c425: am 2b9af44e: am 6da97a24: Merge "Check the bluetooth state for getUuid call" into ics-mr0

* commit 'a4f5c425':
  Check the bluetooth state for getUuid call
parents f955d057 a4f5c425
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -533,6 +533,7 @@ public final class BluetoothAdapter {
     * @hide
     * @hide
     */
     */
    public ParcelUuid[] getUuids() {
    public ParcelUuid[] getUuids() {
        if (getState() != STATE_ON) return null;
        try {
        try {
            return mService.getUuids();
            return mService.getUuids();
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        } catch (RemoteException e) {Log.e(TAG, "", e);}
+7 −7
Original line number Original line Diff line number Diff line
@@ -810,7 +810,7 @@ public class BluetoothService extends IBluetooth.Stub {
        }
        }
    }
    }


    /*package*/ synchronized String getProperty(String name, boolean checkState) {
    /*package*/ String getProperty(String name, boolean checkState) {
        // If checkState is false, check if the event loop is running.
        // If checkState is false, check if the event loop is running.
        // before making the call to Bluez
        // before making the call to Bluez
        if (checkState) {
        if (checkState) {
@@ -854,14 +854,14 @@ public class BluetoothService extends IBluetooth.Stub {
        return getProperty("Name", false);
        return getProperty("Name", false);
    }
    }


    public synchronized ParcelUuid[] getUuids() {
    public ParcelUuid[] getUuids() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        String value =  getProperty("UUIDs", true);
        String value =  getProperty("UUIDs", true);
        if (value == null) return null;
        if (value == null) return null;
        return convertStringToParcelUuid(value);
        return convertStringToParcelUuid(value);
    }
    }


    private synchronized ParcelUuid[] convertStringToParcelUuid(String value) {
    private ParcelUuid[] convertStringToParcelUuid(String value) {
        String[] uuidStrings = null;
        String[] uuidStrings = null;
        // The UUIDs are stored as a "," separated string.
        // The UUIDs are stored as a "," separated string.
        uuidStrings = value.split(",");
        uuidStrings = value.split(",");
@@ -934,7 +934,7 @@ public class BluetoothService extends IBluetooth.Stub {
     * @return The discoverability window of the device, in seconds.  A negative
     * @return The discoverability window of the device, in seconds.  A negative
     *         value indicates an error.
     *         value indicates an error.
     */
     */
    public synchronized int getDiscoverableTimeout() {
    public int getDiscoverableTimeout() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        String timeout = getProperty("DiscoverableTimeout", true);
        String timeout = getProperty("DiscoverableTimeout", true);
        if (timeout != null)
        if (timeout != null)
@@ -943,7 +943,7 @@ public class BluetoothService extends IBluetooth.Stub {
            return -1;
            return -1;
    }
    }


    public synchronized int getScanMode() {
    public int getScanMode() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        if (!isEnabledInternal())
        if (!isEnabledInternal())
            return BluetoothAdapter.SCAN_MODE_NONE;
            return BluetoothAdapter.SCAN_MODE_NONE;
@@ -969,7 +969,7 @@ public class BluetoothService extends IBluetooth.Stub {
        return stopDiscoveryNative();
        return stopDiscoveryNative();
    }
    }


    public synchronized boolean isDiscovering() {
    public boolean isDiscovering() {
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");


        String discoveringProperty = getProperty("Discovering", false);
        String discoveringProperty = getProperty("Discovering", false);
@@ -2387,7 +2387,7 @@ public class BluetoothService extends IBluetooth.Stub {
        mDeviceProfileState.remove(address);
        mDeviceProfileState.remove(address);
    }
    }


    synchronized String[] getKnownDevices() {
    String[] getKnownDevices() {
        String[] bonds = null;
        String[] bonds = null;
        String val = getProperty("Devices", true);
        String val = getProperty("Devices", true);
        if (val != null) {
        if (val != null) {