标签:style color os io java ar strong for art
低电量时,由于系统已经无法继续提供通话服务,为了不影响通话服务质量或其它问题,因此在自动关机时应自动挂断电话
在低电量自动关机时,如果此时有来电,调用挂断电话的接口,挂断电话。
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 = 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);
}
}
});
}
}
注!红色部分为功能实现部分。
标签:style color os io java ar strong for art
原文地址:http://blog.csdn.net/huangyabin001/article/details/39082055