summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Xie <mattx@google.com>2011-11-16 12:27:57 -0800
committerMatthew Xie <mattx@google.com>2011-11-16 12:27:57 -0800
commit44b58ab89e59b3d8241901232c8f7dc9617b206e (patch)
tree698f8d2e9fa6c4ff200b00e5560c240145dd7325
parente562287c85662457864255028cd4bc3b04f13750 (diff)
downloadbase-44b58ab89e59b3d8241901232c8f7dc9617b206e.tar.gz
Check the bluetooth state for getUuid call
Donnot make the bluetoothservice.getUuids call if the bluetooth is not on. Also get rid of all the necessary locks on BluetoothService for get property call. It had a lock on BluetoothAdapterProperty. bug5472114 Change-Id: I383472ae6006fc1f0129c960c8a44ed0df027a43
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java1
-rwxr-xr-xcore/java/android/server/BluetoothService.java14
2 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index ea5c3db86571..d97165256534 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -533,6 +533,7 @@ public final class BluetoothAdapter {
* @hide
*/
public ParcelUuid[] getUuids() {
+ if (getState() != STATE_ON) return null;
try {
return mService.getUuids();
} catch (RemoteException e) {Log.e(TAG, "", e);}
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 9ca58477dd41..5ea8e2a46c2e 100755
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -809,7 +809,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.
// before making the call to Bluez
if (checkState) {
@@ -853,14 +853,14 @@ public class BluetoothService extends IBluetooth.Stub {
return getProperty("Name", false);
}
- public synchronized ParcelUuid[] getUuids() {
+ public ParcelUuid[] getUuids() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
String value = getProperty("UUIDs", true);
if (value == null) return null;
return convertStringToParcelUuid(value);
}
- private synchronized ParcelUuid[] convertStringToParcelUuid(String value) {
+ private ParcelUuid[] convertStringToParcelUuid(String value) {
String[] uuidStrings = null;
// The UUIDs are stored as a "," separated string.
uuidStrings = value.split(",");
@@ -933,7 +933,7 @@ public class BluetoothService extends IBluetooth.Stub {
* @return The discoverability window of the device, in seconds. A negative
* value indicates an error.
*/
- public synchronized int getDiscoverableTimeout() {
+ public int getDiscoverableTimeout() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
String timeout = getProperty("DiscoverableTimeout", true);
if (timeout != null)
@@ -942,7 +942,7 @@ public class BluetoothService extends IBluetooth.Stub {
return -1;
}
- public synchronized int getScanMode() {
+ public int getScanMode() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
if (!isEnabledInternal())
return BluetoothAdapter.SCAN_MODE_NONE;
@@ -968,7 +968,7 @@ public class BluetoothService extends IBluetooth.Stub {
return stopDiscoveryNative();
}
- public synchronized boolean isDiscovering() {
+ public boolean isDiscovering() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
String discoveringProperty = getProperty("Discovering", false);
@@ -2384,7 +2384,7 @@ public class BluetoothService extends IBluetooth.Stub {
mDeviceProfileState.remove(address);
}
- synchronized String[] getKnownDevices() {
+ String[] getKnownDevices() {
String[] bonds = null;
String val = getProperty("Devices", true);
if (val != null) {