栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

RK3399 Android7.1系统自动关机的几种情况

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

RK3399 Android7.1系统自动关机的几种情况

系统出于保护自己的目的会在某些情况下自动关机,不再工作。这包括android和linux内核的几种关机情况。

一,android系统

android系统通常在两种情况下会自动执行关机流程,即电池电量过低和电池温度过高。具体代码在frameworksbaseservicescorejavacomandroidserverBatteryService.java中。

1,电池电量过低

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 == 2 && !isPoweredLocked(BatteryManager.BATTERY_PLUGGED_ANY)) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    if (ActivityManagerNative.isSystemReady()) {
                        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);
                    }
                }
            });
        }
    }

这里的判断条件是:当读到的电池当前电量为2%(这个关机电量值可修改)且没有外接电源适配器供电的情况下执行关机流程。

2,电池温度过高

 private void shutdownIfOverTempLocked() {
        // shut down gracefully if temperature is too high (> 68.0C by default)
        // wait until the system has booted before attempting to display the
        // shutdown dialog.
        if (mBatteryProps.batteryTemperature > mShutdownBatteryTemperature) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    if (ActivityManagerNative.isSystemReady()) {
                        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);
                    }
                }
            });
        }
    }

这里的判断条件只有一个,那就是读到的电池温度大于mShutdownBatteryTemperature时执行自动关机流程。这个mShutdownBatteryTemperature的定义在:

frameworksbasecoreresresvaluesconfig.xml中

680

默认设置为68摄氏度。一般情况下系统不会跑到电池过温关机的流程,因为电池内部会设定一个过温保护的阙值,一般在65摄氏度以下电池就会进入OTP然后电池就不会继续放电了。

以上两个关机流程都有个共同的执行条件就是“if (ActivityManagerNative.isSystemReady())”,这个是指要等系统启动完成以后才会显示关机弹窗并执行关机流程,所以我们可以看到当电池没电以后我们再开机一般会等到系统启动进入主界面然后马上弹出关机弹窗并自动关机。

二,linux内核

内核一般不会执行关机流程,只有在主控芯片(RK3399)温度过高时为保护主控芯片而执行关机动作。瑞芯微有自己的一套温度控制策略,当cpu和gpu温度过高时会通过降低cpu和gpu的运行频率来降低功耗,进而控制温度上升的速度。当温度继续升到设置的关机温度时即执行关机流程。若达到了设置的硬件复位温度值,则通过复位PMIC(如RK808)使RK3399复位,表现的现象就是系统不停重启(只到logo即重启)。

dts里温度控制的相关温度值设定如下:

//temperature
//ctl open(75度开始执行温度控制策略)
&threshold {
    temperature = <75000>;
};
//ctl max(100度为执行温度控制策略的最大温度,达到这个温度后,cpu和gpu频率降至最低。)
&target {
    temperature = <100000>;
};
//ctl soft power off(105度即内核关机的温度值,达到这个温度执行关机流程)
&soc_crit {
    temperature = <105000>;
};
&tsadc {
    rockchip,hw-tshut-mode = <1>;
    rockchip,hw-tshut-polarity = <1>;
    rockchip,hw-tshut-temp = <110000>;//达到110度以后,RK3399通过GPIO复位PMIC(RK808)。
    //status = "disabled";
    status = "okay";
};

软件关机温度值的相关代码位置:

kerneldriversthermalthermal_core.c

static void handle_critical_trips(struct thermal_zone_device *tz,
                int trip, enum thermal_trip_type trip_type)
{
    int trip_temp;

    tz->ops->get_trip_temp(tz, trip, &trip_temp);

    
    if (trip_temp <= 0 || tz->temperature < trip_temp)
        return;

    trace_thermal_zone_trip(tz, trip, trip_type);

    if (tz->ops->notify)
        tz->ops->notify(tz, trip, trip_type);

    if (trip_type == THERMAL_TRIP_CRITICAL) {
        dev_emerg(&tz->device,
              "critical temperature reached(%d C),shutting downn",
              tz->temperature / 1000);
        orderly_poweroff(true);//内核关机函数
    }
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/946596.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号