Please follow the steps below to modify it:
Frameworks\base\media\java\android\media\mediafocuscontrol.java:
1, Import Packages:
Import Com.android.internal.telephony.ITelephony;
Import Android.os.ServiceManager;
2, increase the access to the current phone call state method Getphonecallstate ():
private int getphonecallstate () {
int phonecallstate = Telephonymanager.call_state_idle;
Telephonymanager Telephonymanager = (telephonymanager) mcontext.getsystemservice (Context.telephony_service);
Itelephony Telephonyservice = ITelephony.Stub.asInterface (Servicemanager.getservice (Context.telephony_service));
if (telephonyservice! = null) {
LOG.W (TAG, "Getphonecallstate:mtelephonyservice! = null");
try {
Phonecallstate = Telephonyservice.getprecisecallstate ();
LOG.W (TAG, "getPhoneCallState:telephonyService.getPreciseCallState () =" + phonecallstate);
} catch (RemoteException ex) {
if (Telephonymanager! = null) {
Phonecallstate = Telephonymanager.getcallstate ();
LOG.W (TAG, "getPhoneCallState:telephonyManager.getCallState () =" + phonecallstate);
}
LOG.W (TAG, "Catch exception when Getprecisecallstate:ex ="
+ ex.getmessage ());
}
} else {
LOG.W (TAG, "getphonecallstate:telephonyservice = = null");
if (Telephonymanager! = null) {
Phonecallstate = Telephonymanager.getcallstate ();
LOG.W (TAG, "getPhoneCallState:telephonyManager.getCallState () =" + phonecallstate);
}
}
LOG.W (TAG, "getphonecallstate:phonecallstate =" + phonecallstate);
return phonecallstate;
}
3. Modification
Private Boolean Canreassignaudiofocus () {
Focus requests is rejected during a phone call or when the phone is ringing
This was equivalent to in_voice_comm_focus_id have the FOCUS
if (!mfocusstack.isempty () && Mfocusstack.peek (). Hassameclient (in_voice_comm_focus_id)) {
return false;
}
return true;
}
For
Private Boolean Canreassignaudiofocus () {
Focus requests is rejected during a phone call or when the phone is ringing
This was equivalent to in_voice_comm_focus_id have the FOCUS
if (!mfocusstack.isempty () && Mfocusstack.peek (). Hassameclient (in_voice_comm_focus_id) && ( Getphonecallstate ()! = Telephonymanager.call_state_idle)) {
LOG.W (TAG, "canreassignaudiofocus:return false");
return false;
}
LOG.W (TAG, "Canreassignaudiofocus:return true");
return true;
}
When Android 5.0 plays music, the alarm clock rings, and the phone calls and hangs up, and the alarm clock and music ring simultaneously.