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.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.