├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── TuringBoxJNI
├── .gitignore
├── build.gradle.kts
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── io
│ │ └── github
│ │ └── lumyuan
│ │ └── jni
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ │ ├── CMakeLists.txt
│ │ └── jni.cpp
│ └── java
│ │ └── io
│ │ └── github
│ │ └── lumyuan
│ │ └── jni
│ │ └── NativeLib.kt
│ └── test
│ └── java
│ └── io
│ └── github
│ └── lumyuan
│ └── jni
│ └── ExampleUnitTest.kt
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
├── release-mini
│ ├── Turing Box-0.0.3-23060521-release-mini.apk.idsig
│ └── output-metadata.json
├── release
│ └── output-metadata.json
└── src
│ ├── androidTest
│ └── java
│ │ └── io
│ │ └── github
│ │ └── lumyuan
│ │ └── turingbox
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── addin
│ │ │ ├── disable_charge.sh
│ │ │ ├── fast_charge.sh
│ │ │ ├── fast_charge_run_once.sh
│ │ │ ├── force_compact.sh
│ │ │ ├── freeze_executor.sh
│ │ │ ├── install_busybox.sh
│ │ │ ├── power_save_set.sh
│ │ │ ├── resume_charge.sh
│ │ │ ├── swap_control.sh
│ │ │ └── zram_control.sh
│ │ ├── custom-command
│ │ │ ├── AirplaneMode(OFF).sh
│ │ │ ├── AirplaneMode(ON).sh
│ │ │ ├── Data(OFF).sh
│ │ │ ├── Data(ON).sh
│ │ │ ├── Dex2oat(Everything).sh
│ │ │ ├── Dex2oat(Speed).sh
│ │ │ ├── Dex2oat(Speed-profile).sh
│ │ │ ├── FSTRIM.sh
│ │ │ ├── GPS(OFF).sh
│ │ │ ├── GPS(ON).sh
│ │ │ ├── Power-Reboot.sh
│ │ │ ├── Power-Shutdown.sh
│ │ │ ├── WiFi(OFF).sh
│ │ │ └── WiFi(ON).sh
│ │ ├── powercfg
│ │ │ ├── exynos5
│ │ │ │ ├── active-base.sh
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative-base.sh
│ │ │ │ └── conservative.sh
│ │ │ ├── kona
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── powercfg-base.sh
│ │ │ │ ├── powercfg-utils.sh
│ │ │ │ └── powercfg_extra.json
│ │ │ ├── lahaina
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── powercfg-base.sh
│ │ │ │ ├── powercfg-utils.sh
│ │ │ │ └── powercfg_extra.json
│ │ │ ├── lito
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ └── powercfg-base.sh
│ │ │ ├── msm8952
│ │ │ │ ├── active-base.sh
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative-base.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ └── info.txt
│ │ │ ├── msm8953
│ │ │ │ ├── active-base.sh
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative-base.sh
│ │ │ │ └── conservative.sh
│ │ │ ├── msm8974
│ │ │ │ ├── active-base.sh
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative-base.sh
│ │ │ │ └── conservative.sh
│ │ │ ├── msm8996
│ │ │ │ ├── active-base.sh
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative-base.sh
│ │ │ │ └── conservative.sh
│ │ │ ├── msm8998
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ └── powercfg-base.sh
│ │ │ ├── msmnile
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── powercfg-base.sh
│ │ │ │ ├── powercfg-utils.sh
│ │ │ │ └── powercfg_extra.json
│ │ │ ├── mt6873
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── info.txt
│ │ │ │ └── powercfg-base.sh
│ │ │ ├── mt6885
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── info.txt
│ │ │ │ └── powercfg-base.sh
│ │ │ ├── powercfg-template
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── powercfg-base.sh
│ │ │ │ ├── powercfg-utils.sh.sh
│ │ │ │ └── readme.md
│ │ │ ├── sdm710
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ └── powercfg-base.sh
│ │ │ ├── sdm845
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ └── powercfg-base.sh
│ │ │ └── sm6150
│ │ │ │ ├── active.sh
│ │ │ │ ├── conservative.sh
│ │ │ │ ├── powercfg-base.sh
│ │ │ │ └── powercfg-utils.sh
│ │ └── toolkit
│ │ │ ├── busybox
│ │ │ ├── kr_install_busybox.sh
│ │ │ ├── run
│ │ │ ├── toybox-outside
│ │ │ └── toybox-outside64
│ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── lumyuan
│ │ │ └── turingbox
│ │ │ ├── TuringBox.kt
│ │ │ ├── common
│ │ │ ├── Settings.kt
│ │ │ ├── basic
│ │ │ │ ├── Activities.kt
│ │ │ │ ├── AppInfoLoader.kt
│ │ │ │ └── Contexts.kt
│ │ │ ├── calculator
│ │ │ │ ├── Flags.kt
│ │ │ │ └── GetUpTime.kt
│ │ │ ├── data
│ │ │ │ ├── EventBus.kt
│ │ │ │ ├── EventType.java
│ │ │ │ ├── GlobalStatus.kt
│ │ │ │ ├── IEventReceiver.kt
│ │ │ │ ├── customer
│ │ │ │ │ ├── BatteryReceiver.kt
│ │ │ │ │ ├── ChargeCurve.kt
│ │ │ │ │ └── ScreenOffCleanup.kt
│ │ │ │ └── publisher
│ │ │ │ │ ├── BatteryState.kt
│ │ │ │ │ └── ScreenState.kt
│ │ │ ├── device
│ │ │ │ ├── BatteryCapacity.java
│ │ │ │ ├── GpuInfoUtil.kt
│ │ │ │ └── MiuiThermalAESUtil.java
│ │ │ ├── model
│ │ │ │ ├── AppInfo.java
│ │ │ │ ├── BatteryStatus.java
│ │ │ │ ├── ChargeSpeedHistory.java
│ │ │ │ ├── ChargeTimeHistory.java
│ │ │ │ ├── CpuClusterStatus.java
│ │ │ │ ├── CpuCoreInfo.java
│ │ │ │ ├── CpuStatus.java
│ │ │ │ ├── CustomTaskAction.java
│ │ │ │ ├── SceneConfigInfo.java
│ │ │ │ ├── SceneStandbyMode.kt
│ │ │ │ ├── TaskAction.java
│ │ │ │ ├── TaskActionsExecutor.kt
│ │ │ │ ├── TriggerExecutorService.kt
│ │ │ │ ├── TriggerIEventMonitor.kt
│ │ │ │ └── TriggerInfo.java
│ │ │ ├── permissions
│ │ │ │ ├── Busybox.kt
│ │ │ │ ├── CheckRootStatus.kt
│ │ │ │ └── WriteSettings.kt
│ │ │ ├── pojo
│ │ │ │ └── AppInfo.kt
│ │ │ ├── shared
│ │ │ │ ├── BitmapUtil.java
│ │ │ │ ├── FilePathResolver.java
│ │ │ │ ├── FileWrite.kt
│ │ │ │ ├── MagiskExtend.java
│ │ │ │ ├── ObjectStorage.kt
│ │ │ │ ├── RawText.kt
│ │ │ │ └── RootFileInfo.kt
│ │ │ ├── shell
│ │ │ │ ├── BatteryUtils.kt
│ │ │ │ ├── CpuFrequencyUtils.java
│ │ │ │ ├── CpuLoadUtils.java
│ │ │ │ ├── FileValueMap.kt
│ │ │ │ ├── FstrimUtils.kt
│ │ │ │ ├── GpuUtils.java
│ │ │ │ ├── KeepShell.kt
│ │ │ │ ├── KeepShellAsync.kt
│ │ │ │ ├── KeepShellPublic.kt
│ │ │ │ ├── KernelProp.kt
│ │ │ │ ├── MemoryUtils.java
│ │ │ │ ├── PlatformUtils.kt
│ │ │ │ ├── ProcessInfo.java
│ │ │ │ ├── ProcessUtils.java
│ │ │ │ ├── PropsUtils.kt
│ │ │ │ ├── RootFile.kt
│ │ │ │ ├── ShellConfiguration.kt
│ │ │ │ ├── ShellEvents.kt
│ │ │ │ ├── ShellExecutor.java
│ │ │ │ ├── ThermalControlUtils.java
│ │ │ │ ├── ToyboxIntaller.kt
│ │ │ │ └── ZenModeUtils.kt
│ │ │ ├── store
│ │ │ │ ├── ChargeSpeedStore.java
│ │ │ │ ├── SpfConfig.kt
│ │ │ │ └── TriggerStorage.kt
│ │ │ └── util
│ │ │ │ ├── AppListHelper.kt
│ │ │ │ ├── CommonCmds.kt
│ │ │ │ └── SharedPreferencesUtil.kt
│ │ │ ├── ui
│ │ │ ├── compose
│ │ │ │ ├── Activites.kt
│ │ │ │ └── Timer.kt
│ │ │ ├── icon
│ │ │ │ └── NiaIcons.kt
│ │ │ ├── theme
│ │ │ │ ├── AppTheme.kt
│ │ │ │ ├── AppThemeConfiguration.kt
│ │ │ │ ├── Color.kt
│ │ │ │ ├── DarkTheme.kt
│ │ │ │ ├── Theme.kt
│ │ │ │ └── Type.kt
│ │ │ └── widget
│ │ │ │ ├── CpuChart.kt
│ │ │ │ ├── IndicatorComponent.kt
│ │ │ │ ├── Navigation.kt
│ │ │ │ └── ProgressBar.kt
│ │ │ └── windows
│ │ │ ├── main
│ │ │ ├── DevicePage.kt
│ │ │ ├── FunctionPage.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── MinePage.kt
│ │ │ └── device
│ │ │ │ ├── CpuFreqCard.kt
│ │ │ │ ├── GpuCard.kt
│ │ │ │ ├── MemoryCard.kt
│ │ │ │ └── OtherInfoCard.kt
│ │ │ └── start
│ │ │ └── CheckerActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── app_options_clear.png
│ │ ├── app_options_clear2.png
│ │ ├── ic_battery_power.xml
│ │ ├── ic_check_permission.xml
│ │ ├── ic_clock.png
│ │ ├── ic_danger.png
│ │ ├── ic_edit_electric_current.xml
│ │ ├── ic_graph.png
│ │ ├── ic_home.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_monitor.xml
│ │ ├── ic_nav_function.xml
│ │ ├── ic_power.png
│ │ ├── ic_settings.png
│ │ ├── ic_temperature.png
│ │ ├── icon_android.png
│ │ ├── icon_battery_1.png
│ │ ├── icon_battery_2.png
│ │ ├── icon_battery_3.png
│ │ ├── icon_battery_4.png
│ │ ├── icon_global.png
│ │ ├── icon_mine_fill.xml
│ │ ├── process.png
│ │ ├── process_android.png
│ │ ├── process_linux.png
│ │ └── turing_box.png
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── raw
│ │ ├── change_mac_1
│ │ ├── change_mac_2
│ │ ├── memcg_set
│ │ ├── memcg_set_auto
│ │ ├── memcg_set_init
│ │ └── module_system_prop
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── configs.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ │ └── xml
│ │ ├── backup_rules.xml
│ │ └── data_extraction_rules.xml
│ └── test
│ └── java
│ └── io
│ └── github
│ └── lumyuan
│ └── turingbox
│ └── ExampleUnitTest.kt
├── build.gradle.kts
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle.kts
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gradle files
2 | .gradle/
3 | build/
4 |
5 | # Local configuration file (sdk path, etc)
6 | local.properties
7 |
8 | # Log/OS Files
9 | *.log
10 |
11 | # Android Studio generated files and folders
12 | captures/
13 | .externalNativeBuild/
14 | .cxx/
15 | *.apk
16 | output.json
17 |
18 | # IntelliJ
19 | *.iml
20 | .idea/
21 |
22 | # Keystore files
23 | *.jks
24 | *.keystore
25 |
26 | # Google Services (e.g. APIs or Firebase)
27 | google-services.json
28 |
29 | # Android Profiling
30 | *.hprof
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TuringBox
2 | 一个基于JetPack Compose UI构建的安卓玩机盒子
3 |
4 | ## 开发中,敬请期待
5 |
6 | ## [License](LICENSE)
7 | ```
8 | Turing Box - An Android System Tools Box based on JetPack Compose UI
9 | https://github.com/lumyuan/TuringBox
10 | Copyright (C) 2023 Lumyuan
11 |
12 | This library is free software; you can redistribute it and/or
13 | modify it under the terms of the GNU Lesser General Public
14 | License as published by the Free Software Foundation; either
15 | version 2.1 of the License, or (at your option) any later version.
16 |
17 | This library is distributed in the hope that it will be useful,
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 | Lesser General Public License for more details.
21 |
22 | You should have received a copy of the GNU Lesser General Public
23 | License along with this library; if not, write to the Free Software
24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
25 | USA
26 |
27 | Please contact Lumyuan by email 2205903933@qq.com if you need
28 | additional information or have any questions
29 | ```
--------------------------------------------------------------------------------
/TuringBoxJNI/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/TuringBoxJNI/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
2 | plugins {
3 | alias(libs.plugins.androidLibrary)
4 | alias(libs.plugins.kotlinAndroid)
5 | }
6 |
7 | android {
8 | namespace = "io.github.lumyuan.jni"
9 | compileSdk = 33
10 |
11 | defaultConfig {
12 | minSdk = 21
13 |
14 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles("consumer-rules.pro")
16 | externalNativeBuild {
17 | cmake {
18 | cppFlags("")
19 | }
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | isMinifyEnabled = false
26 | proguardFiles(
27 | getDefaultProguardFile("proguard-android-optimize.txt"),
28 | "proguard-rules.pro"
29 | )
30 | }
31 | create("release-mini") {
32 | isMinifyEnabled = true
33 | proguardFiles(
34 | getDefaultProguardFile("proguard-android-optimize.txt"),
35 | "proguard-rules.pro"
36 | )
37 | }
38 | }
39 | externalNativeBuild {
40 | cmake {
41 | path("src/main/cpp/CMakeLists.txt")
42 | version = "3.22.1"
43 | }
44 | }
45 | compileOptions {
46 | sourceCompatibility = JavaVersion.VERSION_1_8
47 | targetCompatibility = JavaVersion.VERSION_1_8
48 | }
49 | kotlinOptions {
50 | jvmTarget = "1.8"
51 | }
52 | }
53 |
54 | dependencies {
55 |
56 | implementation(libs.core.ktx)
57 | implementation(libs.android.appcompat)
58 | implementation(libs.material)
59 | testImplementation(libs.junit)
60 | androidTestImplementation(libs.androidx.test.ext.junit)
61 | androidTestImplementation(libs.espresso.core)
62 | }
--------------------------------------------------------------------------------
/TuringBoxJNI/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/TuringBoxJNI/consumer-rules.pro
--------------------------------------------------------------------------------
/TuringBoxJNI/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/TuringBoxJNI/src/androidTest/java/io/github/lumyuan/jni/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.jni
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("io.github.lumyuan.jni.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/TuringBoxJNI/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/TuringBoxJNI/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html.
3 | # For more examples on how to use CMake, see https://github.com/android/ndk-samples.
4 |
5 | # Sets the minimum CMake version required for this project.
6 | cmake_minimum_required(VERSION 3.22.1)
7 |
8 | # Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
9 | # Since this is the top level CMakeLists.txt, the project name is also accessible
10 | # with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
11 | # build script scope).
12 | project("jni")
13 |
14 | # Creates and names a library, sets it as either STATIC
15 | # or SHARED, and provides the relative paths to its source code.
16 | # You can define multiple libraries, and CMake builds them for you.
17 | # Gradle automatically packages shared libraries with your APK.
18 | #
19 | # In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
20 | # the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
21 | # is preferred for the same purpose.
22 | #
23 | # In order to load a library into your app from Java/Kotlin, you must call
24 | # System.loadLibrary() and pass the name of the library defined here;
25 | # for GameActivity/NativeActivity derived applications, the same library name must be
26 | # used in the AndroidManifest.xml file.
27 | add_library(${CMAKE_PROJECT_NAME} SHARED
28 | # List C/C++ source files with relative paths to this CMakeLists.txt.
29 | jni.cpp)
30 |
31 | # Specifies libraries CMake should link to your target library. You
32 | # can link libraries from various origins, such as libraries defined in this
33 | # build script, prebuilt third-party libraries, or Android system libraries.
34 | target_link_libraries(${CMAKE_PROJECT_NAME}
35 | # List libraries link to the target library
36 | android
37 | log)
--------------------------------------------------------------------------------
/TuringBoxJNI/src/main/cpp/jni.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | char* jstringToChar(JNIEnv* env, jstring jstr) {
5 | char* rtn = NULL;
6 | jclass clsstring = env->FindClass("java/lang/String");
7 | jstring strencode = env->NewStringUTF("GB2312");
8 | jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B");
9 | jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode);
10 | jsize alen = env->GetArrayLength(barr);
11 | jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE);
12 | if (alen > 0) {
13 | rtn = (char*) malloc(alen + 1);
14 | memcpy(rtn, ba, alen);
15 | rtn[alen] = 0;
16 | }
17 | env->ReleaseByteArrayElements(barr, ba, 0);
18 | return rtn;
19 | }
20 |
21 | extern "C"
22 | JNIEXPORT jlong JNICALL
23 | Java_io_github_lumyuan_jni_NativeLib_getKernelPropLong(JNIEnv *env, jobject thiz, jstring path) {
24 | // std::string hello = "Hello from C++";
25 | // return env->NewStringUTF(hello.c_str());
26 |
27 | // 读取路径 /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
28 | char* charData = jstringToChar(env, path);
29 |
30 | FILE *kernelProp = fopen(charData, "r");
31 | if (kernelProp == nullptr)
32 | return -1;
33 | long freq;
34 | fscanf(kernelProp,"%ld",&freq);
35 | fclose(kernelProp);
36 | return freq;
37 | }
--------------------------------------------------------------------------------
/TuringBoxJNI/src/main/java/io/github/lumyuan/jni/NativeLib.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.jni
2 |
3 | class NativeLib {
4 | external fun getKernelPropLong(path: String): Long
5 |
6 | companion object {
7 | init {
8 | System.loadLibrary("jni")
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/TuringBoxJNI/src/test/java/io/github/lumyuan/jni/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.jni
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | -keepclassmembers public class * extends android.app.Activity
24 | -keepclassmembers public class * extends android.app.Application
25 | -keepclassmembers public class * extends android.app.Service
26 | -keepclassmembers public class * extends android.content.BroadcastReceiver
27 | -keepclassmembers class * extends java.io.Serializable{*;}
28 | -keepclassmembers class * implements java.io.Serializable{*;}
29 | #-keepclassmembers public class * extends android.content.ContentProvider
30 | #-keepclassmembers public class * extends android.app.backup.BackupAgentHelper
31 | #-keepclassmembers public class * extends android.preference.Preference
32 | #-keepclassmembers public class * extends android.view.View
33 | #-keepclassmembers public class com.android.vending.licensing.ILicensingService
34 | #-keepclassmembers class android.support.** {*;}
35 |
36 | -keep class io.github.lumyuan.turingbox.common.model.**{*;}
--------------------------------------------------------------------------------
/app/release-mini/Turing Box-0.0.3-23060521-release-mini.apk.idsig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/release-mini/Turing Box-0.0.3-23060521-release-mini.apk.idsig
--------------------------------------------------------------------------------
/app/release-mini/output-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "artifactType": {
4 | "type": "APK",
5 | "kind": "Directory"
6 | },
7 | "applicationId": "io.github.lumyuan.turingbox",
8 | "variantName": "release-mini",
9 | "elements": [
10 | {
11 | "type": "SINGLE",
12 | "filters": [],
13 | "attributes": [],
14 | "versionCode": 23060521,
15 | "versionName": "0.0.3-23060521",
16 | "outputFile": "Turing Box-0.0.3-23060521-release-mini.apk"
17 | }
18 | ],
19 | "elementType": "File"
20 | }
--------------------------------------------------------------------------------
/app/release/output-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "artifactType": {
4 | "type": "APK",
5 | "kind": "Directory"
6 | },
7 | "applicationId": "io.github.lumyuan.turingbox",
8 | "variantName": "release",
9 | "elements": [
10 | {
11 | "type": "SINGLE",
12 | "filters": [],
13 | "attributes": [],
14 | "versionCode": 1,
15 | "versionName": "1.0",
16 | "outputFile": "app-release.apk"
17 | }
18 | ],
19 | "elementType": "File"
20 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/io/github/lumyuan/turingbox/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("io.github.lumyuan.turingbox", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
22 |
25 |
28 |
31 |
32 |
33 |
35 |
36 |
46 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
60 |
61 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/disable_charge.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | function set_value()
4 | {
5 | if [[ -f "$1" ]];
6 | then
7 | chmod 0666 "$1"
8 | echo "$2" > "$1"
9 | fi
10 | }
11 |
12 | max='/sys/class/power_supply/battery/constant_charge_current_max'
13 | bce='/sys/class/power_supply/battery/battery_charging_enabled'
14 | suspend='/sys/class/power_supply/battery/input_suspend'
15 |
16 | if [[ -f $bce ]] || [[ -f $suspend ]]
17 | then
18 | set_value $bce 0
19 | set_value $suspend 1
20 | setprop vtools.bp 1
21 | elif [[ -f $max ]]
22 | then
23 | current_max_path="/sys/class/power_supply/battery/constant_charge_current_max"
24 | current_max_backup="vtools.charge.current.max"
25 | current_max=`getprop $current_max_backup`
26 | if [[ "$current_max" == "" ]] && [[ -f $current_max_path ]]; then
27 | setprop $current_max_backup `cat $current_max_path`
28 | fi
29 |
30 | set_value $max 0
31 | setprop vtools.bp 1
32 | else
33 | echo 'error'
34 | fi
35 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/fast_charge.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | # 限制电流值 3000
4 | limit_value=$1
5 | # 是否只往上加
6 | only_taller=$2
7 |
8 | if [[ "$limit_value" = "" ]]
9 | then
10 | limit_value=3000
11 | fi
12 |
13 | paths=`ls /sys/class/power_supply/*/constant_charge_current_max`
14 |
15 | # 更改限制 change_limit ?mA
16 | function change_limit() {
17 | echo "更改限制值为:${1}mA"
18 | local limit="${1}000"
19 |
20 | for path in $paths
21 | do
22 | chmod 0664 $path
23 | if [[ "$only_taller" = 1 ]]; then
24 | local current_limit=`cat $path`
25 | if [[ "$current_limit" -lt "$limit" ]]; then
26 | echo $limit > $path
27 | fi
28 | else
29 | echo $limit > $path
30 | fi
31 | done
32 | }
33 |
34 | if [[ `getprop vtools.fastcharge` = "" ]]; then
35 | ./fast_charge_run_once.sh
36 |
37 | setprop vtools.fastcharge 1
38 | fi
39 |
40 | change_limit $limit_value
41 | # echo `date "+%Y-%m-%d %H:%M:%S.%MS"` " -> $limit_value" >> /cache/scene_charge.log
42 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/fast_charge_run_once.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | # 工具函数
4 | function set_rw()
5 | {
6 | if [[ -f "$1" ]];
7 | then
8 | chmod 0664 "$1"
9 | fi
10 | }
11 |
12 | # 工具函数
13 | function set_value()
14 | {
15 | if [[ -f "$1" ]];
16 | then
17 | chmod 0664 "$1"
18 | echo "$2" > "$1"
19 | fi
20 | }
21 |
22 | paths=`ls /sys/class/power_supply/*/constant_charge_current_max`
23 |
24 | set_value /sys/class/qcom-battery/restricted_charging 0
25 | # set_value /sys/class/power_supply/battery/step_charging_enabled 0
26 | set_value /sys/class/power_supply/usb/boost_current 1
27 | set_value /sys/class/power_supply/battery/restricted_charging 0
28 | # set_value /sys/class/power_supply/usb/pd_allowed 1
29 | set_value /sys/class/power_supply/allow_hvdcp3 1
30 | # set_value /sys/class/power_supply/battery/subsystem/usb/pd_allowed 1
31 | set_value /sys/class/power_supply/battery/safety_timer_enabled 0
32 | set_value /sys/class/power_supply/bms/temp_warm 500
33 | set_rw /sys/class/power_supply/main/constant_charge_current_max
34 | set_rw /sys/class/power_supply/battery/constant_charge_current_max
35 |
36 | for path in $paths
37 | do
38 | chmod 0664 $path
39 | done
40 |
41 | current_max_path="/sys/class/power_supply/battery/constant_charge_current_max"
42 | current_max_backup="vtools.charge.current.max"
43 | current_max=`getprop $current_max_backup`
44 | if [[ "$current_max" == "" ]] && [[ -f $current_max_path ]]; then
45 | setprop $current_max_backup `cat $current_max_path`
46 | fi
47 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/freeze_executor.sh:
--------------------------------------------------------------------------------
1 | if [[ "$1" == "" ]] || [[ "$2" == "" ]];then
2 | return
3 | fi
4 |
5 | mode="$1"
6 | delay="$3"
7 |
8 | if [[ ! -f "$2" ]]; then
9 | return
10 | fi
11 |
12 | # freeze_apps=""
13 | source $2
14 |
15 |
16 | if [[ "$delay" != "" ]]; then
17 | uuid=`date "+%Y%m%d%H%M%S"`
18 | setprop vtools.freeze_delay "$uuid"
19 |
20 | sleep $delay
21 |
22 | last_id=`getprop vtools.freeze_delay`
23 | if [[ "$last_id" != "$uuid" ]]; then
24 | return
25 | fi
26 | fi
27 |
28 |
29 | for app in $freeze_apps; do
30 | if [[ "$app" == "com.android.vending" ]]; then
31 | pm disable com.google.android.gsf 2> /dev/null
32 | pm disable com.google.android.gsf.login 2> /dev/null
33 | pm disable com.google.android.gms 2> /dev/null
34 | pm disable com.android.vending 2> /dev/null
35 | pm disable com.google.android.play.games 2> /dev/null
36 | pm disable com.google.android.syncadapters.contacts 2> /dev/null
37 | elif [[ "$mode" == "suspend" ]]; then
38 | pm suspend ${app} 2> /dev/null
39 | am force-stop ${app} 2> /dev/null
40 | am kill current ${app} 2> /dev/null
41 | else
42 | pm disable ${app} 2> /dev/null
43 | fi
44 | done
45 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/install_busybox.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | install_path="$1"
4 |
5 | busybox_install() {
6 | chmod 755 ./busybox
7 | for applet in `./busybox --list`; do
8 | case "$applet" in
9 | "sh"|"busybox"|"shell"|"swapon"|"swapoff"|"mkswap")
10 | echo 'Skip' > /dev/null
11 | ;;
12 | *)
13 | ./busybox ln -sf busybox "$applet"
14 | chmod 755 "$applet"
15 | ;;
16 | esac
17 | done
18 | ./busybox ln -sf busybox busybox_1_30_1
19 | }
20 |
21 | if [[ ! "$install_path" = "" ]] && [[ -d "$install_path" ]]; then
22 | cd "$install_path"
23 | if [[ ! -f busybox_1_30_1 ]]; then
24 | busybox_install
25 | fi
26 | fi
27 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/resume_charge.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | function set_value()
4 | {
5 | if [[ -f "$1" ]];
6 | then
7 | chmod 0666 "$1"
8 | echo "$2" > "$1"
9 | fi
10 | }
11 |
12 |
13 | max='/sys/class/power_supply/battery/constant_charge_current_max'
14 | bce='/sys/class/power_supply/battery/battery_charging_enabled'
15 | suspend='/sys/class/power_supply/battery/input_suspend'
16 |
17 | if [[ -f $max ]] && [[ `cat $max` = "0" ]]
18 | then
19 | set_value $max 3000000
20 | current_max_path=$max
21 | # "/sys/class/power_supply/battery/constant_charge_current_max"
22 | current_max_backup="vtools.charge.current.max"
23 | current_max=`getprop $current_max_backup`
24 | if [[ ! "$current_max" == "" ]] ; then
25 | set_value $current_max_path $current_max
26 | fi
27 |
28 | fi;
29 |
30 |
31 | if [[ -f $bce ]] || [[ -f $suspend ]]
32 | then
33 | set_value $bce 1
34 | set_value $suspend 0
35 | setprop vtools.bp 0
36 | else
37 | echo 'error'
38 | fi;
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/assets/addin/zram_control.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | # TOTAL_RAM=$(awk '/^MemTotal:/{print $2}' /proc/meminfo) 2>/dev/null
4 |
5 | function write() {
6 | echo -n $2 >$1
7 | }
8 |
9 | function round() {
10 | printf "%.${2}f" "${1}"
11 | }
12 |
13 | # 关闭当前所有的zram(如果正在使用,那可不是一般的慢)
14 | function reset_all_zram() {
15 | for zram in $(blkid | grep swap | awk -F[/:] '{print $4}'); do
16 | zram_dev="/dev/block/${zram}"
17 | dev_index="$(echo $zram | grep -o "[0-9]*$")"
18 | write "/sys/class/zram-control/hot_remove" ${dev_index}
19 | swapoff ${zram_dev}
20 | write "/sys/block/$zram/reset" 1
21 | write "/sys/block/$zram/disksize" 0
22 | done
23 | }
24 |
25 | disksz_mb=768
26 |
27 | # enable_swap_props size(Byte)
28 | enable_swap_props() {
29 | local disksz=$1
30 | setprop vnswap.enabled true
31 | setprop ro.config.zram true
32 | setprop ro.config.zram.support true
33 | setprop zram.disksize ${disksz}
34 | write /proc/sys/vm/swappiness 100
35 | write /proc/sys/vm/swap_ratio_enable 1
36 | write /proc/sys/vm/swap_ratio 70
37 | }
38 |
39 |
40 | # 开启zram
41 | function enable_zram() {
42 | zram=""
43 | disksz_mb=768
44 | disksz=$((${disksz_mb} * 1024 * 1024))
45 | algorithm=lzo
46 |
47 | reset_all_zram
48 |
49 | # 获取zram序号
50 | if [ -e "/sys/class/zram-control/hot_add" ]; then
51 | RAM_DEV=$(cat /sys/class/zram-control/hot_add)
52 | else
53 | RAM_DEV='1'
54 | fi
55 |
56 | if [ -z ${zram} ]; then
57 | zram="zram${RAM_DEV}"
58 | zram_dev="/dev/block/${zram}"
59 | fi
60 |
61 | swapoff ${zram_dev} >/dev/null 2>&1
62 | write /sys/block/${zram}/comp_algorithm ${algorithm} # 压缩算法
63 | # write /sys/block/${zram}/max_comp_streams 8
64 | write /sys/block/${zram}/reset 1
65 | write /sys/block/${zram}/disksize ${disksz_mb}M
66 | mkswap ${zram_dev} >/dev/null 2>&1
67 | swapon ${zram_dev} >/dev/null 2>&1
68 |
69 | # enable_swap_props
70 | }
71 |
72 | # 禁用zram
73 | function disable_zram() {
74 | reset_all_zram
75 |
76 | setprop vnswap.enabled false
77 | setprop ro.config.zram false
78 | setprop ro.config.zram.support false
79 | setprop zram.disksize 0
80 | write /proc/sys/vm/swappiness 0
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/AirplaneMode(OFF).sh:
--------------------------------------------------------------------------------
1 | settings put global airplane_mode_on 0
2 | am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/AirplaneMode(ON).sh:
--------------------------------------------------------------------------------
1 | settings put global airplane_mode_on 1
2 | am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
3 |
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Data(OFF).sh:
--------------------------------------------------------------------------------
1 | svc data disable
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Data(ON).sh:
--------------------------------------------------------------------------------
1 | svc data enable
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Dex2oat(Everything).sh:
--------------------------------------------------------------------------------
1 | am startservice -n com.omarea.vtools/.services.CompileService -a com.omarea.vtools.EverythingCompile
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Dex2oat(Speed).sh:
--------------------------------------------------------------------------------
1 | am startservice -n com.omarea.vtools/.services.CompileService -a com.omarea.vtools.SpeedCompile
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Dex2oat(Speed-profile).sh:
--------------------------------------------------------------------------------
1 | am startservice -n com.omarea.vtools/.services.CompileService -a com.omarea.vtools.SpeedProfileCompile
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/FSTRIM.sh:
--------------------------------------------------------------------------------
1 | fstrim /data
2 | fstrim /data
3 | fstrim /system
4 | fstrim /system
5 | fstrim /cache
6 | fstrim /cache
7 | sm fstrim
8 |
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/GPS(OFF).sh:
--------------------------------------------------------------------------------
1 | version=`getprop ro.build.version.sdk`
2 |
3 | if [[ "$version" > 28 ]]; then
4 | settings put secure location_mode 0
5 | elif [[ "$version" > 22 ]]; then
6 | settings put secure location_providers_allowed -gps
7 | else
8 | settings put secure location_providers_allowed network
9 | fi
10 |
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/GPS(ON).sh:
--------------------------------------------------------------------------------
1 | version=`getprop ro.build.version.sdk`
2 |
3 | if [[ "$version" > 28 ]]; then
4 | settings put secure location_mode 3
5 | elif [[ "$version" > 22 ]]; then
6 | settings put secure location_providers_allowed +gps
7 | else
8 | settings put secure location_providers_allowed gps,network
9 | fi
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Power-Reboot.sh:
--------------------------------------------------------------------------------
1 | sync;svc power reboot || reboot
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/Power-Shutdown.sh:
--------------------------------------------------------------------------------
1 | sync;svc power shutdown || reboot -p
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/WiFi(OFF).sh:
--------------------------------------------------------------------------------
1 | svc wifi disable
--------------------------------------------------------------------------------
/app/src/main/assets/custom-command/WiFi(ON).sh:
--------------------------------------------------------------------------------
1 | svc wifi enable
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/kona/active.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 | task=$2
3 |
4 | cfg_dir=$(cd $(dirname $0); pwd)
5 |
6 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
7 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
8 | exit 1
9 | fi
10 |
11 | source "$cfg_dir/powercfg-utils.sh"
12 |
13 | init () {
14 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
15 | source "$cfg_dir/powercfg-base.sh"
16 | elif [[ -f '/data/powercfg-base.sh' ]]; then
17 | source /data/powercfg-base.sh
18 | fi
19 | }
20 |
21 | if [[ "$action" == "init" ]]; then
22 | init
23 | exit 0
24 | fi
25 |
26 | if [[ "$action" == "fast" ]]; then
27 | devfreq_performance
28 | else
29 | devfreq_restore
30 | fi
31 | reset_basic_governor
32 |
33 |
34 | if [[ "$action" = "powersave" ]]; then
35 | # ctl_on cpu4
36 | # ctl_on cpu7
37 | # set_ctl cpu4 60 35 20
38 | # set_ctl cpu7 60 30 20
39 | set_cpu_freq 300000 1708800 710400 1574400 844800 1747200
40 | gpu_pl_up 0
41 | sched_boost 0 0
42 | set_hispeed_freq 1075200 710400 844800
43 | sched_config "70 67" "86 80" "200" "400"
44 | sched_limit 0 0 0 2000 0 1000
45 | cpuset '0-2' '0-3' '0-3' '0-7'
46 | stune_top_app 0 0
47 | set_cpu_pl 0
48 |
49 |
50 | elif [[ "$action" = "balance" ]]; then
51 | # ctl_on cpu4
52 | # ctl_on cpu7
53 | # set_ctl cpu4 60 30 100
54 | # set_ctl cpu7 60 30 100
55 | set_cpu_freq 300000 1804800 710400 2054400 844800 2361600
56 | gpu_pl_up 0
57 | sched_boost 1 0
58 | set_hispeed_freq 1612800 1056000 1305600
59 | sched_config "53 65" "70 80" "200" "400"
60 | sched_limit 0 0 0 0 0 0
61 | cpuset '0-2' '0-3' '0-6' '0-7'
62 | stune_top_app 0 0
63 | set_cpu_pl 1
64 |
65 |
66 | elif [[ "$action" = "performance" ]]; then
67 | # ctl_off cpu4
68 | # ctl_off cpu7
69 | set_cpu_freq 300000 1804800 710400 2419200 825600 3200000
70 | gpu_pl_up 1
71 | sched_boost 1 0
72 | set_hispeed_freq 1612800 1766400 2073600
73 | sched_config "50 63" "65 78" "200" "400"
74 | sched_limit 0 0 0 0 0 0
75 | cpuset '0-1' '0-3' '0-6' '0-7'
76 | stune_top_app 1 0
77 | set_cpu_pl 1
78 |
79 |
80 | elif [[ "$action" = "fast" ]]; then
81 | # ctl_off cpu4
82 | # ctl_off cpu7
83 | set_cpu_freq 1420800 1804800 1766400 2600000 1977600 3200000
84 | set_hispeed_freq 0 0 0
85 | gpu_pl_up 2
86 | sched_boost 1 1
87 | sched_config "47 60" "60 78" "300" "400"
88 | sched_limit 5000 0 2000 0 2000 0
89 | cpuset '0' '0-3' '0-6' '0-7'
90 | stune_top_app 1 50
91 | set_cpu_pl 1
92 |
93 |
94 | fi
95 |
96 |
97 | adjustment_by_top_app
98 | renice -n -20 `pgrep com.miui.home` 2> /dev/null
99 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/kona/conservative.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 | task=$2
3 |
4 | cfg_dir=$(cd $(dirname $0); pwd)
5 |
6 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
7 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
8 | exit 1
9 | fi
10 |
11 | source "$cfg_dir/powercfg-utils.sh"
12 |
13 | init () {
14 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
15 | source "$cfg_dir/powercfg-base.sh"
16 | elif [[ -f '/data/powercfg-base.sh' ]]; then
17 | source /data/powercfg-base.sh
18 | fi
19 | }
20 |
21 | if [[ "$action" == "init" ]]; then
22 | init
23 | exit 0
24 | fi
25 |
26 | if [[ "$action" == "fast" ]]; then
27 | devfreq_performance
28 | else
29 | devfreq_restore
30 | fi
31 | reset_basic_governor
32 |
33 |
34 | if [[ "$action" = "powersave" ]]; then
35 | # ctl_on cpu4
36 | # ctl_on cpu7
37 | # set_ctl cpu4 65 35 20
38 | # set_ctl cpu7 60 30 20
39 | set_cpu_freq 300000 1708800 710400 1574400 844800 1747200
40 | gpu_pl_up 0
41 | sched_boost 0 0
42 | set_hispeed_freq 1075200 710400 844800
43 | sched_config "72 68" "90 80" "150" "400"
44 | sched_limit 0 0 0 2000 0 1000
45 | cpuset '0-2' '0-3' '0-3' '0-7'
46 | stune_top_app 0 0
47 | set_cpu_pl 0
48 |
49 |
50 | elif [[ "$action" = "balance" ]]; then
51 | # ctl_on cpu4
52 | # ctl_on cpu7
53 | # set_ctl cpu4 60 30 100
54 | # set_ctl cpu7 60 30 100
55 | set_cpu_freq 300000 1804800 710400 1862400 844800 2073600
56 | gpu_pl_up 0
57 | sched_boost 1 0
58 | set_hispeed_freq 1612800 1056000 1305600
59 | sched_config "70 67" "80 80" "150" "400"
60 | sched_limit 0 0 0 500 0 500
61 | cpuset '0-2' '0-3' '0-6' '0-7'
62 | stune_top_app 0 0
63 | set_cpu_pl 0
64 |
65 |
66 |
67 | elif [[ "$action" = "performance" ]]; then
68 | # ctl_off cpu4
69 | # ctl_off cpu7
70 | set_cpu_freq 300000 1804800 710400 2419200 825600 2841600
71 | gpu_pl_up 0
72 | sched_boost 1 0
73 | set_hispeed_freq 1612800 1766400 2073600
74 | sched_config "65 65" "75 80" "200" "400"
75 | sched_limit 0 0 0 0 0 0
76 | cpuset '0-1' '0-3' '0-6' '0-7'
77 | stune_top_app 0 0
78 | set_cpu_pl 1
79 |
80 |
81 |
82 | elif [[ "$action" = "fast" ]]; then
83 | # ctl_off cpu4
84 | # ctl_off cpu7
85 | set_cpu_freq 1248000 1804800 1478400 2600000 1516800 3200000
86 | set_hispeed_freq 0 0 0
87 | gpu_pl_up 2
88 | sched_boost 1 0
89 | sched_config "62 62" "70 78" "300" "400"
90 | sched_limit 5000 0 2000 0 2000 0
91 | cpuset '0' '0-3' '0-6' '0-7'
92 | stune_top_app 1 0
93 | set_cpu_pl 1
94 |
95 |
96 | fi
97 |
98 |
99 | adjustment_by_top_app
100 | renice -n -20 `pgrep com.miui.home` 2> /dev/null
101 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/kona/powercfg_extra.json:
--------------------------------------------------------------------------------
1 | {
2 | "affinityMask": {
3 | "0-3": "F",
4 | "0-6": "7F",
5 | "4-6": "70",
6 | "4-7": "F0",
7 | "0-7": "FF",
8 | "7": "80"
9 | },
10 | "apps": [
11 | {
12 | "friendly": "原神",
13 | "packages": [
14 | "com.miHoYo.Yuanshen",
15 | "com.miHoYo.ys.mi",
16 | "com.miHoYo.ys.bilibili",
17 | "com.miHoYo.GenshinImpact"
18 | ],
19 | "rules": [
20 | {
21 | "cmd": [
22 | "UnityMain"
23 | ],
24 | "cores": "4-7"
25 | },
26 | {
27 | "cmd": [
28 | "UnityGfxDevice*",
29 | "UnityMultiRende*"
30 | ],
31 | "cores": "4-6"
32 | },
33 | {
34 | "cmd": [
35 | "Worker Thread",
36 | "AudioTrack"
37 | ],
38 | "targetMode": "powersave,balance",
39 | "cores": "0-3"
40 | },
41 | {
42 | "cmd": [
43 | "*"
44 | ],
45 | "cores": "0-6"
46 | }
47 | ],
48 | "heavy": [
49 | {
50 | "cmd": "UnityMain",
51 | "cores": "7"
52 | }
53 | ]
54 | },
55 | {
56 | "friendly": "和平精英",
57 | "packages": [
58 | "com.tencent.tmgp.pubgmhd",
59 | "com.tencent.ig"
60 | ],
61 | "rules": [
62 | {
63 | "cmd": [
64 | "RenderThread"
65 | ],
66 | "cores": "7"
67 | },
68 | {
69 | "cmd": [
70 | "*"
71 | ],
72 | "cores": "0-6"
73 | }
74 | ],
75 | "heavy": [
76 | {
77 | "cmd": "UnityMain",
78 | "cores": "7"
79 | }
80 | ]
81 | }
82 | ]
83 | }
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/lahaina/active.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 | task=$2
3 |
4 | cfg_dir=$(cd $(dirname $0); pwd)
5 |
6 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
7 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
8 | exit 1
9 | fi
10 |
11 | source "$cfg_dir/powercfg-utils.sh"
12 |
13 | init () {
14 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
15 | source "$cfg_dir/powercfg-base.sh"
16 | elif [[ -f '/data/powercfg-base.sh' ]]; then
17 | source /data/powercfg-base.sh
18 | fi
19 | }
20 |
21 | if [[ "$action" == "init" ]]; then
22 | init
23 | exit 0
24 | fi
25 |
26 | reset_basic_governor
27 |
28 | if [[ "$action" = "powersave" ]]; then
29 | # ctl_on cpu4
30 | # ctl_on cpu7
31 | # set_ctl cpu4 60 35 20
32 | # set_ctl cpu7 60 30 20
33 | set_cpu_freq 300000 1708800 710400 1555200 844800 1785600
34 | gpu_pl_up 0
35 | sched_boost 0 0
36 | set_hispeed_freq 902400 710400 844800
37 | sched_config "85 75" "96 86" "150" "400"
38 | sched_limit 0 0 0 2000 0 1000
39 | cpuset '0-2' '0-3' '0-3' '0-7'
40 | stune_top_app 0 0
41 | cpuctl foreground 0 0 0 1
42 | cpuctl background 0 0 0 0
43 | cpuctl top-app 0 0 0 max
44 | bw_min
45 | bw_down 3 3
46 | thermal_disguise 0
47 | set_cpu_pl 0
48 | if [[ "$manufacturer" == "Xiaomi" ]]; then
49 | stop miuibooster
50 | fi
51 |
52 |
53 | elif [[ "$action" = "balance" ]]; then
54 | # ctl_on cpu4
55 | # ctl_on cpu7
56 | # set_ctl cpu4 60 30 100
57 | # set_ctl cpu7 60 30 100
58 | set_cpu_freq 300000 1804800 710400 1996800 844800 2380800
59 | gpu_pl_up 0
60 | sched_boost 1 0
61 | set_hispeed_freq 1612800 1075200 1305600
62 | sched_config "78 70" "89 82" "150" "400"
63 | sched_limit 0 0 0 500 0 500
64 | cpuset '0-2' '0-3' '0-6' '0-7'
65 | stune_top_app 0 0
66 | cpuctl foreground 0 1 0 max
67 | cpuctl background 0 1 0 1
68 | cpuctl top-app 0 1 0.25 max
69 | bw_min
70 | bw_down 2 2
71 | thermal_disguise 0
72 | set_cpu_pl 0
73 | if [[ "$manufacturer" == "Xiaomi" ]]; then
74 | start miuibooster
75 | fi
76 |
77 |
78 | elif [[ "$action" = "performance" ]]; then
79 | # ctl_off cpu4
80 | # ctl_off cpu7
81 | set_cpu_freq 300000 1804800 710400 2419200 825600 2841600
82 | gpu_pl_up 1
83 | sched_boost 1 0
84 | set_hispeed_freq 0 0 0
85 | sched_config "62 55" "72 65" "200" "400"
86 | sched_limit 0 0 0 0 0 0
87 | cpuset '0-1' '0-3' '0-6' '0-7'
88 | stune_top_app 1 0
89 | cpuctl foreground 0 1 0 max
90 | cpuctl background 0 1 0 max
91 | cpuctl top-app 0 1 0.5 max
92 | bw_min
93 | bw_max
94 | thermal_disguise 0
95 | set_cpu_pl 1
96 | if [[ "$manufacturer" == "Xiaomi" ]]; then
97 | start miuibooster
98 | fi
99 |
100 |
101 | elif [[ "$action" = "fast" ]]; then
102 | # ctl_off cpu4
103 | # ctl_off cpu7
104 | set_cpu_freq 1401600 1804800 1766400 2600000 1670400 3200000
105 | set_hispeed_freq 0 0 0
106 | gpu_pl_up 2
107 | sched_boost 1 1
108 | sched_config "62 35" "70 50" "300" "400"
109 | sched_limit 5000 0 2000 0 2000 0
110 | cpuset '0' '0-3' '0-6' '0-7'
111 | stune_top_app 1 50
112 | cpuctl foreground 0 1 0 max
113 | cpuctl background 0 1 0 max
114 | cpuctl top-app 0 1 max max
115 | bw_max_always
116 | thermal_disguise 1
117 | set_cpu_pl 1
118 | if [[ "$manufacturer" == "Xiaomi" ]]; then
119 | start miuibooster
120 | fi
121 |
122 |
123 | fi
124 |
125 | adjustment_by_top_app
126 | restore_core_online
127 | renice -n -20 `pgrep com.miui.home` 2> /dev/null
128 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/lahaina/conservative.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 | task=$2
3 |
4 | cfg_dir=$(cd $(dirname $0); pwd)
5 |
6 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
7 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
8 | exit 1
9 | fi
10 |
11 | source "$cfg_dir/powercfg-utils.sh"
12 |
13 | init () {
14 | echo '[Scene PerfConfig Init] ...'
15 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
16 | source "$cfg_dir/powercfg-base.sh"
17 | elif [[ -f '/data/powercfg-base.sh' ]]; then
18 | source /data/powercfg-base.sh
19 | fi
20 | echo '[Scene PerfConfig Init] √'
21 | }
22 |
23 | if [[ "$action" == "init" ]]; then
24 | init
25 | exit 0
26 | fi
27 |
28 | reset_basic_governor
29 |
30 | if [[ "$action" = "powersave" ]]; then
31 | # ctl_on cpu4
32 | # ctl_on cpu7
33 | # set_ctl cpu4 60 35 20
34 | # set_ctl cpu7 60 30 20
35 | set_cpu_freq 300000 1708800 710400 1555200 844800 1785600
36 | gpu_pl_up 0
37 | sched_boost 0 0
38 | set_hispeed_freq 902400 710400 844800
39 | sched_config "85 75" "96 86" "150" "400"
40 | sched_limit 0 2000 0 5000 0 1000
41 | cpuset '0-2' '0-3' '0-3' '0-7'
42 | stune_top_app 0 0
43 | cpuctl foreground 0 0 0 1
44 | cpuctl background 0 0 0 0
45 | cpuctl top-app 0 0 0 max
46 | bw_min
47 | bw_down 3 3
48 | thermal_disguise 0
49 | set_cpu_pl 0
50 | if [[ "$manufacturer" == "Xiaomi" ]]; then
51 | stop miuibooster
52 | fi
53 |
54 |
55 | elif [[ "$action" = "balance" ]]; then
56 | # ctl_on cpu4
57 | # ctl_on cpu7
58 | # set_ctl cpu4 60 30 100
59 | # set_ctl cpu7 60 30 100
60 | set_cpu_freq 300000 1804800 710400 1881600 844800 2035200
61 | gpu_pl_up 0
62 | sched_boost 1 0
63 | set_hispeed_freq 1612800 1075200 1305600
64 | sched_config "78 75" "89 86" "150" "400"
65 | sched_limit 0 0 0 500 0 500
66 | cpuset '0-2' '0-3' '0-6' '0-7'
67 | stune_top_app 0 0
68 | cpuctl foreground 0 1 0 max
69 | cpuctl background 0 1 0 1
70 | cpuctl top-app 0 1 0 max
71 | bw_min
72 | bw_down 2 2
73 | thermal_disguise 0
74 | set_cpu_pl 0
75 | if [[ "$manufacturer" == "Xiaomi" ]]; then
76 | stop miuibooster
77 | fi
78 |
79 |
80 | elif [[ "$action" = "performance" ]]; then
81 | # ctl_off cpu4
82 | # ctl_off cpu7
83 | set_cpu_freq 300000 1804800 710400 2419200 825600 2841600
84 | gpu_pl_up 0
85 | sched_boost 1 0
86 | set_hispeed_freq 1612800 1766400 2035200
87 | sched_config "65 65" "75 78" "200" "400"
88 | sched_limit 0 0 0 0 0 0
89 | cpuset '0-1' '0-3' '0-6' '0-7'
90 | stune_top_app 0 0
91 | cpuctl foreground 0 1 0 max
92 | cpuctl background 0 1 0 max
93 | cpuctl top-app 0 1 0.25 max
94 | bw_min
95 | bw_max
96 | thermal_disguise 0
97 | set_cpu_pl 1
98 | if [[ "$manufacturer" == "Xiaomi" ]]; then
99 | start miuibooster
100 | fi
101 |
102 |
103 | elif [[ "$action" = "fast" ]]; then
104 | # ctl_off cpu4
105 | # ctl_off cpu7
106 | set_cpu_freq 1401600 1804800 1440000 2600000 1555200 3200000
107 | set_hispeed_freq 0 0 0
108 | gpu_pl_up 2
109 | sched_boost 1 0
110 | sched_config "62 40" "70 52" "300" "400"
111 | sched_limit 5000 0 2000 0 2000 0
112 | cpuset '0' '0-3' '0-6' '0-7'
113 | stune_top_app 1 0
114 | cpuctl foreground 0 1 0 max
115 | cpuctl background 0 1 0 max
116 | cpuctl top-app 0 1 max max
117 | bw_max_always
118 | thermal_disguise 1
119 | set_cpu_pl 1
120 | if [[ "$manufacturer" == "Xiaomi" ]]; then
121 | start miuibooster
122 | fi
123 |
124 |
125 | fi
126 |
127 | adjustment_by_top_app
128 | restore_core_online
129 | renice -n -20 `pgrep com.miui.home` 2> /dev/null
130 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/lahaina/powercfg_extra.json:
--------------------------------------------------------------------------------
1 | {
2 | "affinityMask": {
3 | "0-3": "F",
4 | "0-6": "7F",
5 | "4-6": "70",
6 | "4-7": "F0",
7 | "0-7": "FF",
8 | "7": "80"
9 | },
10 | "apps": [
11 | {
12 | "friendly": "原神",
13 | "packages": [
14 | "com.miHoYo.Yuanshen",
15 | "com.miHoYo.ys.mi",
16 | "com.miHoYo.ys.bilibili",
17 | "com.miHoYo.GenshinImpact"
18 | ],
19 | "rules": [
20 | {
21 | "cmd": [
22 | "UnityMain"
23 | ],
24 | "cores": "4-7"
25 | },
26 | {
27 | "cmd": [
28 | "UnityGfxDevice*",
29 | "UnityMultiRende*"
30 | ],
31 | "cores": "4-6"
32 | },
33 | {
34 | "cmd": [
35 | "*"
36 | ],
37 | "cores": "0-6"
38 | }
39 | ],
40 | "heavy": [
41 | {
42 | "cmd": "UnityMain",
43 | "cores": "7"
44 | }
45 | ]
46 | },
47 | {
48 | "friendly": "和平精英",
49 | "packages": [
50 | "com.tencent.tmgp.pubgmhd",
51 | "com.tencent.ig"
52 | ],
53 | "rules": [
54 | {
55 | "cmd": [
56 | "RenderThread"
57 | ],
58 | "cores": "7"
59 | },
60 | {
61 | "cmd": [
62 | "*"
63 | ],
64 | "cores": "0-6"
65 | }
66 | ],
67 | "heavy": [
68 | {
69 | "cmd": "UnityMain",
70 | "cores": "7"
71 | }
72 | ]
73 | }
74 | ]
75 | }
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/lito/powercfg-base.sh:
--------------------------------------------------------------------------------
1 | #! /vendor/bin/sh
2 |
3 | target=`getprop ro.board.platform`
4 |
5 | case "$target" in
6 | "kona")
7 |
8 | # Controls how many more tasks should be eligible to run on gold CPUs
9 | # w.r.t number of gold CPUs available to trigger assist (max number of
10 | # tasks eligible to run on previous cluster minus number of CPUs in
11 | # the previous cluster).
12 | #
13 | # Setting to 1 by default which means there should be at least
14 | # 4 tasks eligible to run on gold cluster (tasks running on gold cores
15 | # plus misfit tasks on silver cores) to trigger assitance from gold+.
16 | echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/nr_prev_assist_thresh
17 |
18 | # Disable Core control on silver
19 | echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable
20 |
21 | echo 1 > /sys/devices/system/cpu/cpu6/core_ctl/enable
22 | echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/enable
23 | echo 0 > /sys/devices/system/cpu/cpu6/core_ctl/min_cpus
24 | echo 0 > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus
25 |
26 | # Setting b.L scheduler parameters
27 | echo 95 95 > /proc/sys/kernel/sched_upmigrate
28 | echo 85 85 > /proc/sys/kernel/sched_downmigrate
29 | echo 100 > /proc/sys/kernel/sched_group_upmigrate
30 | echo 85 > /proc/sys/kernel/sched_group_downmigrate
31 | echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks
32 | echo 400000000 > /proc/sys/kernel/sched_coloc_downmigrate_ns
33 |
34 | # cpuset parameters
35 | echo 0-2 > /dev/cpuset/background/cpus
36 | echo 0-3 > /dev/cpuset/system-background/cpus
37 | echo 0-7 > /dev/cpuset/foreground/cpus
38 | echo 0-7 > /dev/cpuset/top-app/cpus
39 |
40 | # Turn off scheduler boost at the end
41 | echo 0 > /proc/sys/kernel/sched_boost
42 |
43 | # Turn on scheduler boost for top app main
44 | echo 1 > /proc/sys/kernel/sched_boost_top_app
45 |
46 | # configure governor settings for silver cluster
47 | echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
48 | echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us
49 | echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us
50 | echo 1516800 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq
51 | echo 300000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
52 | echo 1 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl
53 |
54 | # configure input boost settings
55 | echo "0:1516800" > /sys/devices/system/cpu/cpu_boost/input_boost_freq
56 | echo 120 > /sys/devices/system/cpu/cpu_boost/input_boost_ms
57 | echo "0:1804800 1:0 2:0 3:0 4:0 5:0 6:2208000 7:2400000" > /sys/devices/system/cpu/cpu_boost/powerkey_input_boost_freq
58 | echo 400 > /sys/devices/system/cpu/cpu_boost/powerkey_input_boost_ms
59 |
60 | # configure governor settings for gold cluster
61 | echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor
62 | echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/down_rate_limit_us
63 | echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/up_rate_limit_us
64 | echo 1478400 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/hispeed_freq
65 | echo 1 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/pl
66 |
67 | # configure governor settings for gold+ cluster
68 | echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy7/scaling_governor
69 | echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/down_rate_limit_us
70 | echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/up_rate_limit_us
71 | echo 1766400 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq
72 | echo 1 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/pl
73 |
74 | echo N > /sys/module/lpm_levels/parameters/sleep_disabled
75 | ;;
76 | esac
77 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8952/info.txt:
--------------------------------------------------------------------------------
1 | msm8952 {
2 | 617
3 | ...
4 | msm8976: {
5 | 650
6 | 652
7 | 653
8 | 660
9 | }
10 | }
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8953/active-base.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | #scheduler settings
4 | echo 3 > /proc/sys/kernel/sched_window_stats_policy
5 | echo 3 > /proc/sys/kernel/sched_ravg_hist_size
6 |
7 | #init task load, restrict wakeups to preferred cluster
8 | echo 15 > /proc/sys/kernel/sched_init_task_load
9 | # spill load is set to 100% by default in the kernel
10 | echo 3 > /proc/sys/kernel/sched_spill_nr_run
11 | # Apply inter-cluster load balancer restrictions
12 | echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill
13 |
14 | #governor settings
15 | echo 1 > /sys/devices/system/cpu/cpu0/online
16 | echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
17 | echo "19000 1401600:39000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
18 | echo 85 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
19 | echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate
20 | echo 1401600 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
21 | echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy
22 | echo "85 1401600:80" > /sys/devices/system/cpu/cpufreq/interactive/target_loads
23 | echo 39000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
24 | echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor
25 | echo 652800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
26 |
27 | # Bring up all cores online
28 | echo 1 > /sys/devices/system/cpu/cpu1/online
29 | echo 1 > /sys/devices/system/cpu/cpu2/online
30 | echo 1 > /sys/devices/system/cpu/cpu3/online
31 | echo 1 > /sys/devices/system/cpu/cpu4/online
32 | echo 1 > /sys/devices/system/cpu/cpu5/online
33 | echo 1 > /sys/devices/system/cpu/cpu6/online
34 | echo 1 > /sys/devices/system/cpu/cpu7/online
35 |
36 | # Enable low power modes
37 | echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled
38 |
39 | # SMP scheduler
40 | echo 85 > /proc/sys/kernel/sched_upmigrate
41 | echo 85 > /proc/sys/kernel/sched_downmigrate
42 | echo 19 > /proc/sys/kernel/sched_upmigrate_min_nice
43 |
44 | # Enable sched guided freq control
45 | echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_sched_load
46 | echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_migration_notif
47 | echo 200000 > /proc/sys/kernel/sched_freq_inc_notify
48 | echo 200000 > /proc/sys/kernel/sched_freq_dec_notify
49 | echo 0 > /sys/devices/system/cpu/cpufreq/interactive/use_sched_load
50 |
51 | echo 128 > /sys/block/mmcblk0/bdi/read_ahead_kb
52 | echo 128 > /sys/block/mmcblk0/queue/read_ahead_kb
53 | echo 128 > /sys/block/dm-0/queue/read_ahead_kb
54 | echo 128 > /sys/block/dm-1/queue/read_ahead_kb
55 |
56 | echo 1 > /proc/sys/kernel/sched_prefer_sync_wakee_to_waker
57 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8953/conservative-base.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | #scheduler settings
4 | echo 3 > /proc/sys/kernel/sched_window_stats_policy
5 | echo 3 > /proc/sys/kernel/sched_ravg_hist_size
6 |
7 | #init task load, restrict wakeups to preferred cluster
8 | echo 15 > /proc/sys/kernel/sched_init_task_load
9 | # spill load is set to 100% by default in the kernel
10 | echo 3 > /proc/sys/kernel/sched_spill_nr_run
11 | # Apply inter-cluster load balancer restrictions
12 | echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill
13 |
14 |
15 | #governor settings
16 | echo 1 > /sys/devices/system/cpu/cpu0/online
17 | echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
18 | echo "19000 1401600:39000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
19 | echo 85 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
20 | echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate
21 | echo 1401600 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
22 | echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy
23 | echo "85 1401600:80" > /sys/devices/system/cpu/cpufreq/interactive/target_loads
24 | echo 39000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
25 | echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor
26 | echo 652800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
27 |
28 | # re-enable thermal & BCL core_control now
29 | echo 1 > /sys/module/msm_thermal/core_control/enabled
30 |
31 | # Bring up all cores online
32 | echo 1 > /sys/devices/system/cpu/cpu1/online
33 | echo 1 > /sys/devices/system/cpu/cpu2/online
34 | echo 1 > /sys/devices/system/cpu/cpu3/online
35 | echo 1 > /sys/devices/system/cpu/cpu4/online
36 | echo 1 > /sys/devices/system/cpu/cpu5/online
37 | echo 1 > /sys/devices/system/cpu/cpu6/online
38 | echo 1 > /sys/devices/system/cpu/cpu7/online
39 |
40 | # Enable low power modes
41 | echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled
42 |
43 | # SMP scheduler
44 | echo 85 > /proc/sys/kernel/sched_upmigrate
45 | echo 85 > /proc/sys/kernel/sched_downmigrate
46 | echo 19 > /proc/sys/kernel/sched_upmigrate_min_nice
47 |
48 | # Enable sched guided freq control
49 | echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_sched_load
50 | echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_migration_notif
51 | echo 200000 > /proc/sys/kernel/sched_freq_inc_notify
52 | echo 200000 > /proc/sys/kernel/sched_freq_dec_notify
53 | echo 0 > /sys/devices/system/cpu/cpufreq/interactive/use_sched_load
54 |
55 | echo 128 > /sys/block/mmcblk0/bdi/read_ahead_kb
56 | echo 128 > /sys/block/mmcblk0/queue/read_ahead_kb
57 | echo 128 > /sys/block/dm-0/queue/read_ahead_kb
58 | echo 128 > /sys/block/dm-1/queue/read_ahead_kb
59 |
60 |
61 | #chmod 0755 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
62 | #echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
63 | #chmod 0755 /sys/module/workqueue/parameters/power_efficient
64 | #echo "Y" > /sys/module/workqueue/parameters/power_efficient
65 | #chmod 0755 -R /sys/devices/system/cpu/cpufreq/ondemand
66 | #echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy
67 | #echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
68 |
69 | echo 1 > /proc/sys/kernel/sched_prefer_sync_wakee_to_waker
70 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8974/active-base.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | echo 1 > /sys/devices/system/cpu/cpu0/online
4 | echo 1 > /sys/devices/system/cpu/cpu1/online
5 | echo 1 > /sys/devices/system/cpu/cpu2/online
6 | echo 1 > /sys/devices/system/cpu/cpu3/online
7 |
8 | stop thermal-engine
9 |
10 | echo 0 > /sys/module/msm_thermal/core_control/enabled
11 | echo 0 > /sys/module/msm_thermal/vdd_restriction/enabled
12 | echo N > /sys/module/msm_thermal/parameters/enabled
13 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8974/active.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | action=$1
4 |
5 | init () {
6 | local dir=$(cd $(dirname $0); pwd)
7 | if [[ -f "$dir/powercfg-base.sh" ]]; then
8 | sh "$dir/powercfg-base.sh"
9 | elif [[ -f '/data/powercfg-base.sh' ]]; then
10 | sh /data/powercfg-base.sh
11 | fi
12 | }
13 | if [[ "$action" == "init" ]]; then
14 | init
15 | exit 0
16 | fi
17 |
18 | function set_online() {
19 | echo 1 > /sys/devices/system/cpu/cpu0/online
20 | echo 1 > /sys/devices/system/cpu/cpu1/online
21 | echo 1 > /sys/devices/system/cpu/cpu2/online
22 | echo 1 > /sys/devices/system/cpu/cpu3/online
23 | }
24 |
25 |
26 | function set_freq() {
27 | local freq_min="$1"
28 | local freq_max="$2"
29 | set_online
30 |
31 | echo interactive > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
32 | echo $freq_min > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
33 | echo $freq_max > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
34 |
35 | echo interactive > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
36 | echo $freq_min > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
37 | echo $freq_max > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
38 |
39 | echo interactive > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
40 | echo $freq_min > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq
41 | echo $freq_max > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
42 |
43 | echo interactive > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
44 | echo $freq_min > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq
45 | echo $freq_max > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
46 | }
47 |
48 | # if [[ -f /system/bin/changepowermode.sh ]]; then
49 | # /system/bin/changepowermode.sh middle
50 | # fi
51 |
52 | # if [[ -f /system/bin/changepowermode.sh ]]; then
53 | # /system/bin/changepowermode.sh high
54 | # else
55 |
56 | if [[ "$action" = "powersave" ]]; then
57 | start mpdecision
58 | set_freq 300000 1958400
59 |
60 | exit 0
61 | elif [[ "$action" = "balance" ]]; then
62 | stop mpdecision
63 | set_freq 300000 2457600
64 |
65 | exit 0
66 | elif [[ "$action" = "performance" ]]; then
67 | stop mpdecision
68 | set_freq 960000 2457600
69 |
70 | exit 0
71 | elif [[ "$action" = "fast" ]]; then
72 | stop mpdecision
73 | set_freq 1574400 2457600
74 |
75 | exit 0
76 | fi
77 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8974/conservative-base.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | echo 1 > /sys/devices/system/cpu/cpu0/online
4 | echo 1 > /sys/devices/system/cpu/cpu1/online
5 | echo 1 > /sys/devices/system/cpu/cpu2/online
6 | echo 1 > /sys/devices/system/cpu/cpu3/online
7 |
8 | stop thermal-engine
9 |
10 | echo 0 > /sys/module/msm_thermal/core_control/enabled
11 | echo 0 > /sys/module/msm_thermal/vdd_restriction/enabled
12 | echo N > /sys/module/msm_thermal/parameters/enabled
13 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msm8974/conservative.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | action=$1
4 |
5 | init () {
6 | local dir=$(cd $(dirname $0); pwd)
7 | if [[ -f "$dir/powercfg-base.sh" ]]; then
8 | sh "$dir/powercfg-base.sh"
9 | elif [[ -f '/data/powercfg-base.sh' ]]; then
10 | sh /data/powercfg-base.sh
11 | fi
12 | }
13 | if [[ "$action" == "init" ]]; then
14 | init
15 | exit 0
16 | fi
17 |
18 | function set_online() {
19 | echo 1 > /sys/devices/system/cpu/cpu0/online
20 | echo 1 > /sys/devices/system/cpu/cpu1/online
21 | echo 1 > /sys/devices/system/cpu/cpu2/online
22 | echo 1 > /sys/devices/system/cpu/cpu3/online
23 | }
24 |
25 | function set_freq() {
26 | local freq_min="$1"
27 | local freq_max="$2"
28 | set_online
29 |
30 | echo interactive > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
31 | echo $freq_min > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
32 | echo $freq_max > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
33 |
34 | echo interactive > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
35 | echo $freq_min > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
36 | echo $freq_max > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
37 |
38 | echo interactive > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
39 | echo $freq_min > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq
40 | echo $freq_max > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
41 |
42 | echo interactive > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
43 | echo $freq_min > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq
44 | echo $freq_max > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
45 | }
46 |
47 | if [[ "$action" = "powersave" ]]; then
48 | start mpdecision
49 | set_freq 300000 1958400
50 |
51 | exit 0
52 | elif [[ "$action" = "balance" ]]; then
53 | stop mpdecision
54 | set_freq 300000 2265600
55 |
56 | exit 0
57 | elif [[ "$action" = "performance" ]]; then
58 | stop mpdecision
59 | set_freq 300000 2457600
60 |
61 | exit 0
62 | elif [[ "$action" = "fast" ]]; then
63 | stop mpdecision
64 | set_freq 960000 2457600
65 |
66 | exit 0
67 | fi
68 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msmnile/active.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 | task=$2
3 |
4 | cfg_dir=$(cd $(dirname $0); pwd)
5 |
6 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
7 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
8 | exit 1
9 | fi
10 |
11 | source "$cfg_dir/powercfg-utils.sh"
12 |
13 | init () {
14 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
15 | source "$cfg_dir/powercfg-base.sh"
16 | elif [[ -f '/data/powercfg-base.sh' ]]; then
17 | source /data/powercfg-base.sh
18 | fi
19 | }
20 |
21 | if [[ "$action" == "init" ]]; then
22 | init
23 | exit 0
24 | fi
25 |
26 | if [[ "$action" == "fast" ]]; then
27 | devfreq_performance
28 | else
29 | devfreq_restore
30 | fi
31 | reset_basic_governor
32 |
33 | if [[ "$action" = "powersave" ]]; then
34 | ctl_on cpu4
35 | ctl_on cpu7
36 |
37 | set_cpu_freq 300000 1708800 710400 1612800 825600 1920000
38 | gpu_pl_up 0
39 | sched_boost 1 0
40 | stune_top_app 0 0
41 | sched_config "75 75" "87 90" "160" "260"
42 | sched_limit 0 0 0 5000 0 5000
43 | set_hispeed_freq 1209600 825600 940800
44 | set_hispeed_load 90 90 90
45 | cpuset '0-2' '0-3' '0-3' '0-7'
46 | bw_min
47 | bw_down 1
48 | set_cpu_pl 0
49 |
50 |
51 | elif [[ "$action" = "balance" ]]; then
52 | ctl_on cpu4
53 | ctl_on cpu7
54 | set_cpu_freq 300000 1785600 710400 1920000 825600 2323200
55 | gpu_pl_up 0
56 | sched_boost 1 0
57 | stune_top_app 0 0
58 | sched_config "65 70" "80 87" "120" "200"
59 | sched_limit 0 0 0 500 0 500
60 | set_hispeed_freq 1478400 1056000 1286400
61 | set_hispeed_load 80 90 90
62 | cpuset '0-2' '0-3' '0-6' '0-7'
63 | bw_min
64 | bw_down 1
65 | set_cpu_pl 1
66 |
67 |
68 | elif [[ "$action" = "performance" ]]; then
69 | ctl_off cpu4
70 | ctl_off cpu7
71 | set_cpu_freq 300000 1785600 710400 2419200 825600 2841600
72 | gpu_pl_up 1
73 | sched_boost 1 0
74 | stune_top_app 0 0
75 | sched_config "60 70" "72 83" "85" "100"
76 | sched_limit 0 0 0 0 0 0
77 | set_hispeed_freq 1632000 1708800 2016000
78 | set_hispeed_load 60 70 80
79 | cpuset '0-2' '0-3' '0-6' '0-7'
80 | bw_min
81 | bw_max
82 | set_cpu_pl 1
83 |
84 |
85 | elif [[ "$action" = "fast" ]]; then
86 | ctl_off cpu4
87 | ctl_off cpu7
88 | set_cpu_freq 1036800 1785600 1612800 2600000 1708800 3200000
89 | gpu_pl_up 2
90 | sched_boost 1 0
91 | stune_top_app 1 0
92 | sched_config "55 69" "68 79" "300" "400"
93 | sched_limit 50000 0 20000 0 20000 0
94 | set_hispeed_freq 0 0 0
95 | set_hispeed_load 50 60 70
96 | cpuset '0-1' '0-3' '0-6' '0-7'
97 | bw_max_always
98 | set_cpu_pl 1
99 |
100 |
101 | fi
102 |
103 | adjustment_by_top_app
104 | renice -n -20 `pgrep com.miui.home` 2> /dev/null
105 |
106 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msmnile/conservative.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 | task=$2
3 |
4 | cfg_dir=$(cd $(dirname $0); pwd)
5 |
6 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
7 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
8 | exit 1
9 | fi
10 |
11 | source "$cfg_dir/powercfg-utils.sh"
12 |
13 | init () {
14 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
15 | source "$cfg_dir/powercfg-base.sh"
16 | elif [[ -f '/data/powercfg-base.sh' ]]; then
17 | source /data/powercfg-base.sh
18 | fi
19 | }
20 |
21 | if [[ "$action" == "init" ]]; then
22 | init
23 | exit 0
24 | fi
25 |
26 | if [[ "$action" == "fast" ]]; then
27 | devfreq_performance
28 | else
29 | devfreq_restore
30 | fi
31 | reset_basic_governor
32 |
33 |
34 | if [[ "$action" = "powersave" ]]; then
35 | ctl_on cpu4
36 | ctl_on cpu7
37 | set_cpu_freq 300000 1708800 710400 1401600 825600 1497600
38 | gpu_pl_up 0
39 | sched_boost 0 0
40 | stune_top_app 0 0
41 | sched_config "85 85" "96 96" "160" "260"
42 | sched_limit 0 0 0 5000 0 5000
43 | set_hispeed_freq 1209600 825600 940800
44 | set_hispeed_load 80 90 90
45 | cpuset '0-2' '0-3' '0-3' '0-7'
46 | bw_min
47 | bw_down 2
48 | set_cpu_pl 0
49 |
50 |
51 | elif [[ "$action" = "balance" ]]; then
52 | ctl_on cpu4
53 | ctl_on cpu7
54 | set_cpu_freq 300000 1708800 710400 1708800 825600 1920000
55 | gpu_pl_up 0
56 | sched_boost 1 0
57 | stune_top_app 0 0
58 | sched_config "78 85" "89 96" "120" "200"
59 | sched_limit 0 0 0 500 0 500
60 | set_hispeed_freq 1478400 1056000 1286400
61 | set_hispeed_load 80 90 90
62 | cpuset '0-2' '0-3' '0-6' '0-7'
63 | bw_min
64 | bw_down 1
65 | set_cpu_pl 1
66 |
67 |
68 | elif [[ "$action" = "performance" ]]; then
69 | ctl_off cpu4
70 | ctl_off cpu7
71 | set_cpu_freq 300000 1785600 710400 2419200 825600 2841600
72 | gpu_pl_up 1
73 | sched_boost 1 0
74 | stune_top_app 0 0
75 | sched_config "62 78" "72 85" "85" "100"
76 | sched_limit 0 0 0 0 0 0
77 | set_hispeed_freq 1632000 1708800 2016000
78 | set_hispeed_load 60 70 80
79 | cpuset '0-2' '0-3' '0-6' '0-7'
80 | bw_min
81 | bw_max
82 | set_cpu_pl 1
83 |
84 |
85 | elif [[ "$action" = "fast" ]]; then
86 | ctl_off cpu4
87 | ctl_off cpu7
88 | set_cpu_freq 1209600 1785600 1497600 2600000 1497600 3200000
89 | gpu_pl_up 2
90 | sched_boost 1 0
91 | stune_top_app 1 0
92 | sched_config "55 70" "68 79" "300" "400"
93 | sched_limit 50000 0 20000 0 20000 0
94 | set_hispeed_freq 0 0 0
95 | set_hispeed_load 50 60 70
96 | cpuset '0-1' '0-3' '0-6' '0-7'
97 | bw_min
98 | bw_max
99 | set_cpu_pl 1
100 |
101 |
102 | fi
103 |
104 | adjustment_by_top_app
105 | renice -n -20 `pgrep com.miui.home` 2> /dev/null
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/msmnile/powercfg_extra.json:
--------------------------------------------------------------------------------
1 | {
2 | "affinityMask": {
3 | "0-3": "F",
4 | "0-6": "7F",
5 | "4-6": "70",
6 | "4-7": "F0",
7 | "0-7": "FF",
8 | "7": "80"
9 | },
10 | "apps": [
11 | {
12 | "friendly": "原神",
13 | "packages": [
14 | "com.miHoYo.Yuanshen",
15 | "com.miHoYo.ys.mi",
16 | "com.miHoYo.ys.bilibili",
17 | "com.miHoYo.GenshinImpact"
18 | ],
19 | "rules": [
20 | {
21 | "cmd": [
22 | "UnityMain"
23 | ],
24 | "cores": "4-7"
25 | },
26 | {
27 | "cmd": [
28 | "UnityGfxDevice*",
29 | "UnityMultiRende*"
30 | ],
31 | "cores": "4-6"
32 | },
33 | {
34 | "cmd": [
35 | "Worker Thread",
36 | "AudioTrack"
37 | ],
38 | "targetMode": "powersave,balance",
39 | "cores": "0-3"
40 | },
41 | {
42 | "cmd": [
43 | "*"
44 | ],
45 | "cores": "0-6"
46 | }
47 | ],
48 | "heavy": [
49 | {
50 | "cmd": "UnityMain",
51 | "cores": "7"
52 | }
53 | ]
54 | },
55 | {
56 | "friendly": "和平精英",
57 | "packages": [
58 | "com.tencent.tmgp.pubgmhd",
59 | "com.tencent.ig"
60 | ],
61 | "rules": [
62 | {
63 | "cmd": [
64 | "RenderThread"
65 | ],
66 | "cores": "7"
67 | },
68 | {
69 | "cmd": [
70 | "*"
71 | ],
72 | "cores": "0-6"
73 | }
74 | ],
75 | "heavy": [
76 | {
77 | "cmd": "UnityMain",
78 | "cores": "7"
79 | }
80 | ]
81 | }
82 | ]
83 | }
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/mt6873/info.txt:
--------------------------------------------------------------------------------
1 | mt6889:天玑1000(+)
2 | mt6885:天玑1000l
3 | mt6875:天玑820
4 | mt6873:天玑800
5 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/mt6873/powercfg-base.sh:
--------------------------------------------------------------------------------
1 | function ged() {
2 | echo $2 > /sys/module/ged/parameters/$1
3 | }
4 |
5 | function gpu_limit() {
6 | # echo [id][up_enable][low_enable] > /proc/gpufreq/gpufreq_limit_table
7 | # ex: echo 3 0 0 > /proc/gpufreq/gpufreq_limit_table
8 | # means disable THERMAL upper_limit_idx & lower_limit_idx
9 | #
10 | # [name] [id] [prio] [up_idx] [up_enable] [low_idx] [low_enable]
11 | # STRESS 0 8 -1 0 -1 0
12 | # PROC 1 7 34 0 34 0
13 | # PTPOD 2 6 -1 0 -1 0
14 | # THERMAL 3 5 -1 0 -1 0
15 | # BATT_OC 4 5 -1 0 -1 0
16 | # BATT_LOW 5 5 -1 0 -1 0
17 | # BATT_PERCENT 6 5 -1 0 -1 0
18 | # PBM 7 5 -1 0 -1 0
19 | # POLICY 8 4 -1 0 -1 0
20 |
21 | local limited="$1"
22 | for i in 0 1 2 3 4 5 6 7 8
23 | do
24 | # echo $i $limited $limited
25 | echo $i $limited $limited > /proc/gpufreq/gpufreq_limit_table
26 | done
27 | }
28 |
29 | # gpu_limit 0
30 |
31 | ged boost_gpu_enable 0
32 | ged enable_cpu_boost 0
33 | ged enable_gpu_boost 0
34 | ged ged_boost_enable 0
35 | ged ged_force_mdp_enable 0
36 | ged ged_smart_boost 0
37 | ged gx_force_cpu_boost 0
38 | ged gpu_dvfs_enable 1
39 | ged gx_3D_benchmark_on 0
40 | ged gx_dfps 1
41 | ged gx_game_mode 0
42 |
43 | echo 0 > /sys/kernel/debug/eara_thermal/enable
44 |
45 | # settings put system min_refresh_rate 0
46 | # settings put system peak_refresh_rate 120
47 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/mt6885/active.sh:
--------------------------------------------------------------------------------
1 | function ppm() {
2 | echo $2 > "/proc/ppm/$1"
3 | }
4 |
5 | function policy() {
6 | echo $2 > "/proc/ppm/policy/$1"
7 | }
8 |
9 | function lock_freq() {
10 | policy ut_fix_freq_idx "$1 $2"
11 | }
12 |
13 | function max_freq() {
14 | policy hard_userlimit_max_cpu_freq "0 $1"
15 | policy hard_userlimit_max_cpu_freq "1 $2"
16 | }
17 |
18 | function min_freq() {
19 | policy hard_userlimit_min_cpu_freq "0 $1"
20 | policy hard_userlimit_min_cpu_freq "1 $2"
21 | }
22 |
23 | function ged() {
24 | echo $2 > /sys/module/ged/parameters/$1
25 | }
26 |
27 | function cpuset() {
28 | echo $1 > /dev/cpuset/background/cpus
29 | echo $2 > /dev/cpuset/system-background/cpus
30 | echo $3 > /dev/cpuset/foreground/cpus
31 | echo $4 > /dev/cpuset/top-app/cpus
32 | echo $5 > /dev/cpuset/restricted/cpus
33 | }
34 |
35 | action=$1
36 |
37 | init () {
38 | local dir=$(cd $(dirname $0); pwd)
39 | if [[ -f "$dir/powercfg-base.sh" ]]; then
40 | sh "$dir/powercfg-base.sh"
41 | elif [[ -f '/data/powercfg-base.sh' ]]; then
42 | sh /data/powercfg-base.sh
43 | fi
44 | }
45 | if [[ "$action" == "init" ]]; then
46 | init
47 | exit 0
48 | fi
49 |
50 | # policy_status
51 | # [0] PPM_POLICY_PTPOD: enabled
52 | # [1] PPM_POLICY_UT: enabled
53 | # [2] PPM_POLICY_FORCE_LIMIT: enabled
54 | # [6] PPM_POLICY_HARD_USER_LIMIT: enabled
55 | # [3] PPM_POLICY_PWR_THRO: enabled
56 | # [4] PPM_POLICY_THERMAL: enabled
57 | # [5] PPM_POLICY_DLPT: enabled
58 | # [9] PPM_POLICY_SYS_BOOST: enabled
59 | # [7] PPM_POLICY_USER_LIMIT: enabled
60 | # [8] PPM_POLICY_LCM_OFF: disabled
61 |
62 | # Usage: echo <1/0> > /proc/ppm/policy_status
63 |
64 |
65 | # dump_cluster_0_dvfs_table
66 | # 2000000 1895000 1791000 1708000 1625000 1500000 1393000 1287000 1181000 1048000 968000 862000 756000 703000 650000 500000
67 | # dump_cluster_1_dvfs_table
68 | # 2600000 2529000 2387000 2245000 2068000 1927000 1750000 1622000 1526000 1367000 1271000 1176000 1048000 921000 825000 730000
69 |
70 | ppm enabled 1
71 |
72 | ppm policy_status "1 0"
73 | ppm policy_status "2 0"
74 | # ppm policy_status "4 0"
75 | ppm policy_status "5 0"
76 | ppm policy_status "7 0"
77 | ppm policy_status "9 0"
78 |
79 | if [[ "$action" = "powersave" ]]; then
80 | #powersave
81 |
82 | min_freq 500000 730000
83 | max_freq 2000000 1927000
84 |
85 | ged gpu_dvfs 1
86 | ged gx_game_mode 0
87 | ged gx_3d_benchmark_on 0
88 |
89 | cpuset 0-1 0-3 0-7 0-7 0-3
90 |
91 | exit 0
92 | elif [[ "$action" = "balance" ]]; then
93 | #balance
94 |
95 | min_freq 500000 730000
96 | max_freq 2000000 2433000
97 |
98 | ged gpu_dvfs 1
99 | ged gx_game_mode 0
100 | ged gx_3d_benchmark_on 0
101 |
102 | cpuset 0-1 0-3 0-7 0-7 0-3
103 |
104 | exit 0
105 | elif [[ "$action" = "performance" ]]; then
106 | #performance
107 |
108 | min_freq 1181000 1367000
109 | max_freq 2000000 2600000
110 |
111 | ged gpu_dvfs 1
112 | ged gx_3d_benchmark_on 0
113 | ged gx_game_mode 1
114 |
115 | cpuset 0-1 0-3 0-7 0-7 0-3
116 |
117 | exit 0
118 | elif [[ "$action" = "fast" ]]; then
119 | #fast
120 |
121 | min_freq 1791000 1927000
122 | max_freq 2000000 2600000
123 |
124 | ged gpu_dvfs 1
125 | ged gx_game_mode 0
126 | ged gx_3d_benchmark_on 1
127 |
128 | cpuset 0 0-3 0-7 0-7 0-3
129 |
130 | exit 0
131 | fi
132 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/mt6885/conservative.sh:
--------------------------------------------------------------------------------
1 | function ppm() {
2 | echo $2 > "/proc/ppm/$1"
3 | }
4 |
5 | function policy() {
6 | echo $2 > "/proc/ppm/policy/$1"
7 | }
8 |
9 | function lock_freq() {
10 | policy ut_fix_freq_idx "$1 $2"
11 | }
12 |
13 | function max_freq() {
14 | policy hard_userlimit_max_cpu_freq "0 $1"
15 | policy hard_userlimit_max_cpu_freq "1 $2"
16 | }
17 |
18 | function min_freq() {
19 | policy hard_userlimit_min_cpu_freq "0 $1"
20 | policy hard_userlimit_min_cpu_freq "1 $2"
21 | }
22 |
23 | function ged() {
24 | echo $2 > /sys/module/ged/parameters/$1
25 | }
26 |
27 | function cpuset() {
28 | echo $1 > /dev/cpuset/background/cpus
29 | echo $2 > /dev/cpuset/system-background/cpus
30 | echo $3 > /dev/cpuset/foreground/cpus
31 | echo $4 > /dev/cpuset/top-app/cpus
32 | echo $5 > /dev/cpuset/restricted/cpus
33 | }
34 |
35 | action=$1
36 |
37 | init () {
38 | local dir=$(cd $(dirname $0); pwd)
39 | if [[ -f "$dir/powercfg-base.sh" ]]; then
40 | sh "$dir/powercfg-base.sh"
41 | elif [[ -f '/data/powercfg-base.sh' ]]; then
42 | sh /data/powercfg-base.sh
43 | fi
44 | }
45 | if [[ "$action" == "init" ]]; then
46 | init
47 | exit 0
48 | fi
49 |
50 | # policy_status
51 | # [0] PPM_POLICY_PTPOD: enabled
52 | # [1] PPM_POLICY_UT: enabled
53 | # [2] PPM_POLICY_FORCE_LIMIT: enabled
54 | # [6] PPM_POLICY_HARD_USER_LIMIT: enabled
55 | # [3] PPM_POLICY_PWR_THRO: enabled
56 | # [4] PPM_POLICY_THERMAL: enabled
57 | # [5] PPM_POLICY_DLPT: enabled
58 | # [9] PPM_POLICY_SYS_BOOST: enabled
59 | # [7] PPM_POLICY_USER_LIMIT: enabled
60 | # [8] PPM_POLICY_LCM_OFF: disabled
61 |
62 | # Usage: echo <1/0> > /proc/ppm/policy_status
63 |
64 | # dump_cluster_0_dvfs_table
65 | # 2000000 1895000 1791000 1708000 1625000 1500000 1393000 1287000 1181000 1048000 968000 862000 756000 703000 650000 500000
66 | # dump_cluster_1_dvfs_table
67 | # 2600000 2529000 2387000 2245000 2068000 1927000 1750000 1622000 1526000 1367000 1271000 1176000 1048000 921000 825000 730000
68 |
69 | ppm enabled 1
70 |
71 | ppm policy_status "1 0"
72 | ppm policy_status "2 0"
73 | # ppm policy_status "4 0"
74 | ppm policy_status "5 0"
75 | ppm policy_status "7 0"
76 | ppm policy_status "9 0"
77 |
78 | if [[ "$action" = "powersave" ]]; then
79 | #powersave
80 |
81 | min_freq 500000 730000
82 | max_freq 2000000 1622000
83 |
84 | ged gpu_dvfs 1
85 | ged gx_game_mode 0
86 | ged gx_3d_benchmark_on 0
87 |
88 | cpuset 0-2 0-3 0-7 0-7 0-3
89 |
90 | exit 0
91 | elif [[ "$action" = "balance" ]]; then
92 | #balance
93 |
94 | min_freq 500000 730000
95 | max_freq 2000000 1927000
96 |
97 | ged gpu_dvfs 1
98 | ged gx_game_mode 0
99 | ged gx_3d_benchmark_on 0
100 |
101 | cpuset 0-2 0-3 0-7 0-7 0-3
102 |
103 | exit 0
104 | elif [[ "$action" = "performance" ]]; then
105 | #performance
106 |
107 | min_freq 500000 730000
108 | max_freq 2000000 2600000
109 |
110 | ged gpu_dvfs 1
111 | ged gx_3d_benchmark_on 0
112 | ged gx_game_mode 1
113 |
114 | cpuset 0-1 0-3 0-7 0-7 0-3
115 |
116 | exit 0
117 | elif [[ "$action" = "fast" ]]; then
118 | #fast
119 |
120 | min_freq 1791000 1622000
121 | max_freq 2000000 2600000
122 |
123 | ged gpu_dvfs 1
124 | ged gx_game_mode 0
125 | ged gx_3d_benchmark_on 1
126 |
127 | cpuset 0 0-3 0-7 0-7 0-3
128 |
129 | exit 0
130 | fi
131 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/mt6885/info.txt:
--------------------------------------------------------------------------------
1 | mt6889:天玑1000(+)
2 | mt6885:天玑1000l
3 | mt6875:天玑820
4 | mt6873:天玑800
5 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/mt6885/powercfg-base.sh:
--------------------------------------------------------------------------------
1 | function ged() {
2 | echo $2 > /sys/module/ged/parameters/$1
3 | }
4 |
5 | # ged boost_gpu_enable 0
6 | # ged enable_cpu_boost 0
7 | # ged enable_gpu_boost 0
8 | # ged ged_boost_enable 0
9 | # ged ged_force_mdp_enable 0
10 | # ged ged_smart_boost 0
11 | # ged gx_force_cpu_boost 0
12 | # ged gpu_dvfs_enable 1
13 | # ged gx_3D_benchmark_on 0
14 | # ged gx_dfps 1
15 | # ged gx_game_mode 0
16 |
17 | # echo 0 > /sys/kernel/debug/eara_thermal/enable
18 |
19 | # settings put system min_refresh_rate 0
20 | # settings put system peak_refresh_rate 120
21 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/powercfg-template/active.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 |
3 | init () {
4 | local dir=$(cd $(dirname $0); pwd)
5 | if [[ -f "$dir/powercfg-base.sh" ]]; then
6 | sh "$dir/powercfg-base.sh"
7 | elif [[ -f '/data/powercfg-base.sh' ]]; then
8 | sh /data/powercfg-base.sh
9 | fi
10 | }
11 |
12 | if [[ "$action" == "init" ]]; then
13 | init
14 | exit 0
15 | fi
16 |
17 |
18 | # 当前被打开的前台应用(需要Scene 4.3+版本,并开启【严格模式】才会获得此值)
19 | if [[ "$top_app" != "" ]]; then
20 | echo "应用切换到前台 [$top_app]" >> /cache/scene_powercfg.log
21 | fi
22 |
23 | if [[ "$action" = "powersave" ]]; then
24 | #powersave
25 |
26 | exit 0
27 | elif [[ "$action" = "balance" ]]; then
28 | #balance
29 |
30 | exit 0
31 | elif [[ "$action" = "performance" ]]; then
32 | #performance
33 |
34 | exit 0
35 | elif [[ "$action" = "fast" ]]; then
36 | #fast
37 |
38 | exit 0
39 | fi
40 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/powercfg-template/conservative.sh:
--------------------------------------------------------------------------------
1 | action=$1
2 |
3 | init () {
4 | local dir=$(cd $(dirname $0); pwd)
5 | if [[ -f "$dir/powercfg-base.sh" ]]; then
6 | sh "$dir/powercfg-base.sh"
7 | elif [[ -f '/data/powercfg-base.sh' ]]; then
8 | sh /data/powercfg-base.sh
9 | fi
10 | }
11 |
12 | if [[ "$action" == "init" ]]; then
13 | init
14 | exit 0
15 | fi
16 |
17 |
18 | # 当前被打开的前台应用(需要Scene 4.3+版本,并开启【严格模式】才会获得此值)
19 | if [[ "$top_app" != "" ]]; then
20 | echo "应用切换到前台 [$top_app]" >> /cache/scene_powercfg.log
21 | fi
22 |
23 | if [[ "$action" = "powersave" ]]; then
24 | #powersave
25 |
26 | exit 0
27 | elif [[ "$action" = "balance" ]]; then
28 | #balance
29 |
30 | exit 0
31 | elif [[ "$action" = "performance" ]]; then
32 | #performance
33 |
34 | exit 0
35 | elif [[ "$action" = "fast" ]]; then
36 | #fast
37 |
38 | exit 0
39 | fi
40 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/powercfg-template/powercfg-base.sh:
--------------------------------------------------------------------------------
1 | # 可以保持当前空白状态,此部分代码只执行一次
2 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/powercfg-template/powercfg-utils.sh.sh:
--------------------------------------------------------------------------------
1 | # Only Scene 4.4+
2 | # 这里可以放一些工具函数,它会在安装配置文件时自动被提取到与 powercfg.sh 同一目录下
3 | # 因此,你可以在powercfg.sh 中引用它
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/powercfg-template/readme.md:
--------------------------------------------------------------------------------
1 | 在这里,你可以为你的设备配置两套不同风格的模式文件。打包apk运行时,可以在性能配置界面中切换模式文件。
2 |
3 | # 保守风格的模式文件
4 | - conservative-base.sh
5 | - conservative.sh
6 |
7 | # 调度积极的模式文件
8 | - active-base.sh
9 | - active.sh
10 |
11 | # 具体说明
12 | - active-base.sh 和 conservative-base.sh不会经常用到,只会在最开始的时候执行一次,用于还原一些用户已做的修改,如果没有必要可以留空。
13 | - active.sh 和 conservative.sh作为主要配置脚本,需要在里面定义4种模式要执行的脚本代码。
14 |
15 | - 如果你不想通过修改apk的方式来创建配置,也可以直接将写好的powercfg.sh,复制到data目录下【最终配置脚本路径为 /data/powercfg.sh】,并修改权限为0644。
16 | - 注意配置脚本的编码格式,应为unix,否则无法被命令行识别,也就无法执行模式切换。
17 |
18 | # 单应用适配
19 | - 除了最基础的4个性能调节模式以外,Scene 4.3添加了【严格模式】(需要在性能配置界面手动开启)
20 | - 开启【严格模式】之后,只要前台应用发生变化,Scene就会触发调度切换
21 | - * 若不开启【严格模式】或使用Scene 4.3以前的版本,只有在需要变更模式时才会触发调度切换
22 | - 如何知晓刚刚被打开的是应用?你可以在脚本中,通过Scene保存的 `top_app` 变量来获取,示例:
23 |
24 | ```sh
25 | if [[ "$top_app" != "" ]]; then
26 | echo "应用切换到前台 [$top_app]"
27 | fi
28 | ```
29 |
30 | ## 特殊情况
31 | - 开启【严格模式】模式之后,你依然可能获得空白的`$top_app`
32 | - 这是因为,调度切换并非动态响应功能触发
33 | - 例如:用户主动点击、定时任务、息屏亮屏等方式触发的调度切换,以及执行init时,都会得到空白的`top_app`
34 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/sm6150/active.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | action=$1
4 | task=$2
5 |
6 | cfg_dir=$(cd $(dirname $0); pwd)
7 |
8 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
9 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
10 | exit 1
11 | fi
12 |
13 | source "$cfg_dir/powercfg-utils.sh"
14 |
15 | init () {
16 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
17 | source "$cfg_dir/powercfg-base.sh"
18 | elif [[ -f '/data/powercfg-base.sh' ]]; then
19 | source /data/powercfg-base.sh
20 | fi
21 | }
22 |
23 | if [[ "$action" == "init" ]]; then
24 | init
25 | exit 0
26 | fi
27 |
28 | if [[ "$action" == "fast" ]]; then
29 | devfreq_performance
30 | else
31 | devfreq_restore
32 | fi
33 | reset_basic_governor
34 |
35 |
36 | # Setting b.L scheduler parameters
37 | # default sched up and down migrate values are 90 and 85
38 | # echo 65 > /proc/sys/kernel/sched_downmigrate
39 | # echo 71 > /proc/sys/kernel/sched_upmigrate
40 | # default sched up and down migrate values are 100 and 95
41 | # echo 85 > /proc/sys/kernel/sched_group_downmigrate
42 | # echo 100 > /proc/sys/kernel/sched_group_upmigrate
43 |
44 |
45 | if [ "$action" = "powersave" ]; then
46 | set_cpu_freq 5000 1612800 5000 1555200
47 | set_input_boost_freq 0 0 0
48 | set_hispeed_freq 1248000 806400
49 | sched_boost 0 0
50 | stune_top_app 0 0
51 | ctl_on cpu0
52 | ctl_on cpu6
53 | sched_config 75 92 380 500
54 | sched_limit 0 0 500 1000
55 | cpuset '0-1' '0-3' '0-3' '0-7'
56 |
57 | elif [ "$action" = "balance" ]; then
58 | set_cpu_freq 5000 1708800 5000 1843200
59 | set_input_boost_freq 0 0 0
60 | set_hispeed_freq 1248000 1209600
61 | sched_boost 1 0
62 | stune_top_app 0 0
63 | ctl_off cpu0
64 | ctl_on cpu6
65 | sched_config 68 82 300 400
66 | sched_limit 0 0 0 0
67 | cpuset '0-1' '0-3' '0-5' '0-7'
68 |
69 | elif [ "$action" = "performance" ]; then
70 | set_cpu_freq 300000 2500000 300000 2750000
71 | set_input_boost_freq 1804800 1939200 120
72 | set_hispeed_freq 1708800 1209600
73 | gpu_pl_up 1
74 | sched_boost 1 0
75 | stune_top_app 0 0
76 | ctl_off
77 | ctl_off
78 | sched_config 60 78 300 400
79 | sched_limit 2000 1000 0 0
80 | cpuset '0-1' '0-3' '0-5' '0-7'
81 |
82 | elif [ "$action" = "fast" ]; then
83 | set_cpu_freq 1708800 2500000 1209600 2750000
84 | set_input_boost_freq 1804800 1939200 500
85 | set_hispeed_freq 300000 300000
86 | gpu_pl_up 2
87 | sched_boost 1 1
88 | stune_top_app 1 20
89 | ctl_off
90 | ctl_off
91 | sched_config 50 75 300 400
92 | sched_limit 5000 2000 0 0
93 | cpuset '0-1' '0-3' '0-5' '0-7'
94 |
95 | fi
96 |
--------------------------------------------------------------------------------
/app/src/main/assets/powercfg/sm6150/conservative.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | action=$1
4 | task=$2
5 |
6 | cfg_dir=$(cd $(dirname $0); pwd)
7 |
8 | if [[ ! -f "$cfg_dir/powercfg-utils.sh" ]]; then
9 | echo "The dependent '$cfg_dir/powercfg-utils.sh' was not found !" > /cache/powercfg.sh.log
10 | exit 1
11 | fi
12 |
13 | source "$cfg_dir/powercfg-utils.sh"
14 |
15 | init () {
16 | if [[ -f "$cfg_dir/powercfg-base.sh" ]]; then
17 | source "$cfg_dir/powercfg-base.sh"
18 | elif [[ -f '/data/powercfg-base.sh' ]]; then
19 | source /data/powercfg-base.sh
20 | fi
21 | }
22 |
23 | if [[ "$action" == "init" ]]; then
24 | init
25 | exit 0
26 | fi
27 |
28 | if [[ "$action" == "fast" ]]; then
29 | devfreq_performance
30 | else
31 | devfreq_restore
32 | fi
33 | reset_basic_governor
34 |
35 |
36 | # Setting b.L scheduler parameters
37 | # default sched up and down migrate values are 90 and 85
38 | # echo 95 > /proc/sys/kernel/sched_downmigrate
39 | # echo 92 > /proc/sys/kernel/sched_upmigrate
40 | # default sched up and down migrate values are 100 and 95
41 | # echo 93 > /proc/sys/kernel/sched_group_downmigrate
42 | # echo 100 > /proc/sys/kernel/sched_group_upmigrate
43 |
44 | if [ "$action" = "powersave" ]; then
45 | set_cpu_freq 5000 1612800 5000 1555200
46 | set_input_boost_freq 0 0 0
47 | set_hispeed_freq 1248000 806400
48 | sched_boost 0 0
49 | ctl_on cpu0
50 | ctl_on cpu6
51 | sched_config 85 96 380 500
52 | sched_limit 0 500 0 1000
53 | cpuset '0-1' '0-3' '0-3' '0-7'
54 | stune_top_app 0 0
55 |
56 | elif [ "$action" = "balance" ]; then
57 | set_cpu_freq 5000 1708800 5000 1708800
58 | set_input_boost_freq 0 0 0
59 | set_hispeed_freq 1248000 1209600
60 | sched_boost 1 0
61 | stune_top_app 0 0
62 | ctl_off cpu0
63 | ctl_on cpu6
64 | sched_config 70 85 300 400
65 | sched_limit 0 0 0 1000
66 | cpuset '0-1' '0-3' '0-5' '0-7'
67 |
68 | elif [ "$action" = "performance" ]; then
69 | set_cpu_freq 300000 1804800 300000 2208000
70 | set_input_boost_freq 0 0 0
71 | set_hispeed_freq 1708800 1209600
72 | gpu_pl_up 1
73 | sched_boost 1 0
74 | stune_top_app 1 0
75 | ctl_off cpu0
76 | ctl_off cpu6
77 | sched_config 60 78 300 400
78 | sched_limit 1000 0 0 0
79 | cpuset '0-1' '0-3' '0-5' '0-7'
80 |
81 | elif [ "$action" = "fast" ]; then
82 | set_cpu_freq 1708800 2500000 1209600 2750000
83 | set_input_boost_freq 1804800 1939200 120
84 | set_hispeed_freq 300000 300000
85 | gpu_pl_up 2
86 | sched_boost 1 1
87 | stune_top_app 1 30
88 | ctl_off cpu0
89 | ctl_off cpu6
90 | sched_config 57 75 300 400
91 | sched_limit 3000 2000 0 0
92 | cpuset '0-1' '0-3' '0-5' '0-7'
93 |
94 | fi
95 |
--------------------------------------------------------------------------------
/app/src/main/assets/toolkit/busybox:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/assets/toolkit/busybox
--------------------------------------------------------------------------------
/app/src/main/assets/toolkit/kr_install_busybox.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 |
3 | function busybox_install() {
4 | for applet in `./busybox --list`; do
5 | case "$applet" in
6 | "sh"|"busybox"|"shell"|"swapon"|"swapoff"|"mkswap")
7 | echo 'Skip' > /dev/null
8 | ;;
9 | *)
10 | ./busybox ln -sf busybox "$applet";
11 | ;;
12 | esac
13 | done
14 | ./busybox ln -sf busybox busybox_1_30_1
15 | }
16 |
17 | if [[ ! "$TOOLKIT" = "" ]]; then
18 | cd "$TOOLKIT"
19 | if [[ ! -f busybox_1_30_1 ]]; then
20 | busybox_install
21 | fi
22 | fi
23 |
--------------------------------------------------------------------------------
/app/src/main/assets/toolkit/run:
--------------------------------------------------------------------------------
1 | source $PAGE_WORK_DIR/$1
--------------------------------------------------------------------------------
/app/src/main/assets/toolkit/toybox-outside:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/assets/toolkit/toybox-outside
--------------------------------------------------------------------------------
/app/src/main/assets/toolkit/toybox-outside64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/assets/toolkit/toybox-outside64
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/TuringBox.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import android.content.SharedPreferences
6 | import io.github.lumyuan.turingbox.common.data.customer.ChargeCurve
7 | import io.github.lumyuan.turingbox.common.data.customer.ScreenOffCleanup
8 | import io.github.lumyuan.turingbox.common.data.EventBus
9 | import io.github.lumyuan.turingbox.common.data.publisher.BatteryState
10 | import io.github.lumyuan.turingbox.common.data.publisher.ScreenState
11 | import io.github.lumyuan.turingbox.common.model.TriggerIEventMonitor
12 | import io.github.lumyuan.turingbox.common.permissions.Busybox
13 | import io.github.lumyuan.turingbox.common.permissions.CheckRootStatus
14 | import io.github.lumyuan.turingbox.common.shared.FileWrite
15 | import io.github.lumyuan.turingbox.common.shell.ShellExecutor
16 | import io.github.lumyuan.turingbox.common.store.SpfConfig
17 |
18 | class TuringBox: Application() {
19 |
20 | companion object {
21 | lateinit var application: Application
22 |
23 | val globalConfig: SharedPreferences by lazy {
24 | application.getSharedPreferences(SpfConfig.GLOBAL_SPF, Context.MODE_PRIVATE)
25 | }
26 |
27 | fun getBoolean(key: String, defaultValue: Boolean): Boolean {
28 | return globalConfig.getBoolean(key, defaultValue)
29 | }
30 |
31 | fun setBoolean(key: String, value: Boolean) {
32 | globalConfig.edit().putBoolean(key, value).apply()
33 | }
34 |
35 | fun getString(key: String, defaultValue: String): String? {
36 | return globalConfig.getString(key, defaultValue)
37 | }
38 | }
39 |
40 | // 锁屏状态监听
41 | private lateinit var screenState: ScreenState
42 |
43 |
44 | override fun attachBaseContext(base: Context?) {
45 | super.attachBaseContext(base)
46 | application = this
47 |
48 | // 安装busybox
49 | if (!Busybox.systemBusyboxInstalled()) {
50 | ShellExecutor.setExtraEnvPath(
51 | FileWrite.getPrivateFilePath(this, getString(R.string.toolkit_install_path))
52 | )
53 | }
54 |
55 | //锁屏状态检测
56 | screenState = ScreenState(this)
57 | screenState.autoRegister()
58 |
59 | // 事件任务
60 | EventBus.subscribe(TriggerIEventMonitor(this))
61 |
62 | // 充电曲线
63 | EventBus.subscribe(ChargeCurve(this))
64 |
65 | // 息屏自动关闭悬浮窗
66 | EventBus.subscribe(ScreenOffCleanup(this))
67 |
68 | // 如果上次打开应用成功获得root,触发一下root权限申请
69 | if (getBoolean("root", false)) {
70 | CheckRootStatus.checkRootAsync()
71 | }
72 | }
73 |
74 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/Settings.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common
2 |
3 | enum class Settings {
4 | APP_THEME, DARK_THEME
5 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/basic/Activities.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.basic
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.content.pm.PackageManager
6 | import android.net.Uri
7 | import android.view.Display
8 |
9 | fun Activity.startBrowser(url: String?){
10 | try {
11 | val intent = Intent()
12 | intent.action = "android.intent.action.VIEW"
13 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
14 | intent.data = Uri.parse(url)
15 | startActivity(intent)
16 | } catch (e: Exception) {
17 | e.printStackTrace()
18 | toast(e.toString())
19 | }
20 | }
21 |
22 | fun Activity.startIntentView(uri: String?){
23 | try {
24 | startActivity(
25 | Intent(
26 | Intent.ACTION_VIEW,
27 | Uri.parse(uri)
28 | )
29 | )
30 | }catch (e: Exception){
31 | e.printStackTrace()
32 | toast(e.toString())
33 | }
34 | }
35 |
36 | fun Activity.startApp(packageName: String?) {
37 | try {
38 | val packageManager: PackageManager = packageManager
39 | val intent = packageManager.getLaunchIntentForPackage(packageName!!)!!
40 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED or Intent.FLAG_ACTIVITY_CLEAR_TOP
41 | startActivity(intent)
42 | }catch (e: Exception){
43 | e.printStackTrace()
44 | toast(e.toString())
45 | }
46 | }
47 |
48 | fun Activity.getRefreshRate(): Float {
49 | val display: Display = windowManager.defaultDisplay
50 | return display.refreshRate
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/basic/AppInfoLoader.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.basic
2 |
3 | import android.content.Context
4 | import android.content.pm.PackageManager
5 | import android.graphics.drawable.Drawable
6 | import android.util.LruCache
7 | import io.github.lumyuan.turingbox.common.model.AppInfo
8 | import kotlinx.coroutines.Deferred
9 | import kotlinx.coroutines.Dispatchers
10 | import kotlinx.coroutines.GlobalScope
11 | import kotlinx.coroutines.async
12 | import java.io.File
13 |
14 | open class AppInfoLoader(private val context: Context, private val cacheSize: Int = 0) {
15 | private val iconCaches = if (cacheSize < 1) null else LruCache(cacheSize)
16 | private fun saveCache(packageName: String, drawable: Drawable?) {
17 | if (iconCaches != null && drawable != null) {
18 | iconCaches.put(packageName, drawable)
19 | }
20 | }
21 |
22 | private var pmInstance: PackageManager? = null
23 | protected val pm: PackageManager
24 | get() {
25 | if (pmInstance == null) {
26 | pmInstance = context.packageManager
27 | }
28 | return pmInstance!!
29 | }
30 |
31 | fun loadIcon(item: AppInfo): Deferred {
32 | return GlobalScope.async(Dispatchers.IO) {
33 | val cache = iconCaches?.get(item.packageName)
34 | if (cache != null) {
35 | return@async cache
36 | }
37 |
38 | var icon: Drawable? = loadIcon(item.packageName).await()
39 | if (icon == null && item.path.isNotEmpty()) {
40 | try {
41 | val file = File(item.path.toString())
42 | if (file.exists() && file.canRead()) {
43 | icon = pm.getPackageArchiveInfo(file.absolutePath, PackageManager.GET_ACTIVITIES)?.applicationInfo?.loadIcon(pm)
44 | saveCache(item.packageName, icon)
45 | }
46 | } catch (ex: Exception) {
47 | }
48 | }
49 | return@async icon
50 | }
51 | }
52 |
53 | fun loadIcon(packageName: String): Deferred {
54 | return GlobalScope.async(Dispatchers.IO) {
55 | val cache = iconCaches?.get(packageName)
56 | if (cache != null) {
57 | return@async cache
58 | }
59 |
60 | var icon: Drawable? = null
61 | try {
62 | val installInfo = pm.getPackageInfo(packageName, 0)
63 | icon = installInfo.applicationInfo.loadIcon(pm)
64 | saveCache(packageName, icon)
65 | } catch (ex: Exception) {
66 | } finally {
67 | }
68 | return@async icon
69 | }
70 | }
71 |
72 | class AppBasicInfo(var appName: String, var icon: Drawable?) {
73 | }
74 |
75 | fun loadAppBasicInfo(packageName: String): Deferred {
76 | return GlobalScope.async(Dispatchers.IO) {
77 | var icon: Drawable? = null
78 | var name = packageName
79 | try {
80 | val installInfo = pm.getPackageInfo(packageName, 0)
81 | name = "" + installInfo.applicationInfo.loadLabel(pm)
82 | icon = installInfo.applicationInfo.loadIcon(pm)
83 | // saveCache(packageName, icon)
84 | } catch (ex: Exception) {
85 | } finally {
86 | }
87 |
88 | return@async AppBasicInfo(name, icon)
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/calculator/Flags.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.calculator
2 |
3 | /*
4 | // JAVA
5 | public class Flags {
6 | private int flags;
7 | public Flags(int flags) {
8 | this.flags = flags;
9 | }
10 |
11 | public int addFlag(int flag) {
12 | this.flags |= flag;
13 | return this.flags;
14 | }
15 |
16 | public int removeFlag(int flag) {
17 | this.flags &= ~flag;
18 | return this.flags;
19 | }
20 | }
21 | */
22 |
23 | class Flags(private var flags: Int) {
24 | fun addFlag(flag: Int): Int {
25 | flags = flags or flag
26 | return flags
27 | }
28 |
29 | fun removeFlag(flag: Int): Int {
30 | flags = flags and flag.inv()
31 | return flags
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/calculator/GetUpTime.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.calculator
2 |
3 | import java.util.*
4 |
5 | // 计算还有多久起床
6 | // getUp = hours * 60 + minutes, 例如 6:30 表示为 6 * 60 + 30 = 390
7 | class GetUpTime(private val getUp: Int) {
8 | // 现在时间
9 | val currentTime: Int
10 | get() {
11 | val now = Calendar.getInstance()
12 | return now.get(Calendar.HOUR_OF_DAY) * 60 + now.get(Calendar.MINUTE)
13 | }
14 |
15 | // 距离下次起床还有多少分钟
16 | val minutes: Int
17 | get() {
18 | val nowTimeValue = currentTime
19 | // 距离起床的剩余时间(分钟)
20 | val timeRemaining = (
21 | // 和计算闹钟距离下一次还有多久响的逻辑有点像
22 | // 如果已经过了今天的起床时间,计算到明天的起床时间还有多久
23 | if (nowTimeValue > getUp) {
24 | // (24 * 60) => 1440
25 | // (今天剩余时间 + 明天的起床时间) / 60分钟 计算小时数
26 | ((1440 - nowTimeValue) + getUp)
27 | }
28 | // 如果还没过今天的起床时间
29 | else {
30 | (getUp - nowTimeValue)
31 | })
32 | return timeRemaining
33 | }
34 |
35 | val nextGetUpTime: Long
36 | get() {
37 | return System.currentTimeMillis() + (minutes * 60 * 1000)
38 | }
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/EventBus.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data
2 |
3 | import android.util.Log
4 | import java.util.*
5 |
6 | object EventBus {
7 | private val eventReceivers = ArrayList()
8 |
9 | /**
10 | * 发布事件
11 | *
12 | * @param eventType 事件类型
13 | */
14 | fun publish(eventType: EventType?, data: HashMap? = null) {
15 | if (eventReceivers.size > 0) {
16 | // 复制一个副本用于循环,避免在运行过程中unsubscibe致使eventReceivers发生变化而崩溃
17 | val temp = ArrayList(eventReceivers)
18 | for (eventReceiver in temp) {
19 | try {
20 | if (eventReceiver.eventFilter(eventType!!)) {
21 | if (eventReceiver.isAsync) {
22 | HandlerThread(eventReceiver, eventType, data).start()
23 | } else {
24 | eventReceiver.onReceive(eventType, data)
25 | }
26 | }
27 | } catch (ex: Exception) {
28 | Log.e("SceneEventBus", "" + ex.message)
29 | }
30 | }
31 | }
32 | }
33 |
34 | /**
35 | * 订阅事件
36 | *
37 | * @param eventReceiver 事件接收器
38 | */
39 | fun subscribe(eventReceiver: IEventReceiver) {
40 | if (!eventReceivers.contains(eventReceiver)) {
41 | eventReceivers.add(eventReceiver)
42 | eventReceiver.onSubscribe()
43 | }
44 | }
45 |
46 | /**
47 | * 取消订阅事件
48 | *
49 | * @param eventReceiver 事件接收器
50 | */
51 | fun unsubscribe(eventReceiver: IEventReceiver) {
52 | if (eventReceivers.contains(eventReceiver)) {
53 | eventReceivers.remove(eventReceiver)
54 | eventReceiver.onUnsubscribe()
55 | }
56 | }
57 |
58 | internal class HandlerThread(private val eventReceiver: IEventReceiver, private val eventType: EventType?, private val data: HashMap?) : Thread() {
59 | override fun run() {
60 | eventReceiver.onReceive(eventType!!, data)
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/EventType.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data;
2 |
3 | public enum EventType {
4 | POWER_CONNECTED, // 充电器连接
5 | POWER_DISCONNECTED, // 充电器连接
6 | BATTERY_LOW, // 电池电量不足
7 | BATTERY_CAPACITY_CHANGED, // 电池电量变化
8 | BATTERY_CHANGED, // 电池状态变化
9 | BATTERY_FULL, // 电池充满
10 | CHARGE_CONFIG_CHANGED, // 充电控制配置改变
11 | SCREEN_ON, // 屏幕打开
12 | SCREEN_OFF, // 屏幕关闭
13 | APP_SWITCH, // 应用切换
14 | BOOT_COMPLETED, // 启动完成
15 | TIMER, // 定时器
16 |
17 | SERVICE_DEBUG, // 服务调试配置更新
18 | SERVICE_UPDATE, // 服务配置更新
19 | STATE_RESUME, // 状态恢复(一般指屏幕点亮后应用场景模式配置)
20 |
21 | SCENE_MODE_ACTION, // 场景模式 常驻通知动作触发
22 | SCENE_CONFIG, // 场景模式 公共配置
23 | SCENE_APP_CONFIG, // 场景模式 对应用的配置
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/GlobalStatus.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data
2 |
3 | import android.os.BatteryManager
4 | import io.github.lumyuan.turingbox.common.permissions.CheckRootStatus.Companion.lastCheckResult
5 | import io.github.lumyuan.turingbox.common.shell.BatteryUtils
6 |
7 | object GlobalStatus {
8 | var temperatureCurrent = -1f
9 | private set
10 | private var batteryTempTime = 0L
11 | fun setBatteryTemperature(temperature: Float) {
12 | batteryTempTime = System.currentTimeMillis()
13 | temperatureCurrent = temperature
14 | }
15 |
16 | /**
17 | * 获取实时温度(如果举例上次更新已过去较长时间,使用ROOT权限重新获取温度)
18 | */
19 | fun updateBatteryTemperature(): Float {
20 | // 将更新频率控制在>5秒
21 | if (lastCheckResult && System.currentTimeMillis() - 5000 >= batteryTempTime) {
22 | // 更新电池温度
23 | val temperature = BatteryUtils.getBatteryTemperature().temperature
24 | if (temperature > 10 && temperature < 100) {
25 | setBatteryTemperature(temperature)
26 | }
27 | }
28 | return temperatureCurrent
29 | }
30 |
31 | var batteryCapacity = -1
32 | var batteryCurrentNow: Long = -1
33 | var batteryStatus = BatteryManager.BATTERY_STATUS_UNKNOWN
34 | var lastPackageName = ""
35 | var homeMessage: String? = null
36 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/IEventReceiver.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data
2 |
3 | interface IEventReceiver {
4 | fun eventFilter(eventType: EventType): Boolean
5 | fun onReceive(eventType: EventType, data: HashMap? = null)
6 | val isAsync: Boolean;
7 | fun onSubscribe()
8 | fun onUnsubscribe()
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/customer/ChargeCurve.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data.customer
2 |
3 | import android.content.Context
4 | import android.os.BatteryManager
5 | import io.github.lumyuan.turingbox.common.data.EventType
6 | import io.github.lumyuan.turingbox.common.data.GlobalStatus
7 | import io.github.lumyuan.turingbox.common.data.IEventReceiver
8 | import io.github.lumyuan.turingbox.common.store.ChargeSpeedStore
9 | import io.github.lumyuan.turingbox.common.store.SpfConfig
10 | import java.util.*
11 |
12 | class ChargeCurve(context: Context) : IEventReceiver {
13 | private val storage = ChargeSpeedStore(context)
14 | private var timer: Timer? = null
15 | private var batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
16 | private var globalSPF = context.getSharedPreferences(SpfConfig.GLOBAL_SPF, Context.MODE_PRIVATE)
17 |
18 | override fun eventFilter(eventType: EventType): Boolean {
19 | return when (eventType) {
20 | EventType.POWER_CONNECTED,
21 | EventType.POWER_DISCONNECTED,
22 | EventType.BATTERY_CHANGED -> {
23 | true
24 | }
25 | else -> false
26 | }
27 | }
28 |
29 | override fun onReceive(eventType: EventType, data: HashMap?) {
30 | when (eventType) {
31 | EventType.POWER_CONNECTED -> {
32 | if (GlobalStatus.batteryCapacity != -1 && GlobalStatus.batteryCapacity != storage.lastCapacity()) {
33 | storage.clearAll()
34 | }
35 | }
36 | EventType.POWER_DISCONNECTED -> {
37 | cancelUpdate()
38 | }
39 | EventType.BATTERY_CHANGED -> {
40 | if (timer == null && GlobalStatus.batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
41 | // storage.handleConflics(GlobalStatus.batteryCapacity)
42 |
43 | startUpdate()
44 | }
45 | }
46 | else -> {
47 | }
48 | }
49 | }
50 |
51 | override val isAsync: Boolean
52 | get() = true
53 |
54 | override fun onSubscribe() {
55 |
56 | }
57 |
58 | override fun onUnsubscribe() {
59 |
60 | }
61 |
62 | private fun startUpdate() {
63 | if (timer == null) {
64 | timer = Timer().apply {
65 | schedule(object : TimerTask() {
66 | override fun run() {
67 | saveLog()
68 | }
69 | }, 15000, 1000)
70 | }
71 | }
72 | }
73 |
74 | private fun saveLog() {
75 | if (GlobalStatus.batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
76 | // 电流
77 | GlobalStatus.batteryCurrentNow = (
78 | batteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW) /
79 | globalSPF.getInt(SpfConfig.GLOBAL_SPF_CURRENT_NOW_UNIT, SpfConfig.GLOBAL_SPF_CURRENT_NOW_UNIT_DEFAULT)
80 | )
81 | batteryManager.getIntProperty(BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE)
82 |
83 | if (Math.abs(GlobalStatus.batteryCurrentNow) > 100) {
84 | storage.addHistory(
85 | GlobalStatus.batteryCurrentNow,
86 | GlobalStatus.batteryCapacity,
87 | GlobalStatus.updateBatteryTemperature()
88 | )
89 | }
90 | } else {
91 | cancelUpdate()
92 | }
93 | }
94 |
95 | private fun cancelUpdate() {
96 | timer?.run {
97 | cancel()
98 | timer = null
99 | }
100 | }
101 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/customer/ScreenOffCleanup.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data.customer
2 |
3 | import android.content.Context
4 | import io.github.lumyuan.turingbox.common.data.EventType
5 | import io.github.lumyuan.turingbox.common.data.IEventReceiver
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.delay
9 | import kotlinx.coroutines.launch
10 | import kotlinx.coroutines.withContext
11 |
12 | class ScreenOffCleanup(private val context: Context) : IEventReceiver {
13 | override fun eventFilter(eventType: EventType): Boolean {
14 | return eventType == EventType.SCREEN_OFF || eventType == EventType.SCREEN_ON
15 | }
16 |
17 | private val status = booleanArrayOf(false, false, false, false, false)
18 | override fun onReceive(eventType: EventType, data: HashMap?) {
19 | CoroutineScope(Dispatchers.Main).launch {
20 | // if (eventType == EventType.SCREEN_OFF) {
21 | // status[0] = FloatMonitorMini.show == true
22 | // status[1] = FloatTaskManager.show == true
23 | // status[2] = FloatMonitorThreads.show == true
24 | // status[3] = FloatFpsWatch.show == true
25 | // status[4] = FloatMonitor.show == true
26 | //
27 | // FloatMonitorMini(context).hidePopupWindow()
28 | // FloatTaskManager(context).hidePopupWindow()
29 | // FloatFpsWatch(context).hidePopupWindow()
30 | // FloatMonitor(context).hidePopupWindow()
31 | // FloatMonitorThreads(context).hidePopupWindow()
32 | // } else if (eventType == EventType.SCREEN_ON) {
33 | // withContext(Dispatchers.Main) {
34 | // delay(2000)
35 | // if (status[0]) {
36 | // FloatMonitorMini(context).showPopupWindow()
37 | // status[0] = false
38 | // }
39 | // if (status[1]) {
40 | // FloatTaskManager(context).showPopupWindow()
41 | // status[1] = false
42 | // }
43 | // if (status[2]) {
44 | // FloatMonitorThreads(context).showPopupWindow()
45 | // status[2] = false
46 | // }
47 | // if (status[3]) {
48 | // FloatFpsWatch(context).showPopupWindow()
49 | // status[2] = false
50 | // }
51 | // if (status[4]) {
52 | // FloatMonitor(context).showPopupWindow()
53 | // status[3] = false
54 | // }
55 | // }
56 | // }
57 | }
58 | }
59 |
60 | override val isAsync: Boolean
61 | get() = false
62 |
63 | override fun onSubscribe() {
64 |
65 | }
66 |
67 | override fun onUnsubscribe() {
68 |
69 | }
70 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/data/publisher/ScreenState.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.data.publisher
2 |
3 | import android.app.KeyguardManager
4 | import android.content.BroadcastReceiver
5 | import android.content.Context
6 | import android.content.Intent
7 | import android.content.IntentFilter
8 | import android.os.Build
9 | import android.os.Handler
10 | import android.os.Looper
11 | import io.github.lumyuan.turingbox.common.data.EventBus
12 | import io.github.lumyuan.turingbox.common.data.EventType
13 |
14 | /**
15 | * 监听屏幕开关事件
16 | * Created by Hello on 2018/01/23.
17 | */
18 | class ScreenState(private var context: Context) : BroadcastReceiver() {
19 | private var handler = Handler(Looper.getMainLooper())
20 | private var lastChange = 0L
21 | override fun onReceive(p0: Context?, p1: Intent?) {
22 | if (p1 == null) {
23 | return
24 | }
25 | val pendingResult = goAsync()
26 |
27 | when (p1.action) {
28 | Intent.ACTION_SCREEN_OFF -> {
29 | lastChange = System.currentTimeMillis()
30 | EventBus.publish(EventType.SCREEN_OFF)
31 | }
32 | Intent.ACTION_USER_PRESENT -> {
33 | lastChange = System.currentTimeMillis()
34 | EventBus.publish(EventType.SCREEN_ON)
35 | }
36 | Intent.ACTION_USER_UNLOCKED,
37 | Intent.ACTION_SCREEN_ON -> {
38 | val ms = System.currentTimeMillis()
39 | lastChange = System.currentTimeMillis()
40 | try {
41 | handler.postDelayed({
42 | if (ms == lastChange) {
43 | try {
44 | val mKeyguardManager = p0!!.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
45 | if (!(mKeyguardManager.isKeyguardLocked || mKeyguardManager.inKeyguardRestrictedInputMode())) {
46 | EventBus.publish(EventType.SCREEN_ON)
47 | }
48 | } catch (e: Exception) {
49 | e.printStackTrace()
50 | }
51 | }
52 | }, 5500)
53 | } catch (e: Exception) {
54 | e.printStackTrace()
55 | }
56 | }
57 | }
58 |
59 | pendingResult.finish()
60 | }
61 |
62 | fun autoRegister(): ScreenState {
63 | val c = if (context.applicationContext != null) context.applicationContext else context
64 | c.registerReceiver(this, IntentFilter(Intent.ACTION_SCREEN_OFF))
65 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
66 | c.registerReceiver(this, IntentFilter(Intent.ACTION_USER_UNLOCKED))
67 | }
68 | c.registerReceiver(this, IntentFilter(Intent.ACTION_SCREEN_ON))
69 | c.registerReceiver(this, IntentFilter(Intent.ACTION_USER_PRESENT))
70 |
71 | return this;
72 | }
73 |
74 | fun unRegister() {
75 | val c = if (context.applicationContext != null) context.applicationContext else context
76 | c.unregisterReceiver(this)
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/device/BatteryCapacity.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.device;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 |
6 | public class BatteryCapacity {
7 | /**
8 | * 获取电池容量 mAh
9 | * 源头文件:frameworks/base/core/res\res/xml/power_profile.xml
10 | * Java 反射文件:frameworks\base\core\java\com\android\internal\os\PowerProfile.java
11 | */
12 | @SuppressLint("PrivateApi")
13 | public double getBatteryCapacity(Context context) {
14 | Object mPowerProfile;
15 | double batteryCapacity = 0;
16 | final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile";
17 |
18 | try {
19 | mPowerProfile = Class.forName(POWER_PROFILE_CLASS).getConstructor(Context.class).newInstance(context);
20 | Object getBatteryCapacity = Class.forName(POWER_PROFILE_CLASS).getMethod("getBatteryCapacity").invoke(mPowerProfile);
21 | batteryCapacity = getBatteryCapacity == null ? 0.0d : (double) getBatteryCapacity;
22 |
23 | } catch (Exception e) {
24 | e.printStackTrace();
25 | }
26 |
27 | return batteryCapacity;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/device/GpuInfoUtil.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.device
2 |
3 | import android.opengl.GLSurfaceView
4 | import javax.microedition.khronos.egl.EGLConfig
5 | import javax.microedition.khronos.opengles.GL10
6 |
7 |
8 | class GpuInfoUtil : GLSurfaceView.Renderer {
9 | override fun onSurfaceCreated(gl: GL10, config: EGLConfig?) {
10 | glRenderer = gl.glGetString(GL10.GL_RENDERER) //GPU 渲染器
11 | glVendor = gl.glGetString(GL10.GL_VENDOR) //GPU 供应商
12 | glVersion = gl.glGetString(GL10.GL_VERSION) //GPU 版本
13 | glExtensions = gl.glGetString(GL10.GL_EXTENSIONS) //GPU 扩展名
14 | }
15 |
16 | override fun onSurfaceChanged(gl: GL10, width: Int, height: Int) {}
17 | override fun onDrawFrame(gl: GL10) {}
18 |
19 | companion object {
20 | var glRenderer: String? = null
21 | var glVendor: String? = null
22 | var glVersion: String? = null
23 | var glExtensions: String? = null
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/device/MiuiThermalAESUtil.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.device;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileOutputStream;
5 |
6 | import javax.crypto.Cipher;
7 | import javax.crypto.spec.IvParameterSpec;
8 | import javax.crypto.spec.SecretKeySpec;
9 |
10 | public class MiuiThermalAESUtil {
11 | private static final String KEY = "thermalopenssl.h";
12 | private static final String OFFSET = "thermalopenssl.h";
13 | private static final String ENCODING = "UTF-8";
14 | private static final String ALGORITHM = "AES";
15 | private static final String CIPHER_ALGORITHM = "AES/CBC/PKCS5Padding";
16 |
17 | public static byte[] encrypt(byte[] data) throws Exception {
18 | Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
19 | SecretKeySpec skeySpec = new SecretKeySpec(KEY.getBytes(ENCODING), ALGORITHM);
20 | IvParameterSpec iv = new IvParameterSpec(OFFSET.getBytes());
21 | cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
22 | return cipher.doFinal(data);
23 | }
24 |
25 | public static byte[] decrypt(byte[] buffer) throws Exception {
26 | Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
27 | SecretKeySpec skeySpec = new SecretKeySpec(KEY.getBytes(ENCODING), ALGORITHM);
28 | IvParameterSpec iv = new IvParameterSpec(OFFSET.getBytes());
29 | cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
30 | return cipher.doFinal(buffer);
31 | }
32 |
33 | private static byte[] decryptFile(String path) throws Exception {
34 | FileInputStream input = new FileInputStream(path);
35 | byte[] buffer = new byte[input.available()];
36 | input.read(buffer);
37 |
38 | return decrypt(buffer);
39 | }
40 |
41 | private static void encryptFile(String path) throws Exception {
42 | FileInputStream input = new FileInputStream(path);
43 | byte[] buffer = new byte[input.available()];
44 | input.read(buffer);
45 |
46 | byte[] result = encrypt(buffer);
47 |
48 | String outputPath = path.replace("_decrypted.conf", "");
49 | System.out.println(outputPath);
50 | input.close();
51 | FileOutputStream outputStream = new FileOutputStream(outputPath);
52 | outputStream.write(result);
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/AppInfo.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | /**
6 | * 应用信息
7 | * Created by Hello on 2018/01/26.
8 | */
9 |
10 | public class AppInfo extends io.github.lumyuan.turingbox.common.pojo.AppInfo {
11 | public Drawable icon = null;
12 | public CharSequence stateTags = "";
13 | public CharSequence path = "";
14 | public CharSequence dir = "";
15 | public Boolean enabled = false;
16 | public Boolean suspended = false;
17 | public Boolean updated = false;
18 | public String versionName = "";
19 | public int versionCode = 0;
20 | public AppType appType = AppType.UNKNOW;
21 | public SceneConfigInfo sceneConfigInfo;
22 | public CharSequence desc;
23 | public int targetSdkVersion;
24 | public int minSdkVersion;
25 |
26 | public static AppInfo getItem() {
27 | return new AppInfo();
28 | }
29 |
30 | public enum AppType {
31 | UNKNOW,
32 | USER,
33 | SYSTEM,
34 | BACKUPFILE
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/BatteryStatus.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | public class BatteryStatus {
4 | public long time;
5 | public int level = -1;
6 | public float temperature = -1;
7 | public int status = 0;
8 | public String statusText;
9 | public int io = -1;
10 | public String packageName;
11 | public String mode;
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/ChargeSpeedHistory.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | public class ChargeSpeedHistory {
4 | public long io;
5 | public int capacity;
6 | public float temperature;
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/ChargeTimeHistory.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | public class ChargeTimeHistory {
4 | public long io;
5 | public int capacity;
6 | public long startTime;
7 | public long endTime;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/CpuClusterStatus.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.HashMap;
5 |
6 | public class CpuClusterStatus implements Serializable {
7 | public String min_freq = "";
8 | public String max_freq = "";
9 | public String governor = "";
10 | public HashMap governor_params = null;
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/CpuCoreInfo.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | public class CpuCoreInfo {
4 | public int coreIndex;
5 | public String minFreq;
6 | public String maxFreq;
7 | public String currentFreq;
8 | public double loadRatio;
9 | public CpuCoreInfo(int coreIndex) {
10 | this.coreIndex = coreIndex;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/CpuStatus.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 |
6 | /**
7 | * Created by Hello on 2018/08/04.
8 | */
9 |
10 | public class CpuStatus implements Serializable {
11 | public ArrayList cpuClusterStatuses = new ArrayList<>();
12 |
13 | public String coreControl = "";
14 | public String vdd = "";
15 | public String msmThermal = "";
16 | public ArrayList coreOnline = null;
17 |
18 | public int exynosHmpUP = 0;
19 | public int exynosHmpDown = 0;
20 | public boolean exynosHmpBooster = false;
21 | public boolean exynosHotplug = false;
22 |
23 | public String adrenoMinFreq = "";
24 | public String adrenoMaxFreq = "";
25 | public String adrenoMinPL = "";
26 | public String adrenoMaxPL = "";
27 | public String adrenoDefaultPL = "";
28 | public String adrenoGovernor = "";
29 |
30 | public String cpusetBackground = "";
31 | public String cpusetSysBackground = "";
32 | public String cpusetForeground = "";
33 | public String cpusetTopApp = "";
34 | public String cpusetRestricted = "";
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/CustomTaskAction.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | import java.io.Serializable;
4 |
5 | public class CustomTaskAction implements Serializable {
6 | public String Name = "";
7 | public String Command = "";
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/SceneConfigInfo.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | import android.content.pm.ActivityInfo;
4 |
5 | public class SceneConfigInfo {
6 | public String packageName;
7 |
8 | // 使用独立亮度
9 | public boolean aloneLight = false;
10 | // 独立亮度值
11 | public int aloneLightValue = -1;
12 | // 屏蔽通知
13 | public boolean disNotice = false;
14 | // 拦截按键
15 | public boolean disButton = false;
16 | // 启动时开启GPS
17 | public boolean gpsOn = false;
18 | // 应用偏见(自动冻结)
19 | public boolean freeze = false;
20 | // 屏幕旋转方向
21 | public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
22 |
23 | // cgroup - memory
24 | public String fgCGroupMem = "";
25 | public String bgCGroupMem = "";
26 | public boolean dynamicBoostMem = false;
27 |
28 | // 显示性能监视器
29 | public boolean showMonitor = false;
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/SceneStandbyMode.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model
2 |
3 | import android.content.Context
4 | import io.github.lumyuan.turingbox.R
5 | import io.github.lumyuan.turingbox.common.shell.KeepShell
6 | import io.github.lumyuan.turingbox.common.util.AppListHelper
7 |
8 | class SceneStandbyMode(private val context: Context, private val keepShell: KeepShell) {
9 | companion object {
10 | public val configSpfName = "SceneStandbyList"
11 | }
12 |
13 | private val stateProp = "persist.turingbox.suspend"
14 |
15 | public fun getCmds(on: Boolean): String {
16 | val cmds = StringBuffer()
17 | if (on) {
18 | val apps = AppListHelper(context).getAll()
19 | val command = if (on) "suspend" else "unsuspend"
20 |
21 | val blackListConfig = context.getSharedPreferences(configSpfName, Context.MODE_PRIVATE)
22 | val whiteList = context.resources.getStringArray(R.array.scene_standby_white_list)
23 | for (app in apps) {
24 | if (!whiteList.contains(app.packageName)) {
25 | if (((app.appType == AppInfo.AppType.SYSTEM || app.updated) && blackListConfig.getBoolean(
26 | app.packageName,
27 | false
28 | )) || (app.appType == AppInfo.AppType.USER && (!app.updated) && blackListConfig.getBoolean(
29 | app.packageName,
30 | true
31 | ))
32 | ) {
33 | cmds.append("pm ")
34 | cmds.append(command)
35 | cmds.append(" \"")
36 | cmds.append(app.packageName)
37 | cmds.append("\"\n")
38 | if (on) {
39 | cmds.append("am force-stop ")
40 | cmds.append(" \"")
41 | cmds.append(app.packageName)
42 | cmds.append("\"\n")
43 | // TODO:真的要这么做吗?
44 | // if (app.packageName.equals("com.google.android.gsf")) {
45 | // cmds.append("pm disable com.google.android.gsf 2> /dev/null\n")
46 | // }
47 | }
48 | }
49 | }
50 | }
51 | cmds.append("\n")
52 | cmds.append("sync\n")
53 | cmds.append("echo 3 > /proc/sys/vm/drop_caches\n")
54 | cmds.append("setprop ")
55 | cmds.append(stateProp)
56 | cmds.append(" 1")
57 | cmds.append("\n")
58 | } else {
59 | cmds.append(
60 | "for app in `pm list package | cut -f2 -d ':'`; do\n" +
61 | " pm unsuspend \$app 1 > /dev/null\n" +
62 | " done\n"
63 | )
64 | cmds.append("setprop ")
65 | cmds.append(stateProp)
66 | cmds.append(" 0")
67 | cmds.append("\n")
68 | }
69 | return cmds.toString()
70 | }
71 |
72 | public fun on() {
73 | if (keepShell.doCmdSync("getprop $stateProp").equals("1")) {
74 | return
75 | }
76 | keepShell.doCmdSync(getCmds(true))
77 | }
78 |
79 | public fun off() {
80 | if (keepShell.doCmdSync("getprop $stateProp").equals("0")) {
81 | return
82 | }
83 | keepShell.doCmdSync(getCmds(false))
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/TaskAction.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | public enum TaskAction {
4 | FSTRIM, // fstrim
5 | STANDBY_MODE_ON, // 待机模式
6 | STANDBY_MODE_OFF, // 待机模式
7 | ZEN_MODE_ON, // 勿扰模式开
8 | ZEN_MODE_OFF, // 勿扰模式关
9 | POWER_OFF, // 关机手机
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/TriggerExecutorService.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model
2 |
3 | import android.app.IntentService
4 | import android.content.Intent
5 | import io.github.lumyuan.turingbox.common.store.TriggerStorage
6 |
7 | class TriggerExecutorService : IntentService("TriggerExecutorService") {
8 |
9 | override fun onHandleIntent(intent: Intent?) {
10 | intent?.run {
11 | if (intent.hasExtra("triggers")) {
12 | executeTriggers(intent.getStringArrayListExtra("triggers")!!)
13 | }
14 | }
15 | }
16 |
17 | private fun executeTriggers(triggers: ArrayList) {
18 | val context = this;
19 | val storage = TriggerStorage(this)
20 | triggers.forEach {
21 | storage.load(it)?.run {
22 | TaskActionsExecutor(taskActions, customTaskActions, context).run()
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/TriggerIEventMonitor.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import io.github.lumyuan.turingbox.common.calculator.GetUpTime
6 | import io.github.lumyuan.turingbox.common.data.EventType
7 | import io.github.lumyuan.turingbox.common.data.IEventReceiver
8 | import io.github.lumyuan.turingbox.common.store.TriggerStorage
9 |
10 | class TriggerIEventMonitor(private val context: Context, override val isAsync: Boolean = false) :
11 | IEventReceiver {
12 | private val triggerListConfig = context.getSharedPreferences("scene_trigger_list", Context.MODE_PRIVATE)
13 |
14 | override fun onReceive(eventType: EventType, data: HashMap?) {
15 | val eventName = eventType.name
16 |
17 | // 根据事件筛选
18 | val items = triggerListConfig.all.filter {
19 | (it.value as String).contains(eventName)
20 | }.keys
21 |
22 | val storage = TriggerStorage(context)
23 | val triggers = ArrayList()
24 | items.forEach {
25 | val trigger = storage.load(it)
26 | if (trigger != null && trigger.enabled) {
27 | if (trigger.timeLimited) {
28 | val nowTimeValue = GetUpTime(trigger.timeStart).currentTime
29 | val getUp = trigger.timeEnd
30 | val sleep = trigger.timeStart
31 |
32 | val inTimeSection =
33 | // 如果【起床时间】比【睡觉时间】要大,如 2:00 睡到 9:00 起床
34 | (getUp > sleep && (nowTimeValue in sleep..getUp)) ||
35 | // 正常时间睡觉【睡觉时间】大于【起床时间】,如 23:00 睡到 7:00 起床
36 | (getUp < sleep && (nowTimeValue >= sleep || nowTimeValue <= getUp))
37 | if (!inTimeSection) {
38 | return
39 | }
40 | }
41 | triggers.add(it)
42 | }
43 | }
44 | if (triggers.size > 0) {
45 | startExecutor(triggers)
46 | }
47 | }
48 |
49 | override fun onSubscribe() {
50 |
51 | }
52 |
53 | override fun onUnsubscribe() {
54 |
55 | }
56 |
57 | private fun startExecutor(triggers: ArrayList) {
58 | val taskIntent = Intent(context, TriggerExecutorService::class.java)
59 | taskIntent.putExtra("triggers", triggers)
60 | context.startService(taskIntent)
61 | }
62 |
63 | override fun eventFilter(eventType: EventType): Boolean {
64 | when (eventType) {
65 | EventType.SCREEN_ON,
66 | EventType.SCREEN_OFF,
67 | EventType.BOOT_COMPLETED,
68 | EventType.BATTERY_LOW,
69 | EventType.POWER_CONNECTED,
70 | EventType.POWER_DISCONNECTED -> {
71 | return true
72 | }
73 | else -> return false
74 | }
75 | }
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/model/TriggerInfo.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 |
6 | import io.github.lumyuan.turingbox.common.data.EventType;
7 |
8 | public class TriggerInfo implements Serializable {
9 | // 是否启用
10 | public boolean enabled;
11 | // id
12 | public String id;
13 | // 事件
14 | public ArrayList events;
15 |
16 | // 是否限制执行时间段
17 | public boolean timeLimited = false;
18 | // 时间段 - 开始时间
19 | public int timeStart = 0;
20 | // 时间段 - 结束时间
21 | public int timeEnd = 24 * 60 - 1;
22 |
23 | // 任务动作列表
24 | public ArrayList taskActions;
25 | // 任务动作列表(自定义)
26 | public ArrayList customTaskActions;
27 |
28 | public TriggerInfo(String id) {
29 | this.id = id;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/permissions/WriteSettings.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.permissions
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.net.Uri
6 | import android.os.Build
7 | import android.provider.Settings
8 | import android.widget.Toast
9 | import androidx.core.content.PermissionChecker
10 | import io.github.lumyuan.turingbox.R
11 | import io.github.lumyuan.turingbox.common.shell.KeepShellPublic
12 |
13 |
14 | /**
15 | * Created by SYSTEM on 2018/07/21.
16 | */
17 | class WriteSettings {
18 | private fun checkPermission(context: Context, permission: String): Boolean = PermissionChecker.checkSelfPermission(context, permission) == PermissionChecker.PERMISSION_GRANTED
19 | fun getPermission(context: Context): Boolean =
20 | try {
21 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
22 | Settings.System.canWrite(context)
23 | } else {
24 | // TODO("VERSION.SDK_INT < M")
25 | true
26 | }
27 | } catch (e: Exception) {
28 | e.printStackTrace()
29 | false
30 | }
31 |
32 | fun setPermission(context: Context) {
33 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
34 | // val selfPackageUri = Uri.parse("package:" + context.packageName)
35 | // val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, selfPackageUri)
36 | // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
37 | // context.startActivity(intent)
38 | try {
39 | Toast.makeText(context, R.string.please_arrow_update_system_permission, Toast.LENGTH_LONG).show()
40 | val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
41 | val uri = Uri.fromParts("package", context.getPackageName(), null)
42 | intent.setData(uri)
43 | context.startActivity(intent)
44 | } catch (e: Exception) {
45 | e.printStackTrace()
46 | }
47 | } else {
48 | KeepShellPublic.doCmdSync("pm grant ${context.packageName} android.permission.WRITE_SETTINGS")
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/pojo/AppInfo.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.pojo
2 |
3 | open class AppInfo {
4 | var appName: String = ""
5 | var packageName: String = ""
6 |
7 | // 是否未找到此应用
8 | var notFound: Boolean = false
9 | var selected: Boolean = false
10 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shared/ObjectStorage.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shared
2 |
3 | import android.content.Context
4 | import android.widget.Toast
5 | import java.io.*
6 |
7 | open class ObjectStorage(private val context: Context) {
8 | private val objectStorageDir = "objects/"
9 | protected fun getSaveDir(configFile: String): String {
10 | return FileWrite.getPrivateFilePath(context, objectStorageDir + configFile)
11 | }
12 |
13 | public open fun load(configFile: String): T? {
14 | val file = File(getSaveDir(configFile))
15 | if (file.exists()) {
16 | var fileInputStream: FileInputStream? = null;
17 | var objectInputStream: ObjectInputStream? = null;
18 | try {
19 | fileInputStream = FileInputStream(file)
20 | objectInputStream = ObjectInputStream(fileInputStream)
21 | return objectInputStream.readObject() as T?
22 | } catch (ex: Exception) {
23 | } finally {
24 | try {
25 | if (objectInputStream != null) {
26 | objectInputStream.close()
27 | }
28 | if (fileInputStream != null) {
29 | fileInputStream.close()
30 | }
31 | } catch (ex: Exception) {
32 | }
33 | }
34 | }
35 | return null
36 | }
37 |
38 | public open fun save(obj: T?, configFile: String): Boolean {
39 | val file = File(getSaveDir(configFile))
40 | val parentFile = file.parentFile
41 | if (!parentFile.exists()) {
42 | parentFile.mkdirs()
43 | }
44 | if (obj != null) {
45 | var fileOutputStream: FileOutputStream? = null
46 | var objectOutputStream: ObjectOutputStream? = null
47 | try {
48 | fileOutputStream = FileOutputStream(file)
49 | objectOutputStream = ObjectOutputStream(fileOutputStream)
50 | objectOutputStream.writeObject(obj)
51 | return true
52 | } catch (ex: Exception) {
53 | Toast.makeText(context, "存储配置失败!", Toast.LENGTH_SHORT).show()
54 | return false
55 | } finally {
56 | try {
57 | if (objectOutputStream != null) {
58 | objectOutputStream.close()
59 | }
60 | if (fileOutputStream != null) {
61 | fileOutputStream.close()
62 | }
63 | } catch (ex: Exception) {
64 | }
65 | }
66 | } else {
67 | if (file.exists()) {
68 | file.delete()
69 | }
70 | }
71 | return true
72 | }
73 |
74 | public open fun remove(configFile: String) {
75 | val file = File(getSaveDir(configFile))
76 | if (file.exists()) {
77 | file.delete()
78 | }
79 | }
80 |
81 | public open fun exists(configFile: String): Boolean {
82 | return File(getSaveDir(configFile)).exists()
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shared/RawText.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shared
2 |
3 | import android.content.Context
4 | import java.nio.charset.Charset
5 |
6 | object RawText {
7 | fun getRawText(context: Context, id: Int): String {
8 | try {
9 | return String(context.resources.openRawResource(id).readBytes(), Charset.defaultCharset()).replace(Regex("\r\n"), "\n").replace(Regex("\r\t"), "\t").replace(Regex("\r"), "\n")
10 | } catch (ex: Exception) {
11 | return ""
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shared/RootFileInfo.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shared
2 |
3 | import io.github.lumyuan.turingbox.common.shell.RootFile
4 |
5 |
6 | class RootFileInfo {
7 | constructor()
8 | constructor(path: String) {
9 | val file = RootFile.fileInfo(path)
10 | if (file != null) {
11 | this.parentDir = file.parentDir
12 | this.filePath = file.filePath
13 | this.isDirectory = file.isDirectory
14 | }
15 | }
16 |
17 | var parentDir: String = ""
18 | var filePath: String = ""
19 | var isDirectory: Boolean = false
20 | var fileSize: Long = 0;
21 |
22 | val fileName: String
23 | get() {
24 | if (filePath.endsWith("/")) {
25 | return filePath.substring(0, filePath.length - 1)
26 | }
27 | return filePath
28 | }
29 |
30 | val absolutePath: String
31 | get() = parentDir + "/" + fileName
32 |
33 |
34 | public fun exists(): Boolean {
35 | return RootFile.itemExists(this.absolutePath)
36 | }
37 |
38 | public fun isFile(): Boolean {
39 | return !isDirectory
40 | }
41 |
42 | public fun getParent(): String {
43 | return this.parentDir
44 | }
45 |
46 | public fun getName(): String {
47 | return this.fileName
48 | }
49 |
50 | public fun listFiles(): ArrayList {
51 | if (this.isDirectory) {
52 | return RootFile.list(this.absolutePath)
53 | }
54 | return ArrayList()
55 | }
56 |
57 | fun length(): Long {
58 | return this.fileSize
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/FileValueMap.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | class FileValueMap {
4 | fun mapFileValue(dir: String): HashMap {
5 | val hashMap = HashMap()
6 |
7 | val cmds = StringBuilder("if [[ -e $dir ]]; then\n")
8 | cmds.append("cd $dir\n")
9 | cmds.append("for item in `ls`\n" +
10 | "do\n" +
11 | "\tif [[ -f \$item ]] then\n" +
12 | "\t\techo \"\$item:`cat \$item`\"\n" +
13 | "\t\techo '----'\n" +
14 | "\tfi\n" +
15 | "done\n")
16 | cmds.append("\nfi\n")
17 | val content = KeepShellPublic.doCmdSync(cmds.toString())
18 | if (content != "error") {
19 | val rows = content.split("----")
20 | for (row in rows) {
21 | val item = row.trim()
22 | if (!item.isEmpty() && item.indexOf(":") > -1) {
23 | val end = item.indexOf(":")
24 | val name = item.substring(0, end)
25 | if (end < item.length - 1) {
26 | val value = item.substring(end + 1)
27 | hashMap.put(name, value)
28 | } else {
29 | hashMap.put(name, "")
30 | }
31 | }
32 | }
33 | }
34 |
35 | return hashMap
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/FstrimUtils.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | class FstrimUtils(private val keepShell: KeepShell) {
4 | fun run() {
5 | keepShell.doCmdSync("" +
6 | "fstrim /data\n" +
7 | "fstrim /data\n" +
8 | "fstrim /system\n" +
9 | "fstrim /system\n" +
10 | "fstrim /cache\n" +
11 | "fstrim /cache\n" +
12 | "sm fstrim\n")
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/KeepShellPublic.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | object KeepShellPublic {
4 | private val keepShells = HashMap()
5 |
6 | fun getInstance(key: String, rootMode: Boolean): KeepShell? {
7 | synchronized(keepShells) {
8 | if (!keepShells.containsKey(key)) {
9 | keepShells[key] = KeepShell(rootMode)
10 | }
11 | return keepShells[key]
12 | }
13 | }
14 |
15 | fun destroyInstance(key: String) {
16 | synchronized(keepShells) {
17 | if (!keepShells.containsKey(key)) {
18 | return
19 | } else {
20 | val keepShell = keepShells[key]
21 | keepShells.remove(key)
22 | keepShell?.tryExit()
23 | }
24 | }
25 | }
26 |
27 | fun destroyAll() {
28 | synchronized(keepShells) {
29 | while (keepShells.isNotEmpty()) {
30 | val key = keepShells.keys.first()
31 | val keepShell = keepShells[key]
32 | keepShells.remove(key)
33 | keepShell?.tryExit()
34 | }
35 | }
36 | }
37 |
38 | val defaultKeepShell = KeepShell()
39 | val secondaryKeepShell = KeepShell()
40 |
41 | fun getDefaultInstance(): KeepShell {
42 | return if (defaultKeepShell.isIdle || !secondaryKeepShell.isIdle) {
43 | defaultKeepShell
44 | } else {
45 | secondaryKeepShell
46 | }
47 | }
48 |
49 | fun doCmdSync(commands: List): Boolean {
50 | val stringBuilder = StringBuilder()
51 |
52 | for (cmd in commands) {
53 | stringBuilder.append(cmd)
54 | stringBuilder.append("\n\n")
55 | }
56 |
57 | return doCmdSync(stringBuilder.toString()) != "error"
58 | }
59 |
60 | //执行脚本
61 | fun doCmdSync(cmd: String): String {
62 | return getDefaultInstance().doCmdSync(cmd)
63 | }
64 |
65 | //执行脚本
66 | fun checkRoot(): Boolean {
67 | return defaultKeepShell.checkRoot()
68 | }
69 |
70 | fun tryExit() {
71 | defaultKeepShell.tryExit()
72 | secondaryKeepShell.tryExit()
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/KernelProp.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | /**
4 | * 操作内核参数节点
5 | */
6 | object KernelProp {
7 | /**
8 | * 获取属性
9 | * @param propName 属性名称
10 | * @return
11 | */
12 | fun getProp(propName: String): String {
13 | return KeepShellPublic.doCmdSync("if [[ -e \"$propName\" ]]; then cat \"$propName\"; fi;")
14 | }
15 |
16 | fun getProp(propName: String, grep: String): String {
17 | return KeepShellPublic.doCmdSync("if [[ -e \"$propName\" ]]; then cat \"$propName\" | grep \"$grep\"; fi;")
18 | }
19 |
20 | /**
21 | * 保存属性
22 | * @param propName 属性名称(要永久保存,请以persist.开头)
23 | * @param value 属性值,值尽量是简单的数字或字母,避免出现错误
24 | */
25 | fun setProp(propName: String, value: String): Boolean {
26 | return KeepShellPublic.doCmdSync(
27 | "chmod 664 \"$propName\" 2 > /dev/null\n" +
28 | "echo \"$value\" > \"$propName\""
29 | ) != "error"
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/MemoryUtils.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell;
2 |
3 | public class MemoryUtils {
4 | public static class MemoryInfo {
5 | public int memTotal;
6 | public int memAvailable;
7 | public int swapCached;
8 | public int swapTotal;
9 | public int swapFree;
10 | public int buffers;
11 | public int dirty;
12 | }
13 |
14 | // 提取 /proc/meminfo 里某一行的数值,
15 | // 例: [MemFree: 138828 kB] => [138828]
16 | private static int getMemInfoRowKB(String row) {
17 | return Integer.parseInt(
18 | row.substring(
19 | row.indexOf(":") + 1,
20 | row.lastIndexOf(" ")
21 | ).trim()
22 | );
23 | }
24 |
25 | public MemoryInfo getMemoryInfo() {
26 | String[] memInfos = KernelProp.INSTANCE.getProp("/proc/meminfo").split("\n");
27 | final MemoryInfo memInfo = new MemoryInfo();
28 | for (String row : memInfos) {
29 | if (row.startsWith("MemTotal")) {
30 | memInfo.memTotal = getMemInfoRowKB(row);
31 | } else if (row.startsWith("MemAvailable")) {
32 | memInfo.memAvailable = getMemInfoRowKB(row);
33 | } else if (row.startsWith("SwapCached")) {
34 | memInfo.swapCached = getMemInfoRowKB(row);
35 | } else if (row.startsWith("SwapTotal")) {
36 | memInfo.swapTotal = getMemInfoRowKB(row);
37 | } else if (row.startsWith("SwapFree")) {
38 | memInfo.swapFree = getMemInfoRowKB(row);
39 | } else if (row.startsWith("Buffers")) {
40 | memInfo.buffers = getMemInfoRowKB(row);
41 | } else if (row.startsWith("Dirty")) {
42 | memInfo.dirty = getMemInfoRowKB(row);
43 | }
44 | }
45 | return memInfo;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/PlatformUtils.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | /**
4 | * 读取处理器平台
5 | * Created by helloklf on 2017/6/3.
6 | */
7 |
8 | class PlatformUtils {
9 | companion object {
10 | private var cpu: String? = null
11 | }
12 |
13 | //获取CPU型号,如msm8996
14 | fun getCPUName(): String {
15 | if (cpu == null) {
16 | cpu = PropsUtils.getProp("ro.board.platform")
17 | }
18 |
19 | return cpu!!
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ProcessInfo.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell;
2 |
3 | public class ProcessInfo {
4 | public int pid;
5 | public String name;
6 | public float cpu;
7 | public String getState () {
8 | switch (state) {
9 | case "R": return "R (running)";
10 | case "S": return "S (sleeping)";
11 | case "D": return "D (device I/O)";
12 | case "T": return "T (stopped)";
13 | case "t": return "t (trace stop)";
14 | case "X": return "X (dead)";
15 | case "Z": return "Z (zombie)";
16 | case "P": return "P (parked)";
17 | case "I": return "I (idle)";
18 | case "x": return "x (dead)";
19 | case "K": return "K (wakekill)";
20 | case "W": return "W (waking)";
21 | default: return "Unknown";
22 | }
23 | }
24 |
25 | /*
26 | Process state:
27 | R (running) S (sleeping) D (device I/O) T (stopped) t (trace stop)
28 | X (dead) Z (zombie) P (parked) I (idle)
29 | Also between Linux 2.6.33 and 3.13:
30 | x (dead) K (wakekill) W (waking)
31 | */
32 | public float getCpu () {
33 | /*
34 | switch (state) {
35 | // case "S":
36 | case "T":
37 | case "t":
38 | case "X":
39 | case "P":
40 | case "I":
41 | case "x": {
42 | return 0f;
43 | }
44 | default: {
45 | return cpu;
46 | }
47 | }
48 | */
49 | return cpu;
50 | }
51 | public long res;
52 | public long rss;
53 | public long mem;
54 | public long swap;
55 | public String state = "";
56 | public String user;
57 | public String command = "";
58 | public String cmdline = "";
59 |
60 | public String friendlyName = "";
61 |
62 | public String cpuSet;
63 | public String cGroup;
64 | public String oomAdj;
65 | public String oomScore;
66 | public String oomScoreAdj;
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/PropsUtils.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | /**
4 | * Created by Hello on 2017/8/8.
5 | */
6 |
7 | object PropsUtils {
8 | /**
9 | * 获取属性
10 | *
11 | * @param propName 属性名称
12 | * @return 内容
13 | */
14 | fun getProp(propName: String): String {
15 | return KeepShellPublic.doCmdSync("getprop \"$propName\"")
16 | }
17 |
18 | fun setProp(propName: String, value: String): Boolean {
19 | return KeepShellPublic.doCmdSync("setprop \"$propName\" \"$value\"") != "error"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ShellConfiguration.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | object ShellConfiguration {
4 | var SU = "su"
5 | var SH = "su"
6 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ShellEvents.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | import android.os.Handler
4 |
5 | /**
6 | * Created by Hello on 2018/06/30.
7 | */
8 |
9 | open class ShellEvents {
10 | protected var processHandler: Handler? = null
11 | var PROCESS_EVENT_STAR = 0;
12 | var PROCESS_EVENT_CONTENT = 1;
13 | var PROCESS_EVENT_ERROR_CONTENT = 2;
14 | var PROCESS_EVENT_EXIT = -1;
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ShellExecutor.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.OutputStream;
6 |
7 | public class ShellExecutor {
8 | private static String extraEnvPath = "";
9 | private static String defaultEnvPath = ""; // /sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin
10 |
11 | public static void setExtraEnvPath(String extraEnvPath) {
12 | ShellExecutor.extraEnvPath = extraEnvPath;
13 | }
14 |
15 | private static String getEnvPath() {
16 | // FIXME:非root模式下,默认的 TMPDIR=/data/local/tmp 变量可能会导致某些需要写缓存的场景(例如使用source指令)脚本执行失败!
17 | if (extraEnvPath != null && !extraEnvPath.isEmpty()) {
18 | if (defaultEnvPath.isEmpty()) {
19 | try {
20 | Process process = Runtime.getRuntime().exec("sh");
21 | OutputStream outputStream = process.getOutputStream();
22 | outputStream.write("echo $PATH".getBytes());
23 | outputStream.flush();
24 | outputStream.close();
25 |
26 | InputStream inputStream = process.getInputStream();
27 | byte[] cache = new byte[16384];
28 | int length = inputStream.read(cache);
29 | inputStream.close();
30 | process.destroy();
31 |
32 | String path = new String(cache, 0, length).trim();
33 | if (path.length() > 0) {
34 | defaultEnvPath = path;
35 | } else {
36 | throw new RuntimeException("未能获取到$PATH参数");
37 | }
38 | } catch (Exception ex) {
39 | defaultEnvPath = "/sbin:/system/sbin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin";
40 | }
41 | }
42 |
43 | String path = defaultEnvPath;
44 |
45 | return ( "PATH=" + path + ":" + extraEnvPath);
46 | }
47 |
48 | return null;
49 | }
50 |
51 | private static Process getProcess(String run) throws IOException {
52 | String env = getEnvPath();
53 | Runtime runtime = Runtime.getRuntime();
54 | Process process = runtime.exec(run);
55 | if (env != null) {
56 | OutputStream outputStream = process.getOutputStream();
57 | outputStream.write("export ".getBytes());
58 | outputStream.write(env.getBytes());
59 | outputStream.write("\n".getBytes());
60 | outputStream.flush();
61 | }
62 | return process;
63 | }
64 |
65 | public static Process getSuperUserRuntime() throws IOException {
66 | return getProcess(ShellConfiguration.INSTANCE.getSU());
67 | }
68 |
69 | public static Process getRuntime() throws IOException {
70 | return getProcess(ShellConfiguration.INSTANCE.getSH());
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ThermalControlUtils.java:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell;
2 |
3 | import java.util.ArrayList;
4 |
5 | import io.github.lumyuan.turingbox.common.model.CpuStatus;
6 |
7 | public class ThermalControlUtils {
8 | //Thermal
9 | private final String thermal_core_control = "/sys/module/msm_thermal/core_control/enabled";//1 0
10 | private final String thermal_vdd_restriction = "/sys/module/msm_thermal/vdd_restriction/enabled"; //1 0
11 | private final String thermal_parameters = "/sys/module/msm_thermal/parameters/enabled"; //Y N
12 |
13 | public Boolean isSupported() {
14 | return RootFile.INSTANCE.itemExists(thermal_core_control) ||
15 | RootFile.INSTANCE.itemExists(thermal_vdd_restriction) ||
16 | RootFile.INSTANCE.itemExists(thermal_parameters);
17 | }
18 |
19 | public String getCoreControlState() {
20 | return KernelProp.INSTANCE.getProp(thermal_core_control).trim();
21 | }
22 |
23 | public void setCoreControlState(Boolean online) {
24 | String val = online ? "1" : "0";
25 | ArrayList commands = new ArrayList<>();
26 | commands.add("chmod 0664 " + thermal_core_control);
27 | commands.add("echo " + val + " > " + thermal_core_control);
28 | KeepShellPublic.INSTANCE.doCmdSync(commands);
29 | }
30 |
31 | public String getVDDRestrictionState() {
32 | return KernelProp.INSTANCE.getProp(thermal_vdd_restriction).trim();
33 | }
34 |
35 | public void setVDDRestrictionState(Boolean online) {
36 | String val = online ? "1" : "0";
37 | ArrayList commands = new ArrayList<>();
38 | commands.add("chmod 0664 " + thermal_vdd_restriction);
39 | commands.add("echo " + val + " > " + thermal_vdd_restriction);
40 | KeepShellPublic.INSTANCE.doCmdSync(commands);
41 | }
42 |
43 | public String getTheramlState() {
44 | return KernelProp.INSTANCE.getProp(thermal_parameters).trim();
45 | }
46 |
47 | public void setTheramlState(Boolean online) {
48 | String val = online ? "Y" : "N";
49 | ArrayList commands = new ArrayList<>();
50 | commands.add("chmod 0664 " + thermal_parameters);
51 | commands.add("echo " + val + " > " + thermal_parameters);
52 | KeepShellPublic.INSTANCE.doCmdSync(commands);
53 | }
54 |
55 |
56 | public ArrayList buildSetThermalParams(CpuStatus cpuStatus, ArrayList commands) {
57 | if (!(cpuStatus.coreControl == null || cpuStatus.coreControl.isEmpty())) {
58 | commands.add("chmod 0664 " + thermal_core_control);
59 | commands.add("echo " + cpuStatus.coreControl + " > " + thermal_core_control);
60 | }
61 | if (!(cpuStatus.vdd == null || cpuStatus.vdd.isEmpty())) {
62 | commands.add("chmod 0664 " + thermal_vdd_restriction);
63 | commands.add("echo " + cpuStatus.vdd + " > " + thermal_vdd_restriction);
64 | }
65 | if (!(cpuStatus.msmThermal == null || cpuStatus.msmThermal.isEmpty())) {
66 | commands.add("chmod 0664 " + thermal_parameters);
67 | commands.add("echo " + cpuStatus.msmThermal + " > " + thermal_parameters);
68 | }
69 | return commands;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ToyboxIntaller.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | import android.content.Context
4 | import android.os.Build
5 | import io.github.lumyuan.turingbox.R
6 | import io.github.lumyuan.turingbox.common.shared.FileWrite.getPrivateFilePath
7 | import io.github.lumyuan.turingbox.common.shared.FileWrite.writePrivateFile
8 | import java.io.File
9 | import java.util.*
10 |
11 | class ToyboxIntaller(private val context: Context) {
12 | fun install() : String {
13 |
14 | val installPath: String = context.getString(R.string.toolkit_install_path)
15 | val abi = Build.SUPPORTED_ABIS.joinToString(" ").toLowerCase(Locale.getDefault())
16 | val fileName = if (abi.contains("arm64")) "toybox-outside64" else "toybox-outside";
17 | val toyboxInstallPath = "$installPath/$fileName"
18 | val outsideToybox = getPrivateFilePath(context, toyboxInstallPath)
19 |
20 | if (!File(outsideToybox).exists()) {
21 | writePrivateFile(context.getAssets(), toyboxInstallPath, toyboxInstallPath, context)
22 | }
23 |
24 | return outsideToybox
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/shell/ZenModeUtils.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.shell
2 |
3 | import android.content.Context
4 | import android.provider.Settings
5 |
6 | // 勿扰模式
7 | class ZenModeUtils(private val context: Context) {
8 | /*
9 | // 静音模式(基本已经被勿扰模式取代)
10 | val audioManager = this.getSystemService(Context.AUDIO_SERVICE) as AudioManager
11 | audioManager.ringerMode = AudioManager.RINGER_MODE_VIBRATE
12 | */
13 |
14 | // 从 Settings.Global 复制的
15 | val ZEN_MODE_OFF = 0
16 |
17 | // val ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1
18 | val ZEN_MODE_NO_INTERRUPTIONS = 2
19 | // val ZEN_MODE_ALARMS = 3
20 |
21 | fun on() {
22 | val contentResolver = context.contentResolver
23 | if (Settings.Global.putInt(contentResolver, "zen_mode", ZEN_MODE_NO_INTERRUPTIONS)) {
24 | return
25 | } else {
26 | KeepShellPublic.doCmdSync("settings put global zen_mode $ZEN_MODE_NO_INTERRUPTIONS")
27 | }
28 | }
29 |
30 | fun off() {
31 | val contentResolver = context.contentResolver
32 | if (Settings.Global.putInt(contentResolver, "zen_mode", ZEN_MODE_OFF)) {
33 | return
34 | } else {
35 | KeepShellPublic.doCmdSync("settings put global zen_mode $ZEN_MODE_OFF")
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/store/TriggerStorage.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.store
2 |
3 | import android.content.Context
4 | import io.github.lumyuan.turingbox.common.model.TriggerInfo
5 | import io.github.lumyuan.turingbox.common.shared.ObjectStorage
6 |
7 | class TriggerStorage(private val context: Context) : ObjectStorage(context) {
8 | fun save(obj: TriggerInfo): Boolean {
9 | return super.save(obj, obj.id)
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/util/CommonCmds.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.util
2 |
3 | import android.os.Environment
4 |
5 | /**
6 | * Created by Hello on 2017/2/22.
7 | */
8 |
9 | object CommonCmds {
10 | val SDCardDir: String = Environment.getExternalStorageDirectory().absolutePath
11 |
12 | val AbsBackUpDir = "$SDCardDir/backups/apps/"
13 |
14 | const val MountSystemRW =
15 | "busybox mount -o rw,remount / 2>/dev/null\n" +
16 | "mount -o rw,remount /system 2>/dev/null\n" +
17 | "busybox mount -o rw,remount / 2>/dev/null\n" +
18 | "mount -o rw,remount /system 2>/dev/null\n" +
19 | "busybox mount -o remount,rw /dev/block/bootdevice/by-name/system /system 2>/dev/null\n" +
20 | "mount -o remount,rw /dev/block/bootdevice/by-name/system /system 2>/dev/null\n" +
21 | "busybox mount -o rw,remount /vendor 2>/dev/null\n" +
22 | "mount -o rw,remount /vendor 2>/dev/null\n"
23 |
24 | const val DisableSELinux = "setenforce 0;\n"
25 | const val ResumeSELinux = "setenforce 1;\n"
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/common/util/SharedPreferencesUtil.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.common.util
2 |
3 | import android.content.Context
4 | import io.github.lumyuan.turingbox.TuringBox
5 |
6 | object SharedPreferencesUtil {
7 |
8 | private val sharedPreferences by lazy {
9 | TuringBox.application.getSharedPreferences(TuringBox.application.packageName, Context.MODE_PRIVATE)
10 | }
11 |
12 | fun save(key: Any?, value: String?): Boolean{
13 | return sharedPreferences.edit().putString(key.toString(), value).commit()
14 | }
15 |
16 | fun load(key: Any?): String?{
17 | return sharedPreferences.getString(key?.toString(), null)
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/compose/Activites.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.ui.compose
2 |
3 | import androidx.activity.ComponentActivity
4 | import androidx.activity.compose.setContent
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.runtime.CompositionContext
8 | import androidx.compose.ui.Modifier
9 | import io.github.lumyuan.turingbox.ui.theme.TuringBoxTheme
10 |
11 | fun ComponentActivity.setContentUI(
12 | parent: CompositionContext? = null,
13 | modifier: Modifier = Modifier.fillMaxSize(),
14 | content: @Composable () -> Unit
15 | ) {
16 | setContent(
17 | parent
18 | ) {
19 | TuringBoxTheme(
20 | modifier = modifier,
21 | content = content
22 | )
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/compose/Timer.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.ui.compose
2 |
3 | import androidx.compose.runtime.getValue
4 | import androidx.compose.runtime.mutableStateOf
5 | import androidx.compose.runtime.setValue
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.Job
9 | import kotlinx.coroutines.delay
10 | import kotlinx.coroutines.isActive
11 | import kotlinx.coroutines.launch
12 | import java.util.Calendar
13 | import kotlin.coroutines.CoroutineContext
14 |
15 | /**
16 | * 协程定时器
17 | */
18 | fun launchTimerJob(scopeContext: CoroutineContext = Dispatchers.IO, intervalMillis: Long = 1500, action: suspend (CoroutineScope) -> Unit): Job =
19 | CoroutineScope(scopeContext).launch {
20 | while (isActive) {
21 | action(this)
22 | delay(intervalMillis)
23 | }
24 | }
25 |
26 | class TimerState {
27 | var timerJob: Job? = null
28 | var timer: String by mutableStateOf("00:00:00")
29 |
30 | fun updateTimer() {
31 | val calendar = Calendar.getInstance()
32 | val hours = calendar.get(Calendar.HOUR_OF_DAY)
33 | val minutes = calendar.get(Calendar.MINUTE)
34 | val seconds = calendar.get(Calendar.SECOND)
35 | timer = String.format("%02d:%02d:%02d", hours, minutes, seconds)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/icon/NiaIcons.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Android Open Source Project
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 | * https://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 | package io.github.lumyuan.turingbox.ui.icon
18 |
19 | import androidx.compose.material.icons.Icons
20 | import androidx.compose.material.icons.filled.MoreVert
21 | import androidx.compose.material.icons.outlined.Bookmarks
22 | import androidx.compose.material.icons.outlined.Upcoming
23 | import androidx.compose.material.icons.rounded.Add
24 | import androidx.compose.material.icons.rounded.ArrowBack
25 | import androidx.compose.material.icons.rounded.Bookmark
26 | import androidx.compose.material.icons.rounded.BookmarkBorder
27 | import androidx.compose.material.icons.rounded.Bookmarks
28 | import androidx.compose.material.icons.rounded.Check
29 | import androidx.compose.material.icons.rounded.Close
30 | import androidx.compose.material.icons.rounded.Grid3x3
31 | import androidx.compose.material.icons.rounded.Person
32 | import androidx.compose.material.icons.rounded.Search
33 | import androidx.compose.material.icons.rounded.Settings
34 | import androidx.compose.material.icons.rounded.ShortText
35 | import androidx.compose.material.icons.rounded.Upcoming
36 | import androidx.compose.material.icons.rounded.ViewDay
37 | import androidx.compose.ui.graphics.vector.ImageVector
38 |
39 | /**
40 | * Now in Android icons. Material icons are [ImageVector]s, custom icons are drawable resource IDs.
41 | */
42 | object NiaIcons {
43 | val Add = Icons.Rounded.Add
44 | val ArrowBack = Icons.Rounded.ArrowBack
45 | val Bookmark = Icons.Rounded.Bookmark
46 | val BookmarkBorder = Icons.Rounded.BookmarkBorder
47 | val Bookmarks = Icons.Rounded.Bookmarks
48 | val BookmarksBorder = Icons.Outlined.Bookmarks
49 | val Check = Icons.Rounded.Check
50 | val Close = Icons.Rounded.Close
51 | val Grid3x3 = Icons.Rounded.Grid3x3
52 | val MoreVert = Icons.Default.MoreVert
53 | val Person = Icons.Rounded.Person
54 | val Search = Icons.Rounded.Search
55 | val Settings = Icons.Rounded.Settings
56 | val ShortText = Icons.Rounded.ShortText
57 | val Upcoming = Icons.Rounded.Upcoming
58 | val UpcomingBorder = Icons.Outlined.Upcoming
59 | val ViewDay = Icons.Rounded.ViewDay
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/theme/AppTheme.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.ui.theme
2 |
3 | import io.github.lumyuan.turingbox.R
4 | import io.github.lumyuan.turingbox.TuringBox
5 |
6 | enum class AppTheme {
7 | DEFAULT, DYNAMIC_COLOR, GREEN, RED, PINK, BLUE, CYAN, ORANGE, PURPLE, BROWN, GRAY;
8 |
9 | fun getRealName() =
10 | when (this) {
11 | DEFAULT -> TuringBox.application.getString(R.string.theme_default)
12 | DYNAMIC_COLOR -> TuringBox.application.getString(R.string.theme_dynamic_color)
13 | GREEN -> TuringBox.application.getString(R.string.theme_green)
14 | RED -> TuringBox.application.getString(R.string.theme_red)
15 | PINK -> TuringBox.application.getString(R.string.theme_pink)
16 | BLUE -> TuringBox.application.getString(R.string.theme_blue)
17 | CYAN -> TuringBox.application.getString(R.string.theme_cyan)
18 | ORANGE -> TuringBox.application.getString(R.string.theme_orange)
19 | PURPLE -> TuringBox.application.getString(R.string.theme_purple)
20 | BROWN -> TuringBox.application.getString(R.string.theme_brown)
21 | GRAY -> TuringBox.application.getString(R.string.theme_gray)
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/theme/DarkTheme.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.ui.theme
2 |
3 | enum class DarkTheme {
4 | SYSTEM, LIGHT, NIGHT
5 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/ui/widget/ProgressBar.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.ui.widget
2 |
3 | import androidx.compose.animation.core.Animatable
4 | import androidx.compose.animation.core.FastOutLinearInEasing
5 | import androidx.compose.animation.core.FastOutSlowInEasing
6 | import androidx.compose.animation.core.tween
7 | import androidx.compose.foundation.layout.height
8 | import androidx.compose.foundation.layout.width
9 | import androidx.compose.foundation.shape.RoundedCornerShape
10 | import androidx.compose.material3.MaterialTheme
11 | import androidx.compose.material3.Surface
12 | import androidx.compose.runtime.Composable
13 | import androidx.compose.runtime.LaunchedEffect
14 | import androidx.compose.runtime.remember
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.draw.clip
17 | import androidx.compose.ui.draw.drawWithContent
18 | import androidx.compose.ui.geometry.CornerRadius
19 | import androidx.compose.ui.geometry.Offset
20 | import androidx.compose.ui.graphics.Color
21 | import androidx.compose.ui.graphics.StrokeCap
22 | import androidx.compose.ui.graphics.drawscope.Stroke
23 | import androidx.compose.ui.unit.Dp
24 | import androidx.compose.ui.unit.dp
25 |
26 | @Composable
27 | fun ProgressBar(
28 | modifier: Modifier = Modifier,
29 | progress: Float,
30 | color: Color = MaterialTheme.colorScheme.primary,
31 | cornerRadius: Dp = 4.dp,
32 | backgroundColor: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.1f),
33 | ) {
34 | val progressWidthAnimation = remember {
35 | Animatable(initialValue = 0f)
36 | }
37 |
38 | val realProgress = if (progress <= .5f) .5f else progress
39 |
40 | LaunchedEffect(realProgress){
41 | if (realProgress in 0f .. 100f){
42 | progressWidthAnimation.animateTo(
43 | targetValue = realProgress, animationSpec = tween(
44 | durationMillis = 750, easing = FastOutSlowInEasing
45 | )
46 | )
47 | }
48 | }
49 |
50 | Surface(
51 | shape = RoundedCornerShape(cornerRadius),
52 | color = backgroundColor,
53 | modifier = modifier
54 | .height(cornerRadius * 2)
55 | .clip(RoundedCornerShape(cornerRadius)) // 裁剪矩形区域为圆角矩形,将超出圆角矩形的部分绘制去掉
56 | .drawWithContent {
57 | drawContent() // 先绘制内容后绘制自定义图形,这样我们绘制的图形将显示在内容区域上方
58 | val progressWidth = drawContext.size.width * progressWidthAnimation.value / 100f
59 | drawRoundRect(
60 | color = color,
61 | size = drawContext.size.copy(width = progressWidth),
62 | cornerRadius = CornerRadius(cornerRadius.toPx())
63 | )
64 | },
65 | content = {}
66 | )
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/windows/main/FunctionPage.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.windows.main
2 |
3 | import androidx.compose.foundation.layout.fillMaxSize
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.material3.Card
7 | import androidx.compose.material3.Text
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.res.stringResource
11 | import androidx.compose.ui.unit.dp
12 | import io.github.lumyuan.turingbox.R
13 |
14 | @Composable
15 | fun FunctionPage() {
16 | Card(
17 | modifier = Modifier
18 | .fillMaxSize()
19 | .padding(16.dp)
20 | ) {
21 | Text(text = stringResource(id = R.string.page_function) + "占位函数", modifier = Modifier
22 | .padding(16.dp)
23 | .fillMaxWidth())
24 | }
25 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/windows/main/MinePage.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.windows.main
2 |
3 | import androidx.compose.foundation.layout.fillMaxSize
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.material3.Card
7 | import androidx.compose.material3.Text
8 | import androidx.compose.runtime.Composable
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.unit.dp
11 |
12 |
13 | @Composable
14 | fun MinePage() {
15 | Card(
16 | modifier = Modifier
17 | .fillMaxSize()
18 | .padding(16.dp)
19 | ) {
20 | Text(text = "开源地址:https://github.com/lumyuan/TuringBox", modifier = Modifier
21 | .padding(16.dp)
22 | .fillMaxWidth())
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/io/github/lumyuan/turingbox/windows/main/device/GpuCard.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox.windows.main.device
2 |
3 | import androidx.compose.animation.AnimatedVisibility
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.ColumnScope
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.foundation.layout.Spacer
9 | import androidx.compose.foundation.layout.fillMaxWidth
10 | import androidx.compose.foundation.layout.padding
11 | import androidx.compose.foundation.layout.size
12 | import androidx.compose.foundation.shape.RoundedCornerShape
13 | import androidx.compose.material3.Card
14 | import androidx.compose.material3.MaterialTheme
15 | import androidx.compose.material3.Text
16 | import androidx.compose.runtime.Composable
17 | import androidx.compose.runtime.MutableState
18 | import androidx.compose.ui.Modifier
19 | import androidx.compose.ui.res.stringResource
20 | import androidx.compose.ui.text.font.FontWeight
21 | import androidx.compose.ui.unit.dp
22 | import androidx.compose.ui.unit.sp
23 | import io.github.lumyuan.turingbox.R
24 | import io.github.lumyuan.turingbox.ui.widget.IndicatorComponent
25 | import io.github.lumyuan.turingbox.windows.main.GpuState
26 |
27 | @Composable
28 | fun GpuCard(gpuState: MutableState) {
29 | Card(
30 | modifier = Modifier
31 | .padding(start = 16.dp, end = 16.dp, top = 4.dp, bottom = 4.dp)
32 | .fillMaxWidth(),
33 | shape = RoundedCornerShape(12.dp)
34 | ) {
35 | Row(
36 | modifier = Modifier
37 | .padding(16.dp)
38 | .fillMaxWidth()
39 | ) {
40 | GpuProgress(gpuState)
41 | Spacer(modifier = Modifier.size(16.dp))
42 | Column(
43 | modifier = Modifier.fillMaxWidth(),
44 | verticalArrangement = Arrangement.Center
45 | ) {
46 | FreqText(gpuState)
47 | Spacer(modifier = Modifier.size(4.dp))
48 | UsedText(gpuState)
49 | Spacer(modifier = Modifier.size(4.dp))
50 | KernelText(gpuState)
51 | }
52 | }
53 | }
54 | }
55 |
56 | @Composable
57 | fun ColumnScope.KernelText(gpuState: MutableState) {
58 | val kernel = gpuState.value.kernel
59 | AnimatedVisibility(visible = kernel != null) {
60 | Text(
61 | text = kernel.toString(),
62 | style = MaterialTheme.typography.labelSmall.copy(
63 | fontSize = 8.sp,
64 | fontWeight = FontWeight.Light
65 | )
66 | )
67 | }
68 | }
69 |
70 | @Composable
71 | fun UsedText(gpuState: MutableState) {
72 | Text(
73 | text = String.format(
74 | stringResource(id = R.string.text_gpu_used),
75 | gpuState.value.used.toInt(),
76 | "%"
77 | ),
78 | style = MaterialTheme.typography.bodySmall
79 | )
80 | }
81 |
82 | @Composable
83 | fun ColumnScope.FreqText(gpuState: MutableState) {
84 | val freqText = gpuState.value.freq
85 | AnimatedVisibility(visible = freqText != null) {
86 | Text(text = freqText.toString(), style = MaterialTheme.typography.titleMedium)
87 | }
88 | }
89 |
90 | @Composable
91 | fun GpuProgress(gpuState: MutableState) {
92 | IndicatorComponent(
93 | componentSize = 100.dp,
94 | backgroundIndicatorStrokeWidth = 12.dp,
95 | foregroundSweepAngle = gpuState.value.used
96 | ) {
97 | Text(
98 | text = stringResource(id = R.string.text_gpu),
99 | style = MaterialTheme.typography.bodyMedium
100 | )
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_options_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/app_options_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_options_clear2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/app_options_clear2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_battery_power.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check_permission.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_clock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/ic_clock.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_danger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/ic_danger.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_edit_electric_current.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/ic_graph.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_monitor.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_function.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_power.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/ic_power.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/ic_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_temperature.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/ic_temperature.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/icon_android.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_battery_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/icon_battery_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_battery_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/icon_battery_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_battery_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/icon_battery_3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_battery_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/icon_battery_4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_global.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/icon_global.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_mine_fill.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/process.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/process.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/process_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/process_android.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/process_linux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/process_linux.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/turing_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/drawable/turing_box.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/raw/change_mac_1:
--------------------------------------------------------------------------------
1 |
2 | # mac="aa:bb:cc:dd;ee"
3 |
4 | if [[ ! "$mac" = "" ]];then
5 | svc wifi disable
6 | ifconfig wlan0 down
7 |
8 | ifconfig wlan0 hw ether "$mac"
9 |
10 | for wlan in `find /sys/devices -name 'wlan0'`; do
11 | if [[ -f "$wlan/address" ]]; then
12 | chmod 644 "$wlan/address"
13 | echo "$mac" > "$wlan/address"
14 | echo "$wlan/address"
15 | fi
16 | done
17 |
18 | chmod 0755 /sys/class/net/wlan0/address
19 | echo "$mac" > /sys/class/net/wlan0/address
20 |
21 | for wlan in `find /sys/devices -name '*,wcnss-wlan'`; do
22 | if [[ -f "$wlan/wcnss_mac_addr" ]]; then
23 | chmod 644 "$wlan/wcnss_mac_addr"
24 | echo "$mac" > "$wlan/wcnss_mac_addr"
25 | echo '"$wlan/wcnss_mac_addr"'
26 | fi
27 | done
28 |
29 | ifconfig wlan0 up
30 | svc wifi enable
31 | fi
--------------------------------------------------------------------------------
/app/src/main/res/raw/change_mac_2:
--------------------------------------------------------------------------------
1 | if [[ "$mac" != "" ]]; then
2 | i=1
3 | while [[ $(ifconfig | grep "$mac") == "" && $i -lt 5 ]]
4 | do
5 | echo $i
6 | ifconfig wlan0 down
7 | stop wifi
8 | ifconfig wlan0 hw ether "$mac"
9 | ifconfig wlan0 up
10 | start wifi
11 |
12 | i=$((i+1))
13 | sleep 2
14 | done
15 | fi
16 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/memcg_set:
--------------------------------------------------------------------------------
1 | cgroup_app="$1"
2 | cgroup_mem="$2"
3 |
4 | if [[ -d /sys/fs/cgroup ]]; then
5 | scene_memcg="/sys/fs/cgroup/memory"
6 | elif [[ -d /dev/memcg ]]; then
7 | scene_memcg="/dev/memcg"
8 | fi
9 |
10 | if [[ "$scene_memcg" != "" ]]; then
11 | pgrep -f $cgroup_app | while read pid; do
12 | echo $pid > $scene_memcg$cgroup_mem/cgroup.procs
13 | #ls /proc/$pid/task | while read tid; do
14 | # echo $tid > $scene_memcg$cgroup_mem/tasks
15 | #done
16 | if [[ "$cgroup_mem" == "/scene_cache" ]]; then
17 | echo 1 > $scene_memcg$cgroup_mem/memory.force_empty
18 | fi
19 | done
20 | fi
21 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/memcg_set_auto:
--------------------------------------------------------------------------------
1 | if [[ -d /sys/fs/cgroup ]]; then
2 | scene_memcg="/sys/fs/cgroup/memory"
3 | elif [[ -d /dev/memcg ]]; then
4 | scene_memcg="/dev/memcg"
5 | fi
6 |
7 | # if [[ -f $scene_memcg/scene_bg/cgroup.procs ]]; then
8 | if [[ -f $scene_memcg/scene_lock/cgroup.procs ]]; then
9 | cat /dev/cpuset/background/cgroup.procs | while read line ; do
10 | if [[ -f /proc/$line/oom_adj ]]; then
11 | oom_adj=`cat /proc/$line/oom_adj`
12 | memory_group=`grep 'memory:' /proc/$line/cgroup | cut -f2 -d '/'`
13 | if [[ "$memory_group" == "" ]] && [[ $oom_adj -gt 10 ]]; then
14 | # echo $line > $scene_memcg/scene_bg/cgroup.procs
15 | echo $line > $scene_memcg/scene_lock/cgroup.procs
16 | fi
17 | fi
18 | done
19 | else
20 | cat /dev/cpuset/background/cgroup.procs | while read line ; do
21 | if [[ -f /proc/$line/oom_adj ]]; then
22 | oom_adj=`cat /proc/$line/oom_adj`
23 | memory_group=`grep 'memory:' /proc/$line/cgroup | cut -f2 -d '/'`
24 | if [[ "$memory_group" == "" ]] && [[ $oom_adj -gt 10 ]]; then
25 | echo all > /proc/$line/reclaim 2>/dev/null
26 | fi
27 | fi
28 | done
29 | fi
30 |
31 | # cat /dev/cpuset/background/cgroup.procs | while read line ; do
32 | # echo all > /proc/$line/reclaim 2>/dev/null 2> /dev/null
33 | # done
--------------------------------------------------------------------------------
/app/src/main/res/raw/memcg_set_init:
--------------------------------------------------------------------------------
1 | if [[ -d /sys/fs/cgroup ]]; then
2 | scene_memcg="/sys/fs/cgroup/memory"
3 | elif [[ -d /dev/memcg ]]; then
4 | scene_memcg="/dev/memcg"
5 | fi
6 |
7 | init_group() {
8 | local g=$scene_memcg/$1
9 | if [[ ! -d $g ]]; then
10 | mkdir -p $g
11 | fi
12 | echo $2 > $g/memory.swappiness
13 | echo 1 > $g/memory.oom_control
14 | echo 1 > $g/memory.use_hierarchy
15 | }
16 |
17 | if [[ "$scene_memcg" != "" ]]; then
18 | init_group scene_perf 10
19 | init_group scene_fg 0
20 | init_group scene_lock 100
21 | init_group scene_bg 100
22 | init_group scene_cache 100
23 |
24 | MemTotalStr=`cat /proc/meminfo | grep MemTotal`
25 | MemTotalKB=${MemTotalStr:16:8}
26 | #echo $((MemTotalKB/1024/30))M
27 |
28 | echo $((MemTotalKB/1024/4))M > $scene_memcg/scene_lock/memory.soft_limit_in_bytes
29 | echo $((MemTotalKB/1024/10))M > $scene_memcg/scene_bg/memory.soft_limit_in_bytes
30 | echo $((MemTotalKB/1024/30))M > $scene_memcg/scene_cache/memory.soft_limit_in_bytes
31 |
32 | # echo 8192M > $scene_memcg/scene_bg/memory.memsw.limit_in_bytes
33 | # echo 512M > $scene_memcg/scene_bg/memory.limit_in_bytes
34 | # echo 512M > $scene_memcg/scene_bg/memory.kmem.limit_in_bytes
35 |
36 | if [[ -f $scene_memcg/sys_critical/memory.swappiness ]]; then
37 | echo 0 > $scene_memcg/sys_critical/memory.swappiness
38 | fi
39 | if [[ -f $scene_memcg/system/memory.swappiness ]]; then
40 | echo 0 > $scene_memcg/system/memory.swappiness
41 | fi
42 | find $scene_memcg -name memory.move_charge_at_immigrate | while read row; do
43 | echo 1 > $row
44 | done
45 |
46 | fi
47 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/module_system_prop:
--------------------------------------------------------------------------------
1 | # This file will be read by resetprop
2 | # 示例: 更改 dpi
3 | # ro.sf.lcd_density=410
4 | # vendor.display.lcd_density=410
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/io/github/lumyuan/turingbox/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package io.github.lumyuan.turingbox
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | //@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
3 | plugins {
4 | alias(libs.plugins.androidApplication) apply false
5 | alias(libs.plugins.kotlinAndroid) apply false
6 | alias(libs.plugins.androidLibrary) apply false
7 | }
8 | true // Needed to make the Suppress annotation work for the plugins block
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## For more details on how to configure your build environment visit
2 | # http://www.gradle.org/docs/current/userguide/build_environment.html
3 | #
4 | # Specifies the JVM arguments used for the daemon process.
5 | # The setting is particularly useful for tweaking memory settings.
6 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
7 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8 | #
9 | # When configured, Gradle will run in incubating parallel mode.
10 | # This option should only be used with decoupled projects. More details, visit
11 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12 | # org.gradle.parallel=true
13 | #Thu Jun 01 14:49:31 CST 2023
14 | android.nonTransitiveRClass=true
15 | android.useAndroidX=true
16 | kotlin.code.style=official
17 | org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M" -Dfile.encoding\=UTF-8
18 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.2.0-alpha06"
3 | kotlin = "1.8.10"
4 | core-ktx = "1.9.0"
5 | junit = "4.13.2"
6 | androidx-test-ext-junit = "1.1.5"
7 | espresso-core = "3.5.1"
8 | lifecycle-runtime-ktx = "2.6.1"
9 | activity-compose = "1.7.0"
10 | compose-bom = "2023.03.00"
11 | immersionbar = "3.2.2"
12 | android-appcompat = "1.6.1"
13 | constraint = "1.0.1"
14 | androidxNavigation = "2.5.3"
15 | androidxComposeMaterial3 = "1.1.0-alpha06"
16 | material = "1.8.0"
17 | gsonVersion = "2.9.1"
18 |
19 | [libraries]
20 | core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
21 | junit = { group = "junit", name = "junit", version.ref = "junit" }
22 | androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
23 | espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
24 | lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
25 | activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
26 | androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" }
27 | androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" }
28 | compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
29 | ui = { group = "androidx.compose.ui", name = "ui" }
30 | ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
31 | ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
32 | ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
33 | ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
34 | ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
35 | androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" }
36 | androidx-compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class", version.ref = "androidxComposeMaterial3" }
37 | immersionbar-ui = { group = "com.geyifeng.immersionbar", name = "immersionbar", version.ref = "immersionbar" }
38 | immersionbar-ui-ktx = { group = "com.geyifeng.immersionbar", name = "immersionbar-ktx", version.ref = "immersionbar" }
39 | android-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "android-appcompat" }
40 | constraint-layout = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraint" }
41 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
42 | gson = { group = "com.google.code.gson" , name = "gson", version.ref = "gsonVersion" }
43 |
44 | [plugins]
45 | androidApplication = { id = "com.android.application", version.ref = "agp" }
46 | kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
47 | androidLibrary = { id = "com.android.library", version.ref = "agp" }
48 |
49 | [bundles]
50 |
51 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lumyuan/TuringBox/50c97f725c1a937d4b2fa30d6f7ee35b5977f5a9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue May 30 19:23:50 CST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | maven( url = "https://maven.aliyun.com/repository/public/")
4 | maven( url = "https://maven.aliyun.com/repository/google/")
5 |
6 | google()
7 | mavenCentral()
8 | maven("https://repo.eclipse.org/content/groups/releases/")
9 | maven("https://maven.aliyun.com/nexus/content/groups/public/")
10 |
11 | maven(url = "https://jitpack.io")
12 | gradlePluginPortal()
13 | }
14 | }
15 | dependencyResolutionManagement {
16 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
17 | repositories {
18 | maven( url = "https://maven.aliyun.com/repository/public/")
19 | maven( url = "https://maven.aliyun.com/repository/google/")
20 |
21 | google()
22 | mavenCentral()
23 | maven("https://repo.eclipse.org/content/groups/releases/")
24 | maven("https://maven.aliyun.com/nexus/content/groups/public/")
25 |
26 | maven(url = "https://jitpack.io")
27 | gradlePluginPortal()
28 | }
29 | }
30 |
31 | rootProject.name = "TuringBox"
32 | include(":app")
33 | include(":TuringBoxJNI")
34 |
--------------------------------------------------------------------------------