├── magisk ├── flag │ └── .placeholder ├── META-INF │ └── com │ │ └── google │ │ └── android │ │ ├── updater-script │ │ └── update-binary ├── bin │ └── busybox │ │ └── busybox ├── common │ ├── system.prop │ ├── post-fs-data.sh │ └── service.sh ├── config │ └── perapp_powermode.txt ├── module.prop ├── script │ ├── powercfg.json │ ├── vtools_powercfg.sh │ ├── pathinfo.sh │ ├── powercfg_main.sh │ ├── initsvc.sh │ ├── libuperf.sh │ ├── libpowercfg.sh │ ├── setup.sh │ ├── libcommon.sh │ ├── libsysinfo.sh │ ├── libcgroup.sh │ └── powercfg_once.sh ├── uninstall.sh └── install.sh ├── .gitignore ├── media ├── sflag.png ├── alipay-qr.png ├── android_am.png ├── fingerprint.png ├── render_stop.png ├── render_restart.png ├── wechat_resume.png └── adjusted_demand_capacity_relation.png ├── version.json ├── changelog.md ├── LICENSE ├── config ├── template.json └── README.md ├── README.md └── NOTICE /magisk/flag/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | /.vscode 3 | /build 4 | -------------------------------------------------------------------------------- /magisk/META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /media/sflag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/sflag.png -------------------------------------------------------------------------------- /media/alipay-qr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/alipay-qr.png -------------------------------------------------------------------------------- /media/android_am.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/android_am.png -------------------------------------------------------------------------------- /media/fingerprint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/fingerprint.png -------------------------------------------------------------------------------- /media/render_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/render_stop.png -------------------------------------------------------------------------------- /media/render_restart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/render_restart.png -------------------------------------------------------------------------------- /media/wechat_resume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/wechat_resume.png -------------------------------------------------------------------------------- /magisk/bin/busybox/busybox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/magisk/bin/busybox/busybox -------------------------------------------------------------------------------- /media/adjusted_demand_capacity_relation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yc9559/uperf/HEAD/media/adjusted_demand_capacity_relation.png -------------------------------------------------------------------------------- /magisk/common/system.prop: -------------------------------------------------------------------------------- 1 | # This file will be read by resetprop 2 | # Example: Change dpi 3 | # ro.sf.lcd_density=320 4 | 5 | # headroom for GC 6 | dalvik.vm.heapmaxfree=8m 7 | dalvik.vm.heapminfree=2m 8 | -------------------------------------------------------------------------------- /magisk/config/perapp_powermode.txt: -------------------------------------------------------------------------------- 1 | # 分应用性能模式配置 2 | # Per-app dynamic power mode rule 3 | # '-' means offscreen rule 4 | # '*' means default rule 5 | 6 | com.miHoYo.Yuanshen fast 7 | - balance 8 | * balance 9 | -------------------------------------------------------------------------------- /version.json: -------------------------------------------------------------------------------- 1 | { 2 | "versionCode": 220904, 3 | "version": "v3", 4 | "zipUrl": "https://github.com/yc9559/uperf/releases/download/dev-22.09.04/uperf-dev-22.09.04.zip", 5 | "changelog": "https://github.com/yc9559/uperf/raw/master/changelog.md" 6 | } 7 | -------------------------------------------------------------------------------- /magisk/module.prop: -------------------------------------------------------------------------------- 1 | id=uperf 2 | name=Uperf 3 | version=v3(22.09.04) 4 | versionCode=220904 5 | author=Matt Yang 6 | description=Userspace performance controller for android. Repo: https://github.com/yc9559/uperf/ 7 | updateJson=https://github.com/yc9559/uperf/raw/master/version.json 8 | -------------------------------------------------------------------------------- /magisk/script/powercfg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Uperf", 3 | "author": "Matt Yang", 4 | "version": "22.09.04", 5 | "versionCode": 3, 6 | "features": { 7 | "strict": true, 8 | "pedestal": true 9 | }, 10 | "module": "uperf,sfanalysis", 11 | "state": "/sdcard/Android/yc/uperf/cur_powermode.txt", 12 | "entry": "/data/powercfg.sh", 13 | "projectUrl": "https://github.com/yc9559/uperf" 14 | } -------------------------------------------------------------------------------- /magisk/script/vtools_powercfg.sh: -------------------------------------------------------------------------------- 1 | #!/vendor/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # powercfg wrapper for com.omarea.vtools 19 | # MAKE SURE THAT THE MAGISK MODULE "Uperf" HAS BEEN INSTALLED 20 | -------------------------------------------------------------------------------- /magisk/common/post-fs-data.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2021-2022 Matt Yang 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | MODDIR=${0%/*} 18 | 19 | if [ -f "$MODDIR/flag/need_recuser" ]; then 20 | rm -f $MODDIR/flag/need_recuser 21 | true >$MODDIR/disable 22 | else 23 | true >$MODDIR/flag/need_recuser 24 | fi 25 | -------------------------------------------------------------------------------- /magisk/common/service.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | BASEDIR="$(dirname $(readlink -f "$0"))" 19 | 20 | crash_recuser() { 21 | rm $BASEDIR/logcat.log 22 | logcat -f $BASEDIR/logcat.log & 23 | sleep 60 24 | killall logcat 25 | rm -f $BASEDIR/flag/need_recuser 26 | } 27 | 28 | (crash_recuser &) 29 | sh $BASEDIR/script/initsvc.sh 30 | -------------------------------------------------------------------------------- /magisk/script/pathinfo.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | MODULE_PATH="$(dirname $(readlink -f "$0"))" 19 | MODULE_PATH="${MODULE_PATH%\/script}" 20 | SCRIPT_PATH="$MODULE_PATH/script" 21 | BIN_PATH="$MODULE_PATH/bin" 22 | FLAG_PATH="$MODULE_PATH/flag" 23 | 24 | USER_PATH="/sdcard/Android/yc/uperf" 25 | LOG_FILE="$USER_PATH/initsvc.log" 26 | 27 | # use private busybox 28 | PATH="$BIN_PATH/busybox:$PATH" 29 | -------------------------------------------------------------------------------- /magisk/script/powercfg_main.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | BASEDIR="$(dirname $(readlink -f "$0"))" 19 | . $BASEDIR/pathinfo.sh 20 | 21 | action="$1" 22 | case "$1" in 23 | "powersave" | "balance" | "performance" | "fast" | "auto") echo "$1" >"$USER_PATH/cur_powermode.txt" ;; 24 | "pedestal") echo "performance" >"$USER_PATH/cur_powermode.txt" ;; 25 | "init") echo "balance" >"$USER_PATH/cur_powermode.txt" ;; 26 | *) echo "Failed to apply unknown action '$1'." ;; 27 | esac 28 | -------------------------------------------------------------------------------- /magisk/script/initsvc.sh: -------------------------------------------------------------------------------- 1 | #!/vendor/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | BASEDIR="$(dirname $(readlink -f "$0"))" 19 | . $BASEDIR/pathinfo.sh 20 | . $BASEDIR/libcommon.sh 21 | . $BASEDIR/libuperf.sh 22 | 23 | # create busybox symlinks 24 | $BIN_PATH/busybox/busybox --install -s $BIN_PATH/busybox 25 | 26 | # support vtools 27 | cp -af $SCRIPT_PATH/vtools_powercfg.sh /data/powercfg.sh 28 | cp -af $SCRIPT_PATH/vtools_powercfg.sh /data/powercfg-base.sh 29 | cp -af $SCRIPT_PATH/powercfg.json /data/powercfg.json 30 | chmod 755 /data/powercfg.sh 31 | chmod 755 /data/powercfg-base.sh 32 | echo "sh $SCRIPT_PATH/powercfg_main.sh \"\$1\"" >>/data/powercfg.sh 33 | 34 | wait_until_login 35 | 36 | sh $SCRIPT_PATH/powercfg_once.sh 37 | uperf_start 38 | -------------------------------------------------------------------------------- /magisk/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # MR author: railjty 19 | USER_PATH=/sdcard/Android/yc/uperf 20 | 21 | wait_until_login() { 22 | # in case of /data encryption is disabled 23 | while [ "$(getprop sys.boot_completed)" != "1" ]; do 24 | sleep 1 25 | done 26 | 27 | # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen 28 | local test_file="/sdcard/Android/.PERMISSION_TEST" 29 | true >"$test_file" 30 | while [ ! -f "$test_file" ]; do 31 | true >"$test_file" 32 | sleep 1 33 | done 34 | rm "$test_file" 35 | } 36 | 37 | on_remove() { 38 | wait_until_login 39 | 40 | # keep user perapp config 41 | cp -af $USER_PATH/perapp_powermode.txt /sdcard/ 42 | rm -rf $USER_PATH 43 | mkdir -p $USER_PATH 44 | mv /sdcard/perapp_powermode.txt $USER_PATH/ 45 | 46 | rm -f /data/powercfg* 47 | } 48 | 49 | # do not block boot 50 | (on_remove &) 51 | -------------------------------------------------------------------------------- /magisk/script/libuperf.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | BASEDIR="$(dirname "$0")" 19 | . $BASEDIR/pathinfo.sh 20 | . $BASEDIR/libcommon.sh 21 | . $BASEDIR/libcgroup.sh 22 | 23 | uperf_stop() { 24 | killall uperf 25 | } 26 | 27 | uperf_start() { 28 | # raise inotify limit in case file sync existed 29 | lock_val "1048576" /proc/sys/fs/inotify/max_queued_events 30 | lock_val "1048576" /proc/sys/fs/inotify/max_user_watches 31 | lock_val "1024" /proc/sys/fs/inotify/max_user_instances 32 | 33 | mv $USER_PATH/uperf_log.txt $USER_PATH/uperf_log.txt.bak 34 | if [ -f $BIN_PATH/libc++_shared.so ]; then 35 | ASAN_LIB="$(ls $BIN_PATH/libclang_rt.asan-*-android.so)" 36 | export LD_PRELOAD="$ASAN_LIB $BIN_PATH/libc++_shared.so" 37 | fi 38 | $BIN_PATH/uperf $USER_PATH/uperf.json -o $USER_PATH/uperf_log.txt 39 | 40 | # waiting for uperf initialization 41 | sleep 2 42 | # uperf shouldn't preempt foreground tasks 43 | rebuild_process_scan_cache 44 | change_task_cgroup "uperf" "background" "cpuset" 45 | } 46 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # 更新日志 2 | 3 | ## DEV 22.09.04 4 | 5 | - 改进 cpuset分组预留核心 6 | - 改进 sdm8g1+隐藏频点支持 7 | - 改进 减少二进制体积 8 | - 修复 Exynos2100王者荣耀掉帧,感谢@chbqby 9 | 10 | ## DEV 22.07.24 11 | 12 | - 新增 Helio P35/G35/G37支持 13 | - 改进 小核能耗模型 14 | - 改进 框架执行效率 15 | - 修复 熄屏指纹识别偏慢 16 | 17 | ## DEV 22.07.09 18 | 19 | - 新增 sdm8g1+支持 20 | - 改进 任务放置 21 | - 改进 功耗估计准确度 22 | 23 | ## DEV 22.06.26 24 | 25 | - 新增 移除`swjunk` 26 | - 改进 功耗分配 27 | - 改进 任务放置 28 | - 修复 后台程序破音 29 | 30 | ## DEV 22.06.05 31 | 32 | - 新增 更多兼容性CPU频率写入器 33 | - 新增 兼容性生成CPU频率表 34 | - 修复 微信小程序启动缓慢 35 | - 修复 前台程序破音 36 | - 修复 部分崩溃问题 37 | - 修复 部分高通平台息屏功耗过高,感谢@NepPoseidon 38 | 39 | ## DEV 22.05.20 40 | 41 | - 新增 开放配置文件自定义 42 | - 改进 CPU重负载调频稳定性 43 | - 改进 任务放置 44 | - 改进 顶层APP获取开销,感谢@nakixii 45 | - 修复 perapp切换崩溃 46 | - 修复 部分潜在崩溃代码 47 | - 修复 CPU频率写入器失效 48 | 49 | ## DEV 22.05.09 50 | 51 | - 回退 混合CPU调频 52 | - 改进 触摸响应 53 | - 改进 CPU负载滤波器 54 | - 修复 sdm82x部分场景CPU频率无法写入 55 | - 修复 Exynos 2200支持 56 | 57 | ## DEV 22.05.04 58 | 59 | - 新增 混合CPU调频 60 | - 改进 Android 7.0兼容性 61 | - 修复 EPIC写入器自检错误 62 | - 修复 全面屏手势失效,感谢@NebulaLeep 63 | - 暂时禁用SsAnalysis模块,由于降低了过渡动画流畅度 64 | 65 | ## DEV 22.04.30 66 | 67 | - 改进 提高滑动操作跟手性 68 | - 改进 内核CPU调速器兼容性 69 | - 修复 部分设备全面屏手势失效 70 | - 修复 Pixel设备自动重启 71 | - 修复 任务调度器任务分类错误 72 | - 修复 游戏负载放置不稳定 73 | - 修复 游戏最小化破音 74 | 75 | ## DEV 22.04.23 76 | 77 | - 增加 系统动画主动探针 78 | - 增加 CPU采样器负载预测 79 | - 增加 与系统用户态性能控制器协同调度 80 | - 增加 桌面启动器自动识别 81 | - 增加 适配谷歌tensor/天玑810 82 | - 改进 提高手势操作跟手性 83 | - 改进 减少SfAnalysis误报 84 | - 修复 识别上下文的任务调度器规则匹配错误 85 | - 修复 联发科PPM接口适配 86 | - 修复 破音问题 87 | - 修复 部分平台功耗模型 88 | 89 | ## DEV 22.04.09 90 | 91 | - 增加大量平台初步适配 92 | - 改进Unity游戏和吃鸡游戏抖动 93 | - 改进弹幕2倍速视频流畅度 94 | - 更新部分平台功耗模型 95 | - 日志后缀名更换为txt 96 | 97 | ## DEV 22.04.04 98 | 99 | - 插件式软件架构 100 | - 使用C++重新开发 101 | - 功能模块解耦,易扩展 102 | - 感知能耗的CPU调频器 103 | - 用户态使能全平台统一体验 104 | - 单核高性能,多核高能效 105 | - 20-100hz基础采样率,快响应低开销 106 | - 识别上下文的任务调度器 107 | - UI放大核,非关键放小核 108 | - 全数据驱动,正则匹配 109 | - 花费50%开发时间调试的默认规则 110 | - 动态sysfs写入 111 | - 用户态性能控制器基石功能 112 | - 实现更加简约高效 113 | - SfAnalysis 114 | - 预测掉帧并在发生前拉升CPU 115 | - 改进的帧反馈以及模糊匹配 116 | - patch方式无需更改SELinux状态 117 | - 独立选装,但是强烈推荐 118 | - SsAnalysis 119 | - 跟系统线程放置器斗智斗勇 120 | - 独立选装,但是强烈推荐 121 | -------------------------------------------------------------------------------- /magisk/script/libpowercfg.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | ############################### 19 | # Powermodes helper functions 20 | ############################### 21 | 22 | # $1:keyword $2:nr_max_matched 23 | get_package_name_by_keyword() { 24 | echo "$(pm list package | grep "$1" | head -n "$2" | cut -d: -f2)" 25 | } 26 | 27 | # $1:"0:576000 4:710400 7:825600" 28 | set_cpufreq_min() { 29 | lock_val "$1" /sys/module/msm_performance/parameters/cpu_min_freq 30 | local key 31 | local val 32 | for kv in $1; do 33 | key=${kv%:*} 34 | val=${kv#*:} 35 | lock_val "$val" /sys/devices/system/cpu/cpu$key/cpufreq/scaling_min_freq 36 | done 37 | } 38 | 39 | # $1:"0:576000 4:710400 7:825600" 40 | set_cpufreq_max() { 41 | lock_val "$1" /sys/module/msm_performance/parameters/cpu_max_freq 42 | local key 43 | local val 44 | for kv in $1; do 45 | key=${kv%:*} 46 | val=${kv#*:} 47 | lock_val "$val" /sys/devices/system/cpu/cpu$key/cpufreq/scaling_max_freq 48 | done 49 | } 50 | 51 | # $1:"schedutil/pl" $2:"0:4 4:3 7:1" 52 | set_governor_param() { 53 | local key 54 | local val 55 | for kv in $2; do 56 | key=${kv%:*} 57 | val=${kv#*:} 58 | lock_val "$val" /sys/devices/system/cpu/cpu$key/cpufreq/$1 59 | # sdm625 hmp 60 | lock_val "$val" /sys/devices/system/cpu/cpufreq/$1 61 | done 62 | } 63 | 64 | # $1:"min_cpus" $2:"0:4 4:3 7:1" 65 | set_corectl_param() { 66 | local key 67 | local val 68 | for kv in $2; do 69 | key=${kv%:*} 70 | val=${kv#*:} 71 | lock_val "$val" /sys/devices/system/cpu/cpu$key/core_ctl/$1 72 | done 73 | } 74 | 75 | # stop before updating cfg 76 | perfhal_stop() { 77 | for i in 0 1 2 3 4; do 78 | for j in 0 1 2 3 4; do 79 | stop "perf-hal-$i-$j" 2>/dev/null 80 | done 81 | done 82 | usleep 500 83 | } 84 | 85 | # start after updating cfg 86 | perfhal_start() { 87 | for i in 0 1 2 3 4; do 88 | for j in 0 1 2 3 4; do 89 | start "perf-hal-$i-$j" 2>/dev/null 90 | done 91 | done 92 | } 93 | -------------------------------------------------------------------------------- /magisk/script/setup.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | BASEDIR="$(dirname $(readlink -f "$0"))" 19 | . $BASEDIR/pathinfo.sh 20 | . $BASEDIR/libsysinfo.sh 21 | 22 | # $1:error_message 23 | abort() { 24 | echo "$1" 25 | echo "! Uperf installation failed." 26 | exit 1 27 | } 28 | 29 | # $1:file_node $2:owner $3:group $4:permission $5:secontext 30 | set_perm() { 31 | chown $2:$3 $1 32 | chmod $4 $1 33 | chcon $5 $1 34 | } 35 | 36 | # $1:directory $2:owner $3:group $4:dir_permission $5:file_permission $6:secontext 37 | set_perm_recursive() { 38 | find $1 -type d 2>/dev/null | while read dir; do 39 | set_perm $dir $2 $3 $4 $6 40 | done 41 | find $1 -type f -o -type l 2>/dev/null | while read file; do 42 | set_perm $file $2 $3 $5 $6 43 | done 44 | } 45 | 46 | install_uperf() { 47 | echo "- Finding platform specified config" 48 | echo "- ro.board.platform=$(getprop ro.board.platform)" 49 | echo "- ro.product.board=$(getprop ro.product.board)" 50 | 51 | local target 52 | local cfgname 53 | target="$(getprop ro.board.platform)" 54 | cfgname="$(get_config_name $target)" 55 | if [ "$cfgname" == "unsupported" ]; then 56 | target="$(getprop ro.product.board)" 57 | cfgname="$(get_config_name $target)" 58 | fi 59 | 60 | if [ "$cfgname" == "unsupported" ] || [ ! -f $MODULE_PATH/config/$cfgname.json ]; then 61 | abort "! Target [$target] not supported." 62 | fi 63 | 64 | echo "- Uperf config is located at $USER_PATH" 65 | mkdir -p $USER_PATH 66 | mv -f $USER_PATH/uperf.json $USER_PATH/uperf.json.bak 67 | cp -f $MODULE_PATH/config/$cfgname.json $USER_PATH/uperf.json 68 | [ ! -e "$USER_PATH/perapp_powermode.txt" ] && cp $MODULE_PATH/config/perapp_powermode.txt $USER_PATH/perapp_powermode.txt 69 | rm -rf $MODULE_PATH/config 70 | 71 | set_perm_recursive $BIN_PATH 0 0 0755 0755 u:object_r:system_file:s0 72 | } 73 | 74 | echo "" 75 | echo "* Uperf https://github.com/yc9559/uperf/" 76 | echo "* Author: Matt Yang" 77 | echo "* Version: v3(22.09.04)" 78 | echo "" 79 | 80 | echo "- Installing uperf" 81 | install_uperf 82 | -------------------------------------------------------------------------------- /magisk/script/libcommon.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | ############################### 19 | # Basic tool functions 20 | ############################### 21 | 22 | # $1:value $2:filepaths 23 | lock_val() { 24 | for p in $2; do 25 | if [ -f "$p" ]; then 26 | chown root:root "$p" 27 | chmod 0666 "$p" 28 | echo "$1" >"$p" 29 | chmod 0444 "$p" 30 | fi 31 | done 32 | } 33 | 34 | # $1:value $2:filepaths 35 | mask_val() { 36 | touch /data/local/tmp/mount_mask 37 | for p in $2; do 38 | if [ -f "$p" ]; then 39 | umount "$p" 40 | chmod 0666 "$p" 41 | echo "$1" >"$p" 42 | mount --bind /data/local/tmp/mount_mask "$p" 43 | fi 44 | done 45 | } 46 | 47 | # $1:value $2:filepaths 48 | mutate() { 49 | for p in $2; do 50 | if [ -f "$p" ]; then 51 | chmod 0666 "$p" 52 | echo "$1" >"$p" 53 | fi 54 | done 55 | } 56 | 57 | # $1:file path 58 | lock() { 59 | if [ -f "$1" ]; then 60 | chown root:root "$p" 61 | chmod 0444 "$1" 62 | fi 63 | } 64 | 65 | # $1:value $2:list 66 | has_val_in_list() { 67 | for item in $2; do 68 | if [ "$1" == "$item" ]; then 69 | echo "true" 70 | return 71 | fi 72 | done 73 | echo "false" 74 | } 75 | 76 | ############################### 77 | # Config File Operator 78 | ############################### 79 | 80 | # $1:key $return:value(string) 81 | read_cfg_value() { 82 | local value="" 83 | if [ -f "$PANEL_FILE" ]; then 84 | value="$(grep -i "^$1=" "$PANEL_FILE" | head -n 1 | tr -d ' ' | cut -d= -f2)" 85 | fi 86 | echo "$value" 87 | } 88 | 89 | # $1:content 90 | write_panel() { 91 | echo "$1" >>"$PANEL_FILE" 92 | } 93 | 94 | clear_panel() { 95 | true >"$PANEL_FILE" 96 | } 97 | 98 | wait_until_login() { 99 | # in case of /data encryption is disabled 100 | while [ "$(getprop sys.boot_completed)" != "1" ]; do 101 | sleep 1 102 | done 103 | 104 | # we doesn't have the permission to rw "/sdcard" before the user unlocks the screen 105 | local test_file="/sdcard/Android/.PERMISSION_TEST" 106 | true >"$test_file" 107 | while [ ! -f "$test_file" ]; do 108 | true >"$test_file" 109 | sleep 1 110 | done 111 | rm "$test_file" 112 | } 113 | 114 | ############################### 115 | # Log 116 | ############################### 117 | 118 | # $1:content 119 | log() { 120 | echo "$1" >>"$LOG_FILE" 121 | } 122 | 123 | clear_log() { 124 | true >"$LOG_FILE" 125 | } 126 | -------------------------------------------------------------------------------- /magisk/META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | TMPDIR=/dev/tmp 4 | MOUNTPATH=/dev/magisk_img 5 | 6 | # Default permissions 7 | umask 022 8 | 9 | # Initial cleanup 10 | rm -rf $TMPDIR 2>/dev/null 11 | mkdir -p $TMPDIR 12 | 13 | # echo before loading util_functions 14 | ui_print() { echo "$1"; } 15 | 16 | require_new_magisk() { 17 | ui_print "***********************************" 18 | ui_print " Please install the latest Magisk! " 19 | ui_print "***********************************" 20 | exit 1 21 | } 22 | 23 | imageless_magisk() { 24 | [ $MAGISK_VER_CODE -gt 18100 ] 25 | return $? 26 | } 27 | 28 | ########################################################################################## 29 | # Environment 30 | ########################################################################################## 31 | 32 | OUTFD=$2 33 | ZIPFILE=$3 34 | 35 | mount /data 2>/dev/null 36 | 37 | # Load utility functions 38 | if [ -f /data/adb/magisk/util_functions.sh ]; then 39 | . /data/adb/magisk/util_functions.sh 40 | NVBASE=/data/adb 41 | else 42 | require_new_magisk 43 | fi 44 | 45 | # Preperation for flashable zips 46 | setup_flashable 47 | 48 | # Mount partitions 49 | mount_partitions 50 | 51 | # Detect version and architecture 52 | api_level_arch_detect 53 | 54 | # Setup busybox and binaries 55 | $BOOTMODE && boot_actions || recovery_actions 56 | 57 | ########################################################################################## 58 | # Preparation 59 | ########################################################################################## 60 | 61 | # Extract common files 62 | unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2 63 | 64 | [ ! -f $TMPDIR/install.sh ] && abort "! Unable to extract zip file!" 65 | # Load install script 66 | . $TMPDIR/install.sh 67 | 68 | if imageless_magisk; then 69 | $BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules 70 | MODULEROOT=$NVBASE/$MODDIRNAME 71 | else 72 | $BOOTMODE && IMGNAME=magisk_merge.img || IMGNAME=magisk.img 73 | IMG=$NVBASE/$IMGNAME 74 | request_zip_size_check "$ZIPFILE" 75 | mount_magisk_img 76 | MODULEROOT=$MOUNTPATH 77 | fi 78 | 79 | MODID=`grep_prop id $TMPDIR/module.prop` 80 | MODPATH=$MODULEROOT/$MODID 81 | 82 | print_modname 83 | 84 | ui_print "******************************" 85 | ui_print "Powered by Magisk (@topjohnwu)" 86 | ui_print "******************************" 87 | 88 | ########################################################################################## 89 | # Install 90 | ########################################################################################## 91 | 92 | # Create mod paths 93 | rm -rf $MODPATH 2>/dev/null 94 | mkdir -p $MODPATH 95 | 96 | on_install 97 | 98 | # Remove placeholder 99 | rm -f $MODPATH/system/placeholder 2>/dev/null 100 | 101 | # Custom uninstaller 102 | [ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh 103 | 104 | # Auto Mount 105 | if imageless_magisk; then 106 | $SKIPMOUNT && touch $MODPATH/skip_mount 107 | else 108 | $SKIPMOUNT || touch $MODPATH/auto_mount 109 | fi 110 | 111 | # prop files 112 | $PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop 113 | 114 | # Module info 115 | cp -af $TMPDIR/module.prop $MODPATH/module.prop 116 | if $BOOTMODE; then 117 | # Update info for Magisk Manager 118 | if imageless_magisk; then 119 | mktouch $NVBASE/modules/$MODID/update 120 | cp -af $TMPDIR/module.prop $NVBASE/modules/$MODID/module.prop 121 | else 122 | mktouch /sbin/.magisk/img/$MODID/update 123 | cp -af $TMPDIR/module.prop /sbin/.magisk/img/$MODID/module.prop 124 | fi 125 | fi 126 | 127 | # post-fs-data mode scripts 128 | $POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh 129 | 130 | # service mode scripts 131 | $LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh 132 | 133 | # Handle replace folders 134 | for TARGET in $REPLACE; do 135 | mktouch $MODPATH$TARGET/.replace 136 | done 137 | 138 | ui_print "- Setting permissions" 139 | set_permissions 140 | 141 | ########################################################################################## 142 | # Finalizing 143 | ########################################################################################## 144 | 145 | cd / 146 | imageless_magisk || unmount_magisk_img 147 | $BOOTMODE || recovery_cleanup 148 | rm -rf $TMPDIR $MOUNTPATH 149 | 150 | ui_print "- Done" 151 | exit 0 152 | -------------------------------------------------------------------------------- /magisk/install.sh: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # Config Flags 3 | ########################################################################################## 4 | 5 | # Set to true if you do *NOT* want Magisk to mount 6 | # any files for you. Most modules would NOT want 7 | # to set this flag to true 8 | SKIPMOUNT=false 9 | 10 | # Set to true if you need to load system.prop 11 | PROPFILE=true 12 | 13 | # Set to true if you need post-fs-data script 14 | POSTFSDATA=true 15 | 16 | # Set to true if you need late_start service script 17 | LATESTARTSERVICE=true 18 | 19 | ########################################################################################## 20 | # Replace list 21 | ########################################################################################## 22 | 23 | # List all directories you want to directly replace in the system 24 | # Check the documentations for more info why you would need this 25 | 26 | # Construct your list in the following format 27 | # This is an example 28 | # REPLACE_EXAMPLE=" 29 | # /system/app/Youtube 30 | # /system/priv-app/SystemUI 31 | # /system/priv-app/Settings 32 | # /system/framework 33 | # " 34 | 35 | # Construct your own list here 36 | REPLACE="" 37 | 38 | ########################################################################################## 39 | # 40 | # Function Callbacks 41 | # 42 | # The following functions will be called by the installation framework. 43 | # You do not have the ability to modify update-binary, the only way you can customize 44 | # installation is through implementing these functions. 45 | # 46 | # When running your callbacks, the installation framework will make sure the Magisk 47 | # internal busybox path is *PREPENDED* to PATH, so all common commands shall exist. 48 | # Also, it will make sure /data, /system, and /vendor is properly mounted. 49 | # 50 | ########################################################################################## 51 | ########################################################################################## 52 | # 53 | # The installation framework will export some variables and functions. 54 | # You should use these variables and functions for installation. 55 | # 56 | # ! DO NOT use any Magisk internal paths as those are NOT public API. 57 | # ! DO NOT use other functions in util_functions.sh as they are NOT public API. 58 | # ! Non public APIs are not guranteed to maintain compatibility between releases. 59 | # 60 | # Available variables: 61 | # 62 | # MAGISK_VER (string): the version string of current installed Magisk 63 | # MAGISK_VER_CODE (int): the version code of current installed Magisk 64 | # BOOTMODE (bool): true if the module is currently installing in Magisk Manager 65 | # MODPATH (path): the path where your module files should be installed 66 | # TMPDIR (path): a place where you can temporarily store files 67 | # ZIPFILE (path): your module's installation zip 68 | # ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64 69 | # IS64BIT (bool): true if $ARCH is either arm64 or x64 70 | # API (int): the API level (Android version) of the device 71 | # 72 | # Availible functions: 73 | # 74 | # ui_print 75 | # print to console 76 | # Avoid using 'echo' as it will not display in custom recovery's console 77 | # 78 | # abort 79 | # print error message to console and terminate installation 80 | # Avoid using 'exit' as it will skip the termination cleanup steps 81 | # 82 | # set_perm [context] 83 | # if [context] is empty, it will default to "u:object_r:system_file:s0" 84 | # this function is a shorthand for the following commands 85 | # chown owner.group target 86 | # chmod permission target 87 | # chcon context target 88 | # 89 | # set_perm_recursive [context] 90 | # if [context] is empty, it will default to "u:object_r:system_file:s0" 91 | # for all files in , it will call: 92 | # set_perm file owner group filepermission context 93 | # for all directories in (including itself), it will call: 94 | # set_perm dir owner group dirpermission context 95 | # 96 | ##########################################################################################x 97 | 98 | # Set what you want to display when installing your module 99 | print_modname() { 100 | return 101 | } 102 | 103 | # Copy/extract your module files into $MODPATH in on_install. 104 | on_install() { 105 | $BOOTMODE || abort "! Uperf cannot be installed in recovery." 106 | [ $ARCH == "arm64" ] || abort "! Uperf ONLY support arm64 platform." 107 | 108 | ui_print "- Extracting module files" 109 | unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >/dev/null 110 | 111 | # use universal setup.sh 112 | sh $MODPATH/script/setup.sh 113 | [ "$?" != "0" ] && abort 114 | } 115 | 116 | # Only some special files require specific permissions 117 | # This function will be called after on_install is done 118 | # The default permissions should be good enough for most cases 119 | set_permissions() { 120 | return 121 | } 122 | 123 | # You can add more functions to assist your custom script code 124 | -------------------------------------------------------------------------------- /magisk/script/libsysinfo.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | ############################### 19 | # Platform info functions 20 | ############################### 21 | 22 | # $1:"4.14" return:string_in_version 23 | match_linux_version() { 24 | echo "$(cat /proc/version | grep -i "$1")" 25 | } 26 | 27 | get_socid() { 28 | if [ -f /sys/devices/soc0/soc_id ]; then 29 | echo "$(cat /sys/devices/soc0/soc_id)" 30 | else 31 | echo "$(cat /sys/devices/system/soc/soc0/id)" 32 | fi 33 | } 34 | 35 | get_nr_core() { 36 | echo "$(cat /proc/stat | grep cpu[0-9] | wc -l)" 37 | } 38 | 39 | # $1:cpuid 40 | get_maxfreq() { 41 | echo "$(cat "/sys/devices/system/cpu/cpu$1/cpufreq/cpuinfo_max_freq")" 42 | } 43 | 44 | is_aarch64() { 45 | if [ "$(getprop ro.product.cpu.abi)" == "arm64-v8a" ]; then 46 | echo "true" 47 | else 48 | echo "false" 49 | fi 50 | } 51 | 52 | is_eas() { 53 | if [ "$(grep sched /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" != "" ]; then 54 | echo "true" 55 | else 56 | echo "false" 57 | fi 58 | } 59 | 60 | is_mtk() { 61 | if [ "$(getprop | grep ro.mtk)" != "" ]; then 62 | echo "true" 63 | else 64 | echo "false" 65 | fi 66 | } 67 | 68 | _get_sm6150_type() { 69 | case "$(get_socid)" in 70 | 365 | 366) echo "sdm730" ;; 71 | 355 | 369) echo "sdm675" ;; 72 | esac 73 | } 74 | 75 | _get_sdm76x_type() { 76 | if [ "$(get_maxfreq 7)" -gt 2300000 ]; then 77 | echo "sdm765" 78 | else 79 | echo "sdm750" 80 | fi 81 | } 82 | 83 | _get_msm8916_type() { 84 | case "$(get_socid)" in 85 | "206" | "247" | "248" | "249" | "250") echo "msm8916" ;; 86 | "233" | "240" | "242") echo "sdm610" ;; 87 | "239" | "241" | "263" | "268" | "269" | "270" | "271") echo "sdm616" ;; 88 | *) echo "msm8916" ;; 89 | esac 90 | } 91 | 92 | _get_lahaina_type() { 93 | if [ "$(get_maxfreq 7)" -gt 2600000 ]; then 94 | echo "sdm888" 95 | else 96 | if [ "$(get_maxfreq 4)" -gt 2300000 ]; then 97 | echo "sdm778" 98 | else 99 | echo "sdm780" 100 | fi 101 | fi 102 | } 103 | 104 | _get_taro_type() { 105 | if [ "$(get_maxfreq 4)" -gt 2700000 ]; then 106 | echo "sdm8g1+" 107 | else 108 | echo "sdm8g1" 109 | fi 110 | } 111 | 112 | # $1:board_name 113 | get_config_name() { 114 | case "$1" in 115 | "taro") echo "$(_get_taro_type)" ;; 116 | "lahaina") echo "$(_get_lahaina_type)" ;; 117 | "shima") echo "$(_get_lahaina_type)" ;; 118 | "yupik") echo "$(_get_lahaina_type)" ;; 119 | "kona") echo "sdm865" ;; # 865, 870 120 | "msmnile") echo "sdm855" ;; # 855, 860 121 | "sdm845") echo "sdm845" ;; 122 | "lito") echo "$(_get_sdm76x_type)" ;; 123 | "sm6150") echo "$(_get_sm6150_type)" ;; 124 | "sdm710") echo "sdm710" ;; 125 | "msm8916") echo "$(_get_msm8916_type)" ;; 126 | "msm8939") echo "sdm616" ;; 127 | "msm8953") echo "sdm625" ;; # 625 128 | "msm8953pro") echo "sdm625" ;; # 626 129 | "sdm660") echo "sdm660" ;; 130 | "sdm636") echo "sdm660" ;; 131 | "trinket") echo "sdm665" ;; # sdm665 132 | "bengal") echo "sdm665" ;; # sdm662 133 | "msm8976") echo "sdm652" ;; 134 | "msm8956") echo "sdm650" ;; 135 | "msm8998") echo "sdm835" ;; 136 | "msm8996") echo "sdm820" ;; 137 | "msm8996pro") echo "sdm820" ;; 138 | "s5e9925") echo "e2200" ;; 139 | "exynos2100") echo "e2100" ;; 140 | "exynos1080") echo "e1080" ;; 141 | "exynos990") echo "e990" ;; 142 | "universal9925") echo "e2200" ;; 143 | "universal2100") echo "e2100" ;; 144 | "universal1080") echo "e1080" ;; 145 | "universal990") echo "e990" ;; 146 | "universal9825") echo "e9820" ;; 147 | "universal9820") echo "e9820" ;; 148 | "universal9810") echo "e9810" ;; 149 | "universal8895") echo "e8895" ;; 150 | "universal8890") echo "e8890" ;; 151 | "universal7420") echo "e7420" ;; 152 | "mt6765") echo "mtp35" ;; # Helio P35(mt6765)/G35(mt6765g)/G37(mt6765h) 153 | "mt6768") echo "mtg80" ;; # Helio P65(mt6768)/G70(mt6769v)/G80(mt6769t)/G85(mt6769z) 154 | "mt6785") echo "mtg90t" ;; 155 | "mt6833") echo "mtd720" ;; 156 | "mt6833p") echo "mtd720" ;; # Dimensity 810 157 | "mt6833v") echo "mtd720" ;; # Dimensity 810 158 | "mt6853") echo "mtd720" ;; 159 | "mt6873") echo "mtd820" ;; 160 | "mt6875") echo "mtd820" ;; 161 | "mt6877") echo "mtd920" ;; 162 | "mt6885") echo "mtd1000" ;; 163 | "mt6889") echo "mtd1000" ;; 164 | "mt6891") echo "mtd1100" ;; 165 | "mt6893") echo "mtd1200" ;; 166 | "mt6895") echo "mtd8100" ;; 167 | "mt6983") echo "mtd9000" ;; 168 | "gs101") echo "gs101" ;; 169 | *) echo "unsupported" ;; 170 | esac 171 | } 172 | -------------------------------------------------------------------------------- /magisk/script/libcgroup.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # process scan cache 19 | ps_ret="" 20 | 21 | # launcher&home usually in foreground cpuset group 22 | # reserve one LITTLE for hwservicemanager which will block composer 23 | # thread priority settings not working on hwservicemanager 24 | # okay, disabling perf-hal resulting hwservicemanager frequently wakeup 25 | # CPUMASK_LOW="0e" 26 | # CPUMASK_MID="73" 27 | # CPUMASK_HIGH="f0" 28 | # CPUID_LOW="1-3" 29 | # CPUID_MID="0-1,4-7" # uperf set 0-1/0-6 for foreground, cpu7 reserved for launcher 30 | # CPUID_HIGH="4-7" 31 | 32 | # $1:task_name $2:cgroup_name $3:"cpuset"/"stune" 33 | change_task_cgroup() { 34 | local comm 35 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 36 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 37 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 38 | echo "$temp_tid" >"/dev/$3/$2/tasks" 39 | done 40 | done 41 | } 42 | 43 | # $1:process_name $2:cgroup_name $3:"cpuset"/"stune" 44 | change_proc_cgroup() { 45 | local comm 46 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 47 | comm="$(cat /proc/$temp_pid/comm)" 48 | echo $temp_pid >"/dev/$3/$2/cgroup.procs" 49 | done 50 | } 51 | 52 | # $1:task_name $2:thread_name $3:cgroup_name $4:"cpuset"/"stune" 53 | change_thread_cgroup() { 54 | local comm 55 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 56 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 57 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 58 | if [ "$(echo $comm | grep -i -E "$2")" != "" ]; then 59 | echo "$temp_tid" >"/dev/$4/$3/tasks" 60 | fi 61 | done 62 | done 63 | } 64 | 65 | # $1:task_name $2:cgroup_name $3:"cpuset"/"stune" 66 | change_main_thread_cgroup() { 67 | local comm 68 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 69 | comm="$(cat /proc/$temp_pid/comm)" 70 | echo $temp_pid >"/dev/$3/$2/tasks" 71 | done 72 | } 73 | 74 | # $1:task_name $2:hex_mask(0x00000003 is CPU0 and CPU1) 75 | change_task_affinity() { 76 | local comm 77 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 78 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 79 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 80 | taskset -p "$2" "$temp_tid" >>$LOG_FILE 81 | done 82 | done 83 | } 84 | 85 | # $1:task_name $2:thread_name $3:hex_mask(0x00000003 is CPU0 and CPU1) 86 | change_thread_affinity() { 87 | local comm 88 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 89 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 90 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 91 | if [ "$(echo $comm | grep -i -E "$2")" != "" ]; then 92 | taskset -p "$3" "$temp_tid" >>$LOG_FILE 93 | fi 94 | done 95 | done 96 | } 97 | 98 | # $1:task_name $2:nice(relative to 120) 99 | change_task_nice() { 100 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 101 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 102 | renice -n +40 -p "$temp_tid" 103 | renice -n -19 -p "$temp_tid" 104 | renice -n "$2" -p "$temp_tid" 105 | done 106 | done 107 | } 108 | 109 | # $1:task_name $2:thread_name $3:nice(relative to 120) 110 | change_thread_nice() { 111 | local comm 112 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 113 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 114 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 115 | if [ "$(echo $comm | grep -i -E "$2")" != "" ]; then 116 | renice -n +40 -p "$temp_tid" 117 | renice -n -19 -p "$temp_tid" 118 | renice -n "$3" -p "$temp_tid" 119 | fi 120 | done 121 | done 122 | } 123 | 124 | # $1:task_name $2:priority(99-x, 1<=x<=99) 125 | change_task_rt() { 126 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 127 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 128 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 129 | chrt -f -p "$2" "$temp_tid" >>$LOG_FILE 130 | done 131 | done 132 | } 133 | 134 | # $1:task_name $2:thread_name $3:priority(99-x, 1<=x<=99) 135 | change_thread_rt() { 136 | local comm 137 | for temp_pid in $(echo "$ps_ret" | grep -i -E "$1" | awk '{print $1}'); do 138 | for temp_tid in $(ls "/proc/$temp_pid/task/"); do 139 | comm="$(cat /proc/$temp_pid/task/$temp_tid/comm)" 140 | if [ "$(echo $comm | grep -i -E "$2")" != "" ]; then 141 | chrt -f -p "$3" "$temp_tid" >>$LOG_FILE 142 | fi 143 | done 144 | done 145 | } 146 | 147 | # $1:task_name 148 | change_task_high_prio() { 149 | # audio thread nice <= -16 150 | change_task_nice "$1" "-15" 151 | } 152 | 153 | # $1:task_name $2:thread_name 154 | change_thread_high_prio() { 155 | # audio thread nice <= -16 156 | change_thread_nice "$1" "$2" "-15" 157 | } 158 | 159 | # $1:task_name $2:thread_name 160 | unpin_thread() { 161 | change_thread_cgroup "$1" "$2" "" "cpuset" 162 | } 163 | 164 | # $1:task_name $2:thread_name 165 | pin_thread_on_pwr() { 166 | change_thread_cgroup "$1" "$2" "background" "cpuset" 167 | } 168 | 169 | # $1:task_name $2:thread_name 170 | pin_thread_on_mid() { 171 | unpin_thread "$1" "$2" 172 | change_thread_affinity "$1" "$2" "7f" 173 | } 174 | 175 | # $1:task_name $2:thread_name 176 | pin_thread_on_perf() { 177 | unpin_thread "$1" "$2" 178 | change_thread_affinity "$1" "$2" "f0" 179 | } 180 | 181 | # $1:task_name 182 | unpin_proc() { 183 | change_task_cgroup "$1" "" "cpuset" 184 | } 185 | 186 | # $1:task_name 187 | pin_proc_on_pwr() { 188 | change_task_cgroup "$1" "background" "cpuset" 189 | } 190 | 191 | # $1:task_name 192 | pin_proc_on_mid() { 193 | unpin_proc "$1" 194 | change_task_affinity "$1" "7f" 195 | } 196 | 197 | # $1:task_name 198 | pin_proc_on_perf() { 199 | unpin_proc "$1" 200 | change_task_affinity "$1" "f0" 201 | } 202 | 203 | rebuild_process_scan_cache() { 204 | # avoid matching grep itself 205 | # ps -Ao pid,args | grep kswapd 206 | # 150 [kswapd0] 207 | # 16490 grep kswapd 208 | ps_ret="$(ps -Ao pid,args)" 209 | } 210 | -------------------------------------------------------------------------------- /magisk/script/powercfg_once.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # 3 | # Copyright (C) 2021-2022 Matt Yang 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # Runonce after boot, to speed up the transition of power modes in powercfg 19 | 20 | BASEDIR="$(dirname $(readlink -f "$0"))" 21 | . $BASEDIR/pathinfo.sh 22 | . $BASEDIR/libcommon.sh 23 | . $BASEDIR/libpowercfg.sh 24 | . $BASEDIR/libcgroup.sh 25 | 26 | unify_cgroup() { 27 | # clear top-app 28 | for p in $(cat /dev/cpuset/top-app/tasks); do 29 | echo $p >/dev/cpuset/foreground/tasks 30 | done 31 | 32 | # unused 33 | rmdir /dev/cpuset/foreground/boost 34 | 35 | # work with uperf/ContextScheduler 36 | change_task_cgroup "surfaceflinger" "" "cpuset" 37 | change_task_cgroup "system_server" "foreground" "cpuset" 38 | change_task_cgroup "netd|allocator" "foreground" "cpuset" 39 | change_task_cgroup "hardware.media.c2|vendor.mediatek.hardware" "background" "cpuset" 40 | change_task_cgroup "aal_sof|kfps|dsp_send_thread|vdec_ipi_recv|mtk_drm_disp_id|disp_feature|hif_thread|main_thread|rx_thread|ged_" "background" "cpuset" 41 | change_task_cgroup "pp_event|crtc_" "background" "cpuset" 42 | } 43 | 44 | unify_sched() { 45 | # clear stune & uclamp 46 | for d in /dev/stune/*/; do 47 | lock_val "0" $d/schedtune.boost 48 | lock_val "0" $d/schedtune.prefer_idle 49 | done 50 | for d in /dev/cpuctl/*/; do 51 | lock_val "0" $d/cpu.uclamp.min 52 | lock_val "0" $d/cpu.uclamp.latency_sensitive 53 | done 54 | 55 | for d in kernel walt; do 56 | mask_val "0" /proc/sys/$d/sched_force_lb_enable 57 | done 58 | } 59 | 60 | unify_devfreq() { 61 | for df in /sys/class/devfreq; do 62 | for d in $df/*cpubw $df/*llccbw $df/*cpu-cpu-llcc-bw $df/*cpu-llcc-ddr-bw; do 63 | lock_val "9999000000" "$d/max_freq" 64 | done 65 | done 66 | for d in DDR LLCC L3; do 67 | lock_val "9999000000" "/sys/devices/system/cpu/bus_dcvs/$d/*/max_freq" 68 | done 69 | } 70 | 71 | unify_lpm() { 72 | # Qualcomm enter C-state level 3 took ~500us 73 | lock_val "0" /sys/module/lpm_levels/parameters/lpm_ipi_prediction 74 | lock_val "0" /sys/module/lpm_levels/parameters/lpm_prediction 75 | lock_val "2" /sys/module/lpm_levels/parameters/bias_hyst 76 | for d in kernel walt; do 77 | mask_val "255" /proc/sys/$d/sched_busy_hysteresis_enable_cpus 78 | mask_val "2000000" /proc/sys/$d/sched_busy_hyst_ns 79 | done 80 | } 81 | 82 | disable_hotplug() { 83 | # Exynos hotplug 84 | mutate "0" /sys/power/cpuhotplug/enabled 85 | mutate "0" /sys/devices/system/cpu/cpuhotplug/enabled 86 | 87 | # turn off msm_thermal 88 | lock_val "0" /sys/module/msm_thermal/core_control/enabled 89 | lock_val "N" /sys/module/msm_thermal/parameters/enabled 90 | 91 | # 3rd 92 | lock_val "0" /sys/kernel/intelli_plug/intelli_plug_active 93 | lock_val "0" /sys/module/blu_plug/parameters/enabled 94 | lock_val "0" /sys/devices/virtual/misc/mako_hotplug_control/enabled 95 | lock_val "0" /sys/module/autosmp/parameters/enabled 96 | lock_val "0" /sys/kernel/zen_decision/enabled 97 | 98 | # stop sched core_ctl 99 | set_corectl_param "enable" "0:0 6:0 7:0" 100 | 101 | # bring all cores online 102 | for i in 0 1 2 3 4 5 6 7 8 9; do 103 | lock_val "1" /sys/devices/system/cpu/cpu$i/online 104 | done 105 | } 106 | 107 | disable_kernel_boost() { 108 | # Qualcomm 109 | lock_val "0" "/sys/devices/system/cpu/cpu_boost/*" 110 | lock_val "0" "/sys/devices/system/cpu/cpu_boost/parameters/*" 111 | lock_val "0" "/sys/module/cpu_boost/parameters/*" 112 | lock_val "0" "/sys/module/msm_performance/parameters/*" 113 | lock_val "0" "/sys/kernel/msm_performance/parameters/*" 114 | lock_val "0" "/proc/sys/walt/input_boost/*" 115 | 116 | # no msm_performance limit 117 | set_cpufreq_min "0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0" 118 | set_cpufreq_max "0:9999000 1:9999000 2:9999000 3:9999000 4:9999000 5:9999000 6:9999000 7:9999000" 119 | 120 | # MediaTek 121 | # policy_status 122 | # [0] PPM_POLICY_PTPOD: Meature PMIC buck currents 123 | # [1] PPM_POLICY_UT: Unit test 124 | # [2] PPM_POLICY_FORCE_LIMIT: enabled 125 | # [3] PPM_POLICY_PWR_THRO: enabled 126 | # [4] PPM_POLICY_THERMAL: enabled 127 | # [5] PPM_POLICY_DLPT: Power measurment and power budget managing 128 | # [6] PPM_POLICY_HARD_USER_LIMIT: enabled 129 | # [7] PPM_POLICY_USER_LIMIT: enabled 130 | # [8] PPM_POLICY_LCM_OFF: disabled 131 | # [9] PPM_POLICY_SYS_BOOST: disabled 132 | # [10] PPM_POLICY_HICA: ? 133 | # Usage: echo <1(enable)/0(disable)> > /proc/ppm/policy_status 134 | # use cpufreq interface with PPM_POLICY_HARD_USER_LIMIT enabled, thanks to helloklf@github 135 | lock_val "1" /proc/ppm/enabled 136 | for i in 0 1 2 3 4 5 6 7 8 9 10; do 137 | lock_val "$i 0" /proc/ppm/policy_status 138 | done 139 | lock_val "6 1" /proc/ppm/policy_status 140 | lock_val "enable 0" /proc/perfmgr/tchbst/user/usrtch 141 | lock "/proc/ppm/policy/*" 142 | lock "/proc/ppm/*" 143 | lock_val "0" "/sys/module/mtk_fpsgo/parameters/boost_affinity*" 144 | lock_val "0" "/sys/module/fbt_cpu/parameters/boost_affinity*" 145 | lock_val "9999000" "/sys/kernel/fpsgo/fbt/limit_*" 146 | lock_val "0" /sys/kernel/fpsgo/fbt/switch_idleprefer 147 | lock_val "1" /proc/perfmgr/syslimiter/syslimiter_force_disable 148 | lock_val "1" /sys/module/mtk_core_ctl/parameters/policy_enable 149 | lock_val "90" /sys/kernel/fpsgo/fbt/thrm_temp_th 150 | lock_val "-1" /sys/kernel/fpsgo/fbt/thrm_limit_cpu 151 | lock_val "-1" /sys/kernel/fpsgo/fbt/thrm_sub_cpu 152 | 153 | # Samsung 154 | mutate "0" "/sys/class/input_booster/*" 155 | 156 | # Oneplus 157 | lock_val "N" "/sys/module/control_center/parameters/*" 158 | lock_val "0" /sys/module/aigov/parameters/enable 159 | lock_val "0" "/sys/module/houston/parameters/*" 160 | # OnePlus opchain always pins UX threads on the big cluster 161 | lock_val "0" /sys/module/opchain/parameters/chain_on 162 | 163 | # 3rd 164 | lock_val "0" "/sys/kernel/cpu_input_boost/*" 165 | lock_val "0" "/sys/module/cpu_input_boost/parameters/*" 166 | lock_val "0" "/sys/module/dsboost/parameters/*" 167 | lock_val "0" "/sys/module/devfreq_boost/parameters/*" 168 | } 169 | 170 | disable_userspace_boost() { 171 | # xiaomi vip-task scheduler override 172 | chmod 0000 /dev/migt 173 | for f in /sys/module/migt/parameters/*; do 174 | chmod 0000 $f 175 | done 176 | 177 | # xiaomi perfservice 178 | stop vendor.perfservice 179 | stop miuibooster 180 | # stop vendor.miperf 181 | 182 | # brain service maybe not smart 183 | stop oneplus_brain_service 2>/dev/null 184 | 185 | # Qualcomm perfd 186 | stop perfd 2>/dev/null 187 | 188 | # Qualcomm&MTK perfhal 189 | perfhal_stop 190 | 191 | # libperfmgr 192 | stop vendor.power-hal-1-0 193 | stop vendor.power-hal-1-1 194 | stop vendor.power-hal-1-2 195 | stop vendor.power-hal-1-3 196 | stop vendor.power-hal-aidl 197 | } 198 | 199 | restart_userspace_boost() { 200 | # Qualcomm&MTK perfhal 201 | perfhal_start 202 | 203 | # libperfmgr 204 | start vendor.power-hal-1-0 205 | start vendor.power-hal-1-1 206 | start vendor.power-hal-1-2 207 | start vendor.power-hal-1-3 208 | start vendor.power-hal-aidl 209 | } 210 | 211 | disable_userspace_thermal() { 212 | # yes, let it respawn 213 | killall mi_thermald 214 | # prohibit mi_thermald use cpu thermal interface 215 | for i in 0 2 4 6 7; do 216 | local maxfreq="$(cat /sys/devices/system/cpu/cpu$i/cpufreq/cpuinfo_max_freq)" 217 | [ "$maxfreq" -gt "0" ] && lock_val "cpu$i $maxfreq" /sys/devices/virtual/thermal/thermal_message/cpu_limits 218 | done 219 | } 220 | 221 | restart_userspace_thermal() { 222 | # yes, let it respawn 223 | killall mi_thermald 224 | } 225 | 226 | clear_log 227 | exec 1>$LOG_FILE 228 | # exec 2>&1 229 | echo "PATH=$PATH" 230 | echo "sh=$(which sh)" 231 | 232 | # set permission 233 | disable_kernel_boost 234 | disable_hotplug 235 | unify_sched 236 | unify_devfreq 237 | unify_lpm 238 | 239 | disable_userspace_thermal 240 | restart_userspace_thermal 241 | disable_userspace_boost 242 | restart_userspace_boost 243 | 244 | # unify value 245 | disable_kernel_boost 246 | disable_hotplug 247 | unify_sched 248 | unify_devfreq 249 | unify_lpm 250 | 251 | # make sure that all the related cpu is online 252 | rebuild_process_scan_cache 253 | unify_cgroup 254 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2021-2022 Matt Yang 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /config/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "meta": { 3 | "name": "platform[yy.mm.dd]", 4 | "author": "author@community" 5 | }, 6 | "modules": { 7 | "switcher": { 8 | "switchInode": "/sdcard/Android/yc/uperf/cur_powermode.txt", 9 | "perapp": "/sdcard/Android/yc/uperf/perapp_powermode.txt", 10 | "hintDuration": { 11 | "idle": 0.0, 12 | "touch": 4.0, 13 | "trigger": 0.03, 14 | "gesture": 0.1, 15 | "switch": 0.4, 16 | "junk": 0.06 17 | } 18 | }, 19 | "atrace": { 20 | "enable": false 21 | }, 22 | "log": { 23 | "level": "info" 24 | }, 25 | "input": { 26 | "enable": true, 27 | "swipeThd": 0.03, 28 | "gestureThdX": 0.03, 29 | "gestureThdY": 0.03, 30 | "gestureDelayTime": 2.0, 31 | "holdEnterTime": 1.0 32 | }, 33 | "sfanalysis": { 34 | "enable": true, 35 | "renderIdleSlackTime": 0.2 36 | }, 37 | "cpu": { 38 | "enable": true, 39 | "powerModel": [] 40 | }, 41 | "sysfs": { 42 | "enable": true, 43 | "knob": { 44 | "cpusetTa": "/dev/cpuset/top-app/cpus", 45 | "cpusetFg": "/dev/cpuset/foreground/cpus", 46 | "cpusetBg": "/dev/cpuset/background/cpus", 47 | "cpusetSysBg": "/dev/cpuset/system-background/cpus", 48 | "cpusetRe": "/dev/cpuset/restricted/cpus" 49 | } 50 | }, 51 | "sched": { 52 | "enable": true, 53 | "cpumask": { 54 | "all": [0, 1, 2, 3, 4, 5, 6, 7], 55 | "c0": [0, 1, 2, 3], 56 | "c1": [4, 5, 6], 57 | "c2": [7] 58 | }, 59 | "affinity": { 60 | "auto": { "bg": "", "fg": "", "idle": "", "touch": "", "boost": "" }, 61 | "norm": { "bg": "", "fg": "all", "idle": "all", "touch": "all", "boost": "all" }, 62 | "bg": { "bg": "", "fg": "c0", "idle": "c0", "touch": "c0", "boost": "c0" }, 63 | "ui": { "bg": "", "fg": "all", "idle": "all", "touch": "c1", "boost": "all" }, 64 | "crit": { "bg": "", "fg": "all", "idle": "all", "touch": "c1", "boost": "c1" }, 65 | "gtcoop": { "bg": "", "fg": "all", "idle": "all", "touch": "c1", "boost": "all" }, 66 | "gtmain": { "bg": "", "fg": "all", "idle": "all", "touch": "c2", "boost": "all" } 67 | }, 68 | "prio": { 69 | "auto": { "bg": 0, "fg": 0, "idle": 0, "touch": 0, "boost": 0 }, 70 | "bg": { "bg": -3, "fg": 139, "idle": 139, "touch": 139, "boost": 139 }, 71 | "norm": { "bg": -1, "fg": -1, "idle": 120, "touch": 120, "boost": 130 }, 72 | "coop": { "bg": -3, "fg": 124, "idle": 122, "touch": 122, "boost": 130 }, 73 | "ui": { "bg": -3, "fg": 120, "idle": 110, "touch": 98, "boost": 116 }, 74 | "rtusr": { "bg": 98, "fg": 98, "idle": 97, "touch": 97, "boost": 98 }, 75 | "rtsys": { "bg": 97, "fg": 97, "idle": 96, "touch": 96, "boost": 97 } 76 | }, 77 | "rules": [ 78 | { 79 | "name": "Launcher", 80 | "regex": "/HOME_PACKAGE/", 81 | "pinned": true, 82 | "rules": [ 83 | { "k": "/MAIN_THREAD/", "ac": "crit", "pc": "rtusr" }, 84 | { "k": "^(RenderThread|GLThread)", "ac": "crit", "pc": "rtusr" }, 85 | { "k": "^(GPU completion|HWC release|hwui|FramePolicy|ScrollPolicy|ged-swd)", "ac": "bg", "pc": "rtusr" }, 86 | { "k": ".", "ac": "auto", "pc": "auto" } 87 | ] 88 | }, 89 | { 90 | "name": "SurfaceFlinger", 91 | "regex": "/system/bin/surfaceflinger", 92 | "pinned": true, 93 | "rules": [ 94 | { "k": "/MAIN_THREAD/", "ac": "crit", "pc": "auto" }, 95 | { "k": "^(app|RenderEngine)", "ac": "crit", "pc": "auto" }, 96 | { "k": "^Binder:", "ac": "auto", "pc": "auto" }, 97 | { "k": ".", "ac": "bg", "pc": "auto" } 98 | ] 99 | }, 100 | { 101 | "name": "SystemServer", 102 | "regex": "system_server", 103 | "pinned": true, 104 | "rules": [ 105 | { "k": "^(TaskSnapshot|Greezer|CachedApp|SystemPressure|SensorService)|[Mm]emory", "ac": "bg", "pc": "auto" }, 106 | { "k": "^Async", "ac": "auto", "pc": "norm" }, 107 | { "k": ".", "ac": "auto", "pc": "auto" } 108 | ] 109 | }, 110 | { 111 | "name": "SystemUI", 112 | "regex": "com.android.systemui", 113 | "pinned": true, 114 | "rules": [ 115 | { "k": "^(Jit thread pool|HeapTaskDaemon|FinalizerDaemon|ReferenceQueueD)", "ac": "bg", "pc": "auto" }, 116 | { "k": ".", "ac": "auto", "pc": "auto" } 117 | ] 118 | }, 119 | { 120 | "name": "MediaProvider", 121 | "regex": "^com.android.providers.media", 122 | "pinned": true, 123 | "rules": [{ "k": ".", "ac": "auto", "pc": "bg" }] 124 | }, 125 | { 126 | "name": "Memory reclaim", 127 | "regex": "swapd|compactd", 128 | "pinned": true, 129 | "rules": [{ "k": ".", "ac": "auto", "pc": "bg" }] 130 | }, 131 | { 132 | "name": "Phone", 133 | "regex": "com.android.phone", 134 | "pinned": false, 135 | "rules": [{ "k": ".", "ac": "auto", "pc": "auto" }] 136 | }, 137 | { 138 | "name": "Other system processes", 139 | "regex": "^(/system|/vendor|magiskd|zygiskd)|@|-service$", 140 | "pinned": false, 141 | "rules": [{ "k": ".", "ac": "auto", "pc": "auto" }] 142 | }, 143 | { 144 | "name": "App co-process", 145 | "regex": "[.].+:", 146 | "pinned": false, 147 | "rules": [{ "k": "^(Jit thread pool|HeapTaskDaemon|FinalizerDaemon|ReferenceQueueD)", "ac": "bg", "pc": "auto" }] 148 | }, 149 | { 150 | "name": "Default rule", 151 | "regex": ".", 152 | "pinned": false, 153 | "rules": [ 154 | { "k": "/MAIN_THREAD/", "ac": "ui", "pc": "ui" }, 155 | { "k": "^(UnityMain|RenderThread |GameThread)", "ac": "gtmain", "pc": "auto" }, 156 | { "k": "^(Unity|Worker Thread|TaskGraph|RHIThread|GLThread|Thread-|Job.Worker)", "ac": "gtcoop", "pc": "auto" }, 157 | { "k": "^(RenderThread|JNISurfaceText|IJK_External_Re)|[Aa]nim|([.]raster|[.]ui)$", "ac": "ui", "pc": "ui" }, 158 | { "k": "^(Chrome_InProc|CrRendererMain|CrGpuMain|CompositorTile)", "ac": "norm", "pc": "auto" }, 159 | { "k": "^(Viz|Chrome_|Compositor)|[Vv]sync|mali-", "ac": "ui", "pc": "ui" }, 160 | { "k": "^(OkHttp|Ysa|Xqa|Rx|APM|TVKDL-|tp-|cgi-|ODCP-|Bugly|xlog_)", "ac": "bg", "pc": "auto" }, 161 | { "k": "^(xg_vip_service|Profile|SearchDaemon|default_matrix|FrameDecoder|FrameSeq)", "ac": "bg", "pc": "auto" }, 162 | { "k": "^(GPU completion|HWC release|hwui|FramePolicy|ScrollPolicy|ged-swd)", "ac": "bg", "pc": "rtusr" }, 163 | { "k": "^(JS|libweexjsb|WeexJsBridge|mqt_native|mqt_js|JavaScriptTh)", "ac": "norm", "pc": "coop" }, 164 | { "k": "^(pool-|glide-|launcher-|Fresco)|[Dd]ownload|[Ss]chedule|[Ww]ork|[Pp]ool|[Dd]efau", "ac": "norm", "pc": "coop" }, 165 | { "k": ".", "ac": "norm", "pc": "auto" } 166 | ] 167 | } 168 | ] 169 | } 170 | }, 171 | "initials": { 172 | "cpu": { 173 | "baseSampleTime": 0.01, 174 | "baseSlackTime": 0.01, 175 | "latencyTime": 0.5, 176 | "slowLimitPower": 3.0, 177 | "fastLimitPower": 6.0, 178 | "fastLimitCapacity": 10.0, 179 | "fastLimitRecoverScale": 0.3, 180 | "predictThd": 0.3, 181 | "margin": 0.25, 182 | "burst": 0.0, 183 | "guideCap": true, 184 | "limitEfficiency": false 185 | }, 186 | "sysfs": { 187 | "cpusetTa": "0-7", 188 | "cpusetFg": "0-2,4-7", 189 | "cpusetBg": "0-2", 190 | "cpusetSysBg": "0-2", 191 | "cpusetRe": "0-6" 192 | }, 193 | "sched": { 194 | "scene": "idle" 195 | } 196 | }, 197 | "presets": { 198 | "balance": { 199 | "*": { 200 | "cpu.latencyTime": 0.2, 201 | "cpu.slowLimitPower": 2.0, 202 | "cpu.fastLimitPower": 2.0, 203 | "cpu.fastLimitCapacity": 16.0, 204 | "cpu.margin": 0.2 205 | }, 206 | "idle": { 207 | "cpu.baseSampleTime": 0.04, 208 | "cpu.baseSlackTime": 0.08, 209 | "cpu.predictThd": 0.3, 210 | "cpu.limitEfficiency": true, 211 | "sched.scene": "idle" 212 | }, 213 | "touch": { 214 | "cpu.baseSampleTime": 0.04, 215 | "sched.scene": "touch" 216 | }, 217 | "trigger": { 218 | "cpu.latencyTime": 0.0, 219 | "cpu.margin": 0.4, 220 | "sched.scene": "touch" 221 | }, 222 | "gesture": { 223 | "cpu.margin": 0.6, 224 | "sched.scene": "touch" 225 | }, 226 | "junk": { 227 | "cpu.burst": 0.6, 228 | "sched.scene": "touch" 229 | }, 230 | "switch": { 231 | "cpu.latencyTime": 0.0, 232 | "cpu.slowLimitPower": 3.0, 233 | "cpu.fastLimitPower": 5.0, 234 | "cpu.fastLimitRecoverScale": 0.1, 235 | "cpu.margin": 0.4, 236 | "sched.scene": "boost" 237 | } 238 | }, 239 | "powersave": { 240 | "*": { 241 | "cpu.latencyTime": 0.4, 242 | "cpu.slowLimitPower": 1.0, 243 | "cpu.fastLimitPower": 1.0, 244 | "cpu.fastLimitCapacity": 4.0, 245 | "cpu.margin": 0.1 246 | }, 247 | "idle": { 248 | "cpu.baseSampleTime": 0.04, 249 | "cpu.baseSlackTime": 0.08, 250 | "cpu.predictThd": 1.0, 251 | "cpu.limitEfficiency": true, 252 | "sched.scene": "idle" 253 | }, 254 | "touch": { 255 | "cpu.baseSampleTime": 0.04, 256 | "sched.scene": "touch" 257 | }, 258 | "trigger": { 259 | "cpu.latencyTime": 0.0, 260 | "cpu.margin": 0.3, 261 | "sched.scene": "touch" 262 | }, 263 | "gesture": { 264 | "cpu.margin": 0.6, 265 | "sched.scene": "touch" 266 | }, 267 | "junk": { 268 | "cpu.burst": 0.3, 269 | "sched.scene": "touch" 270 | }, 271 | "switch": { 272 | "cpu.latencyTime": 0.0, 273 | "cpu.slowLimitPower": 1.5, 274 | "cpu.fastLimitPower": 2.5, 275 | "cpu.fastLimitRecoverScale": 0.1, 276 | "cpu.margin": 0.3, 277 | "sched.scene": "boost" 278 | } 279 | }, 280 | "performance": { 281 | "*": { 282 | "cpu.latencyTime": 0.0, 283 | "cpu.slowLimitPower": 4.0, 284 | "cpu.fastLimitPower": 10.0, 285 | "cpu.fastLimitCapacity": 360.0, 286 | "cpu.margin": 0.4 287 | }, 288 | "idle": { 289 | "cpu.baseSampleTime": 0.01, 290 | "cpu.baseSlackTime": 0.04, 291 | "sched.scene": "idle" 292 | }, 293 | "touch": { 294 | "sched.scene": "touch" 295 | }, 296 | "trigger": { 297 | "cpu.margin": 0.8, 298 | "sched.scene": "touch" 299 | }, 300 | "gesture": { 301 | "cpu.margin": 0.8, 302 | "sched.scene": "touch" 303 | }, 304 | "junk": { 305 | "cpu.burst": 0.5, 306 | "sched.scene": "touch" 307 | }, 308 | "switch": { 309 | "cpu.burst": 0.2, 310 | "sched.scene": "boost" 311 | } 312 | }, 313 | "fast": { 314 | "*": { 315 | "cpu.latencyTime": 0.0, 316 | "cpu.slowLimitPower": 2.5, 317 | "cpu.fastLimitPower": 2.5, 318 | "cpu.fastLimitCapacity": 0.0, 319 | "cpu.margin": 0.4 320 | }, 321 | "idle": { 322 | "cpu.baseSampleTime": 0.01, 323 | "cpu.baseSlackTime": 0.04, 324 | "sched.scene": "idle" 325 | }, 326 | "touch": { 327 | "sched.scene": "touch" 328 | }, 329 | "trigger": { 330 | "cpu.margin": 0.8, 331 | "sched.scene": "touch" 332 | }, 333 | "gesture": { 334 | "cpu.margin": 0.8, 335 | "sched.scene": "touch" 336 | }, 337 | "junk": { 338 | "cpu.burst": 0.5, 339 | "sched.scene": "touch" 340 | }, 341 | "switch": { 342 | "cpu.burst": 0.2, 343 | "sched.scene": "boost" 344 | } 345 | } 346 | } 347 | } 348 | -------------------------------------------------------------------------------- /config/README.md: -------------------------------------------------------------------------------- 1 | # Uperf v3 配置文件说明 2 | 3 | Uperf v3 使用插件化的软件结构设计,每个功能模块均可拥有独立的配置参数空间。 4 | 5 | ## meta/元信息 6 | 7 | | 字段 | 类型 | 描述 | 8 | | ------ | ------ | ------------------ | 9 | | name | string | 配置文件的名称 | 10 | | author | string | 配置文件的作者信息 | 11 | 12 | ## modules/模块定义 13 | 14 | 功能模块的静态参数段,仅在模块实例化时读取一次,用于开关功能、定义模型参数等。 15 | 16 | ### switcher/动态配置切换器 17 | 18 | 根据关联的 native 层信号,跳转对应的 hint 状态切换,应用对应的动态参数,并持续指定时长。用户可定义多个性能配置,每个性能配置有各个 hint 的动态参数。动态参数的默认值定义在`/initials`,动态参数的动态值定义在`/presets`。如果在写入`/presets`定义了`powersave`和`balance`两个性能配置,那么`switchInode`文件允许写入`auto`、`powersave`和`balance`,其中`auto`表示启用`内置分APP性能配置切换器`。 19 | 20 | 注:由于是基础模块,此模块**不可关闭**。 21 | 22 | 内置分 APP 性能配置切换器的规则样例如下,包名按大小写敏感的全字匹配。行首为`*`表示默认规则,行首为`-`表示熄屏规则,**必须包含默认和熄屏规则**。 23 | 24 | ``` 25 | # 分应用性能模式配置 26 | # Per-app dynamic power mode rule 27 | # '-' means offscreen rule 28 | # '*' means default rule 29 | 30 | com.miHoYo.Yuanshen fast 31 | - balance 32 | * balance 33 | ``` 34 | 35 | | 字段 | 类型 | 描述 | 36 | | ------------ | ------ | ------------------------------ | 37 | | switchInode | string | 监听手动切换性能模式的文件节点 | 38 | | perapp | string | 内置分 APP 性能配置文件路径 | 39 | | hintDuration | object | 每个 hint 的最长持续时间 | 40 | 41 | #### hintDuration/hint 最长持续时间 42 | 43 | 各个 hint 使用状态机完成跳转,状态转移图如下: 44 | 45 | ```mermaid 46 | stateDiagram-v2 47 | 48 | [*] --> idle 49 | idle --> touch: pressed touch / pressed button 50 | idle --> switch: woke up screen 51 | touch --> trigger: released touch / started scrolling 52 | touch --> gesture: detected fullscreen gesture 53 | touch --> switch: detected window animation 54 | touch --> junk: detected junk 55 | gesture --> switch: detected window animation 56 | gesture --> junk: detected junk 57 | junk --> touch: timeout / finished junk 58 | trigger --> touch: timeout / not rendering 59 | gesture --> touch: timeout / not rendering 60 | switch --> touch: timeout / not rendering 61 | touch --> idle: timeout / not rendering 62 | ``` 63 | 64 | | 字段 | 类型 | 描述 | 65 | | ------- | ----- | -------------------------------------------------- | 66 | | idle | float | (单位:秒)默认 | 67 | | touch | float | (单位:秒)触摸屏幕/按下按键 | 68 | | trigger | float | (单位:秒)点击操作离开屏幕/松开按键/滑动操作起始 | 69 | | gesture | float | (单位:秒)全面屏手势 | 70 | | switch | float | (单位:秒)应用切换动画/点亮屏幕 | 71 | | junk | float | (单位:秒)touch/gesture 中 sfanalysis 检测到掉帧 | 72 | 73 | ### atrace/数据打点 74 | 75 | 用于 uperf 程序调试。 76 | 77 | | 字段 | 类型 | 描述 | 78 | | ------ | ---- | ------------ | 79 | | enable | bool | 启用数据打点 | 80 | 81 | ### log/日志级别 82 | 83 | 用于 uperf 配置文件调试。 84 | 85 | | 字段 | 类型 | 描述 | 86 | | ----- | ------ | ----------------------------------------------------- | 87 | | level | string | 日志级别,可用`err`、`warn`、`info`、`debug`、`trace` | 88 | 89 | ### input/用户输入监听 90 | 91 | 监听用户触摸屏触摸操作、按键操作、鼠标操作。支持输入设备热插拔。 92 | 93 | | 字段 | 类型 | 描述 | 94 | | ---------------- | ----- | ------------------------------------------------ | 95 | | enable | bool | 启用用户输入监听 | 96 | | swipeThd | float | 单次触摸轨迹百分比长度超过该阈值,判定为滑动操作 | 97 | | gestureThdX | float | 全面屏手势起始 X 轴百分比位置 | 98 | | gestureThdY | float | 全面屏手势起始 Y 轴百分比位置 | 99 | | gestureDelayTime | float | 暂不使用 | 100 | | holdEnterTime | float | 暂不使用 | 101 | 102 | ### sfanalysis/SurfaceFlinger 信号分析 103 | 104 | 接收 sfanalysis 模块在 SurfaceFlinger 内部的信号分析结果。检测到掉帧触发 hint,渲染结束提前结束 hint。 105 | 106 | | 字段 | 类型 | 描述 | 107 | | ------------------- | ----- | ------------------------------------------------ | 108 | | enable | bool | 启用 SurfaceFlinger 信号分析 | 109 | | renderIdleSlackTime | float | (单位:秒)渲染结束保持一段时间,判定为渲染结束 | 110 | 111 | ### cpu/用户态 CPU 调频 112 | 113 | 基于能耗模型的用户态 CPU 调频器,使能 HMP/EAS 全平台统一体验。根据功耗模型计算每个频点的每瓦性能,选择最佳的频率限制。 114 | 115 | | 字段 | 类型 | 描述 | 116 | | ---------- | ------ | ------------------- | 117 | | enable | bool | 启用用户态 CPU 调频 | 118 | | powerModel | object | CPU 能耗模型 | 119 | 120 | #### powerModel/能耗模型 121 | 122 | 仅需一组实测数据即可完成标定。经验模型结合实测数据,保持模型精度并显著减少平台适配工作量。类型为对象列表,与 CPU 集群顺序一致。 123 | 124 | 注:**典型频点并非调频最大值**,大于典型频点的功耗使用模型外插计算。 125 | 126 | | 字段 | 类型 | 描述 | 127 | | ------------ | ----- | --------------------------------------------- | 128 | | efficiency | int | 单核相对同频性能(以Cortex-A53@1.0Ghz为 100) | 129 | | nr | int | 集群内核心数量 | 130 | | typicalPower | float | (单位:瓦)单核典型功耗 | 131 | | typicalFreq | float | (单位:千兆赫)单核典型频点 | 132 | | sweetFreq | float | (单位:千兆赫)单核甜点交界频点 | 133 | | plainFreq | float | (单位:千兆赫)单核线性交界频点 | 134 | | freeFreq | float | (单位:千兆赫)单核最低功耗频点 | 135 | 136 | ### sysfs/内核节点写入器 137 | 138 | 用户态性能控制器的核心功能,为不同场景设置不同的内核参数。此模块高度优化,写入目标值开销极低。 139 | 140 | | 字段 | 类型 | 描述 | 141 | | ------ | ------ | ------------------ | 142 | | enable | bool | 启用内核节点写入器 | 143 | | knob | object | 内核节点定义 | 144 | 145 | #### knob/内核节点定义 146 | 147 | 按键值对定义: 148 | 149 | - 键:内核节点名称 150 | - 值:内核节点文件路径 151 | 152 | 例子: 153 | 154 | ```json 155 | "cpusetTa": "/dev/cpuset/top-app/cpus" 156 | ``` 157 | 158 | ### sched/识别上下文的任务调度器 159 | 160 | 在相同的能耗下,改进 QoS 提升用户感知的流畅度。正则匹配进程名和线程名,绑定到指定的 CPU 核心,并设置指定的调度优先级。此模块高度优化,进程扫描和动态规则应用开销极低。 161 | 162 | 识别上下文的任务调度器定义有如下场景: 163 | 164 | - `bg`:进程处于后台 165 | - `fg`:进程处于前台 166 | - `idle`:进程处于顶层可见,默认场景 167 | - `touch`:进程处于顶层可见,交互场景 168 | - `boost`:进程处于顶层可见,重负载场景 169 | 170 | | 字段 | 类型 | 描述 | 171 | | -------- | ------ | -------------------------- | 172 | | enable | bool | 启用识别上下文的任务调度器 | 173 | | cpumask | object | CPU 组定义 | 174 | | affinity | object | CPU 亲和性类别定义 | 175 | | prio | object | 调度优先级类别定义 | 176 | | rules | object | 进程规则 | 177 | 178 | #### cpumask/CPU 组定义 179 | 180 | 按键值对定义: 181 | 182 | - 键:CPU 组名称 183 | - 值:此 CPU 组包含的 CPU 核心 id 列表 184 | 185 | 例子: 186 | 187 | ```json 188 | "perf": [4, 5, 6, 7] 189 | ``` 190 | 191 | #### affinity/CPU 亲和性类别定义 192 | 193 | 按键值对定义: 194 | 195 | - 键:CPU 亲和性类别名称 196 | - 值:每个场景绑定到的`cpumask` 197 | 198 | 例子: 199 | 200 | ```json 201 | "coop": { 202 | "bg": "eff", 203 | "fg": "eff", 204 | "idle": "norm", 205 | "touch": "norm", 206 | "boost": "norm" 207 | } 208 | ``` 209 | 210 | #### prio/调度优先级类别定义 211 | 212 | 按键值对定义: 213 | 214 | - 键:调度优先级类别名称 215 | - 值:每个场景应用的调度优先级,值定义如下 216 | 217 | | 数值 | 描述 | 218 | | ------- | ------------------------------------------------------ | 219 | | 0 | 跳过 SCHED 类别设置 | 220 | | 1~98 | 设置线程调度类别为`SCHED_FIFO`,数值为实时静态优先级 | 221 | | 100~139 | 设置线程调度类别为`SCHED_NORMAL`,数值为实时静态优先级 | 222 | | -1 | 设置线程调度类别为`SCHED_NORMAL` | 223 | | -2 | 设置线程调度类别为`SCHED_BATCH` | 224 | | -3 | 设置线程调度类别为`SCHED_IDLE` | 225 | 226 | 例子: 227 | 228 | ```json 229 | "high": { 230 | "bg": -3, 231 | "fg": 110, 232 | "idle": 104, 233 | "touch": 102, 234 | "boost": 100 235 | } 236 | ``` 237 | 238 | #### rules/进程规则 239 | 240 | 类型为对象列表,与匹配优先级顺序一致。 241 | 242 | 注:正则匹配规则`/HOME_PACKAGE/`在内部会自动替换为当前系统启动器的包名。 243 | 244 | | 字段 | 类型 | 描述 | 245 | | ------ | ------ | -------------------------------------------- | 246 | | name | string | 进程规则名 | 247 | | regex | string | 进程名正则匹配规则,注意不要与 json 语法冲突 | 248 | | pinned | bool | 始终作为`处于顶层可见的进程`应用规则 | 249 | | rules | object | 此进程的线程规则 | 250 | 251 | ##### rules/线程规则 252 | 253 | 类型为对象列表,与匹配优先级顺序一致。 254 | 255 | 注:正则匹配规则`/MAIN_THREAD/`在内部会自动替换为主线程线程名。 256 | 257 | | 字段 | 类型 | 描述 | 258 | | ---- | ------ | ----------------------------------------------------------------------- | 259 | | k | string | 线程名正则匹配规则,注意不要与 json 语法冲突(abbr: keyword) | 260 | | ac | string | 线程的 CPU 亲和性类别,需要在`affinity`预先定义(abbr: affinity class) | 261 | | pc | string | 线程的调度优先级类别,需要在`prio`预先定义(abbr: priority class) | 262 | 263 | ## initials/初始值 264 | 265 | 功能模块的动态参数段,模块初始化完成后可动态切换,用于调整阈值、模块行为倾向性等。在此段定义的值为该模块参数的默认值。 266 | 267 | ### cpu/用户态 CPU 调频 268 | 269 | 基于能耗模型的用户态 CPU 调频器工作流程如下,提供多个可调节参数: 270 | 271 | 1. 从内核周期性采样 CPU 每个核心的负载 272 | - CPU 整体存在一定负载时,以`baseSampleTime`周期采样 CPU 频率,提高响应速度 273 | - CPU 整体进入空载时,以`baseSlackTime`周期采样 CPU 频率,减少轮询开销 274 | 2. 计算每个集群的性能负载和性能需求 275 | - 如果 CPU 集群最大负载增加量大于`predictThd`,则性能需求计算使用预测的负载值 276 | - 根据性能负载计算性能需求,`demand = load + (1 - load) * (margin + burst)` 277 | - 与`margin`不同,`burst`非零时即使当前负载较低也能计算到较大的性能需求 278 | 3. 计算性能需求对应的工作频点 279 | - CPU 整体如果存在多个集群,它们共享整个`latencyTime`,表示从性能最低的集群的最低频到性能最高的集群的最高频率的最小延迟 280 | - 由于离散采样周期的存在,实测 CPU 整体升频最小延迟一般会大于设定的`latencyTime` 281 | - 能耗代价越大的频点,升频到它的延迟也越大,且低于`sweetFreq`的频点没有额外的升频延迟 282 | 4. 限制 CPU 整体的功耗 283 | - 类似于 Intel 处理器的 PL1 和 PL2 功耗限制,兼顾短期爆发性能需求和长期能效需求 284 | - 根据能耗模型和每个核心的负载,估计当前周期 CPU 整体的能耗值 285 | - 如果当前能耗大于`slowLimitPower`,能耗缓冲池余量减少 286 | - 如果当前能耗小于`slowLimitPower`,能耗缓冲池余量增加,并按照`fastLimitRecoverScale`缩放因子恢复,总量不超过`fastLimitCapacity` 287 | - 限制 CPU 功耗根据能耗模型选择最优频率限制,在限定功耗下提供最佳整体性能 288 | - `burst`非零时忽略`fastLimitPower`和`slowLimitPower`限制 289 | 5. 引导任务调度器放置任务 290 | - 启用`guideCap`后,根据能耗模型调节集群性能容量,引导 EAS 任务调度器把任务放置到能效最佳的集群 291 | - 启用`limitEfficiency`后,低性能集群最大频点能效值不高于高性能集群当前频点的能效值 292 | 6. 写入目标 CPU 频率到内核 293 | - 高效的 CPU 频率写入器,用户态 CPU 调频整体周期运行耗时大约为 0.0005 秒 294 | 295 | | 字段 | 类型 | 描述 | 296 | | --------------------- | ----- | -------------------------------------------------------------------------------------------- | 297 | | baseSampleTime | float | (单位:秒)(0.01~0.5)基础采样周期 | 298 | | baseSlackTime | float | (单位:秒)(0.01~0.5)闲置采样周期,CPU 整体进入空载时生效 | 299 | | latencyTime | float | (单位:秒)(0.0~10.0)CPU 整体升频最小延迟 | 300 | | slowLimitPower | float | (单位:瓦)(0.05~999.0)CPU 长期功耗限制 | 301 | | fastLimitPower | float | (单位:瓦)(0.05~999.0)CPU 短期功耗限制,能耗缓冲池消耗完毕后进入长期功耗限制 | 302 | | fastLimitCapacity | float | (单位:瓦秒)(0.0~999.0)CPU 短期功耗限制容量,增加时重置余量为限制容量 | 303 | | fastLimitRecoverScale | float | (0.1~10.0)CPU 短期功耗限制容量恢复缩放因子 | 304 | | predictThd | float | (0.1~1.0)CPU 集群最大负载增加量大于该阈值,则集群调频使用预测的负载值,并忽略`latencyTime` | 305 | | margin | float | (0.0~1.0)调频提供的性能余量 | 306 | | burst | float | (0.0~1.0)调频提供的额外性能余量,非零时忽略`latencyTime`和功耗限制 | 307 | | guideCap | bool | 启用引导 EAS 任务调度负载转移 | 308 | | limitEfficiency | bool | 启用 CPU 整体能效限制 | 309 | 310 | ### sysfs/内核节点写入器 311 | 312 | 按键值对定义: 313 | 314 | - 键:内核节点名称 315 | - 值:内核节点文件写入值,支持`string`和`int`类型 316 | 317 | 例子: 318 | 319 | ```json 320 | "cpusetTa": "0-7" 321 | ``` 322 | 323 | ### sched/识别上下文的任务调度器 324 | 325 | | 字段 | 类型 | 描述 | 326 | | ----- | ------ | -------------------------------------------------------- | 327 | | scene | string | 进程处于顶层可见的场景,合法值有`idle`, `touch`, `boost` | 328 | 329 | ## presets/参数预设 330 | 331 | 功能模块的参数预设段,在这里定义不同的性能模式,如均衡模式、节能模式。 332 | 333 | 每组参数预设必须包含`*`, `idle`, `touch`, `trigger`, `gesture`, `junk`, `switch`,如下样例所示。参数预设中子配置名称定义同[动态配置切换器](#switcher/动态配置切换器),在状态跳转后应用对应模式的动态参数。其中`*`中的参数为该组参数预设的动态参数默认值。 334 | 335 | ```json 336 | "balance": { 337 | "*": { 338 | }, 339 | "idle": { 340 | }, 341 | "touch": { 342 | }, 343 | "trigger": { 344 | }, 345 | "gesture": { 346 | }, 347 | "junk": { 348 | }, 349 | "switch": { 350 | } 351 | } 352 | ``` 353 | 354 | 为了提高参数预设的可读性,参数值采用`层叠样式表`的设计方式。以下示例展示参数值`cpu.baseSampleTime`的覆盖关系: 355 | 356 | 1. 在`/initial/cpu`中定义`baseSampleTime`全局默认值为`0.01` 357 | 2. 在`/presets/balance/*`中定义`baseSampleTime`在该参数预设默认值为`0.02`,覆盖全局默认值`0.01` 358 | 3. 在`/presets/balance/idle`中定义`baseSampleTime`在`idle`场景值为`0.04`,覆盖该参数预设默认值`0.02` 359 | 360 | ``` 361 | "initials": { 362 | "cpu": { 363 | "baseSampleTime": 0.01, 364 | } 365 | }, 366 | "presets": { 367 | "balance": { 368 | "*": { 369 | "cpu.baseSampleTime": 0.02 370 | }, 371 | "idle": { 372 | "cpu.baseSampleTime": 0.04 373 | } 374 | } 375 | } 376 | ``` 377 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Uperf 2 | 3 | 一个Android用户态性能控制器,实现大部分内核态升频功能,并支持更多情景识别。 4 | 5 | ## 主要功能 6 | 7 | - 根据识别的场景类型,动态设定参数控制性能释放,支持所有`sysfs`节点 8 | - 支持动态绑定正在操作的APP的UI相关线程到大核集群 9 | - 从Linux层面读取Android的触摸屏输入信号,识别点击和滑动 10 | - 主动采样系统负载,识别例如APP启动的瞬间重负载 11 | - 监听cpuset分组更新操作,识别正在操作的APP发生切换 12 | - 监听唤醒锁更新操作,识别屏幕是否熄灭 13 | - 监听注入到Surfaceflinger的hook发送的通知,识别渲染开始、滞后、结束 14 | - 支持Android 6.0 - 12 15 | - 支持arm64-v8a 16 | - 支持Magisk方式一键安装,版本不低于20.4+ 17 | - 不依赖于Magisk,可以手动方式安装 18 | - 除非SfAnalysis注入失败,大多数情况SELinux可保持`enforcing` 19 | - 不依赖于任何Android应用层框架以及第三方内核 20 | - 为大多数热门硬件平台提供了调参后的配置文件 21 | 22 | ## 下载 23 | 24 | https://github.com/yc9559/uperf/releases 25 | 26 | ## 安装 27 | 28 | ### Magisk方式 29 | 30 | 1. 下载后通过Magisk Manager刷入,Magisk版本不低于18.0 31 | 2. 重启后查看`/sdcard/Android/yc/uperf/uperf_log.txt`检查uperf是否正常自启动 32 | 33 | ### 手动安装 34 | 35 | 1. 如果你的设备无法安装Magisk,并且已经获取到ROOT权限 36 | 2. 下载后手动解压缩,例如解压缩到`/data/uperf` 37 | 3. 修改`setup_uperf.sh`,`run_uperf.sh`,`initsvc_uperf.sh`权限为755 38 | 4. 执行`setup_uperf.sh`完成安装,检查输出信息是否有报错 39 | 5. 执行`run_uperf.sh`启动uperf,检查输出信息是否有报错 40 | 6. 打开`/data/cache/injector.log`,检查sfanalysis注入是否成功 41 | 7. 如果关联自启动到第三方APP,设置在开机完成后执行`run_uperf.sh` 42 | 8. 如果关联自启动到系统启动脚本,插入`sh /data/uperf/initsvc_uperf.sh` 43 | 9. 重启后查看`/sdcard/yc/uperf/uperf_log.txt`检查uperf是否正常自启动 44 | 45 | ### 性能模式切换 46 | 47 | #### 修改启动时的默认性能模式 48 | 49 | 1. 打开`/sdcard/Android/yc/uperf/cur_powermode.txt` 50 | 2. 修改`auto`, 其中`auto`为开机后使用的默认性能模式,可选的模式有: 51 | - `auto`根据正在使用的App进行动态响应 52 | - `balance`均衡模式,比原厂略流畅的同时略省电 53 | - `powersave`卡顿模式,保证基本流畅的同时尽可能降低功耗 54 | - `performance`费电模式,保证费电的同时多一点流畅度 55 | - `fast`性能模式,相对于均衡模式更加激进 56 | 3. 重启 57 | 58 | #### 启动完成后切换性能模式 59 | 60 | 方法1: 61 | 执行`sh /data/powercfg.sh balance`,其中`balance`是想要切换到的性能模式名称。 62 | 63 | 方法2: 64 | 安装[Scene](https://www.coolapk.com/apk/com.omarea.vtools)为APP绑定对应的性能模式。 65 | 66 | ## 常见问题 67 | 68 | Q:是否对待机功耗有负面影响? 69 | A:Uperf的实现做了不少低功耗的优化,自身运行的功耗开销很低。此外预制配置文件的待机模式中,减少了待机时唤醒的核心数量并使用了保守的升频参数。待机功耗的优化主要靠减少唤醒时长比例,在此基础上Uperf可进一步降低一点待机功耗。 70 | 71 | Q:为什么使用了Uperf还是很费电? 72 | A:SOC的AP部分功耗主要取决于计算量以及使用的频点。Uperf只能控制性能释放,改进频点的选择从而降低功耗,如果后台APP的计算量很大是无法得到显著的续航延长的。这一问题可以通过Scene工具箱的进程管理器来定位。 73 | 74 | Q:是否需要关闭系统的温度控制? 75 | A:系统温度控制是一种硬件保护措施,或者用于改善高负载下的用户体验。大多数情况下无需关闭它,如果你遇到性能严重受限的情况,例如运行竞技游戏CPU最大频率限制在1.4Ghz,请提升温控介入的阈值或者关闭系统温度控制。 76 | 77 | Q:Uperf和Scene工具箱是什么关系? 78 | A:这两个软件独立运作,没有互相依赖。Uperf实现了接口可供Scene工具箱调用,例如性能模式切换以及分APP性能模式。如果不安装Scene工具箱也可以实现性能模式切换,详情见使用方式。 79 | 80 | Q:是否还需要关闭系统的performance boost? 81 | A:Uperf模块内脚本已经关闭了大部分主流的用户态和内核态升频,如果有非常规的升频需要用户自己关闭。 82 | 83 | Q:我遇到了一些奇怪的系统故障,是怎么回事? 84 | A:Uperf在大多数平台可以正常工作,在测试阶段收集到了以下可能发生的故障: 85 | - 桌面启动器不响应触摸。这个目前只在MIUI 12遇到,如果遇到了此问题请删除`/data/adb/modules/uperf/enable_sfanalysis` 86 | - 触摸屏报点间断丢失。请检查是否使用了自动跳过之类的APP,特别是支持坐标点击的 87 | - 睡死。用户态应用程序理论上不会影响系统稳定性,请更换为官方内核和ROM 88 | 89 | Q:使用Magisk安装时提示`not supported`,这是为什么? 90 | A:此硬件平台没有预制的配置文件,可能需要自行适配。 91 | 92 | ## 详细介绍 93 | 94 | 这是在[Project WIPE](https://github.com/yc9559/cpufreq-interactive-opt)、[Project WIPE v2](https://github.com/yc9559/wipe-v2)、[Perfd-opt](https://github.com/yc9559/perfd-opt)、[QTI-mem-opt](https://github.com/yc9559/qti-mem-opt)之后的一个新项目。在之前的工作中,往往是基于一个现有的性能控制器做调参,这也意味着最后究竟能做到多好取决于控制器本身的上限。在EAS调度器成为主流之后无法应用WIPE系列的思路,因为EAS的参数自由度实在太少,等到借助了高通Boost框架才实现了更广范围的调整,才有了Perfd-opt。一方面受制于现有的性能控制器的功能限制,一方面还有一部分老设备没有这些新的性能控制器。没有条件就要创造条件,编写了一个安卓全平台的用户态性能控制器。 95 | 96 | 用户态性能控制通常有着较高的延迟(因为修改sysfs节点消耗相对较多的时间),但是距离实际应用场景很近可以在一些已知的重负载开始之前主动提升性能减少卡顿。一般的工作模式是在系统框架Java层发送Hint,由Native层的服务接收Hint并执行对应的sysfs修改,例如高通CAF Boost Framework、Power-libperfmgr。 97 | 98 | 与其他用户态性能控制器不同的是,Uperf没有Java层的部分,只有Native层接收时间通知和主动采样,这也就没有了系统框架层面的依赖。因此她不需要重新编译内核,也不需要修改Android框架源码,她也没有几乎硬件平台的限制。她的修改范围涵盖了所有内核态性能控制能够做到的,也就是说不用换掉没啥bug的官方内核,就能使用输入升频(没错,少部分老内核没有这个)、Dynamic Stune Boost、Devfreq Boost这些花式Boost。 99 | 100 | 下表为几个主要的性能优化方案的功能对比: 101 | | 功能 | Project WIPE | Perfd-opt(CAF) | libperfmgr | Uperf | 102 | | :--------------------: | :----------: | :------------: | :--------: | :---: | 103 | | HMP+interactive | ✔️ | | | ✔️ | 104 | | EAS+schedutil | | ✔️ | ✔️ | ✔️ | 105 | | 非高通平台 | ✔️ | | | ✔️ | 106 | | Android < 8.0 | ✔️ | | | ✔️ | 107 | | HMP模型自动调参 | ✔️ | | | ✔️ | 108 | | UI线程的CPU亲和性 | | | | ✔️ | 109 | | 点击升频 | | | ✔️ | ✔️ | 110 | | 列表滚动升频 | | ✔️ | ✔️ | ✔️ | 111 | | APP启动加速 | | ✔️ | ✔️ | ✔️ | 112 | | APK安装加速 | | ✔️ | | | 113 | | 待机优化 | | | | ✔️ | 114 | | 帧渲染滞后 | | | | ✔️ | 115 | | 渲染开始、结束 | | | | ✔️ | 116 | | surfaceflinger复杂合成 | | | ✔️ | | 117 | | 视频录制情景 | | | ✔️ | | 118 | | 多性能模式 | ✔️ | ✔️ | | ✔️ | 119 | 120 | ### 情景识别 121 | 122 | 注:v3版本已经修改,此部分不适用 123 | Uperf支持如下几种情景识别: 124 | - `None`,无Hint的常规状态 125 | - `Touch`,触摸到屏幕切换的Hint 126 | - `Pressed`,长按时切换的的Hint 127 | - `Tap`,在刚触摸到屏幕切换的Hint 128 | - `Swipe`,在屏幕滑动一段距离后切换的Hint 129 | - `HeavyLoad`,在Tap或Swipe检测到重负载后切换,负载降低后回落到Tap 130 | - `SfLag`,给Surfaceflinger的渲染提交出现滞后切换的Hint 131 | - `SfBoost`,Surfaceflinger的渲染提交需要加速切换的Hint 132 | - `Standby`,屏幕熄灭时的Hint,一般滞后20秒(隐藏Hint) 133 | - `SsAnim`,系统动画播放切换的Hint 134 | - `WakeUp`,亮屏解锁切换的Hint 135 | 136 | 137 | 138 | #### 触摸信号识别 139 | 140 | 本程序采用了跟安卓系统框架获取触摸信号一样的方式,监听位于/dev/input的设备,解析来自触摸屏的报点信息,可以获取到最基本的手指触摸到屏幕和手指离开屏幕的事件。根据一段连续的报点信息可以得到手指滑动的距离以及离开屏幕时末端速度,由此可以推断是点击操作还是滑动操作,以及根据末端速度推算APP滚动的持续时间。 141 | 142 | #### 重负载跟踪与限制 143 | 144 | 因为不在安卓框架层插入Hook无法确切知道APP正在启动,因此本程序在Hint开始后,用主动轮询的方式更新所有CPU核心的使用率和运行频率得到系统整体负载。`系统整体负载 = sum(efficiency(i) * (load_pct(i) / 100) * (freq_mhz(i) / 1000))`,其中`i`为CPU核心ID。如果整体负载高于`heavyLoad`,那么把当前Hint切换到重负载Hint。重负载Hint的响应性能很好但耗电也偏多,本程序会持续监测系统负载,如果整体负载低于阈值,提前结束耗电的重负载Hint。对于负载不是那么高的APP热启动,甚至不会触发重负载,不像高通Boost框架不管负载多少强行拉满CPU持续2s。此外,这样的检测不仅涵盖了APP冷热启动,还涵盖了例如点击进入微信朋友圈这样的短时重负载场景。本功能的能耗开销也是在非常低的0.6ms/100ms(Cortex-A55@1.0g)。下图为微信热启动Hint状态切换与持续时间。 145 | 146 | ![微信热启动](media/wechat_resume.png) 147 | 148 | 某些的游戏负载确实非常高,系统负载能够非常稳定的持续超过阈值。理论上重负载游戏应该运行在功耗拐点的频率上,保持足够的性能输出的同时才不会发热过大,这与突发重负载的设置初衷矛盾。因此限制了请求进入重负载Hint的请求间隔,在上一次HeavyLoad结束后,负载低于`idleLoad`保持1秒,并且在`requestBurstSlack`这段时间内没有HeavyLoad请求,才能响应新的HeavyLoad,也就过滤了游戏这类持续重负载能耗过高的问题。 149 | 150 | #### 正在操作的APP发生切换 151 | 152 | 基于能够响应上面这些主要的事件,完全可以把非操作时的参数设置的比以前更加保守而不用担心卡顿,但是点亮唤醒是个例外。屏幕下指纹在息屏显示时,按压指纹传感器完成解锁这个操作就算触摸到了屏幕也没有input事件。而点亮屏幕的动画过程往往伴随着大量进程唤醒,保守的参数会造成显著卡顿。本程序通过监测安卓框架的ActivityManager的活动,ActivityManager在正在交互的APP发生变化、解锁屏幕、锁定屏幕时会非常活跃,由此可以推断是否发生了解锁屏幕事件。通过这一监测,还可以实现在APP切换或者启动时,把APP更早的放到大核心,负载迁移延迟可以降低大约100ms。本功能由事件驱动,几乎没有额外的能耗开销。下图为光学屏幕指纹解锁过程。 153 | 154 | ![光学屏幕指纹解锁过程](media/android_am.png) 155 | 156 | #### 识别屏幕熄灭 157 | 158 | 在以往的Project WIPE和Perfd-opt中,很多用户借助Scene工具箱实现熄屏后自动切换到省点模式降低一点待机耗电。处于Native层的Uperf无法像Scene工具箱一样收到系统的熄屏广播,而是监听唤醒锁更新操作来识别屏幕是否熄灭。 159 | 160 | #### SfAnalysis 161 | 162 | Sfanalysis是一个独立于Uperf的模块,注入到surfaceflinger进行修改,从这个负责Android所有帧渲染提交的进程发出信号,通知Uperf调整性能输出,在观察到卡顿之前就提升性能,真正做到未卜先知,这是所有内核态升频所不能企及的。然而想要她的实现有诸多限制,OEM可以改源码,做内核的可以改内核源码,Uperf为了普适性不能修改源码。如果使用注入方式,surfaceflinger是native进程,使用C++编写,相比system_server这类Java写成的hook位点更少,更不用提不同Android版本的实现还不一样。就算注入成功,由于Android对系统进程设置了很多SELinux规则,防止被注入攻击后取得太多的权限,通知信号也难以发出。绕过了这些限制后,Sfanalysis具有以下功能: 163 | 164 | - hook关键调用,推测并向外部传递渲染开始、渲染提交滞后、渲染结束事件 165 | - 自适应动态刷新率、自适应vsync信号滞后间隔 166 | - 在SELinux的权限范围内,向外部传递信号,因此不需要关闭SELinux才能使用 167 | 168 | ![检测到渲染延迟立即拉升CPU频率](./media/sflag.png) 169 | 170 | 渲染提交滞后对应的Hint`SfLag`与重负载一样,有调用频率限制避免长时间拉升高频,相关参数暂时没有开放更改。`SfLag`使用可用次数缓冲池控制调用频率,每满400ms间隔可用次数+1,最大到20次。为了避免不必要的频率拉升,只允许从`Tap`、`Swipe`、`Touch`、`Pressed`转移到`SfLag`。SfAnalysis正常工作后在日志以如下方式体现: 171 | ``` 172 | [13:03:36][I] SfAnalysis: Surfaceflinger analysis connected 173 | ``` 174 | 175 | #### 渲染结束提前结束Hint 176 | 177 | 即使有了触摸末端速度推算,由于每个设备的滑动阻尼不同,实际的渲染持续时间也大不相同,套用固定值容易导致电量浪费。在内核态boost可以通过在drm/atomic添加hook实现渲染结束后提前结束Boost,本程序也使用类似的方法,在渲染结束后200-300ms内结束Hint的响应,覆盖全程UI渲染过程的同时减少电量浪费。本程序在Hint开始后,使用主动轮询的方式监控安卓的surfaceflinger活动,几乎所有版本的安卓的渲染提交都经过它,同时能耗开销在非常低的0.4ms/100ms(Cortex-A55@1.0g)。 178 | 179 | 使用SfAnalysis渲染结束信号之后,提前结束Hint的延迟可以进一步降低到66ms。 180 | ![渲染停止](media/render_stop.png) 181 | 182 | 在尽可能缩短渲染结束提前结束的滞后的同时,会导致某些UI响应本身存在滞后的场景发生太多卡顿,因为Hint已经提前退出。此类情况大多发生在浏览信息流点击图片切换到全屏显示图片的过程。因此在提前结束Hint的同时,还需要检测是否有滞后的UI响应,在点击的700ms以内如果重新开始渲染会恢复先前的Hint。使用主动轮询的方式监控安卓的surfaceflinger活动,恢复Hint的延时在100ms以上,使用SfAnalysis渲染开始信号之后延迟可以进一步降低到33ms。 183 | 184 | ![滞后UI渲染开始](media/render_restart.png) 185 | 186 | ### 写入器 187 | 188 | 写入器基本功能是把目标字符串值写入到`sysfs`节点,除此以外,Uperf还内建了多种写入器实现了其他功能和更加紧凑的参数序列。在切换动作时,Uperf会比对与上一动作参数值的差异,跳过写入重复的值来减少自身功耗开销。Uperf支持的`knob`有如下几种类型: 189 | - `string`,最基础的写入器。效果等同于`echo "val" > /path`。 190 | - `percluster`,分集群紧凑型写入器。使用配置文件中`platform/clusterCpuId`的CPU序号替换`path`中的`%d`,各个值由逗号分隔,使得按集群做区分的值更加紧凑,改善可读性。 191 | - `percpu`,分核心紧凑型写入器。根据配置文件中`platform/efficiency`的列表长度,生成CPU序号替换`path`中的`%d`,各个值由逗号分隔,使得按CPU核心做区分的值更加紧凑,改善可读性。 192 | - `cpufreq`,`percluster`写入器的变种。大部分功能相同,不同的是写入值=设定值*100000,缩短了频率参数序列的长度,以及带有写入失败重试以处理新的最低频率高于原有的最高频率。 193 | - `cgroup_procs`,Cgroup专用写入器。支持最大4个值,各个值由逗号分隔,设定值为进程名称,Uperf在初始化时会扫描系统所有进程,用匹配到的第一个PID替换它们。一般用于设置系统关键进程到指定的cgroup。由于一个进程的线程可能会动态变化,因此此类写入器会关闭去重。 194 | - `uxaffinity`,UxAffinity写入器。在每次正在操作的APP发生切换时,Uperf都会扫描属于顶层APP的cgroup的所有线程,缓存所有UI相关线程的ID。当设定它为1时,把UI相关线程固定到大核心。当设定它为0时,允许UI相关线程使用全部可用核心。在大多数EAS平台上设置`schedtune.boost > 0`和`schedtune.prefer_idle = 1`即可把任务固定到大核,但是EAS在各个平台的具体实现层次不齐,这个参数组不合适用于所有EAS平台。为了解决这一问题,Uperf主动设置这些关键线程的CPU核心亲和性,适用于所有EAS平台,甚至是HMP平台。 195 | 196 | ### 预调参 197 | 198 | - Uperf模块为大多数热门硬件平台提供了调参后的配置文件,以尽可能发挥Uperf的优势 199 | - HMP平台均衡和卡顿版的`interactive`参数与HMP负载迁移阈值由改进的[Project WIPE v2](https://github.com/yc9559/wipe-v2)提供,费电模式采用固定在功耗拐点的频点提供最稳定持续的性能 200 | - EAS平台的频点选择综合了SOC功耗模型和常见负载的性能需求,由一套固定策略生成 201 | - 三星、sdm845以及移植的EAS平台,由于缺少关键内核功能采用传统的调参方法,即普通场景不提供过高的性能容量 202 | - sdm845以后的高通EAS平台,采用调整后性能需求-性能容量模型,见下图 203 | 204 | ![调整后性能需求-性能容量模型](media/adjusted_demand_capacity_relation.png) 205 | 206 | 假设系统负载只由单个任务贡献。EAS默认的方式由于`schedutil`总是预留25%性能余量,而SOC的不同频点的能耗比表现不同,越接近最大频率能耗比越低,EAS的默认策略会导致较高负载时最大频率占比偏大。从现实负载变化的规律来看,25%性能余量并不总是够用,负载较低时容易产生大的波动,负载较高时性能需求反而是相对稳定的。从SOC的功耗模型和现实负载变化的规律来看,负载较低时由于波动值的相对百分比较大应该留出更大的性能余量,SOC的低频段一般能耗比差别不大,功耗负面影响不大;负载较高时由于波动值的相对百分比较小应该留出较小的性能余量,SOC的高频段的每个频点之间的能耗比差别比较明显,功耗正面影响较大。 207 | 208 | ### 外围改进 209 | 210 | 本模块除了Uperf本体以及SfAnalysis注入,还配合一些外围的改进共同改进用户体验。 211 | - Uperf启动前其他参数统一化,包括: 212 | - schedtune置零 213 | - 使用CFQ调速器,降低多任务运行时前台任务的IO延迟 214 | - 降低非前台APP的IO带宽占用权重 215 | - 设置与UI性能密切相关的系统进程到顶层APP的cgroup分组 216 | - 固定于过渡动画相关的线程到大核 217 | - 减少大部分传感器线程在大核的唤醒 218 | - 禁用大多数内核态和用户态boost、热插拔 219 | - `interactive`和`schedutil`调速器、`core_ctl`、任务调度器外围参数一致化 220 | - 为指纹识别提供最大性能(EAS平台) 221 | 222 | ![为指纹识别提供最大性能](./media/fingerprint.png) 223 | 224 | ## 自定义配置文件 225 | 226 | 本项目已经为大多数热门硬件平台提供了调参后的Uperf配置文件,但总有一些情况预调参的配置不适用于你的软硬件平台,例如冷门的硬件平台、自定义的内核。此外,也有自定义现有预调参配置文件的需求,例如调高交互时的最低CPU频率、增加GPU频率范围调整。在Uperf设计之初便考虑到了这类需求,开放几乎所有的可调参数,并且在配置文件更改保存后自动重新加载,改善在手机端调试参数的效率。Magisk模块使用的配置文件位于`/sdcard/yc/uperf/cfg_uperf.json`。 227 | 228 | ### 元信息 229 | 230 | ```json 231 | "meta": { 232 | "name": "sdm855/sdm855+ v20200516", 233 | "author": "yc@coolapk", 234 | "features": "touch cpuload render standby sfanalysis" 235 | } 236 | ``` 237 | 238 | | 字段名 | 数据类型 | 描述 | 239 | | -------- | -------- | ---------------------------------------------- | 240 | | name | string | 配置文件的名称 | 241 | | author | string | 配置文件的作者信息 | 242 | | features | string | 配置文件支持的功能列表,目前是保留字段不起作用 | 243 | 244 | `name`与`author`在日志以如下方式体现: 245 | ``` 246 | [13:03:33][I] CfgMgr: Using [sdm855/sdm855+ v20200516] by [yc@coolapk] 247 | ``` 248 | 249 | ### 全局参数 250 | 251 | ```json 252 | "common": { 253 | "switchInode": "/sdcard/yc/uperf/cur_powermode", 254 | "verboseLog": false, 255 | "uxAffinity": true, 256 | "stateTransThd": { 257 | "heavyLoad": 1500, 258 | "idleLoad": 1000, 259 | "requestBurstSlack": 3000 260 | }, 261 | "dispatch": [ 262 | { 263 | "hint": "None", 264 | "action": "normal", 265 | "maxDuration": 0 266 | }, 267 | { 268 | "hint": "Tap", 269 | "action": "interaction", 270 | "maxDuration": 1500 271 | }, 272 | ... 273 | ] 274 | } 275 | ``` 276 | 277 | | 字段名 | 数据类型 | 描述 | 278 | | ----------------- | -------- | ------------------------------------------------------------------------------- | 279 | | switchInode | string | 接收性能模式切换的inode节点 | 280 | | verboseLog | bool | 开启详细日志,用于调试Hint切换 | 281 | | uxAffinity | bool | 开启UX线程自动设置,固定高优先级的UX线程到大核,并限制低优先级线程的需求响应 | 282 | | heavyLoad | int | 进入重负载的系统负载阈值,详见[重负载跟踪与限制](#重负载跟踪与限制) | 283 | | idleLoad | int | 退出重负载的系统负载阈值,详见[重负载跟踪与限制](#重负载跟踪与限制) | 284 | | requestBurstSlack | int | 单位毫秒,响应新的重负载请求前的延时,详见[重负载跟踪与限制](#重负载跟踪与限制) | 285 | | hint | string | 对应到Uperf内部支持的Hint类型 | 286 | | action | string | 绑定的动作名称,可以自定义 | 287 | | maxDuration | int | 单位毫秒,动作保持的最大时长 | 288 | 289 | 在Uperf启动时会读取`switchInode`对应路径的文件获取默认性能模式,在日志以如下方式体现: 290 | ``` 291 | [13:03:33][I] CfgMgr: Read default powermode from /sdcard/yc/uperf/cur_powermode 292 | [13:03:33][I] CfgMgr: Powermode "(null)" -> "balance" 293 | ``` 294 | `switchInode`对应路径的文件,监听新模式名称的写入完成模式切换: 295 | ```shell 296 | echo "powersave" > /sdcard/yc/uperf/cur_powermode 297 | ``` 298 | 在日志以如下方式体现: 299 | ``` 300 | [13:06:45][I] CfgMgr: Powermode "balance" -> "powersave" 301 | ``` 302 | 303 | `dispatch`的绑定关系,在日志以如下方式体现: 304 | ``` 305 | [13:03:33][I] CfgMgr: Bind HintNone -> normal 306 | [13:03:33][I] CfgMgr: Bind HintTap -> interaction 307 | [13:03:33][I] CfgMgr: Bind HintSwipe -> interaction 308 | [13:03:33][I] CfgMgr: Bind HintHeavyLoad -> heavyLoad 309 | [13:03:33][I] CfgMgr: Bind HintAndroidAM -> amSwitch 310 | [13:03:33][I] CfgMgr: Bind HintStandby -> standby 311 | [13:03:33][I] CfgMgr: Bind HintSflag -> sfLag 312 | ``` 313 | 314 | `UxAffinity`和`SfAnalysis`这两项功能在日志以如下方式体现: 315 | ``` 316 | [13:03:33][I] CfgMgr: UX affinity enabled 317 | ... 318 | [13:03:36][I] SfAnalysis: Surfaceflinger analysis connected 319 | ``` 320 | 321 | ### 平台信息 322 | 323 | ```json 324 | "platform": { 325 | "clusterCpuId": [ 326 | 0, 327 | 4, 328 | 7 329 | ], 330 | "efficiency": [ 331 | 120, 332 | 120, 333 | 120, 334 | 120, 335 | 220, 336 | 220, 337 | 220, 338 | 240 339 | ], 340 | "knobs": [ 341 | { 342 | "name": "cpuFreqMax", 343 | "path": "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", 344 | "type": "cpufreq", 345 | "enable": true 346 | }, 347 | ... 348 | ] 349 | } 350 | ``` 351 | 352 | | 字段名 | 数据类型 | 描述 | 353 | | ------------ | ----------- | --------------------------------------------------------------------- | 354 | | clusterCpuId | int list | 多集群CPU每个集群的首个CPU ID | 355 | | efficiency | int list | 每个CPU核心的的相对同频性能,以Cortex-A53@1.0g为100,顺序与CPU ID对应 | 356 | | knobs | object list | `sysfs`节点列表 | 357 | 358 | `knobs`中的每个对象为`knob`,有以下属性: 359 | | 字段名 | 数据类型 | 描述 | 360 | | ------ | -------- | -------------------------------------- | 361 | | name | string | `sysfs`节点名称 | 362 | | path | string | `sysfs`节点路径 | 363 | | type | string | `sysfs`节点类型,详见[写入器](#写入器) | 364 | | enable | bool | 是否启用,方便调试时一键禁用 | 365 | 366 | 当`enable`字段为false时,在日志以如下方式体现: 367 | ``` 368 | [13:03:33][I] CfgMgr: Ignored root/platform/knobs/topCSProcs [Disabled by config file] 369 | ``` 370 | 371 | 当`path`字段对应的`sysfs`节点不存在或者不可写入时,在日志以如下方式体现: 372 | ``` 373 | [13:03:33][I] CfgMgr: Ignored root/platform/knobs/bigHifreq [Path is not writable] 374 | ``` 375 | 376 | ### 性能模式参数 377 | 378 | ```json 379 | "powermodes": [ 380 | { 381 | "name": "balance", 382 | "actions": { 383 | "interaction": { 384 | "cpuFreqMax": "18,18,22", 385 | "cpuFreqMin": "10,10,8", 386 | "cpuLoadBoost": "0,0,0,0,0,0,0,0", 387 | "fgCpus": "0-3", 388 | "topCSProcs": "com.android.systemui,system_server", 389 | "fgSTProcs": "system_server", 390 | "ddrBwMax": "6000", 391 | "ddrBwMin": "2500", 392 | "uxAffinity": "1" 393 | }, 394 | ... 395 | }, 396 | ... 397 | }, 398 | ... 399 | ] 400 | ``` 401 | 402 | | 字段名 | 数据类型 | 描述 | 403 | | ---------- | -------- | ----------------------------------------- | 404 | | name | string | 可自定义,用于备份调参的多个版本 | 405 | | 动作名称 | string | 与`common/dispatch`中定义的动作名对应 | 406 | | `knob`名称 | string | 与`platform/knobs`中定义的`sysfs`节点名称 | 407 | | `knob`值 | string | 值的格式详见[写入器](#写入器) | 408 | 409 | 一个动作应该为所有在`platform/knobs`定义的`knob`设置值。某些时候需要故意跳过某些值的设定,或者复用大部分前一动作的设定值,可以省略部分`knob`设置值,但不能全部。Uperf在加载配置文件时会提示哪些值没有设定会被跳过,在日志以如下方式体现: 410 | ``` 411 | [13:03:33][I] CfgMgr: Ignored knobs in action root/powermodes/balance/actions/amSwitch: 412 | [13:03:33][I] CfgMgr: cpuFreqMin llccBwMax llccBwMin ddrBwMax ddrBwMin l3LatBig ddrLatBig 413 | ``` 414 | 415 | ### 示例 416 | 417 | 利用Uperf为交互和重负载添加关闭UFS节能,以此降低性能关键场景的IO瓶颈问题。 418 | 419 | UFS节能开关的`sysfs`节点路径为`/sys/devices/platform/soc/1d84000.ufshc/clkgate_enable`,接收字符串类型写入,写入"0"为关闭UFS节能,写入"1"为开启UFS节能,把这一节点取名为`ufsClkGateEnable`。在配置文件添加如下文本完成`knob`定义: 420 | ```json 421 | "platform": { 422 | ... 423 | "knobs": [ 424 | ... 425 | { 426 | "name": "ufsClkGateEnable", 427 | "path": "/sys/devices/platform/soc/1d84000.ufshc/clkgate_enable", 428 | "type": "string", 429 | "enable": true, 430 | "note": "UFS时钟门开关" 431 | }, 432 | ... 433 | ] 434 | } 435 | ``` 436 | 437 | 根据[情景识别](#情景识别)中的定义,交互的hint名称为`Tap`和`Swipe`,重负载的hint名称为`HeavyLoad`。 438 | ```json 439 | "dispatch": [ 440 | ... 441 | { 442 | "hint": "Tap", 443 | "action": "interaction", 444 | "maxDuration": 1500 445 | }, 446 | { 447 | "hint": "Swipe", 448 | "action": "interaction", 449 | "maxDuration": 3000 450 | }, 451 | { 452 | "hint": "HeavyLoad", 453 | "action": "heavyLoad", 454 | "maxDuration": 2000 455 | }, 456 | ... 457 | } 458 | ``` 459 | 460 | 根据配置文件内定义的hint与动作的绑定关系,需要给动作`interaction`和`heavyLoad`设置关闭UFS节能,其他动作保持开启UFS节能。在配置文件添加如下文本完成动作定义: 461 | ```json 462 | "powermodes": [ 463 | { 464 | "name": "balance", 465 | "actions": { 466 | "normal": { 467 | ... 468 | "ufsClkGateEnable": "1", 469 | ... 470 | }, 471 | "interaction": { 472 | ... 473 | "ufsClkGateEnable": "0", 474 | ... 475 | }, 476 | "heavyLoad": { 477 | ... 478 | "ufsClkGateEnable": "0", 479 | ... 480 | }, 481 | "amSwitch": { 482 | ... 483 | }, 484 | "standby": { 485 | ... 486 | "ufsClkGateEnable": "1", 487 | ... 488 | }, 489 | "sfLag": { 490 | ... 491 | }, 492 | }, 493 | }, 494 | { 495 | "name": "powersave", 496 | "actions": { 497 | "normal": { 498 | ... 499 | "ufsClkGateEnable": "1", 500 | ... 501 | }, 502 | ... 503 | }, 504 | }, 505 | ... 506 | ] 507 | ``` 508 | 509 | 更改配置文件后保存,Uperf会自动创建新的子进程加载新的配置文件,如果新的配置文件格式存在问题,会终止新的子进程保留老的子进程。接下来验证配置文件中设定动作是否能如期执行,对应路径的值是否发生更改。 510 | 511 | ## 致谢 512 | 513 | 感谢以下用户或项目的源码对本项目的帮助: 514 | - [@AndroidDumps](https://github.com/AndroidDumps) 515 | - [TinyInjector](https://github.com/shunix/TinyInjector) 516 | - [xHook](https://github.com/iqiyi/xHook) 517 | - [@cjybyjk](https://github.com/cjybyjk) 518 | - [@SatySatsZB](https://github.com/SatySatsZB) 519 | - [@osm0sis](https://github.com/osm0sis) 520 | - @YMJ 521 | 522 | 感谢以下用户的测试反馈和错误定位: 523 | - @HEX_Stan(coolapk) 524 | - @僞裝灬(coolapk) 525 | - @Yoooooo(coolapk) 526 | - @我愿你安i(coolapk) 527 | - @鹰雏(coolapk) 528 | - @yishisanren(coolapk) 529 | - @asd821385525(coolapk) 530 | - @倚楼醉听曲(coolapk) 531 | - @NepPoseidon(coolapk) 532 | - @寻光丿STLD(coolapk) 533 | - @比企谷の雪乃(coolapk) 534 | - @非洲咸鱼(coolapk) 535 | - @哔哩哔哩弹慕网(coolapk) 536 | - @我心飞翔的安(coolapk) 537 | - @浏泽仔(coolapk) 538 | - @〇MH1031(coolapk) 539 | - @今天我头条了吗(coolapk) 540 | - @瓜瓜皮(coolapk) 541 | - @Universes(coolapk) 542 | - @Superpinkcat(coolapk) 543 | - @asto18089(coolapk) 544 | - @顺其自然的肥肉(coolapk) 545 | - @酷斗吧(coolapk) 546 | - @何为永恒(coolapk) 547 | - @我为啥叫这个(coolapk) 548 | - @goddard(coolapk) 549 | - @正果sss(coolapk) 550 | - @Cowen(coolapk) 551 | - @瞬光飞翔(coolapk) 552 | - @kuiot(coolapk) 553 | - @常凯申将军(coolapk) 554 | - emptybot08(github) 555 | - ahzhi(github) 556 | - Saumer7(github) 557 | 558 | ## 捐赠 559 | 560 | 如果你实在愿意,下面是感谢云讨饭通道(备注写上你的ID和来源平台): 561 | 562 | ![](media/alipay-qr.png) -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | uperf 2 | 3 | THIRD-PARTY SOFTWARE NOTICES AND INFORMATION 4 | Do Not Translate or Localize 5 | 6 | This project incorporates components from the projects listed below. The original copyright notices and the licenses under are set forth below. Reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise. 7 | 8 | 1. jpcre2/jpcre2 version 10.32.01 (https://github.com/jpcre2/jpcre2) 9 | 2. nlohmann/json version 3.10.4 (https://github.com/nlohmann/json) 10 | 3. PhilipHazel/pcre2 version 10.39 (https://github.com/PhilipHazel/pcre2) 11 | 4. eliaskosunen/scnlib version 0.4.0 (https://github.com/eliaskosunen/scnlib) 12 | 5. gabime/spdlog version 1.9.2 (https://github.com/gabime/spdlog) 13 | 6. osm0sis/android-busybox-ndk 1.31.1 (https://github.com/osm0sis/android-busybox-ndk) 14 | 15 | %% jpcre2/jpcre2 NOTICES AND INFORMATION BEGIN HERE 16 | ========================================= 17 | JPCRE2 LICENCE 18 | ------------- 19 | 20 | JPCRE2 is a wrapper for PCRE2 library which supports regular expressions whose syntax 21 | and semantics are as close as possible to those of the Perl 5 language. 22 | 23 | JPCRE2 is distributed under the terms of the "BSD" licence, as 24 | specified below. The test source files (prefixed 'test' in their name) 25 | are not copyrighted and are in the public domain. 26 | 27 | The basic library functions are written in C++ and are dependent upon the 28 | original PCRE2 library. 29 | 30 | THE BASIC LIBRARY FUNCTIONS/CLASSES 31 | ----------------------------------- 32 | 33 | Written by: Md Jahidul Hamid 34 | Email local part: jahidulhamid 35 | Email domain: yahoo.com 36 | 37 | 38 | Copyright (c) Md Jahidul Hamid. 39 | 40 | 41 | THE "BSD" LICENCE 42 | ----------------- 43 | 44 | Redistribution and use in source and binary forms, with or without 45 | modification, are permitted provided that the following conditions are met: 46 | 47 | * Redistributions of source code must retain the above copyright notice, 48 | this list of conditions and the following disclaimer. 49 | 50 | * Redistributions in binary form must reproduce the above copyright 51 | notice, this list of conditions and the following disclaimer in the 52 | documentation and/or other materials provided with the distribution. 53 | 54 | * The names of its contributors may not be used to endorse or promote 55 | products derived from this software without specific prior written 56 | permission. 57 | 58 | Disclaimer: 59 | 60 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 61 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 62 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 63 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 64 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 65 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 66 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 67 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 68 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 69 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 70 | POSSIBILITY OF SUCH DAMAGE. 71 | 72 | End 73 | ========================================= 74 | END OF jpcre2/jpcre2 NOTICES AND INFORMATION 75 | 76 | %% nlohmann/json NOTICES AND INFORMATION BEGIN HERE 77 | ========================================= 78 | MIT License 79 | 80 | Copyright (c) 2013-2022 Niels Lohmann 81 | 82 | Permission is hereby granted, free of charge, to any person obtaining a copy 83 | of this software and associated documentation files (the "Software"), to deal 84 | in the Software without restriction, including without limitation the rights 85 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 86 | copies of the Software, and to permit persons to whom the Software is 87 | furnished to do so, subject to the following conditions: 88 | 89 | The above copyright notice and this permission notice shall be included in all 90 | copies or substantial portions of the Software. 91 | 92 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 93 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 94 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 95 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 96 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 97 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 98 | SOFTWARE. 99 | ========================================= 100 | END OF nlohmann/json NOTICES AND INFORMATION 101 | 102 | %% PhilipHazel/pcre2 NOTICES AND INFORMATION BEGIN HERE 103 | ========================================= 104 | PCRE2 LICENCE 105 | ------------- 106 | 107 | PCRE2 is a library of functions to support regular expressions whose syntax 108 | and semantics are as close as possible to those of the Perl 5 language. 109 | 110 | Releases 10.00 and above of PCRE2 are distributed under the terms of the "BSD" 111 | licence, as specified below, with one exemption for certain binary 112 | redistributions. The documentation for PCRE2, supplied in the "doc" directory, 113 | is distributed under the same terms as the software itself. The data in the 114 | testdata directory is not copyrighted and is in the public domain. 115 | 116 | The basic library functions are written in C and are freestanding. Also 117 | included in the distribution is a just-in-time compiler that can be used to 118 | optimize pattern matching. This is an optional feature that can be omitted when 119 | the library is built. 120 | 121 | 122 | THE BASIC LIBRARY FUNCTIONS 123 | --------------------------- 124 | 125 | Written by: Philip Hazel 126 | Email local part: Philip.Hazel 127 | Email domain: gmail.com 128 | 129 | Retired from University of Cambridge Computing Service, 130 | Cambridge, England. 131 | 132 | Copyright (c) 1997-2021 University of Cambridge 133 | All rights reserved. 134 | 135 | 136 | PCRE2 JUST-IN-TIME COMPILATION SUPPORT 137 | -------------------------------------- 138 | 139 | Written by: Zoltan Herczeg 140 | Email local part: hzmester 141 | Email domain: freemail.hu 142 | 143 | Copyright(c) 2010-2021 Zoltan Herczeg 144 | All rights reserved. 145 | 146 | 147 | STACK-LESS JUST-IN-TIME COMPILER 148 | -------------------------------- 149 | 150 | Written by: Zoltan Herczeg 151 | Email local part: hzmester 152 | Email domain: freemail.hu 153 | 154 | Copyright(c) 2009-2021 Zoltan Herczeg 155 | All rights reserved. 156 | 157 | 158 | THE "BSD" LICENCE 159 | ----------------- 160 | 161 | Redistribution and use in source and binary forms, with or without 162 | modification, are permitted provided that the following conditions are met: 163 | 164 | * Redistributions of source code must retain the above copyright notices, 165 | this list of conditions and the following disclaimer. 166 | 167 | * Redistributions in binary form must reproduce the above copyright 168 | notices, this list of conditions and the following disclaimer in the 169 | documentation and/or other materials provided with the distribution. 170 | 171 | * Neither the name of the University of Cambridge nor the names of any 172 | contributors may be used to endorse or promote products derived from this 173 | software without specific prior written permission. 174 | 175 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 176 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 177 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 179 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 180 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 181 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 182 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 183 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 184 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 185 | POSSIBILITY OF SUCH DAMAGE. 186 | 187 | 188 | EXEMPTION FOR BINARY LIBRARY-LIKE PACKAGES 189 | ------------------------------------------ 190 | 191 | The second condition in the BSD licence (covering binary redistributions) does 192 | not apply all the way down a chain of software. If binary package A includes 193 | PCRE2, it must respect the condition, but if package B is software that 194 | includes package A, the condition is not imposed on package B unless it uses 195 | PCRE2 independently. 196 | 197 | End 198 | ========================================= 199 | END OF PhilipHazel/pcre2 NOTICES AND INFORMATION 200 | 201 | %% eliaskosunen/scnlib NOTICES AND INFORMATION BEGIN HERE 202 | ========================================= 203 | Apache License 204 | Version 2.0, January 2004 205 | http://www.apache.org/licenses/ 206 | 207 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 208 | 209 | 1. Definitions. 210 | 211 | "License" shall mean the terms and conditions for use, reproduction, 212 | and distribution as defined by Sections 1 through 9 of this document. 213 | 214 | "Licensor" shall mean the copyright owner or entity authorized by 215 | the copyright owner that is granting the License. 216 | 217 | "Legal Entity" shall mean the union of the acting entity and all 218 | other entities that control, are controlled by, or are under common 219 | control with that entity. For the purposes of this definition, 220 | "control" means (i) the power, direct or indirect, to cause the 221 | direction or management of such entity, whether by contract or 222 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 223 | outstanding shares, or (iii) beneficial ownership of such entity. 224 | 225 | "You" (or "Your") shall mean an individual or Legal Entity 226 | exercising permissions granted by this License. 227 | 228 | "Source" form shall mean the preferred form for making modifications, 229 | including but not limited to software source code, documentation 230 | source, and configuration files. 231 | 232 | "Object" form shall mean any form resulting from mechanical 233 | transformation or translation of a Source form, including but 234 | not limited to compiled object code, generated documentation, 235 | and conversions to other media types. 236 | 237 | "Work" shall mean the work of authorship, whether in Source or 238 | Object form, made available under the License, as indicated by a 239 | copyright notice that is included in or attached to the work 240 | (an example is provided in the Appendix below). 241 | 242 | "Derivative Works" shall mean any work, whether in Source or Object 243 | form, that is based on (or derived from) the Work and for which the 244 | editorial revisions, annotations, elaborations, or other modifications 245 | represent, as a whole, an original work of authorship. For the purposes 246 | of this License, Derivative Works shall not include works that remain 247 | separable from, or merely link (or bind by name) to the interfaces of, 248 | the Work and Derivative Works thereof. 249 | 250 | "Contribution" shall mean any work of authorship, including 251 | the original version of the Work and any modifications or additions 252 | to that Work or Derivative Works thereof, that is intentionally 253 | submitted to Licensor for inclusion in the Work by the copyright owner 254 | or by an individual or Legal Entity authorized to submit on behalf of 255 | the copyright owner. For the purposes of this definition, "submitted" 256 | means any form of electronic, verbal, or written communication sent 257 | to the Licensor or its representatives, including but not limited to 258 | communication on electronic mailing lists, source code control systems, 259 | and issue tracking systems that are managed by, or on behalf of, the 260 | Licensor for the purpose of discussing and improving the Work, but 261 | excluding communication that is conspicuously marked or otherwise 262 | designated in writing by the copyright owner as "Not a Contribution." 263 | 264 | "Contributor" shall mean Licensor and any individual or Legal Entity 265 | on behalf of whom a Contribution has been received by Licensor and 266 | subsequently incorporated within the Work. 267 | 268 | 2. Grant of Copyright License. Subject to the terms and conditions of 269 | this License, each Contributor hereby grants to You a perpetual, 270 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 271 | copyright license to reproduce, prepare Derivative Works of, 272 | publicly display, publicly perform, sublicense, and distribute the 273 | Work and such Derivative Works in Source or Object form. 274 | 275 | 3. Grant of Patent License. Subject to the terms and conditions of 276 | this License, each Contributor hereby grants to You a perpetual, 277 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 278 | (except as stated in this section) patent license to make, have made, 279 | use, offer to sell, sell, import, and otherwise transfer the Work, 280 | where such license applies only to those patent claims licensable 281 | by such Contributor that are necessarily infringed by their 282 | Contribution(s) alone or by combination of their Contribution(s) 283 | with the Work to which such Contribution(s) was submitted. If You 284 | institute patent litigation against any entity (including a 285 | cross-claim or counterclaim in a lawsuit) alleging that the Work 286 | or a Contribution incorporated within the Work constitutes direct 287 | or contributory patent infringement, then any patent licenses 288 | granted to You under this License for that Work shall terminate 289 | as of the date such litigation is filed. 290 | 291 | 4. Redistribution. You may reproduce and distribute copies of the 292 | Work or Derivative Works thereof in any medium, with or without 293 | modifications, and in Source or Object form, provided that You 294 | meet the following conditions: 295 | 296 | (a) You must give any other recipients of the Work or 297 | Derivative Works a copy of this License; and 298 | 299 | (b) You must cause any modified files to carry prominent notices 300 | stating that You changed the files; and 301 | 302 | (c) You must retain, in the Source form of any Derivative Works 303 | that You distribute, all copyright, patent, trademark, and 304 | attribution notices from the Source form of the Work, 305 | excluding those notices that do not pertain to any part of 306 | the Derivative Works; and 307 | 308 | (d) If the Work includes a "NOTICE" text file as part of its 309 | distribution, then any Derivative Works that You distribute must 310 | include a readable copy of the attribution notices contained 311 | within such NOTICE file, excluding those notices that do not 312 | pertain to any part of the Derivative Works, in at least one 313 | of the following places: within a NOTICE text file distributed 314 | as part of the Derivative Works; within the Source form or 315 | documentation, if provided along with the Derivative Works; or, 316 | within a display generated by the Derivative Works, if and 317 | wherever such third-party notices normally appear. The contents 318 | of the NOTICE file are for informational purposes only and 319 | do not modify the License. You may add Your own attribution 320 | notices within Derivative Works that You distribute, alongside 321 | or as an addendum to the NOTICE text from the Work, provided 322 | that such additional attribution notices cannot be construed 323 | as modifying the License. 324 | 325 | You may add Your own copyright statement to Your modifications and 326 | may provide additional or different license terms and conditions 327 | for use, reproduction, or distribution of Your modifications, or 328 | for any such Derivative Works as a whole, provided Your use, 329 | reproduction, and distribution of the Work otherwise complies with 330 | the conditions stated in this License. 331 | 332 | 5. Submission of Contributions. Unless You explicitly state otherwise, 333 | any Contribution intentionally submitted for inclusion in the Work 334 | by You to the Licensor shall be under the terms and conditions of 335 | this License, without any additional terms or conditions. 336 | Notwithstanding the above, nothing herein shall supersede or modify 337 | the terms of any separate license agreement you may have executed 338 | with Licensor regarding such Contributions. 339 | 340 | 6. Trademarks. This License does not grant permission to use the trade 341 | names, trademarks, service marks, or product names of the Licensor, 342 | except as required for reasonable and customary use in describing the 343 | origin of the Work and reproducing the content of the NOTICE file. 344 | 345 | 7. Disclaimer of Warranty. Unless required by applicable law or 346 | agreed to in writing, Licensor provides the Work (and each 347 | Contributor provides its Contributions) on an "AS IS" BASIS, 348 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 349 | implied, including, without limitation, any warranties or conditions 350 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 351 | PARTICULAR PURPOSE. You are solely responsible for determining the 352 | appropriateness of using or redistributing the Work and assume any 353 | risks associated with Your exercise of permissions under this License. 354 | 355 | 8. Limitation of Liability. In no event and under no legal theory, 356 | whether in tort (including negligence), contract, or otherwise, 357 | unless required by applicable law (such as deliberate and grossly 358 | negligent acts) or agreed to in writing, shall any Contributor be 359 | liable to You for damages, including any direct, indirect, special, 360 | incidental, or consequential damages of any character arising as a 361 | result of this License or out of the use or inability to use the 362 | Work (including but not limited to damages for loss of goodwill, 363 | work stoppage, computer failure or malfunction, or any and all 364 | other commercial damages or losses), even if such Contributor 365 | has been advised of the possibility of such damages. 366 | 367 | 9. Accepting Warranty or Additional Liability. While redistributing 368 | the Work or Derivative Works thereof, You may choose to offer, 369 | and charge a fee for, acceptance of support, warranty, indemnity, 370 | or other liability obligations and/or rights consistent with this 371 | License. However, in accepting such obligations, You may act only 372 | on Your own behalf and on Your sole responsibility, not on behalf 373 | of any other Contributor, and only if You agree to indemnify, 374 | defend, and hold each Contributor harmless for any liability 375 | incurred by, or claims asserted against, such Contributor by reason 376 | of your accepting any such warranty or additional liability. 377 | 378 | END OF TERMS AND CONDITIONS 379 | 380 | APPENDIX: How to apply the Apache License to your work. 381 | 382 | To apply the Apache License to your work, attach the following 383 | boilerplate notice, with the fields enclosed by brackets "[]" 384 | replaced with your own identifying information. (Don't include 385 | the brackets!) The text should be enclosed in the appropriate 386 | comment syntax for the file format. We also recommend that a 387 | file or class name and description of purpose be included on the 388 | same "printed page" as the copyright notice for easier 389 | identification within third-party archives. 390 | 391 | Copyright [yyyy] [name of copyright owner] 392 | 393 | Licensed under the Apache License, Version 2.0 (the "License"); 394 | you may not use this file except in compliance with the License. 395 | You may obtain a copy of the License at 396 | 397 | http://www.apache.org/licenses/LICENSE-2.0 398 | 399 | Unless required by applicable law or agreed to in writing, software 400 | distributed under the License is distributed on an "AS IS" BASIS, 401 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 402 | See the License for the specific language governing permissions and 403 | limitations under the License. 404 | ========================================= 405 | END OF eliaskosunen/scnlib NOTICES AND INFORMATION 406 | 407 | %% gabime/spdlog NOTICES AND INFORMATION BEGIN HERE 408 | ========================================= 409 | The MIT License (MIT) 410 | 411 | Copyright (c) 2016 Gabi Melman. 412 | 413 | Permission is hereby granted, free of charge, to any person obtaining a copy 414 | of this software and associated documentation files (the "Software"), to deal 415 | in the Software without restriction, including without limitation the rights 416 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 417 | copies of the Software, and to permit persons to whom the Software is 418 | furnished to do so, subject to the following conditions: 419 | 420 | The above copyright notice and this permission notice shall be included in 421 | all copies or substantial portions of the Software. 422 | 423 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 424 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 425 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 426 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 427 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 428 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 429 | THE SOFTWARE. 430 | 431 | -- NOTE: Third party dependency used by this software -- 432 | This software depends on the fmt lib (MIT License), 433 | and users must comply to its license: https://github.com/fmtlib/fmt/blob/master/LICENSE.rst 434 | ========================================= 435 | END OF gabime/spdlog NOTICES AND INFORMATION 436 | 437 | %% osm0sis/android-busybox-ndk NOTICES AND INFORMATION BEGIN HERE 438 | ========================================= 439 | --- A note on GPL versions 440 | 441 | BusyBox is distributed under version 2 of the General Public License (included 442 | in its entirety, below). Version 2 is the only version of this license which 443 | this version of BusyBox (or modified versions derived from this one) may be 444 | distributed under. 445 | 446 | ------------------------------------------------------------------------ 447 | GNU GENERAL PUBLIC LICENSE 448 | Version 2, June 1991 449 | 450 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 451 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 452 | Everyone is permitted to copy and distribute verbatim copies 453 | of this license document, but changing it is not allowed. 454 | 455 | Preamble 456 | 457 | The licenses for most software are designed to take away your 458 | freedom to share and change it. By contrast, the GNU General Public 459 | License is intended to guarantee your freedom to share and change free 460 | software--to make sure the software is free for all its users. This 461 | General Public License applies to most of the Free Software 462 | Foundation's software and to any other program whose authors commit to 463 | using it. (Some other Free Software Foundation software is covered by 464 | the GNU Library General Public License instead.) You can apply it to 465 | your programs, too. 466 | 467 | When we speak of free software, we are referring to freedom, not 468 | price. Our General Public Licenses are designed to make sure that you 469 | have the freedom to distribute copies of free software (and charge for 470 | this service if you wish), that you receive source code or can get it 471 | if you want it, that you can change the software or use pieces of it 472 | in new free programs; and that you know you can do these things. 473 | 474 | To protect your rights, we need to make restrictions that forbid 475 | anyone to deny you these rights or to ask you to surrender the rights. 476 | These restrictions translate to certain responsibilities for you if you 477 | distribute copies of the software, or if you modify it. 478 | 479 | For example, if you distribute copies of such a program, whether 480 | gratis or for a fee, you must give the recipients all the rights that 481 | you have. You must make sure that they, too, receive or can get the 482 | source code. And you must show them these terms so they know their 483 | rights. 484 | 485 | We protect your rights with two steps: (1) copyright the software, and 486 | (2) offer you this license which gives you legal permission to copy, 487 | distribute and/or modify the software. 488 | 489 | Also, for each author's protection and ours, we want to make certain 490 | that everyone understands that there is no warranty for this free 491 | software. If the software is modified by someone else and passed on, we 492 | want its recipients to know that what they have is not the original, so 493 | that any problems introduced by others will not reflect on the original 494 | authors' reputations. 495 | 496 | Finally, any free program is threatened constantly by software 497 | patents. We wish to avoid the danger that redistributors of a free 498 | program will individually obtain patent licenses, in effect making the 499 | program proprietary. To prevent this, we have made it clear that any 500 | patent must be licensed for everyone's free use or not licensed at all. 501 | 502 | The precise terms and conditions for copying, distribution and 503 | modification follow. 504 | 505 | GNU GENERAL PUBLIC LICENSE 506 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 507 | 508 | 0. This License applies to any program or other work which contains 509 | a notice placed by the copyright holder saying it may be distributed 510 | under the terms of this General Public License. The "Program", below, 511 | refers to any such program or work, and a "work based on the Program" 512 | means either the Program or any derivative work under copyright law: 513 | that is to say, a work containing the Program or a portion of it, 514 | either verbatim or with modifications and/or translated into another 515 | language. (Hereinafter, translation is included without limitation in 516 | the term "modification".) Each licensee is addressed as "you". 517 | 518 | Activities other than copying, distribution and modification are not 519 | covered by this License; they are outside its scope. The act of 520 | running the Program is not restricted, and the output from the Program 521 | is covered only if its contents constitute a work based on the 522 | Program (independent of having been made by running the Program). 523 | Whether that is true depends on what the Program does. 524 | 525 | 1. You may copy and distribute verbatim copies of the Program's 526 | source code as you receive it, in any medium, provided that you 527 | conspicuously and appropriately publish on each copy an appropriate 528 | copyright notice and disclaimer of warranty; keep intact all the 529 | notices that refer to this License and to the absence of any warranty; 530 | and give any other recipients of the Program a copy of this License 531 | along with the Program. 532 | 533 | You may charge a fee for the physical act of transferring a copy, and 534 | you may at your option offer warranty protection in exchange for a fee. 535 | 536 | 2. You may modify your copy or copies of the Program or any portion 537 | of it, thus forming a work based on the Program, and copy and 538 | distribute such modifications or work under the terms of Section 1 539 | above, provided that you also meet all of these conditions: 540 | 541 | a) You must cause the modified files to carry prominent notices 542 | stating that you changed the files and the date of any change. 543 | 544 | b) You must cause any work that you distribute or publish, that in 545 | whole or in part contains or is derived from the Program or any 546 | part thereof, to be licensed as a whole at no charge to all third 547 | parties under the terms of this License. 548 | 549 | c) If the modified program normally reads commands interactively 550 | when run, you must cause it, when started running for such 551 | interactive use in the most ordinary way, to print or display an 552 | announcement including an appropriate copyright notice and a 553 | notice that there is no warranty (or else, saying that you provide 554 | a warranty) and that users may redistribute the program under 555 | these conditions, and telling the user how to view a copy of this 556 | License. (Exception: if the Program itself is interactive but 557 | does not normally print such an announcement, your work based on 558 | the Program is not required to print an announcement.) 559 | 560 | These requirements apply to the modified work as a whole. If 561 | identifiable sections of that work are not derived from the Program, 562 | and can be reasonably considered independent and separate works in 563 | themselves, then this License, and its terms, do not apply to those 564 | sections when you distribute them as separate works. But when you 565 | distribute the same sections as part of a whole which is a work based 566 | on the Program, the distribution of the whole must be on the terms of 567 | this License, whose permissions for other licensees extend to the 568 | entire whole, and thus to each and every part regardless of who wrote it. 569 | 570 | Thus, it is not the intent of this section to claim rights or contest 571 | your rights to work written entirely by you; rather, the intent is to 572 | exercise the right to control the distribution of derivative or 573 | collective works based on the Program. 574 | 575 | In addition, mere aggregation of another work not based on the Program 576 | with the Program (or with a work based on the Program) on a volume of 577 | a storage or distribution medium does not bring the other work under 578 | the scope of this License. 579 | 580 | 3. You may copy and distribute the Program (or a work based on it, 581 | under Section 2) in object code or executable form under the terms of 582 | Sections 1 and 2 above provided that you also do one of the following: 583 | 584 | a) Accompany it with the complete corresponding machine-readable 585 | source code, which must be distributed under the terms of Sections 586 | 1 and 2 above on a medium customarily used for software interchange; or, 587 | 588 | b) Accompany it with a written offer, valid for at least three 589 | years, to give any third party, for a charge no more than your 590 | cost of physically performing source distribution, a complete 591 | machine-readable copy of the corresponding source code, to be 592 | distributed under the terms of Sections 1 and 2 above on a medium 593 | customarily used for software interchange; or, 594 | 595 | c) Accompany it with the information you received as to the offer 596 | to distribute corresponding source code. (This alternative is 597 | allowed only for noncommercial distribution and only if you 598 | received the program in object code or executable form with such 599 | an offer, in accord with Subsection b above.) 600 | 601 | The source code for a work means the preferred form of the work for 602 | making modifications to it. For an executable work, complete source 603 | code means all the source code for all modules it contains, plus any 604 | associated interface definition files, plus the scripts used to 605 | control compilation and installation of the executable. However, as a 606 | special exception, the source code distributed need not include 607 | anything that is normally distributed (in either source or binary 608 | form) with the major components (compiler, kernel, and so on) of the 609 | operating system on which the executable runs, unless that component 610 | itself accompanies the executable. 611 | 612 | If distribution of executable or object code is made by offering 613 | access to copy from a designated place, then offering equivalent 614 | access to copy the source code from the same place counts as 615 | distribution of the source code, even though third parties are not 616 | compelled to copy the source along with the object code. 617 | 618 | 4. You may not copy, modify, sublicense, or distribute the Program 619 | except as expressly provided under this License. Any attempt 620 | otherwise to copy, modify, sublicense or distribute the Program is 621 | void, and will automatically terminate your rights under this License. 622 | However, parties who have received copies, or rights, from you under 623 | this License will not have their licenses terminated so long as such 624 | parties remain in full compliance. 625 | 626 | 5. You are not required to accept this License, since you have not 627 | signed it. However, nothing else grants you permission to modify or 628 | distribute the Program or its derivative works. These actions are 629 | prohibited by law if you do not accept this License. Therefore, by 630 | modifying or distributing the Program (or any work based on the 631 | Program), you indicate your acceptance of this License to do so, and 632 | all its terms and conditions for copying, distributing or modifying 633 | the Program or works based on it. 634 | 635 | 6. Each time you redistribute the Program (or any work based on the 636 | Program), the recipient automatically receives a license from the 637 | original licensor to copy, distribute or modify the Program subject to 638 | these terms and conditions. You may not impose any further 639 | restrictions on the recipients' exercise of the rights granted herein. 640 | You are not responsible for enforcing compliance by third parties to 641 | this License. 642 | 643 | 7. If, as a consequence of a court judgment or allegation of patent 644 | infringement or for any other reason (not limited to patent issues), 645 | conditions are imposed on you (whether by court order, agreement or 646 | otherwise) that contradict the conditions of this License, they do not 647 | excuse you from the conditions of this License. If you cannot 648 | distribute so as to satisfy simultaneously your obligations under this 649 | License and any other pertinent obligations, then as a consequence you 650 | may not distribute the Program at all. For example, if a patent 651 | license would not permit royalty-free redistribution of the Program by 652 | all those who receive copies directly or indirectly through you, then 653 | the only way you could satisfy both it and this License would be to 654 | refrain entirely from distribution of the Program. 655 | 656 | If any portion of this section is held invalid or unenforceable under 657 | any particular circumstance, the balance of the section is intended to 658 | apply and the section as a whole is intended to apply in other 659 | circumstances. 660 | 661 | It is not the purpose of this section to induce you to infringe any 662 | patents or other property right claims or to contest validity of any 663 | such claims; this section has the sole purpose of protecting the 664 | integrity of the free software distribution system, which is 665 | implemented by public license practices. Many people have made 666 | generous contributions to the wide range of software distributed 667 | through that system in reliance on consistent application of that 668 | system; it is up to the author/donor to decide if he or she is willing 669 | to distribute software through any other system and a licensee cannot 670 | impose that choice. 671 | 672 | This section is intended to make thoroughly clear what is believed to 673 | be a consequence of the rest of this License. 674 | 675 | 8. If the distribution and/or use of the Program is restricted in 676 | certain countries either by patents or by copyrighted interfaces, the 677 | original copyright holder who places the Program under this License 678 | may add an explicit geographical distribution limitation excluding 679 | those countries, so that distribution is permitted only in or among 680 | countries not thus excluded. In such case, this License incorporates 681 | the limitation as if written in the body of this License. 682 | 683 | 9. The Free Software Foundation may publish revised and/or new versions 684 | of the General Public License from time to time. Such new versions will 685 | be similar in spirit to the present version, but may differ in detail to 686 | address new problems or concerns. 687 | 688 | Each version is given a distinguishing version number. If the Program 689 | specifies a version number of this License which applies to it and "any 690 | later version", you have the option of following the terms and conditions 691 | either of that version or of any later version published by the Free 692 | Software Foundation. If the Program does not specify a version number of 693 | this License, you may choose any version ever published by the Free Software 694 | Foundation. 695 | 696 | 10. If you wish to incorporate parts of the Program into other free 697 | programs whose distribution conditions are different, write to the author 698 | to ask for permission. For software which is copyrighted by the Free 699 | Software Foundation, write to the Free Software Foundation; we sometimes 700 | make exceptions for this. Our decision will be guided by the two goals 701 | of preserving the free status of all derivatives of our free software and 702 | of promoting the sharing and reuse of software generally. 703 | 704 | NO WARRANTY 705 | 706 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 707 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 708 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 709 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 710 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 711 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 712 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 713 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 714 | REPAIR OR CORRECTION. 715 | 716 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 717 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 718 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 719 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 720 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 721 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 722 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 723 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 724 | POSSIBILITY OF SUCH DAMAGES. 725 | 726 | END OF TERMS AND CONDITIONS 727 | 728 | How to Apply These Terms to Your New Programs 729 | 730 | If you develop a new program, and you want it to be of the greatest 731 | possible use to the public, the best way to achieve this is to make it 732 | free software which everyone can redistribute and change under these terms. 733 | 734 | To do so, attach the following notices to the program. It is safest 735 | to attach them to the start of each source file to most effectively 736 | convey the exclusion of warranty; and each file should have at least 737 | the "copyright" line and a pointer to where the full notice is found. 738 | 739 | 740 | Copyright (C) 741 | 742 | This program is free software; you can redistribute it and/or modify 743 | it under the terms of the GNU General Public License as published by 744 | the Free Software Foundation; either version 2 of the License, or 745 | (at your option) any later version. 746 | 747 | This program is distributed in the hope that it will be useful, 748 | but WITHOUT ANY WARRANTY; without even the implied warranty of 749 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 750 | GNU General Public License for more details. 751 | 752 | You should have received a copy of the GNU General Public License 753 | along with this program; if not, write to the Free Software 754 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 755 | 756 | 757 | Also add information on how to contact you by electronic and paper mail. 758 | 759 | If the program is interactive, make it output a short notice like this 760 | when it starts in an interactive mode: 761 | 762 | Gnomovision version 69, Copyright (C) year name of author 763 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 764 | This is free software, and you are welcome to redistribute it 765 | under certain conditions; type `show c' for details. 766 | 767 | The hypothetical commands `show w' and `show c' should show the appropriate 768 | parts of the General Public License. Of course, the commands you use may 769 | be called something other than `show w' and `show c'; they could even be 770 | mouse-clicks or menu items--whatever suits your program. 771 | 772 | You should also get your employer (if you work as a programmer) or your 773 | school, if any, to sign a "copyright disclaimer" for the program, if 774 | necessary. Here is a sample; alter the names: 775 | 776 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 777 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 778 | 779 | , 1 April 1989 780 | Ty Coon, President of Vice 781 | 782 | This General Public License does not permit incorporating your program into 783 | proprietary programs. If your program is a subroutine library, you may 784 | consider it more useful to permit linking proprietary applications with the 785 | library. If this is what you want to do, use the GNU Library General 786 | Public License instead of this License. 787 | ========================================= 788 | END OF osm0sis/android-busybox-ndk NOTICES AND INFORMATION 789 | --------------------------------------------------------------------------------