diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2009-09-16 12:30:02 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-09-16 17:05:15 -0700 |
commit | dd0463aef18d251c741bfc9dc7a2787443ef36f1 (patch) | |
tree | 8a479d072af6e783e0f46de0fb60045d4fe72df2 /core/java/android/server | |
parent | 82c3ef7adc235e857736b09864c2aa81d41d7132 (diff) | |
download | frameworks_base-dd0463aef18d251c741bfc9dc7a2787443ef36f1.zip frameworks_base-dd0463aef18d251c741bfc9dc7a2787443ef36f1.tar.gz frameworks_base-dd0463aef18d251c741bfc9dc7a2787443ef36f1.tar.bz2 |
Change handling of remoteUuids.
Use the ParcelUuid instead of UUID
Change-Id:Ie05d65a62e8a4df8182a4c737d46c14142bfec43
Diffstat (limited to 'core/java/android/server')
-rw-r--r-- | core/java/android/server/BluetoothA2dpService.java | 32 | ||||
-rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 4 | ||||
-rw-r--r-- | core/java/android/server/BluetoothService.java | 35 |
3 files changed, 33 insertions, 38 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index 9c687e2..be8c777 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -27,6 +27,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothUuid; import android.bluetooth.IBluetoothA2dp; +import android.bluetooth.ParcelUuid; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -42,7 +43,6 @@ import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.Set; -import java.util.UUID; public class BluetoothA2dpService extends IBluetoothA2dp.Stub { private static final String TAG = "BluetoothA2dpService"; @@ -188,15 +188,9 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } private boolean isSinkDevice(BluetoothDevice device) { - String uuids[] = mBluetoothService.getRemoteUuids(device.getAddress()); - UUID uuid; - if (uuids != null) { - for (String deviceUuid: uuids) { - uuid = UUID.fromString(deviceUuid); - if (BluetoothUuid.isAudioSink(uuid)) { - return true; - } - } + ParcelUuid[] uuids = mBluetoothService.getRemoteUuids(device.getAddress()); + if (uuids != null && BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.AudioSink)) { + return true; } return false; } @@ -229,18 +223,14 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { for (String path: paths) { String address = mBluetoothService.getAddressFromObjectPath(path); BluetoothDevice device = mAdapter.getRemoteDevice(address); - String []uuids = mBluetoothService.getRemoteUuids(address); - if (uuids != null) - for (String uuid: uuids) { - UUID remoteUuid = UUID.fromString(uuid); - if (BluetoothUuid.isAudioSink(remoteUuid) || - BluetoothUuid.isAudioSource(remoteUuid) || - BluetoothUuid.isAdvAudioDist(remoteUuid)) { - addAudioSink(device); - break; - } + ParcelUuid[] remoteUuids = mBluetoothService.getRemoteUuids(address); + if (remoteUuids != null) + if (BluetoothUuid.containsAnyUuid(remoteUuids, + new ParcelUuid[] {BluetoothUuid.AudioSink, + BluetoothUuid.AdvAudioDist})) { + addAudioSink(device); } - } + } } mAudioManager.setParameters(BLUETOOTH_ENABLED+"=true"); } diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 1ed5c49..ba53307 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -21,6 +21,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothUuid; +import android.bluetooth.ParcelUuid; import android.content.Context; import android.content.Intent; import android.os.Handler; @@ -28,7 +29,6 @@ import android.os.Message; import android.util.Log; import java.util.HashMap; -import java.util.UUID; /** * TODO: Move this to @@ -501,7 +501,7 @@ class BluetoothEventLoop { } boolean authorized = false; - UUID uuid = UUID.fromString(deviceUuid); + ParcelUuid uuid = ParcelUuid.fromString(deviceUuid); // Bluez sends the UUID of the local service being accessed, _not_ the // remote service if (mBluetoothService.isEnabled() && diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index de0cad7..c0e4f34 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -24,11 +24,12 @@ package android.server; -import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.IBluetooth; +import android.bluetooth.ParcelUuid; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; @@ -51,7 +52,6 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; public class BluetoothService extends IBluetooth.Stub { @@ -967,22 +967,26 @@ public class BluetoothService extends IBluetooth.Stub { /** - * Gets the remote features encoded as bit mask. - * - * Note: This method may be obsoleted soon. + * Gets the UUIDs supported by the remote device * - * @return String array of 128bit UUIDs + * @return array of 128bit ParcelUuids */ - public synchronized String[] getRemoteUuids(String address) { + public synchronized ParcelUuid[] getRemoteUuids(String address) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (!BluetoothAdapter.checkBluetoothAddress(address)) { return null; } String value = getRemoteDeviceProperty(address, "UUIDs"); - String[] uuids = null; + if (value == null) return null; + + String[] uuidStrings = null; // The UUIDs are stored as a "," separated string. - if (value != null) - uuids = value.split(","); + uuidStrings = value.split(","); + ParcelUuid[] uuids = new ParcelUuid[uuidStrings.length]; + + for (int i = 0; i < uuidStrings.length; i++) { + uuids[i] = ParcelUuid.fromString(uuidStrings[i]); + } return uuids; } @@ -990,16 +994,17 @@ public class BluetoothService extends IBluetooth.Stub { * Gets the rfcomm channel associated with the UUID. * * @param address Address of the remote device - * @param uuid UUID of the service attribute + * @param uuid ParcelUuid of the service attribute * * @return rfcomm channel associated with the service attribute */ - public int getRemoteServiceChannel(String address, String uuid) { + public int getRemoteServiceChannel(String address, ParcelUuid uuid) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); if (!BluetoothAdapter.checkBluetoothAddress(address)) { return BluetoothDevice.ERROR; } - return getDeviceServiceChannelNative(getObjectPathFromAddress(address), uuid, 0x0004); + return getDeviceServiceChannelNative(getObjectPathFromAddress(address), uuid.toString(), + 0x0004); } public synchronized boolean setPin(String address, byte[] pin) { @@ -1148,11 +1153,11 @@ public class BluetoothService extends IBluetooth.Stub { mBondState.getAttempt(address), getRemoteName(address)); if (bondState == BluetoothDevice.BOND_BONDED) { - String[] uuids = getRemoteUuids(address); + ParcelUuid[] uuids = getRemoteUuids(address); if (uuids == null) { pw.printf("\tuuids = null\n"); } else { - for (String uuid : uuids) { + for (ParcelUuid uuid : uuids) { pw.printf("\t" + uuid + "\n"); } } |