Merge "Fix issue 5252593: any app can restart the runtime"
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user