├── .vscode └── settings.json ├── LICENSE ├── META-INF └── com │ └── google │ └── android │ ├── update-binary │ └── updater-script ├── README.md ├── common └── apks │ └── KsuWebUI.apk ├── customize.sh ├── module.prop ├── post-fs-data.sh ├── service.sh ├── util_functions.sh └── webroot ├── apis └── deviceApi.js ├── assets ├── ResizeObserver.global.js ├── await-to-js.js ├── kernelsu │ ├── index.d.ts │ └── index.js ├── naive-ui.js ├── style.css ├── taildwind.css.js └── vue.global.js ├── hooks ├── useBatteryInfo.js └── useRealQuantity.js ├── index.html └── web.config.js /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "liveServer.settings.port": 5501 3 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ################# 4 | # Initialization 5 | ################# 6 | 7 | umask 022 8 | 9 | # echo before loading util_functions 10 | ui_print() { echo "$1"; } 11 | 12 | require_new_magisk() { 13 | ui_print "*******************************" 14 | ui_print " Please install Magisk v20.4+! " 15 | ui_print "*******************************" 16 | exit 1 17 | } 18 | 19 | ######################### 20 | # Load util_functions.sh 21 | ######################### 22 | 23 | OUTFD=$2 24 | ZIPFILE=$3 25 | 26 | mount /data 2>/dev/null 27 | 28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk 29 | . /data/adb/magisk/util_functions.sh 30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk 31 | 32 | install_module 33 | exit 0 34 | -------------------------------------------------------------------------------- /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hyper OS 电池信息 For Web UI 2 | 3 | ## 模块简介 4 | 5 | 该Magisk模块可以可视化查看有关 Hyper OS 设备的内核电池健康信息 6 | 7 | ## Web UI 开发模式和生产模式 8 | 9 | 开发阶段: 10 | 11 | 修改webroot下的web.config.js,将env修改为dev 12 | 13 | 生产阶段: 14 | 15 | 修改webroot下的web.config.js,将env修改为prod 16 | 17 | ## 其他 18 | 19 | 有关模块库的更多信息请查看Github (https://github.com/sothx/shamiko-mode-web-ui) 20 | -------------------------------------------------------------------------------- /common/apks/KsuWebUI.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sothx/hyper-battery-info-web-ui/bcf828f7154f2431b2421e458efe096916efba05/common/apks/KsuWebUI.apk -------------------------------------------------------------------------------- /customize.sh: -------------------------------------------------------------------------------- 1 | SKIPUNZIP=0 2 | . "$MODPATH"/util_functions.sh 3 | api_level_arch_detect 4 | magisk_path=/data/adb/modules/ 5 | module_id=$(grep_prop id $MODPATH/module.prop) 6 | 7 | # 基础函数 8 | add_props() { 9 | local line="$1" 10 | echo "$line" >>"$MODPATH"/system.prop 11 | } 12 | 13 | add_post_fs_data() { 14 | local line="$1" 15 | printf "\n$line\n" >>"$MODPATH"/post-fs-data.sh 16 | } 17 | 18 | key_check() { 19 | while true; do 20 | key_check=$(/system/bin/getevent -qlc 1) 21 | key_event=$(echo "$key_check" | awk '{ print $3 }' | grep 'KEY_') 22 | key_status=$(echo "$key_check" | awk '{ print $4 }') 23 | if [[ "$key_event" == *"KEY_"* && "$key_status" == "DOWN" ]]; then 24 | keycheck="$key_event" 25 | break 26 | fi 27 | done 28 | while true; do 29 | key_check=$(/system/bin/getevent -qlc 1) 30 | key_event=$(echo "$key_check" | awk '{ print $3 }' | grep 'KEY_') 31 | key_status=$(echo "$key_check" | awk '{ print $4 }') 32 | if [[ "$key_event" == *"KEY_"* && "$key_status" == "UP" ]]; then 33 | break 34 | fi 35 | done 36 | } 37 | 38 | if [[ "$KSU" == "true" ]]; then 39 | ui_print "- KernelSU 用户空间当前的版本号: $KSU_VER_CODE" 40 | ui_print "- KernelSU 内核空间当前的版本号: $KSU_KERNEL_VER_CODE" 41 | if [ "$KSU_VER_CODE" -lt 11551 ]; then 42 | ui_print "*********************************************" 43 | ui_print "- 请更新 KernelSU 到 v0.8.0+ !" 44 | abort "*********************************************" 45 | fi 46 | elif [[ "$APATCH" == "true" ]]; then 47 | ui_print "- APatch 当前的版本号: $APATCH_VER_CODE" 48 | ui_print "- APatch 当前的版本名: $APATCH_VER" 49 | ui_print "- KernelPatch 用户空间当前的版本号: $KERNELPATCH_VERSION" 50 | ui_print "- KernelPatch 内核空间当前的版本号: $KERNEL_VERSION" 51 | if [ "$APATCH_VER_CODE" -lt 10568 ]; then 52 | ui_print "*********************************************" 53 | ui_print "- 请更新 APatch 到 10568+ !" 54 | abort "*********************************************" 55 | fi 56 | else 57 | ui_print "- Magisk 版本: $MAGISK_VER_CODE" 58 | fi 59 | 60 | # KSU Web UI 61 | is_need_install_ksu_web_ui=1 62 | HAS_BEEN_INSTALLED_KsuWebUI_APK=$(pm list packages | grep io.github.a13e300.ksuwebui) 63 | if [[ "$KSU" == "true" || "$APATCH" == "true" ]]; then 64 | is_need_install_ksu_web_ui=0 65 | fi 66 | if [[ $HAS_BEEN_INSTALLED_KsuWebUI_APK == *"package:io.github.a13e300.ksuwebui"* ]]; then 67 | is_need_install_ksu_web_ui=0 68 | fi 69 | if [[ $is_need_install_ksu_web_ui == 1 ]]; then 70 | ui_print "*********************************************" 71 | ui_print "- 是否安装KsuWebUI?" 72 | ui_print "- [重要提醒]: 赋予Root权限可以可视化管理模块提供的功能" 73 | ui_print " 音量+ :是" 74 | ui_print " 音量- :否" 75 | ui_print "*********************************************" 76 | key_check 77 | if [[ "$keycheck" == "KEY_VOLUMEUP" ]]; then 78 | ui_print "- 正在为你安装KSU Web UI,请稍等~" 79 | unzip -jo "$ZIPFILE" 'common/apks/KsuWebUI.apk' -d /data/local/tmp/ &>/dev/null 80 | pm install -r /data/local/tmp/KsuWebUI.apk &>/dev/null 81 | rm -rf /data/local/tmp/KsuWebUI.apk 82 | HAS_BEEN_INSTALLED_KsuWebUI_APK=$(pm list packages | grep io.github.a13e300.ksuwebui) 83 | if [[ $HAS_BEEN_INSTALLED_KsuWebUI_APK == *"package:io.github.a13e300.ksuwebui"* ]]; then 84 | ui_print "- 好诶,KSUWebUI安装完成!" 85 | else 86 | abort "- KSUWebUI安装失败,请尝试重新安装!" 87 | abort "- 也可前往模块网盘下载单独的 KsuWebUI apk 进行手动安装!" 88 | fi 89 | else 90 | ui_print "*********************************************" 91 | ui_print "- 你选择不安装KsuWebUI" 92 | ui_print "*********************************************" 93 | fi 94 | fi 95 | 96 | 97 | ui_print "*********************************************" 98 | ui_print "- 好诶w,模块已经安装完成了,重启设备后生效" 99 | ui_print "- 功能具体支持情况以系统为准" 100 | ui_print "*********************************************" 101 | -------------------------------------------------------------------------------- /module.prop: -------------------------------------------------------------------------------- 1 | id=hyper-battery-info-web-ui 2 | name=Hyper OS 电池信息 For Web UI 3 | version=1.00.08 4 | versionCode=10008 5 | author=酷安@做梦书 6 | description=可视化查看有关Hyper OS设备电池健康的内核信息,有关模块库的更多信息请查看Github(https://github.com/sothx/hyper-battery-info-web-ui) 7 | -------------------------------------------------------------------------------- /post-fs-data.sh: -------------------------------------------------------------------------------- 1 | MODDIR=${0%/*} 2 | . "$MODDIR"/util_functions.sh 3 | api_level_arch_detect -------------------------------------------------------------------------------- /service.sh: -------------------------------------------------------------------------------- 1 | MODDIR=${0%/*} 2 | 3 | wait_login() { 4 | while [ "$(getprop sys.boot_completed)" != "1" ]; do 5 | sleep 1 6 | done 7 | 8 | while [ ! -d "/sdcard/Android" ]; do 9 | sleep 1 10 | done 11 | } 12 | wait_login 13 | 14 | . "$MODDIR"/util_functions.sh 15 | api_level_arch_detect 16 | 17 | 18 | -------------------------------------------------------------------------------- /util_functions.sh: -------------------------------------------------------------------------------- 1 | api_level_arch_detect() { 2 | API=$(getprop ro.build.version.sdk) 3 | ABI=$(getprop ro.product.cpu.abi) 4 | if [ "$ABI" = "x86" ]; then 5 | ARCH=x86 6 | ABI32=x86 7 | IS64BIT=false 8 | elif [ "$ABI" = "arm64-v8a" ]; then 9 | ARCH=arm64 10 | ABI32=armeabi-v7a 11 | IS64BIT=true 12 | elif [ "$ABI" = "x86_64" ]; then 13 | ARCH=x64 14 | ABI32=x86 15 | IS64BIT=true 16 | else 17 | ARCH=arm 18 | ABI=armeabi-v7a 19 | ABI32=armeabi-v7a 20 | IS64BIT=false 21 | fi 22 | } 23 | 24 | # 获取设备类型 25 | check_device_type() { 26 | local redmi_pad_list=$1 27 | local device_code=$2 28 | local result="xiaomi" 29 | for i in $redmi_pad_list; do 30 | if [[ "$device_code" == "$i" ]]; then 31 | result=redmi 32 | break 33 | fi 34 | done 35 | echo $result 36 | } 37 | 38 | grep_prop() { 39 | local REGEX="s/^$1=//p" 40 | shift 41 | local FILES=$@ 42 | [ -z "$FILES" ] && FILES='/system/build.prop' 43 | cat $FILES 2>/dev/null | dos2unix | sed -n "$REGEX" | head -n 1 44 | } 45 | -------------------------------------------------------------------------------- /webroot/apis/deviceApi.js: -------------------------------------------------------------------------------- 1 | import { 2 | exec 3 | } from '../assets/kernelsu/index.js'; 4 | import webConfig from '../web.config.js' 5 | export const getQcomBatteryFg1RSoc = () => { 6 | const shellCommon = `cat /sys/class/qcom-battery/fg1_rsoc`; 7 | return new Promise(async (resolve, reject) => { 8 | if (webConfig.env === 'dev') { 9 | resolve(`90`); 10 | } else { 11 | const { errno, stdout, stderr } = await exec(shellCommon); 12 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 13 | } 14 | }) 15 | }; 16 | 17 | export const getBatterySohQcom = () => { 18 | const shellCommon = `cat /sys/class/qcom-battery/soh`; 19 | return new Promise(async (resolve, reject) => { 20 | if (webConfig.env === 'dev') { 21 | resolve(`90`); 22 | } else { 23 | const { errno, stdout, stderr } = await exec(shellCommon); 24 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 25 | } 26 | }) 27 | }; 28 | 29 | export const getBatterySohXMPower = () => { 30 | const shellCommon = `cat /sys/class/xm_power/fg_master/soh`; 31 | return new Promise(async (resolve, reject) => { 32 | if (webConfig.env === 'dev') { 33 | resolve(`90`); 34 | } else { 35 | const { errno, stdout, stderr } = await exec(shellCommon); 36 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 37 | } 38 | }) 39 | }; 40 | 41 | export const getBatterySohMTK = () => { 42 | const shellCommon = `cat /sys/class/power_supply/bms/soh`; 43 | return new Promise(async (resolve, reject) => { 44 | if (webConfig.env === 'dev') { 45 | resolve(`90`); 46 | } else { 47 | const { errno, stdout, stderr } = await exec(shellCommon); 48 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 49 | } 50 | }) 51 | }; 52 | 53 | export const getBatteryChargeFullDesign = () => { 54 | const shellCommon = `cat /sys/class/power_supply/battery/charge_full_design`; 55 | return new Promise(async (resolve, reject) => { 56 | if (webConfig.env === 'dev') { 57 | resolve(`8600000`); 58 | } else { 59 | const { errno, stdout, stderr } = await exec(shellCommon); 60 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 61 | } 62 | }) 63 | }; 64 | 65 | export const getBatteryChargeFull = () => { 66 | const shellCommon = `cat /sys/class/power_supply/battery/charge_full`; 67 | return new Promise(async (resolve, reject) => { 68 | if (webConfig.env === 'dev') { 69 | resolve(`7785000`); 70 | } else { 71 | const { errno, stdout, stderr } = await exec(shellCommon); 72 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 73 | } 74 | }) 75 | }; 76 | 77 | export const getBatteryCycleCount = () => { 78 | const shellCommon = `cat /sys/class/power_supply/battery/cycle_count`; 79 | return new Promise(async (resolve, reject) => { 80 | if (webConfig.env === 'dev') { 81 | resolve(`338`); 82 | } else { 83 | const { errno, stdout, stderr } = await exec(shellCommon); 84 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 85 | } 86 | }) 87 | }; 88 | 89 | export const getCapacityRaw = () => { 90 | const shellCommon = `cat /sys/class/power_supply/bms/capacity_raw`; 91 | return new Promise(async (resolve, reject) => { 92 | if (webConfig.env === 'dev') { 93 | resolve(`9001`); 94 | } else { 95 | const { errno, stdout, stderr } = await exec(shellCommon); 96 | errno ? reject(stderr) : stdout === 'null' ? resolve('') : resolve(stdout); 97 | } 98 | }) 99 | }; 100 | -------------------------------------------------------------------------------- /webroot/assets/ResizeObserver.global.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2. 3 | * Original file: /npm/resize-observer-polyfill@1.5.1/dist/ResizeObserver.es.js 4 | * 5 | * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 | */ 7 | var t="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some((function(t,r){return t[0]===e&&(n=r,!0)})),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),r=this.__entries__[n];return r&&r[1]},e.prototype.set=function(e,n){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,r=t(n,e);~r&&n.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n0},t.prototype.connect_=function(){n&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),s?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){n&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;o.some((function(t){return!!~n.indexOf(t)}))&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),a=function(t,e){for(var n=0,r=Object.keys(e);n0},t}(),w="undefined"!=typeof WeakMap?new WeakMap:new e,g=function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=c.getInstance(),r=new m(e,n,this);w.set(this,r)};["observe","unobserve","disconnect"].forEach((function(t){g.prototype[t]=function(){var e;return(e=w.get(this))[t].apply(e,arguments)}}));var E=void 0!==r.ResizeObserver?r.ResizeObserver:g;export{E as default}; 8 | //# sourceMappingURL=/sm/4af5a6e97cdad16f73da7bf7f9838ef21d5f2e74d591fdc592b72b8598c917cf.map -------------------------------------------------------------------------------- /webroot/assets/await-to-js.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2. 3 | * Original file: /npm/await-to-js@3.0.0/dist/await-to-js.es5.js 4 | * 5 | * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 | */ 7 | function n(n,t){return n.then((function(n){return[null,n]})).catch((function(n){return t&&Object.assign(n,t),[n,void 0]}))}export{n as default,n as to}; 8 | //# sourceMappingURL=/sm/025e0847b660a188ac9b485e898ec8a4f2903168a25f025493f5ed89b5d8a5e1.map -------------------------------------------------------------------------------- /webroot/assets/kernelsu/index.d.ts: -------------------------------------------------------------------------------- 1 | interface ExecOptions { 2 | cwd?: string, 3 | env?: { [key: string]: string } 4 | } 5 | 6 | export interface ExecResults { 7 | errno: number, 8 | stdout: string, 9 | stderr: string 10 | } 11 | 12 | declare function exec(command: string): Promise; 13 | declare function exec(command: string, options: ExecOptions): Promise; 14 | 15 | interface SpawnOptions { 16 | cwd?: string, 17 | env?: { [key: string]: string } 18 | } 19 | 20 | interface Stdio { 21 | on(event: 'data', callback: (data: string) => void) 22 | } 23 | 24 | interface ChildProcess { 25 | stdout: Stdio, 26 | stderr: Stdio, 27 | on(event: 'exit', callback: (code: number) => void) 28 | on(event: 'error', callback: (err: any) => void) 29 | } 30 | 31 | declare function spawn(command: string): ChildProcess; 32 | declare function spawn(command: string, args: string[]): ChildProcess; 33 | declare function spawn(command: string, options: SpawnOptions): ChildProcess; 34 | declare function spawn(command: string, args: string[], options: SpawnOptions): ChildProcess; 35 | 36 | declare function fullScreen(isFullScreen: boolean); 37 | 38 | declare function toast(message: string); 39 | 40 | declare function moduleInfo(): string; 41 | 42 | export { 43 | exec, 44 | spawn, 45 | fullScreen, 46 | toast, 47 | moduleInfo 48 | } -------------------------------------------------------------------------------- /webroot/assets/kernelsu/index.js: -------------------------------------------------------------------------------- 1 | let callbackCounter = 0; 2 | function getUniqueCallbackName(prefix) { 3 | return `${prefix}_callback_${Date.now()}_${callbackCounter++}`; 4 | } 5 | 6 | export function exec(command, options) { 7 | if (typeof options === "undefined") { 8 | options = {}; 9 | } 10 | 11 | return new Promise((resolve, reject) => { 12 | // Generate a unique callback function name 13 | const callbackFuncName = getUniqueCallbackName("exec"); 14 | 15 | // Define the success callback function 16 | window[callbackFuncName] = (errno, stdout, stderr) => { 17 | resolve({ errno, stdout, stderr }); 18 | cleanup(callbackFuncName); 19 | }; 20 | 21 | function cleanup(successName) { 22 | delete window[successName]; 23 | } 24 | 25 | try { 26 | ksu.exec(command, JSON.stringify(options), callbackFuncName); 27 | } catch (error) { 28 | reject(error); 29 | cleanup(callbackFuncName); 30 | } 31 | }); 32 | } 33 | 34 | class Stdio { 35 | constructor() { 36 | this.listeners = {}; 37 | } 38 | on(event, listener) { 39 | if (!this.listeners[event]) { 40 | this.listeners[event] = []; 41 | } 42 | this.listeners[event].push(listener); 43 | } 44 | emit(event, ...args) { 45 | if (this.listeners[event]) { 46 | this.listeners[event].forEach((listener) => listener(...args)); 47 | } 48 | } 49 | } 50 | 51 | 52 | 53 | class ChildProcess { 54 | constructor() { 55 | this.listeners = {}; 56 | this.stdin = new Stdio(); 57 | this.stdout = new Stdio(); 58 | this.stderr = new Stdio(); 59 | } 60 | on(event, listener) { 61 | if (!this.listeners[event]) { 62 | this.listeners[event] = []; 63 | } 64 | this.listeners[event].push(listener); 65 | } 66 | emit(event, ...args) { 67 | if (this.listeners[event]) { 68 | this.listeners[event].forEach((listener) => listener(...args)); 69 | } 70 | } 71 | } 72 | 73 | 74 | 75 | export function spawn(command, args, options) { 76 | if (typeof args === "undefined") { 77 | args = []; 78 | } else if (!(args instanceof Array)) { 79 | // allow for (command, options) signature 80 | options = args; 81 | } 82 | 83 | if (typeof options === "undefined") { 84 | options = {}; 85 | } 86 | 87 | const child = new ChildProcess(); 88 | const childCallbackName = getUniqueCallbackName("spawn"); 89 | window[childCallbackName] = child; 90 | 91 | function cleanup(name) { 92 | delete window[name]; 93 | } 94 | 95 | child.on("exit", code => { 96 | cleanup(childCallbackName); 97 | }); 98 | 99 | try { 100 | ksu.spawn( 101 | command, 102 | JSON.stringify(args), 103 | JSON.stringify(options), 104 | childCallbackName 105 | ); 106 | } catch (error) { 107 | child.emit("error", error); 108 | cleanup(childCallbackName); 109 | } 110 | return child; 111 | } 112 | 113 | export function fullScreen(isFullScreen) { 114 | ksu.fullScreen(isFullScreen); 115 | } 116 | 117 | export function toast(message) { 118 | ksu.toast(message); 119 | } 120 | 121 | export function moduleInfo() { 122 | return ksu.moduleInfo(); 123 | } -------------------------------------------------------------------------------- /webroot/assets/style.css: -------------------------------------------------------------------------------- 1 | /* CSS变量 */ 2 | :root { 3 | --sothx-text-color: rgb(31, 34, 37); 4 | --sothx-base-color: #fff; 5 | --sothx-bg-color: #fff; 6 | --sothx-border-color: rgb(239,239,245); 7 | } 8 | @media (prefers-color-scheme: dark) { 9 | :root { 10 | --sothx-base-color: rgb(24,24,28); 11 | --sothx-text-color: rgba(255, 255, 255, 0.9); 12 | --sothx-bg-color: rgb(16,16,20); 13 | --sothx-border-color: rgb(255,255,255,0.09); 14 | } 15 | } 16 | 17 | 18 | * { 19 | margin: 0; 20 | padding: 0; 21 | } 22 | 23 | html, 24 | body, 25 | #layout, 26 | #app { 27 | height: 100%; 28 | box-sizing: border-box; 29 | background-color: var(--sothx-base-color); 30 | } 31 | 32 | #layout { 33 | display: flex; 34 | flex-wrap: wrap; 35 | box-sizing: border-box; 36 | } 37 | 38 | #header { 39 | height: 50px; 40 | background-color: var(--sothx-base-color); 41 | color: var(--sothx-text-color); 42 | text-align: center; 43 | line-height: 50px; 44 | flex-basis: 100%; 45 | box-sizing:border-box; 46 | border-bottom: 1px solid var(--sothx-border-color); 47 | } 48 | 49 | #footer { 50 | height: 30px; 51 | background-color: var(--sothx-base-color); 52 | color: var(--sothx-text-color); 53 | text-align: center; 54 | line-height: 30px; 55 | flex-basis: 100%; 56 | box-sizing:border-box; 57 | border-top: 1px solid var(--sothx-border-color); 58 | } 59 | 60 | 61 | #main { 62 | height: calc(100% - 82px); 63 | overflow: scroll; 64 | width: 100%; 65 | box-sizing: border-box; 66 | display: flex; 67 | flex-direction: column; 68 | margin: 0 auto; 69 | color: var(--sothx-text-color); 70 | background-color: var(--sothx-bg-color); 71 | /* background-color: #eee; */ 72 | text-align: left; 73 | } 74 | 75 | #main::-webkit-scrollbar { 76 | display: none; 77 | } 78 | 79 | 80 | .animated-bg { 81 | background-image: linear-gradient( 82 | 101.22deg, 83 | rgb(255, 182, 133) -18.32%, 84 | rgb(255, 111, 29) 7.01%, 85 | rgb(252, 181, 232) 41.59%, 86 | rgb(135, 148, 255) 70.98%, 87 | rgb(60, 112, 255) 91.35%, 88 | rgb(60, 112, 255) 110.17% 89 | ); 90 | background-size: 300% 300%; 91 | animation: gradientShift 6s infinite ease-in-out; 92 | } 93 | 94 | .gradient-box { 95 | background: linear-gradient(90deg, #c5dfff, #eaf7ff, #ffe6f2); 96 | border-radius: 8px; 97 | display: flex; 98 | align-items: center; 99 | justify-content: space-between; 100 | padding: 0 15px; 101 | font-family: Arial, sans-serif; 102 | color: #333; 103 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); 104 | } 105 | 106 | 107 | @keyframes gradientShift { 108 | 0% { 109 | background-position: 30% 50%; 110 | } 111 | 50% { 112 | background-position: 70% 50%; 113 | } 114 | 100% { 115 | background-position: 30% 50%; 116 | } 117 | } 118 | 119 | [v-cloak] { 120 | display: none; 121 | } -------------------------------------------------------------------------------- /webroot/hooks/useBatteryInfo.js: -------------------------------------------------------------------------------- 1 | import $to from '../assets/await-to-js.js'; 2 | import * as deviceApi from '../apis/deviceApi.js'; 3 | const { 4 | createApp, 5 | ref, 6 | watchEffect, 7 | onMounted, 8 | computed, 9 | reactive, 10 | onUnmounted 11 | } = Vue; 12 | const { 13 | useOsTheme, 14 | darkTheme, 15 | lightTheme, 16 | createDiscreteApi 17 | } = naive; 18 | export function useBatteryInfo() { 19 | const osThemeRef = useOsTheme() 20 | const configProviderPropsRef = computed(() => ({ 21 | theme: osThemeRef === 'dark' ? darkTheme : lightTheme 22 | })) 23 | 24 | const { message, modal } = createDiscreteApi(['message', 'modal'], { 25 | configProviderProps: configProviderPropsRef, 26 | }); 27 | 28 | const sohQcom = ref(0); 29 | 30 | const sohMTK = ref(0); 31 | 32 | const sohXMPower = ref(0); 33 | 34 | const chargeFullDesign = ref(0); 35 | 36 | const chargeFull = ref(0); 37 | 38 | const cycleCount = ref(0); 39 | 40 | async function initDefault() { 41 | const executeWithoutWaiting = [ 42 | // 售后电池健康度 43 | $to(deviceApi.getBatterySohQcom()), 44 | $to(deviceApi.getBatterySohMTK()), 45 | $to(deviceApi.getBatterySohXMPower()), 46 | // 电池设计容量 47 | $to(deviceApi.getBatteryChargeFullDesign()), 48 | // 当前电池容量 49 | $to(deviceApi.getBatteryChargeFull()), 50 | // 电池循环次数 51 | $to(deviceApi.getBatteryCycleCount()), 52 | ]; 53 | // 等待所有 promises 完成 54 | const executeWithoutWaitingResults = await Promise.all(executeWithoutWaiting); 55 | const [ 56 | [, getBatterySohQcomRes], 57 | [, getBatterySohMTKRes], 58 | [, getBatterySohXMPowerRes], 59 | [, getBatteryChargeFullDesignRes], 60 | [, getBatteryChargeFullRes], 61 | [, getBatteryCycleCountRes], 62 | ] = executeWithoutWaitingResults; 63 | // 售后电池健康度 64 | sohQcom.value = Number(getBatterySohQcomRes) 65 | sohMTK.value = Number(getBatterySohMTKRes) 66 | sohXMPower.value = Number(getBatterySohXMPowerRes) 67 | // 电池设计容量 68 | chargeFullDesign.value = Number(getBatteryChargeFullDesignRes) 69 | // 当前电池容量 70 | chargeFull.value = Number(getBatteryChargeFullRes) 71 | // 当前电池循环次数 72 | cycleCount.value = Number(getBatteryCycleCountRes) 73 | } 74 | 75 | 76 | onMounted(async () => { 77 | initDefault() 78 | }); 79 | 80 | return { 81 | sohQcom, 82 | sohMTK, 83 | sohXMPower, 84 | chargeFullDesign, 85 | chargeFull, 86 | cycleCount 87 | }; 88 | } -------------------------------------------------------------------------------- /webroot/hooks/useRealQuantity.js: -------------------------------------------------------------------------------- 1 | import $to from '../assets/await-to-js.js'; 2 | import * as deviceApi from '../apis/deviceApi.js'; 3 | const { 4 | createApp, 5 | ref, 6 | watchEffect, 7 | onMounted, 8 | computed, 9 | reactive, 10 | onUnmounted 11 | } = Vue; 12 | const { 13 | useOsTheme, 14 | darkTheme, 15 | lightTheme, 16 | createDiscreteApi 17 | } = naive; 18 | export function useRealQuantity() { 19 | const osThemeRef = useOsTheme() 20 | const configProviderPropsRef = computed(() => ({ 21 | theme: osThemeRef === 'dark' ? darkTheme : lightTheme 22 | })) 23 | 24 | const { message, modal } = createDiscreteApi(['message', 'modal'], { 25 | configProviderProps: configProviderPropsRef, 26 | }); 27 | 28 | 29 | const qcomBatteryFg1RSocInfo = reactive({ 30 | current: 0, 31 | autoReload: false, 32 | timer: 3, 33 | reload: async() => { 34 | const [, getQcomBatteryFg1RSocRes] = await $to(deviceApi.getQcomBatteryFg1RSoc()); 35 | if (getQcomBatteryFg1RSocRes) { 36 | qcomBatteryFg1RSocInfo.current = Number(getQcomBatteryFg1RSocRes); 37 | } 38 | }, 39 | interval: null 40 | }) 41 | 42 | const capacityRawInfo = reactive({ 43 | current: 0, 44 | autoReload: false, 45 | timer: 3, 46 | reload: async() => { 47 | const [, getCapacityRawRes] = await $to(deviceApi.getCapacityRaw()); 48 | if (getCapacityRawRes) { 49 | capacityRawInfo.current = Number(getCapacityRawRes); 50 | } 51 | }, 52 | interval: null 53 | }) 54 | 55 | const setupAutoReload = (info) => { 56 | // Clear the existing interval if any 57 | if (info.interval) { 58 | clearInterval(info.interval); 59 | info.interval = null; 60 | } 61 | 62 | // Set a new interval if autoReload is true 63 | if (info.autoReload) { 64 | info.interval = setInterval(() => { 65 | info.reload(); 66 | }, info.timer * 1000); 67 | } 68 | }; 69 | 70 | watchEffect(() => setupAutoReload(qcomBatteryFg1RSocInfo)); 71 | watchEffect(() => setupAutoReload(capacityRawInfo)); 72 | 73 | onMounted(async () => { 74 | qcomBatteryFg1RSocInfo.reload() 75 | capacityRawInfo.reload() 76 | }); 77 | 78 | onUnmounted(() => { 79 | // Clear intervals when the component is unmounted 80 | if (qcomBatteryFg1RSocInfo.interval !== null) clearInterval(qcomBatteryFg1RSocInfo.interval); 81 | if (capacityRawInfo.interval !== null) clearInterval(capacityRawInfo.interval); 82 | }); 83 | 84 | return { 85 | qcomBatteryFg1RSocInfo, 86 | capacityRawInfo 87 | }; 88 | } -------------------------------------------------------------------------------- /webroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 29 |
30 |
31 |
32 |
33 |

