diff options
author | Danesh M <daneshm90@gmail.com> | 2013-01-07 12:08:00 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-02-12 13:31:45 -0800 |
commit | ffcfe4c5ea45f69e99711f7953ba91cc839c617d (patch) | |
tree | 7f1ae7336057069477d0bddb725a45376292bc77 /services/core/java/com/android/server/audio/AudioService.java | |
parent | 9fdfca4a0d725d2d9b5d924156def3b6c54686f6 (diff) | |
download | frameworks_base-ffcfe4c5ea45f69e99711f7953ba91cc839c617d.zip frameworks_base-ffcfe4c5ea45f69e99711f7953ba91cc839c617d.tar.gz frameworks_base-ffcfe4c5ea45f69e99711f7953ba91cc839c617d.tar.bz2 |
AudioService: launch default music player on headset connect [2/3]
Change-Id: Ibbb0607a56ab4d9246c14632eb4199558866854a
Diffstat (limited to 'services/core/java/com/android/server/audio/AudioService.java')
-rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 82c658e..2db03ba 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -5083,12 +5083,14 @@ public class AudioService extends IAudioService.Stub { connType = AudioRoutesInfo.MAIN_HEADSET; intent.setAction(Intent.ACTION_HEADSET_PLUG); intent.putExtra("microphone", 1); + startMusicPlayer(); } else if (device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE || device == AudioSystem.DEVICE_OUT_LINE) { /*do apps care about line-out vs headphones?*/ connType = AudioRoutesInfo.MAIN_HEADPHONES; intent.setAction(Intent.ACTION_HEADSET_PLUG); intent.putExtra("microphone", 0); + startMusicPlayer(); } else if (device == AudioSystem.DEVICE_OUT_HDMI || device == AudioSystem.DEVICE_OUT_HDMI_ARC) { connType = AudioRoutesInfo.MAIN_HDMI; @@ -5121,6 +5123,17 @@ public class AudioService extends IAudioService.Stub { } } + private void startMusicPlayer() { + boolean launchPlayer = CMSettings.System.getIntForUser(mContext.getContentResolver(), + CMSettings.System.HEADSET_CONNECT_PLAYER, 0, UserHandle.USER_CURRENT) != 0; + if (launchPlayer) { + Intent playerIntent = new Intent(Intent.ACTION_MAIN); + playerIntent.addCategory(Intent.CATEGORY_APP_MUSIC); + playerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mContext.startActivity(playerIntent); + } + } + private void onSetWiredDeviceConnectionState(int device, int state, String address, String deviceName, String caller) { if (DEBUG_DEVICES) { |