Skip to content
Snippets Groups Projects
Commit 1e6791a5 authored by himta ram's avatar himta ram
Browse files

FM: add headset detection logic using AudioManager API

 Check if current audioManager outputDevice list contains
 WIRED_HEADSET or WIRED_HEADPHONES device.

CRs-Fixed: 2438531
Change-Id: I7321d9eb24e84481cdebf6312b8e3ea1382b4950
parent a17a340d
Branches
No related tags found
No related merge requests found
......@@ -288,7 +288,16 @@ public class FMRadioService extends Service
getA2dpStatusAtStart();
mGainFocusReq = requestAudioFocus();
AudioManager mAudioManager =
(AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] deviceList = mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
for (int index = 0; index < deviceList.length; index++) {
if ((deviceList[index].getType() == AudioDeviceInfo.TYPE_WIRED_HEADSET ) ||
(deviceList[index].getType() == AudioDeviceInfo.TYPE_WIRED_HEADPHONES )){
mHeadsetPlugged = true;
break;
}
}
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment