Solve the Problem of automatic call shutdown when the power is low.

Source: Internet
Author: User
1. Problem description:

When the power is low, the system cannot continue to provide the call service. In order not to affect the quality of the call service or other problems, the call should be automatically suspended when the system shuts down automatically.

2. solution:

When a low-power automatic shutdown occurs, if there is a call at this time, call the interface for hanging up the phone and stop the phone.

3. Implementation Method:

Batteryservice. Java

Private void shutdownifnopowerlocked (){
// Shut down gracefully if our battery is critically low and we are not powered.
// Wait until the system has booted before attempting to display the shutdown dialog.
If (mbatteryprops. batterylevel = 0 &&! Ispoweredlocked (batterymanager. battery_plugged_any )){
Mhandler. Post (New runnable (){
@ Override
Public void run (){
If (activitymanagernative. issystemready ()){
If (featureoption. mtk_ipo_support = true ){
Systemproperties. Set ("SYS. IPO. battlow", "1 ");
}


Try {
Itelephony = itelephony. stub. asinterface (servicemanager. getservice (context. telephony_service ));
If (itelephony! = NULL ){
Itelephony. endcall ();
}
} Catch (exception e ){
E. printstacktrace ();
}

Intent intent = new intent (intent. action_request_shutdown );
Intent. putextra (intent. extra_key_confirm, false );
Intent. setflags (intent. flag_activity_new_task );
Mcontext. startactivityasuser (intent, userhandle. Current );
}
}
});
}
}

Note! The red part is the function implementation part.

Solve the Problem of automatic call shutdown when the power is low.

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.