34 | 电池信息 49 |

50 |

53 | 查看有关电池健康的内核信息 54 |

55 |
56 | 57 |
60 |
63 |
67 |
70 | 真实电量(高通) 71 |
72 |
75 |

76 | {{ `${realQuantityHook.qcomBatteryFg1RSocInfo.current} 77 | %` }} 78 | 手动刷新 87 | 92 | 93 | 94 | 95 |

96 |
99 |

100 | 隔 {{ realQuantityHook.qcomBatteryFg1RSocInfo.timer }} 101 | 秒刷新一次 102 |

103 |

104 | 111 |

112 |
113 |
114 |
115 |
119 |
122 | 真实电量 123 |
124 |
127 |

128 | {{ `${realQuantityHook.capacityRawInfo.current / 100} %` 129 | }} 130 | 手动刷新 139 | 144 | 145 | 146 | 147 |

148 |
149 |

150 | 隔 {{ realQuantityHook.capacityRawInfo.timer }} 151 | 秒刷新一次 152 |

153 |

154 | 161 |

162 |
163 |
164 |
165 |
169 |
172 | 电池出厂设计容量 173 |
174 |
177 |

178 | {{ `${batteryInfoHook.chargeFullDesign.value / 1000} 179 | mAh` }} 180 |

181 |
182 |
183 |
187 |
190 | 电池当前预估容量 191 |
192 |
195 |

