• 解决:在低电量关机的同时自动挂断电话电话


    首先我们通过定位找到低电量自动关机的代码:

    相关类:service/java/com/android/server/BatteryService.java

    相关方法:shutdownIfNoPowerLocked()

    修改后代码(红色部分为关键代码):

    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);

                        }

                    }

                });

            }

        }

    另外不要忘记引入相关库:

    import com.android.internal.telephony.ITelephony;


  • 相关阅读:
    Asp.Net Mvc Filter
    使用 EntityFramework后把一个对象序列化成json字符串引起循环引用的问题
    RCTF2020 calc & EasyBlog & swoole
    GKCTF-EzWeb+redis未授权访问
    BJD3rd
    http走私
    网鼎杯2020青龙组 web writeup
    De1CTF 2020 部分web
    js相关trick总结
    xss常见编码解析
  • 原文地址:https://www.cnblogs.com/bill-technology/p/4130820.html
Copyright © 2020-2023  润新知