http://blog.csdn.net/matrix_xu/article/details/8509319
众所周知,在Android系 统的耗电量排行里,cpu的耗电占了比较大的一部分比例,也就是说,cpu的使用率和使用频率将直接或间接的影响电量的分配和使用,但很遗 憾,android-sdk中没有为android的开发者提供类似cpu管理的功能,但是当下很多省电类应用或专业的cpu管理软件都提供了cpu的降 频甚至是超频的功能,那么这样的功能是如何实现的,本文将详细说明在android环境下调整cpu频率的一些方法,仅供参考。
按照我写文章的风格,在阐述过程和结论之前,都不得不对关键性的概念做一下解释,本文也不例外。
1.CPU的工作频率
单位赫兹或者兆赫兹,具体含义不解释,说实话也不太清楚,不过可以确认一点的是,CPU的工作频率越高,耗电量越大,反之亦然。我们做这个模块省电的终极目标就是降低cpu的工作频率。
2.CPU的调控模式
英文词为:Governor,解释为调速器,控制器。大家 都指导android的framework是基于linux平台的,那么cpu的管理体系这块也跟linux基本上一样,其中包括cat命令,和一些文件 的读写配置都是基本上差不多的。Linux在管理CPU方面,提供了如下集中调控模式,分别为:
Governor |
Select this governor if |
How it works |
performance |
Performance is the only consideration. |
Sets the CPU to run at the highest frequency (scaling_max_freq) |
powersave |
Efficiency is the only consideration |
Sets the CPU to run at the lowest frequency (scaling_min_freq) |
ondemand |
Adaptation to the current load is the main consideration. |
Checks the load regularly. When the load rises aboveup_threshold, sets the CPU to run at the highest frequency (scaling_max_freq). When the load falls below the same threshold, sets the CPU to run at the next lowest frequency. Causes less latency than the conservative governor. |
conservative |
Close adaptation to the current load is the consideration. |
Checks the load regularly. When the load rises aboveup_threshold, sets the CPU to run at the next highest frequency. When the load falls belowdown_threshold, sets the CPU to run at the next lowest frequency. Has more latency than the ondemand governor. |
userspace |
Control by other user space program is preferred. |
Sets the CPU frequency to the value specified by the user space program (through the use of thescaling_setspeed parameter). |
这个表格的出自:http://publib.boulder.ibm.com/infocenter/lnxinfo/v3r0m0/index.jsp?topic=%2Fliaai%2Fcpufreq%2FTheCPUFreqGovernors.htm
按照原文给出的解释,我大概把这5种调控模式理解为一下几种观点,如有不足,还请指正!
1.performance,这个不多说,就是将cpu的工作频率调整到最大模式,让cpu充分的工作。
2.powersave,将cpu的工作频率调整到节能模式,也就是这个模式下的cpu平率是最低的。
3.ondemand,定期检查负载。当负荷超越了阈值, 设置的CPU运行以最高的频率。当负载低于相同的阈值,设置的CPU运行在下一个的最低频率。导致更少的延迟比。这个理解起来可能比较困难,我用白话大概 解释一下,ondemand从字面翻译是“根据需求,按照需要”,cpu在工作的时候频率会在一个最大值和最小值之间波动,当负载提高时,该调控期会自动 提高cpu的频率,反之亦然。“Causes less latency than the conservative governor.”这句话的意思是,该模式跟conservative相比,会导致更少的延迟。ok,那让我们再看看conservative是如何解 释的。
4.conservative,改词用来形容保守的,守旧 的。该模式与ondemand的最大区别在于,conservative模式不会立刻在负载增加的情况下将cpu频率调整到最大,他会调整到比目前频率稍 微大的频段去工作,保守,实在是保守!所以换来的结果是,在某种极端情况下,该模式的延迟会大于ondemand。
5.usersapce,该模式将cpu的掌控权交给了用 户态,也就是交给了应用程序,应用程序可以通过配置文件的方式修改cpu的频率信息,上面3种模式好比linux已经给你定义好的4种模 式,userspace好比上面4种模式无法满足我的需求,我需要自定义!(由于第四种方式需要进行大量的文件操作和配置,本文不阐述了,与省电的目标相 差比较远)
ok!我们了解了这5种省电模式,那么如何查看你的android手机当前运行在哪种模式下呢?当前的cpu运行的工作频率是多少呢?最大最小频率是多少?我如何修改模式呢?
其实很简单,android的cat命令都为我们解决了这些问题,首先要强调的是,必须要获得系统的root权限,才能进行以下操作。
第一步:adb shell 进入root 命令行模式
第二步 cd /sys/devices/system/cpu/cpu0/cpufreq 进入这个目录下面
第三步 ls
第四步 你能看见很多的文件
第五步 参考下面的命令,打一遍就清楚了,不过为了给傻瓜提供更好的服务,我还是尽可能的将命令的使用和作用写的详细。
/**
* cpu cat命令大全
* cat [%cpuFreqPath%]/cpuinfo_cur_freq (当前cpu频率)
* cat [%cpuFreqPath%]/cpuinfo_max_freq (最大cpu频率)
* cat [%cpuFreqPath%]/cpuinfo_min_freq (最小cpu频率)
* cat [%cpuFreqPath%]/related_cpus (cpu数量标号,从0开始,如果是双核,结果为0,1)
* cat [%cpuFreqPath%]/scaling_available_frequencies (cpu所有可用频率)
* cat [%cpuFreqPath%]/scaling_available_governors (cpu所有可用调控模式)
* cat [%cpuFreqPath%]/scaling_available_governors (cpu所有可用调控模式)
* cat [%cpuFreqPath%]/scaling_cur_freq (?????)
* cat [%cpuFreqPath%]/scaling_driver (调控驱动)
* cat [%cpuFreqPath%]/scaling_governor (当前使用哪种调控模式)
* cat [%cpuFreqPath%]/scaling_max_freq (?????)
* cat [%cpuFreqPath%]/scaling_min_freq (?????)
* cat [%cpuFreqPath%]/scaling_setspeed (?????)
* cat [%cpuFreqPath%]/cpuinfo_transition_latency (变频延迟)
*/
熟悉了这些语法和密令之后,我们就可以很轻松的明白,如何省电了,无非就是将cpu降频嘛,把当前的调控模式调整为powersave就可以了嘛,不错,但是还不完全正确。
首先我先讲一下如何通过命令行改写当前的调控模式,很简单,一句命令:
echo “你想使用的调控模式” /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
但是因为手机出场适配等问题,有些机器上是没有 powersave这个模式的,对了,你一定要确认当前手机是否有powersave这个模式,具体怎么看就在我上面给的命令大全里面,自己找!在没有 powersave模式的情况下,我们只好通过更狠的方法修改cpu的频率,那就是直接改写cpu的频率,命令:
echo 2331000 > cpu0/cpufreq/scaling_min_freq 设置最小的工作频率,同时也可以设置最大的工作频率。
ok!设置cpu的频率的两种方式我基本上说清楚了,本质没什么差别。那么在实际java端的开发中,我们如何使用呢?
贴贴代码吧,不做过多的解释了,相信大家多能读懂!
- <span style=“font-family:Microsoft YaHei;”>
- public class CPUFreqSetting {
-
- private final String TAG = “SetCPU”;
- private final String cpuFreqPath = “/sys/devices/system/cpu/cpu0/cpufreq”;
- private final static String PERFORMANCE_GOVERNOR = “performance”;
- private final static String POWER_SAVE_GOVERNOR = “performance”;
- private final static String ONDEMAND_GOVERNOR = “performance”;
- private final static String CONSERVATIVE_GOVERNOR = “performance”;
- private final static String USERSAPCE_GOVERNOR = “performance”;
-
- public void getCpuCurGovernor() {
- try {
- DataInputStream is = null;
- Process process = Runtime.getRuntime().exec(“cat “ + cpuFreqPath + “/scaling_governor”);
- is = new DataInputStream(process.getInputStream());
- String line = is.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private boolean writeCpuGovernor(String governor) {
- DataOutputStream os = null;
- byte[] buffer = new byte[256];
- String command = “echo “ + governor + ” > “ + cpuFreqPath + “/scaling_governor”;
- Log.i(TAG, “command: “ + command);
- try {
- Process process = Runtime.getRuntime().exec(“su”);
- os = new DataOutputStream(process.getOutputStream());
- os.writeBytes(command + “\n”);
- os.writeBytes(“exit\n”);
- os.flush();
- process.waitFor();
- Log.i(TAG, “exit value = “ + process.exitValue());
- } catch (IOException e) {
- Log.i(TAG, “writeCpuGovernor: write CPU Governor(“ + governor + “) failed!”);
- return false;
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return true;
- }
-
- private List<String> readCpuGovernors() {
- List<String> governors = new ArrayList<String>();
- DataInputStream is = null;
- try {
- Process process = Runtime.getRuntime().exec(“cat “ + cpuFreqPath + “/scaling_available_governors”);
- is = new DataInputStream(process.getInputStream());
- String line = is.readLine();
- String[] strs = line.split(” “);
- for (int i = 0; i < strs.length; i++)
- governors.add(strs[i]);
- } catch (IOException e) {
- Log.i(TAG, “readCpuGovernors: read CPU Governors failed!”);
- }
- return governors;
- }
- }</span>
完!
分解boot.img看到这段代码是与CPU相关的 我主要是想将CPU电压和频率降低 解决发热和延长待机
说实话感觉4核有点性能过剩。平时适用我想将CPU频率降低到1.35MHZ已经做够了 最好可以关停2个
核心。
请大神指教如何修改 谢谢!
#
# Copyright 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import init.aries.usb.rc
import init.aries_svelte.rc
on early-init
mount debugfs debugfs /sys/kernel/debug
chown system system /sys/kernel/debug/kgsl/proc
on init
# See storage config details at http://source.android.com/tech/storage/
mkdir /storage 0775 system system
mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/usbdisk 0700 media_rw media_rw
mkdir /storage/sdcard0 0775 system system
mkdir /storage/usbdisk 0775 system system
#
Set permissions for persist partition
mkdir /persist 0771 system system
mkdir /firmware 0771 system system
export EXTERNAL_STORAGE /storage/sdcard0
# Support legacy paths
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/usbdisk /usbdisk
symlink /storage/usbdisk /mnt/usbdisk
# Setup custom emergency number list based on
# the MCC. This is needed by RIL.
setprop persist.radio.custom_ecc “1”
setprop persist.radio.custom_ecc_mcc “{234,235,424,426,427,430,431:999},{334:060,066},{422:9999},{730:133}”
setprop persist.radio.custom_ecc_mcc_ex “{450:111,112,113,119,122,125,127},{724:190}”
setprop persist.radio.custom_ecc_voice “{515:117},{452:113,114,115}”
setprop persist.radio.custom_ecc_hard “911,*911,#911,112,999,000,08,118,120,122,110,119,995,111,113,125,127,133”
on fs
exec /sbin/dualboot_init ./fstab.aries
mount_all ./fstab.aries.patched
restorecon /persist
restorecon /persist/bluetooth
restorecon /persist/bluetooth/.bdaddr
restorecon /persist/playready
restorecon /persist/playready/dxhdcp2
restorecon /persist/playready/dxhdcp2/acGSIRU1TX-2o-nJ69e1aFGgUxE_
restorecon /persist/playready/dxhdcp2/acGSIRU1TX-2o-nJ69e1aFGgUxE_/etK7oituoft7bxrO5H7GIVuhEQM_
restorecon /persist/playready/dxhdcp2/acGSIRU1TX-2o-nJ69e1aFGgUxE_/zttE+GVYd9YzREzMHiKY-IlERZM_
restorecon /persist/sensors
restorecon /persist/sensors/sns.reg
restorecon /persist/widevine
restorecon /persist/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_
restorecon /persist/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/RXFABDUxyT6Q+Zwx9ZhPGOq2Bq8_
restorecon /persist/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/D3qpp0bxmJhbiZwIsCbXJ1434rc_
restorecon /persist/wifi
restorecon /persist/wifi/.macaddr
write /sys/kernel/boot_adsp/boot 1
on early-boot
# set RLIMIT_MEMLOCK to 64MB
setrlimit 8 67108864 67108864
on boot
#Create QMUX deamon socket area
mkdir /dev/socket/qmux_radio 0770 radio radio
chmod 2770 /dev/socket/qmux_radio
mkdir /dev/socket/qmux_audio 0770 media audio
chmod 2770 /dev/socket/qmux_audio
mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth
chmod 2770 /dev/socket/qmux_bluetooth
mkdir /dev/socket/qmux_gps 0770 gps gps
chmod 2770 /dev/socket/qmux_gps
# early start of rmnet_usb driver
write /sys/module/rmnet_usb/parameters/rmnet_data_init 1
# allow setting mac address
chmod 0660 /sys/devices/platform/primaconfig/mac_address
chown radio radio /sys/devices/platform/primaconfig/mac_address
# Allow QMUX daemon to assign port open wait time
chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
#Remove SUID bit for iproute2 ip tool
chmod 0755 /system/bin/ip
#port-bridge
chmod 0660 /dev/smd0
chown system system /dev/smd0
#BT DUN port-bridge
chmod 0660 /dev/smd7
chown bluetooth bluetooth /dev/smd7
chmod 0444 /sys/devices/platform/msm_hsusb/gadget/usb_state
# create symlink for fb1 as HDMI
symlink /dev/graphics/fb1 /dev/graphics/hdmi
# Remove write permissions to video related nodes
chmod 0664 /sys/devices/virtual/graphics/fb1/hpd
chmod 0664 /sys/devices/virtual/graphics/fb1/video_mode
chmod 0664 /sys/devices/virtual/graphics/fb1/format_3d
# Change owner and group for media server and surface flinger
chown system system /sys/devices/virtual/graphics/fb1/format_3d
chown system system /sys/devices/virtual/graphics/fb1/hpd
#For bridgemgr daemon to inform the USB driver of the correct transport
chown radio radio /sys/class/android_usb/f_rmnet_smd_sdio/transport
chmod 660 /dev/rtc0
chown system system /dev/rtc0
chown root system /proc/net/ip_conntrack
# Enable DEBUG_SUSPEND, DEBUG_EXIT_SUSPEND, and DEBUG_WAKEUP
write /sys/module/wakelock/parameters/debug_mask 7
#To allow interfaces to get v6 address when tethering is enabled
write /proc/sys/net/ipv6/conf/rmnet0/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet1/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet2/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet3/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet4/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet5/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet6/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet7/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio0/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio1/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio2/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio3/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio4/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio5/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio6/accept_ra 2
write /proc/sys/net/ipv6/conf/rmnet_sdio7/accept_ra 2
# Assign TCP buffer thresholds to be ceiling value of technology maximums
# Increased technology maximums should be reflected here.
write /proc/sys/net/core/rmem_max 1220608
write /proc/sys/net/core/wmem_max 1220608
# msm specific files that need to be created on /data
on post-fs-data
mkdir /data/media 0770 media_rw media_rw
# Create the directories used by the Wireless subsystem
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
mkdir /data/misc/dhcp 0770 dhcp dhcp
# to observe dnsmasq.leases file for dhcp information of soft ap.
chown dhcp system /data/misc/dhcp
mkdir /data/misc/playready
restorecon /data/misc/playready
mkdir /data/misc/tzapps
restorecon /data/misc/tzapps
chown system system /dev/wcnss_wlan
write /sys/module/wcnss_ssr_8960/parameters/enable_riva_ssr 1
# Create directory used by audio subsystem
mkdir /data/misc/audio 0770 audio audio
# Mounting of persist is moved to ‘on emmc-fs’ and ‘on fs’ sections
# We chown/chmod /persist again so because mount is run as root + defaults
chown system system /persist
chmod 0664 /sys/devices/platform/msm_sdcc.1/polling
chmod 0664 /sys/devices/platform/msm_sdcc.2/polling
chmod 0664 /sys/devices/platform/msm_sdcc.3/polling
chmod 0664 /sys/devices/platform/msm_sdcc.4/polling
# Chown polling nodes as needed from UI running on system server
chown system system /sys/devices/platform/msm_sdcc.1/polling
chown system system /sys/devices/platform/msm_sdcc.2/polling
chown system system /sys/devices/platform/msm_sdcc.3/polling
chown system system /sys/devices/platform/msm_sdcc.4/polling
#Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant
mkdir /data/system 0775 system system
#symlink /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant
#Create directory used by sensor subsystem(dsps)
mkdir /data/system/sensors
chmod 665 /data/system/sensors
write /data/system/sensors/settings 1
restorecon /data/system/sensors/settings
chmod 660 /data/system/sensors/settings
# AKM setting data
mkdir /data/misc/sensors
chmod 775 /data/misc/sensors
mkdir /persist/sensors
chmod 775 /persist/sensors
#Provide the access to hostapd.conf only to root and group
chmod 0660 /data/hostapd/hostapd.conf
# Enable the setgid bit on the directory
mkdir /data/audio 0770 media audio
chmod 2770 /data/audio
# kickstart
mkdir /data/qcks 0770 system system
chown system /dev/block/platform/msm_sdcc.1/by-name
setprop vold.post_fs_data_done 1
rm /data/local/tmp/adreno_config.txt
# LED On/Off synchronization
chown system system /sys/class/leds/red/device/lock
# communicate with mpdecision and thermald
mkdir /dev/socket/mpdecision 0770 system system
chmod 2770 /dev/socket/mpdecision
# adjust vibrator amplitude
write /sys/class/timed_output/vibrator/amp 90
# Enable Power modes and set the CPU Freq Sampling rates
write /sys/module/rpm_resources/enable_low_power/L2_cache 1
write /sys/module/rpm_resources/enable_low_power/pxo 1
write /sys/module/rpm_resources/enable_low_power/vdd_dig 1
write /sys/module/rpm_resources/enable_low_power/vdd_mem 1
write /sys/module/pm_8x60/modes/cpu0/retention/idle_enabled 0
write /sys/module/pm_8x60/modes/cpu1/retention/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu2/retention/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu3/retention/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu0/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu1/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu2/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu3/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu1/standalone_power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu2/standalone_power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu3/standalone_power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu0/standalone_power_collapse/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu1/standalone_power_collapse/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu2/standalone_power_collapse/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu3/standalone_power_collapse/idle_enabled 1
write /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled 1
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold 90
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 50000
write /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy 1
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor 4
write /sys/devices/system/cpu/cpufreq/ondemand/down_differential 10
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core 60
write /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core 3
write /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq 918000
write /sys/devices/system/cpu/cpufreq/ondemand/sync_freq 1026000
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load 80
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu1/online 1
write /sys/devices/system/cpu/cpu2/online 1
write /sys/devices/system/cpu/cpu3/online 1
write /dev/cpuctl/apps/cpu.notify_on_migrate 1
# Chown cpu online files as needed for the Settings app
chown system system /sys/devices/system/cpu/cpu1/online
chown system system /sys/devices/system/cpu/cpu2/online
chown system system /sys/devices/system/cpu/cpu3/online
# Hardware tunables
chown root system /sys/class/timed_output/vibrator/amp
chown root system /sys/devices/platform/kcal_ctrl.0/kcal
chown root system /sys/devices/platform/kcal_ctrl.0/kcal_ctrl
chown root system /sys/devices/platform/mipi_hitachi.2049/kgamma_r
chown root system /sys/devices/platform/mipi_hitachi.2049/kgamma_g
chown root system /sys/devices/platform/mipi_hitachi.2049/kgamma_b
chown root system /sys/devices/platform/mipi_hitachi.2049/kgamma_apply
chown root system /sys/devices/platform/mipi_hitachi.2049/cabc
chown root system /sys/devices/platform/mipi_hitachi.2049/ce
chown root system /sys/devices/i2c-3/3-004b/disable_keys
chmod 0664 /sys/class/timed_output/vibrator/amp
chmod 0664 /sys/devices/platform/kcal_ctrl.0/kcal
chmod 0664 /sys/devices/platform/kcal_ctrl.0/kcal_ctrl
chmod 0664 /sys/devices/platform/mipi_hitachi.2049/kgamma_r
chmod 0664 /sys/devices/platform/mipi_hitachi.2049/kgamma_g
chmod 0664 /sys/devices/platform/mipi_hitachi.2049/kgamma_b
chmod 0664 /sys/devices/platform/mipi_hitachi.2049/kgamma_apply
chmod 0664 /sys/devices/platform/mipi_hitachi.2049/cabc
chmod 0664 /sys/devices/platform/mipi_hitachi.2049/ce
chmod 0664 /sys/devices/i2c-3/3-004b/disable_keys
restorecon /sys/class/timed_output/vibrator/amp
restorecon /sys/devices/platform/kcal_ctrl.0/kcal
restorecon /sys/devices/platform/kcal_ctrl.0/kcal_ctrl
restorecon /sys/devices/platform/mipi_hitachi.2049/kgamma_r
restorecon /sys/devices/platform/mipi_hitachi.2049/kgamma_g
restorecon /sys/devices/platform/mipi_hitachi.2049/kgamma_b
restorecon /sys/devices/platform/mipi_hitachi.2049/kgamma_apply
restorecon /sys/devices/platform/mipi_hitachi.2049/cabc
restorecon /sys/devices/platform/mipi_hitachi.2049/ce
restorecon /sys/devices/i2c-3/3-004b/disable_keys
on charger
# Enable Power modes and set the CPU Freq Sampling rates
write /sys/module/rpm_resources/enable_low_power/L2_cache 1
write /sys/module/rpm_resources/enable_low_power/pxo 1
write /sys/module/rpm_resources/enable_low_power/vdd_dig 1
write /sys/module/rpm_resources/enable_low_power/vdd_mem 1
write /sys/module/pm_8x60/modes/cpu0/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu1/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu2/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu3/power_collapse/suspend_enabled 1
write /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled 1
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor “powersave”
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor “powersave”
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor “powersave”
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor “powersave”
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold 90
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 50000
write /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy 1
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor 4
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 384000
write /sys/devices/system/cpu/cpu1/online 0
write /sys/devices/system/cpu/cpu2/online 0
write /sys/devices/system/cpu/cpu3/online 0
on property:init.svc.wpa_supplicant=stopped
stop dhcpcd
service rmt_storage /system/bin/rmt_storage
class core
user root
service fm_dl /system/bin/sh /system/etc/init.aries.fm.sh
class late_start
user system
group qcom_oncrpc system
disabled
oneshot
service hciattach /system/bin/sh /system/etc/init.aries.bt.sh
class late_start
user bluetooth
group qcom_oncrpc bluetooth net_bt_admin system
disabled
oneshot
on property:bluetooth.hciattach=true
start hciattach
on property:bluetooth.hciattach=false
setprop bluetooth.status off
service bridgemgrd /system/bin/bridgemgrd
class main
user radio
group radio
# QMUX must be in multiple groups to support external process connections
service qmuxd /system/bin/qmuxd
class main
user radio
group radio audio bluetooth gps
service kickstart /system/bin/qcks -i /firmware/image/ -r /data/tombstones/mdm/
class core
user system
group system
oneshot
service netmgrd /system/bin/netmgrd
class main
service sensors /system/bin/sensors.qcom
class late_start
user root
group root
service wcnss-service /system/bin/wcnss_service
class main
user system
group system wifi radio
oneshot
service wpa_supplicant /system/bin/wpa_supplicant \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-I/system/etc/wifi/wpa_supplicant_overlay.conf \
-O/data/misc/wifi/sockets \
-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
# we will start as root and wpa_supplicant will switch to user wifi
# after setting up the capabilities required for WEXT
# user wifi
# group wifi inet keystore
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
service p2p_supplicant /system/bin/wpa_supplicant \
-ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
-I/system/etc/wifi/p2p_supplicant_overlay.conf -N \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-I/system/etc/wifi/wpa_supplicant_overlay.conf \
-O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \
-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
# we will start as root and wpa_supplicant will switch to user wifi
# after setting up the capabilities required for WEXT
# user wifi
# group wifi inet keystore
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
service dhcpcd_wlan0 /system/bin/dhcpcd -aABDKL
class main
disabled
oneshot
service dhcpcd_p2p /system/bin/dhcpcd -aABKL
class main
disabled
oneshot
service iprenew_wlan0 /system/bin/dhcpcd -n
class main
disabled
oneshot
service iprenew_p2p /system/bin/dhcpcd -n
class main
disabled
oneshot
service dhcpcd_bt-pan /system/bin/dhcpcd -BKLG
disabled
oneshot
service iprenew_bt-pan /system/bin/dhcpcd -n
disabled
oneshot
on property:ro.data.large_tcp_window_size=true
# Adjust socket buffer to enlarge TCP receive window for high bandwidth (e.g. DO-RevB)
write /proc/sys/net/ipv4/tcp_adv_win_scale 2
service charger /sbin/charger_aries
class charger
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
service fuse_usbdisk /system/bin/sdcard -u 1023 -g 1023 /mnt/media_rw/usbdisk /storage/usbdisk
class late_start
disabled
service thermald /system/bin/thermald
class main
service mpdecision /system/bin/mpdecision –no_sleep –avg_comp
class main
service ppd /system/bin/mm-pp-daemon
class late_start
user system
socket pps stream 0660 system system graphics
group system graphics
service qcamerasvr /system/bin/mm-qcamera-daemon
class late_start
user camera
group camera system inet input
service bdAddrLoader /system/bin/bdAddrLoader -f /persist/bluetooth/.bdaddr -h -x
class main
user bluetooth
group system bluetooth
oneshot
# bugreport is triggered by holding down volume down, volume up and power
service bugreport /system/bin/dumpstate -d -p -B \
-o /data/data/com.android.shell/files/bugreports/bugreport
class main
disabled
oneshot
keycodes 114 115 116
service qseecomd /system/bin/qseecomd
class late_start
user system
group system
service diag_mdlog /system/bin/diag_mdlog -s 100
class late_start
disabled
service qrngd /system/bin/qrngd -f
class main
user root
group root
# on property:gsm.sim.state=READY
# start diag_mdlog
# CM Performance Profiles
# Powersave
on property:sys.perf.profile=0
start mpdecision
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor “conservative”
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor “conservative”
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor “conservative”
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor “conservative”
write /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor “ondemand”
# Balanced
on property:sys.perf.profile=1
start mpdecision
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor “ondemand”
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 50000
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold 90
write /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy 1
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor 4
write /sys/devices/system/cpu/cpufreq/ondemand/down_differential 10
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core 70
write /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core 3
write /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq 918000
write /sys/devices/system/cpu/cpufreq/ondemand/sync_freq 1026000
write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load 80
write /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor “ondemand”
# Performance
on property:sys.perf.profile=2
stop mpdecision
write /sys/devices/system/cpu/cpu0/online 1
write /sys/devices/system/cpu/cpu1/online 1
write /sys/devices/system/cpu/cpu2/online 1
write /sys/devices/system/cpu/cpu3/online 1
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor “performance”
write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor “performance”
write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor “performance”
write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor “performance”
write /sys/class/kgsl/kgsl-3d0/pwrscale/trustzone/governor “performance”