Loading services/core/java/com/android/server/audio/AudioService.java +71 −44 Original line number Diff line number Diff line Loading @@ -689,6 +689,7 @@ public class AudioService extends IAudioService.Stub { intentFilter.addAction(Intent.ACTION_USER_BACKGROUND); intentFilter.addAction(Intent.ACTION_USER_FOREGROUND); intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); // TODO merge orientation and rotation Loading Loading @@ -3164,11 +3165,36 @@ public class AudioService extends IAudioService.Stub { } } public void onServiceDisconnected(int profile) { ArraySet<String> toRemove = null; switch (profile) { case BluetoothProfile.A2DP: disconnectA2dp(); break; case BluetoothProfile.A2DP_SINK: disconnectA2dpSink(); break; case BluetoothProfile.HEADSET: disconnectHeadset(); break; default: break; } } }; void disconnectAllBluetoothProfiles() { disconnectA2dp(); disconnectA2dpSink(); disconnectHeadset(); } void disconnectA2dp() { synchronized (mConnectedDevices) { synchronized (mA2dpAvrcpLock) { ArraySet<String> toRemove = null; // Disconnect ALL DEVICE_OUT_BLUETOOTH_A2DP devices for (int i = 0; i < mConnectedDevices.size(); i++) { DeviceListSpec deviceSpec = mConnectedDevices.valueAt(i); Loading @@ -3187,10 +3213,11 @@ public class AudioService extends IAudioService.Stub { } } } break; } case BluetoothProfile.A2DP_SINK: void disconnectA2dpSink() { synchronized (mConnectedDevices) { ArraySet<String> toRemove = null; // Disconnect ALL DEVICE_IN_BLUETOOTH_A2DP devices for(int i = 0; i < mConnectedDevices.size(); i++) { DeviceListSpec deviceSpec = mConnectedDevices.valueAt(i); Loading @@ -3205,9 +3232,9 @@ public class AudioService extends IAudioService.Stub { } } } break; } case BluetoothProfile.HEADSET: void disconnectHeadset() { synchronized (mScoClients) { if (mBluetoothHeadsetDevice != null) { setBtScoDeviceConnectionState(mBluetoothHeadsetDevice, Loading @@ -3215,13 +3242,7 @@ public class AudioService extends IAudioService.Stub { } mBluetoothHeadset = null; } break; default: break; } } }; private void onCheckMusicActive(String caller) { synchronized (mSafeMediaVolumeState) { Loading Loading @@ -5228,6 +5249,12 @@ public class AudioService extends IAudioService.Stub { int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); UserManagerService.getInstance().setUserRestriction( UserManager.DISALLOW_RECORD_AUDIO, false, userId); } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1); if (state == BluetoothAdapter.STATE_OFF || state == BluetoothAdapter.STATE_TURNING_OFF) { disconnectAllBluetoothProfiles(); } } } } // end class AudioServiceBroadcastReceiver Loading Loading
services/core/java/com/android/server/audio/AudioService.java +71 −44 Original line number Diff line number Diff line Loading @@ -689,6 +689,7 @@ public class AudioService extends IAudioService.Stub { intentFilter.addAction(Intent.ACTION_USER_BACKGROUND); intentFilter.addAction(Intent.ACTION_USER_FOREGROUND); intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); // TODO merge orientation and rotation Loading Loading @@ -3164,11 +3165,36 @@ public class AudioService extends IAudioService.Stub { } } public void onServiceDisconnected(int profile) { ArraySet<String> toRemove = null; switch (profile) { case BluetoothProfile.A2DP: disconnectA2dp(); break; case BluetoothProfile.A2DP_SINK: disconnectA2dpSink(); break; case BluetoothProfile.HEADSET: disconnectHeadset(); break; default: break; } } }; void disconnectAllBluetoothProfiles() { disconnectA2dp(); disconnectA2dpSink(); disconnectHeadset(); } void disconnectA2dp() { synchronized (mConnectedDevices) { synchronized (mA2dpAvrcpLock) { ArraySet<String> toRemove = null; // Disconnect ALL DEVICE_OUT_BLUETOOTH_A2DP devices for (int i = 0; i < mConnectedDevices.size(); i++) { DeviceListSpec deviceSpec = mConnectedDevices.valueAt(i); Loading @@ -3187,10 +3213,11 @@ public class AudioService extends IAudioService.Stub { } } } break; } case BluetoothProfile.A2DP_SINK: void disconnectA2dpSink() { synchronized (mConnectedDevices) { ArraySet<String> toRemove = null; // Disconnect ALL DEVICE_IN_BLUETOOTH_A2DP devices for(int i = 0; i < mConnectedDevices.size(); i++) { DeviceListSpec deviceSpec = mConnectedDevices.valueAt(i); Loading @@ -3205,9 +3232,9 @@ public class AudioService extends IAudioService.Stub { } } } break; } case BluetoothProfile.HEADSET: void disconnectHeadset() { synchronized (mScoClients) { if (mBluetoothHeadsetDevice != null) { setBtScoDeviceConnectionState(mBluetoothHeadsetDevice, Loading @@ -3215,13 +3242,7 @@ public class AudioService extends IAudioService.Stub { } mBluetoothHeadset = null; } break; default: break; } } }; private void onCheckMusicActive(String caller) { synchronized (mSafeMediaVolumeState) { Loading Loading @@ -5228,6 +5249,12 @@ public class AudioService extends IAudioService.Stub { int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); UserManagerService.getInstance().setUserRestriction( UserManager.DISALLOW_RECORD_AUDIO, false, userId); } else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1); if (state == BluetoothAdapter.STATE_OFF || state == BluetoothAdapter.STATE_TURNING_OFF) { disconnectAllBluetoothProfiles(); } } } } // end class AudioServiceBroadcastReceiver Loading