196 | {{ `${batteryInfoHook.chargeFull.value / 1000} mAh` }} 197 |

198 |
199 |
200 |
204 |
207 | 电池循环充电次数 208 |
209 |
212 |

{{ `${batteryInfoHook.cycleCount.value} 次` }}

213 |
214 |
215 |
219 |
222 | 电池预估健康度 223 |
224 |
227 |

228 | {{ `${((batteryInfoHook.chargeFull.value / 229 | batteryInfoHook.chargeFullDesign.value) * 230 | 100).toFixed(2)} %` }} 231 |

232 |
233 |
234 |
238 |
241 | 电池售后健康度(高通) 242 |
243 |
246 |

{{ `${batteryInfoHook.sohQcom.value} %` }}

247 |

248 | {{ `≈ 249 | ${Math.round((batteryInfoHook.chargeFullDesign.value * 250 | (batteryInfoHook.sohQcom.value / 100)) / 1000)} mAh` }} 251 |

252 |

(Tips:在设备保修期内健康度低于80%可以申请电池质保)

253 |
254 |
255 |
259 |
262 | 电池售后健康度 263 |
264 |
267 |

{{ `${batteryInfoHook.sohMTK.value} %` }}

268 |

269 | {{ `≈ 270 | ${Math.round((batteryInfoHook.chargeFullDesign.value * 271 | (batteryInfoHook.sohMTK.value / 100)) / 1000)} mAh` }} 272 |

273 |

(Tips:在设备保修期内健康度低于80%可以申请电池质保)

274 |
275 |
276 |
280 |
283 | 电池售后健康度(小米) 284 |
285 |
288 |

{{ `${batteryInfoHook.sohXMPower.value} %` }}

289 |

290 | {{ `≈ 291 | ${Math.round((batteryInfoHook.chargeFullDesign.value * 292 | (batteryInfoHook.sohXMPower.value / 100)) / 1000)} mAh` }} 293 |

294 |

(Tips:在设备保修期内健康度低于80%可以申请电池质保)

295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |

307 | Designed By Sothx 308 |

309 |
310 |
311 |
312 | 396 | 397 | 398 | -------------------------------------------------------------------------------- /webroot/web.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | env: 'prod', // 调试阶段请改为dev,发布阶段请改为prod 3 | } --------------------------------------------------------------------------------