summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-09-02 14:20:56 -0700
committerEric Laurent <elaurent@google.com>2011-09-02 15:59:50 -0700
commitdca56b9432e2cc851d1a58920071fed2e1e3d142 (patch)
treedec365b40e97c1e8331db5e0174548251aebdb92
parent5afd2bd02ae44d5a38f9e560047723ddab176405 (diff)
downloadframeworks_base-dca56b9432e2cc851d1a58920071fed2e1e3d142.zip
frameworks_base-dca56b9432e2cc851d1a58920071fed2e1e3d142.tar.gz
frameworks_base-dca56b9432e2cc851d1a58920071fed2e1e3d142.tar.bz2
Fix issue 5252593: any app can restart the runtime
Replace null device address string by empty sting. Change-Id: I285c35f3345334e6d2190493b1a8a5aca1a361a4
-rw-r--r--core/java/android/bluetooth/BluetoothDeviceProfileState.java2
-rw-r--r--core/java/android/bluetooth/BluetoothProfileState.java4
-rw-r--r--media/java/android/media/AudioService.java40
-rw-r--r--media/libmedia/AudioSystem.cpp8
4 files changed, 37 insertions, 17 deletions
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 316c474..48d0203 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -127,7 +127,7 @@ public final class BluetoothDeviceProfileState extends StateMachine {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
- if (!device.equals(mDevice)) return;
+ if (device == null || !device.equals(mDevice)) return;
if (action.equals(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)) {
int newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0);
diff --git a/core/java/android/bluetooth/BluetoothProfileState.java b/core/java/android/bluetooth/BluetoothProfileState.java
index 98afdb8..b0c0a0b 100644
--- a/core/java/android/bluetooth/BluetoothProfileState.java
+++ b/core/java/android/bluetooth/BluetoothProfileState.java
@@ -59,7 +59,9 @@ public class BluetoothProfileState extends StateMachine {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-
+ if (device == null) {
+ return;
+ }
if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
int newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0);
if (mProfile == HFP && (newState == BluetoothProfile.STATE_CONNECTED ||
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index cd15718..d233f92 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -2295,7 +2295,13 @@ public class AudioService extends IAudioService.Stub {
int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
BluetoothProfile.STATE_DISCONNECTED);
BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (btDevice == null) {
+ return;
+ }
String address = btDevice.getAddress();
+ if (!BluetoothAdapter.checkBluetoothAddress(address)) {
+ address = "";
+ }
boolean isConnected =
(mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) &&
mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP).equals(address));
@@ -2331,24 +2337,30 @@ public class AudioService extends IAudioService.Stub {
int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
BluetoothProfile.STATE_DISCONNECTED);
int device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO;
- BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
String address = null;
- if (btDevice != null) {
- address = btDevice.getAddress();
- BluetoothClass btClass = btDevice.getBluetoothClass();
- if (btClass != null) {
- switch (btClass.getDeviceClass()) {
- case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
- case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
- device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
- break;
- case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
- device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
- break;
- }
+
+ BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (btDevice == null) {
+ return;
+ }
+
+ address = btDevice.getAddress();
+ BluetoothClass btClass = btDevice.getBluetoothClass();
+ if (btClass != null) {
+ switch (btClass.getDeviceClass()) {
+ case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
+ case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
+ device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
+ break;
+ case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
+ device = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
+ break;
}
}
+ if (!BluetoothAdapter.checkBluetoothAddress(address)) {
+ address = "";
+ }
boolean isConnected = (mConnectedDevices.containsKey(device) &&
mConnectedDevices.get(device).equals(address));
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 853a5f6..7b14c18 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -511,9 +511,15 @@ status_t AudioSystem::setDeviceConnectionState(audio_devices_t device,
const char *device_address)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ const char *address = "";
+
if (aps == 0) return PERMISSION_DENIED;
- return aps->setDeviceConnectionState(device, state, device_address);
+ if (device_address != NULL) {
+ address = device_address;
+ }
+
+ return aps->setDeviceConnectionState(device, state, address);
}
audio_policy_dev_state_t AudioSystem::getDeviceConnectionState(audio_devices_t device,