mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-13 20:01:17 +08:00
Compare commits
197 Commits
Download
...
13d54c3b11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13d54c3b11 | ||
|
|
9c9986ba80 | ||
|
|
3926179403 | ||
|
|
1719cc62f6 | ||
|
|
343dd9e683 | ||
|
|
c69354cb0d | ||
|
|
719b777ea7 | ||
|
|
dc74fd665d | ||
|
|
91c3b8311b | ||
|
|
a414e2a9c8 | ||
|
|
73325ee306 | ||
|
|
a9d43e9977 | ||
|
|
a0e0741924 | ||
|
|
a38d9c661c | ||
|
|
422189b16e | ||
|
|
12726a5831 | ||
|
|
999f9a088f | ||
|
|
49c293d30d | ||
|
|
87a8059a06 | ||
|
|
8e85c34db3 | ||
|
|
72ad0479df | ||
|
|
479251fb67 | ||
|
|
dec3bc0a42 | ||
|
|
32f2fc7215 | ||
|
|
4246e2910e | ||
|
|
3cd3b87707 | ||
|
|
693b707922 | ||
|
|
90466bb3fb | ||
|
|
cef006ced2 | ||
|
|
2a94e1da69 | ||
|
|
94beae5f45 | ||
|
|
a63fd5510a | ||
|
|
24b0fbbd48 | ||
|
|
d38b79aec2 | ||
|
|
8f1453f420 | ||
|
|
b1373d7141 | ||
|
|
7e922f3ec6 | ||
|
|
8d45df61e3 | ||
|
|
57895c7f2c | ||
|
|
1af01b391b | ||
|
|
6108f9c4ba | ||
|
|
d709dd87e9 | ||
|
|
c0ae491954 | ||
|
|
a9c8528671 | ||
|
|
2761c288f8 | ||
|
|
a9cf0bcca0 | ||
|
|
9f92186e5f | ||
|
|
5197f11ecb | ||
|
|
396e9bf453 | ||
|
|
8e6485cd0f | ||
|
|
afb3316595 | ||
|
|
432ec13c05 | ||
|
|
f2f133c5b9 | ||
|
|
320a393a7c | ||
|
|
117c18b45e | ||
|
|
1ad1b75eff | ||
|
|
201d9550d2 | ||
|
|
1f0f2d31f2 | ||
|
|
0d34d3a4bb | ||
|
|
93f6eaf74d | ||
|
|
61b6dc448e | ||
|
|
cad773ec99 | ||
|
|
bfda4f0df3 | ||
|
|
e32718eedf | ||
|
|
b2e465ba3d | ||
|
|
919694fce7 | ||
|
|
f5ff3e78c4 | ||
|
|
3619fbf4d3 | ||
|
|
7acd0aaff8 | ||
|
|
785208c1ab | ||
|
|
d108f46a19 | ||
|
|
a44a29b7b7 | ||
|
|
29e9bb34ab | ||
|
|
1a15df5822 | ||
|
|
dad17170ff | ||
|
|
3aca588693 | ||
|
|
cd731f7a21 | ||
|
|
5e35cfb3e3 | ||
|
|
daa3c02d1a | ||
|
|
f83d439374 | ||
|
|
176682fa38 | ||
|
|
c02d9e1874 | ||
|
|
d8baadae59 | ||
|
|
d2035121ce | ||
|
|
b29bfb45f9 | ||
|
|
657c65164f | ||
|
|
5c3ca4caa4 | ||
|
|
08b4abf08c | ||
|
|
acdbd23248 | ||
|
|
2bed96532f | ||
|
|
314fc7b46f | ||
|
|
ff94fce5d0 | ||
|
|
d56d291e51 | ||
|
|
fc1800932b | ||
|
|
181869687e | ||
|
|
5ee5dd71b1 | ||
|
|
b6d8529624 | ||
|
|
243bc39dd6 | ||
|
|
4332ac6ed8 | ||
|
|
8309c9a69a | ||
|
|
62561d4c34 | ||
|
|
4c13ad4152 | ||
|
|
6f91cab9b8 | ||
|
|
ca2ffa4c3f | ||
|
|
f44f095c65 | ||
|
|
68c67d139b | ||
|
|
2b1eaf6634 | ||
|
|
c91a46cabb | ||
|
|
a7947d5a2f | ||
|
|
bb8150583c | ||
|
|
a4fe68c141 | ||
|
|
61f64ba7bb | ||
|
|
bfff5cc446 | ||
|
|
509fef5e06 | ||
|
|
f88ff6db15 | ||
|
|
2b352738f5 | ||
|
|
085b375dc6 | ||
|
|
7c13214e2d | ||
|
|
469f004baa | ||
|
|
eec755d642 | ||
|
|
14ca833ec1 | ||
|
|
8bcb89b04d | ||
|
|
f2df033393 | ||
|
|
ab41dea173 | ||
|
|
7d9f45b92f | ||
|
|
8c08466ed6 | ||
|
|
801ade5859 | ||
|
|
984b909197 | ||
|
|
0a6b114354 | ||
|
|
f6653aef78 | ||
|
|
1f7dbba6a8 | ||
|
|
87a2f04b65 | ||
|
|
25dba39daf | ||
|
|
7ad1bcb763 | ||
|
|
1aee169089 | ||
|
|
8eb42fdf38 | ||
|
|
fddf3ffb76 | ||
|
|
6e4e8ed97b | ||
|
|
e5e64821a8 | ||
|
|
8ab8330c94 | ||
|
|
7c8f061c30 | ||
|
|
406b1a740b | ||
|
|
54e3b0ab29 | ||
|
|
5fcb39bb58 | ||
|
|
bc9469a9b6 | ||
|
|
61b24111f1 | ||
|
|
a87bf7318b | ||
|
|
9bd6aee5e9 | ||
|
|
dfa47653f0 | ||
|
|
92b345af77 | ||
|
|
dfd1c660f5 | ||
|
|
d431798808 | ||
|
|
ff95c6d782 | ||
|
|
2f23263333 | ||
|
|
788e46cb39 | ||
|
|
fcfd29a86b | ||
|
|
3d4720fc42 | ||
|
|
2f26cedb2b | ||
|
|
6f30dcdac5 | ||
|
|
8488332cec | ||
|
|
157e087c99 | ||
|
|
ffdf296357 | ||
|
|
987f33b584 | ||
|
|
7cc2819307 | ||
|
|
a6df8ff014 | ||
|
|
8c13c702e9 | ||
|
|
fcf57c3796 | ||
|
|
830397a590 | ||
|
|
3fd32b4ec8 | ||
|
|
7a5c39620b | ||
|
|
05493d35d4 | ||
|
|
2f1930f704 | ||
|
|
1e6eb58dab | ||
|
|
11908a7381 | ||
|
|
117acc99f7 | ||
|
|
e3909c5996 | ||
|
|
da80efc8ba | ||
|
|
fabbd19929 | ||
|
|
e608c504fe | ||
|
|
b483ce52c8 | ||
|
|
2421b5d285 | ||
|
|
63e360cc62 | ||
|
|
d4d6605c7b | ||
|
|
dc7e45e4ad | ||
|
|
df72a5f363 | ||
|
|
cd0aaef385 | ||
|
|
b71fa8a15e | ||
|
|
323cb2bffa | ||
|
|
029ad43508 | ||
|
|
8c6deb16cf | ||
|
|
93bdeaba0b | ||
|
|
d2ff9d61e7 | ||
|
|
780db8dfa5 | ||
|
|
dcc26b0e43 | ||
|
|
eaaa802054 | ||
|
|
99f47443eb | ||
|
|
0433cbe5ab |
23
.github/workflows/android.yml
vendored
23
.github/workflows/android.yml
vendored
@@ -13,10 +13,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: set up JDK 11
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '11'
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
- uses: actions/cache@v2
|
||||
@@ -32,24 +34,9 @@ jobs:
|
||||
path: |
|
||||
~/.gradle/caches/build-cache-*
|
||||
key: gradle-builds-${{ github.sha }}
|
||||
|
||||
- name: Init Submodule
|
||||
run: |
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
- name: Build with Gradle
|
||||
run: bash ./gradlew assemble
|
||||
|
||||
- name: Upload Release APK
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: SimplicityTools_Release
|
||||
path: "app/build/outputs/apk/release/*.apk"
|
||||
|
||||
- name: Upload Debug APK
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Simplicity Tools_Debug
|
||||
path: "app/build/outputs/apk/debug/*.apk"
|
||||
|
||||
run: bash ./gradlew :app:packageDebug
|
||||
|
||||
98
README.md
98
README.md
@@ -1,6 +1,6 @@
|
||||
<div align="center">
|
||||
<img width="160" src="https://raw.githubusercontent.com/LittleTurtle2333/SimplicityTools/main/doc/ic_launcher.png" alt="logo">
|
||||
<h1>Simplicity Tools</h1>
|
||||
<h1>WooBox For MIUI</h1>
|
||||
<p>
|
||||
<b><a href="https://github.com/LittleTurtle2333/SimplicityTools/blob/main/README_EN.md">English</a> 丨 简体中文</b>
|
||||
</p>
|
||||
@@ -15,100 +15,12 @@
|
||||
|
||||
### 模块说明
|
||||
|
||||
仅支持MIUI13(Android12)。其余版本可能无效,请不要安装使用。
|
||||
目前处于开发初期阶段,功能较少,后续将逐步完善。
|
||||
仅支持MIUI13(Android12),其余版本无法使用。
|
||||
|
||||
开发者:[酷安@乌堆小透明](http://www.coolapk.com/u/883441)
|
||||
|
||||
---
|
||||
|
||||
### 已实现功能
|
||||
<details>
|
||||
<summary>点击展开详情</summary>
|
||||
|
||||
- 状态栏
|
||||
- 状态栏网速秒刷新
|
||||
- 隐藏状态栏电量(%)
|
||||
- 隐藏状态栏网速(/s)单位
|
||||
- 解除通知图标个数上限
|
||||
- 状态栏布局
|
||||
- 时间居中
|
||||
- 兼容模式
|
||||
- 左边距自定义
|
||||
- 右边距自定义
|
||||
- 状态栏时钟格式
|
||||
- 显示年份开关
|
||||
- 显示月份开关
|
||||
- 显示日期开关
|
||||
- 显示星期开关
|
||||
- 显示时辰开关
|
||||
- 显示时段开关
|
||||
- 显示秒数开关
|
||||
- 隐藏间隔开关
|
||||
- 双行显示开关
|
||||
- 时钟大小自定义
|
||||
- 双排时钟大小自定义
|
||||
- 状态栏图标
|
||||
- 隐藏电池图标开关
|
||||
- 隐藏充电图标开关
|
||||
- 隐藏GPS图标开关
|
||||
- 隐藏蓝牙图标开关
|
||||
- 隐藏蓝牙电量图标开关
|
||||
- 隐藏小HD图标开关
|
||||
- 隐藏大HD图标开关
|
||||
- 隐藏HD无服务开关
|
||||
- 隐藏SIM卡一图标开关
|
||||
- 隐藏SIM卡二图标开关
|
||||
- 隐藏无SIM卡图标开关
|
||||
- 隐藏移动类型图标开关
|
||||
- 隐藏移动箭头图标开关
|
||||
- 隐藏WIFI图标开关
|
||||
- 隐藏WIFI箭头开关
|
||||
- 隐藏WIFI标准开关
|
||||
- 隐藏WiFi辅助图标开关
|
||||
- 隐藏WIFI热点图标开关
|
||||
- 隐藏VPN图标开关
|
||||
- 隐藏飞行模式图标开关
|
||||
- 隐藏闹钟图标开关
|
||||
- 隐藏耳机图标开关
|
||||
- 隐藏声音、勿扰图标开关
|
||||
- 隐藏网速分隔符
|
||||
- 通知面板
|
||||
- 显示天气开关
|
||||
- 显示天气地区开关
|
||||
- 控制中心
|
||||
- 显示天气开关
|
||||
- 显示天气地区开关
|
||||
- 锁屏
|
||||
- 移除锁屏侧边功能
|
||||
- 移除锁屏相机功能
|
||||
- 桌面
|
||||
- 始终显示桌面时钟
|
||||
- 系统框架
|
||||
- 移除上层显示通知
|
||||
- 允许截图(支持磁贴)
|
||||
- 解除安装限制(支持降级、不同签名、无签名安装)
|
||||
- 解除不支持小窗应用限制
|
||||
- 性能
|
||||
- 锁定当前刷新率上限(支持磁贴)
|
||||
- 防止恢复电池优化白名单
|
||||
- 手机管家
|
||||
- 跳过5/10秒警告时间
|
||||
- 锁定 100 分
|
||||
- 去除游戏自动连招黑名单
|
||||
- 相册编辑
|
||||
- 解锁无限裁切图片/截图功能
|
||||
- 系统更新
|
||||
- 移除OTA验证
|
||||
- 设置
|
||||
- 显示通知重要程度
|
||||
- 去广告
|
||||
- 移除主题壁纸广告
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
### 模块截图
|
||||

|
||||
|
||||
@@ -128,10 +40,16 @@ Xposed仓库下载:[点击此处下载最新发行版](https://github.com/Xpos
|
||||
---
|
||||
|
||||
### 第三方开源引用
|
||||
##### GNU General Public License v3.0
|
||||
[qqlittleice/MiuiHome](https://github.com/qqlittleice/MiuiHome)
|
||||
[yujincheng08/BiliRoaming](https://github.com/yujincheng08/BiliRoaming)
|
||||
[Mikanoshi/CustoMIUIzer](https://code.highspec.ru/Mikanoshi/CustoMIUIzer)
|
||||
##### GNU General Public License v2.0
|
||||
[LSPosed/CorePatch](https://github.com/LSPosed/CorePatch)
|
||||
##### GNU Lesser General Public License v2.1
|
||||
[577fkj/blockmiui](https://github.com/577fkj/blockmiui)
|
||||
##### Apache License 2.0
|
||||
[KyuubiRan/EzXHelper](https://github.com/KyuubiRan/EzXHelper)
|
||||
|
||||
---
|
||||
|
||||
|
||||
100
README_EN.md
100
README_EN.md
@@ -1,6 +1,6 @@
|
||||
<div align="center">
|
||||
<img width="160" src="https://raw.githubusercontent.com/LittleTurtle2333/SimplicityTools/main/doc/ic_launcher.png" alt="logo">
|
||||
<h1>Simplicity Tools</h1>
|
||||
<h1>WooBox For MIUI</h1>
|
||||
<p>
|
||||
<b>English 丨 <a href="https://github.com/LittleTurtle2333/SimplicityTools/blob/main/README.md">简体中文</a></b>
|
||||
</p>
|
||||
@@ -15,95 +15,7 @@
|
||||
|
||||
### Description
|
||||
|
||||
Only MIUI13 (Android12) is supported. The rest of the versions may not be valid, please do not install and use.
|
||||
It is in the early stage of development, with fewer functions, and will be improved gradually.
|
||||
|
||||
---
|
||||
|
||||
### Features
|
||||
<details>
|
||||
<summary>Click to expand details</summary>
|
||||
|
||||
- Status Bar
|
||||
- Status bar web speed second refresh
|
||||
- Hide status bar power (%)
|
||||
- Hide status bar speed (/) unit
|
||||
- Unlock the maximum number of notification icons
|
||||
- Status bar layout
|
||||
- Time centered
|
||||
- Compatible mode
|
||||
- Left margin customization
|
||||
- Right margin customization
|
||||
- Status bar clock format
|
||||
- Show year switch
|
||||
- Show month switch
|
||||
- Show date switch
|
||||
- Show day switch
|
||||
- Show chinese twelve hour switch
|
||||
- Display AM/PM switch
|
||||
- Display seconds switch
|
||||
- Hide space switch
|
||||
- Double line display switch
|
||||
- Clock size customization
|
||||
- Double row clock size customization
|
||||
- Status bar icons
|
||||
- Hide battery icon switch
|
||||
- Hide charging icon switch
|
||||
- Hide GPS icon switch
|
||||
- Hide Bluetooth icon switch
|
||||
- Hide Bluetooth power icon switch
|
||||
- Hide small HD icon switch
|
||||
- Hide large HD icon switch
|
||||
- Hide HD no service switch
|
||||
- Hide SIM card one icon switch
|
||||
- Hide SIM card two icon switch
|
||||
- Hide SIM-less icon switch
|
||||
- Hide mobile type icon switch
|
||||
- Hide mobile arrow icon switch
|
||||
- Hide WIFI icon switch
|
||||
- Hide WIFI arrow switch
|
||||
- Hide WIFI standard switch
|
||||
- Hide WiFi auxiliary icon switch
|
||||
- Hide WIFI hotspot icon switch
|
||||
- Hide VPN icon switch
|
||||
- Hide Airplane Mode icon switch
|
||||
- Hide alarm clock icon switch
|
||||
- Hide headset icon switch
|
||||
- Hide sound, do not disturb icon switch
|
||||
- Hide internet speed separator
|
||||
- Notification panel
|
||||
- Show weather switch
|
||||
- Show weather area switch
|
||||
- Control Center
|
||||
- Show weather switch
|
||||
- Show weather area switch
|
||||
- Lock Screen
|
||||
- Remove lock screen side function
|
||||
- Remove lock screen camera function
|
||||
- Home
|
||||
- Always show desktop clock
|
||||
- System Framework
|
||||
- Remove upper display notifications
|
||||
- Allow screenshots (tile support)
|
||||
- CorePatch (support downgrade, different signature, unsigned installation)
|
||||
- Unlock unsupported small windows applications
|
||||
- Nature
|
||||
- Lock current refresh rate cap (tile support)
|
||||
- Prevent recovery of battery optimization whitelist
|
||||
- Phone Manager
|
||||
- Skip 5/10 seconds warning time
|
||||
- Lock 100 points
|
||||
- Remove game macro blacklist
|
||||
- Album editing
|
||||
- Unlock unlimited crop image/screenshot function
|
||||
- System Update
|
||||
- Remove OTA authentication
|
||||
- Settings
|
||||
- Show notification importance
|
||||
- Remove Ads
|
||||
- Remove theme manager ads
|
||||
|
||||
</details>
|
||||
Only MIUI13 (Android12) is supported. The rest of the versions not be valid.
|
||||
|
||||
---
|
||||
|
||||
@@ -119,16 +31,22 @@ Xposed Repo:[Click here to download the latest release](https://github.com/Xpo
|
||||
|
||||
---
|
||||
|
||||
### 改进翻译
|
||||
### Participate in translation
|
||||
[](https://crowdin.com/project/simplicitytools)[Click here to Crowdin](https://crowdin.com/project/simplicitytools)
|
||||
|
||||
---
|
||||
|
||||
## Third party open source references
|
||||
##### GNU General Public License v3.0
|
||||
[qqlittleice/MiuiHome](https://github.com/qqlittleice/MiuiHome)
|
||||
[yujincheng08/BiliRoaming](https://github.com/yujincheng08/BiliRoaming)
|
||||
[Mikanoshi/CustoMIUIzer](https://code.highspec.ru/Mikanoshi/CustoMIUIzer)
|
||||
##### GNU General Public License v2.0
|
||||
[LSPosed/CorePatch](https://github.com/LSPosed/CorePatch)
|
||||
##### GNU Lesser General Public License v2.1
|
||||
[577fkj/blockmiui](https://github.com/577fkj/blockmiui)
|
||||
##### Apache License 2.0
|
||||
[KyuubiRan/EzXHelper](https://github.com/KyuubiRan/EzXHelper)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -6,22 +6,21 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 32
|
||||
buildToolsVersion = "32.0.0"
|
||||
compileSdk = 33
|
||||
buildToolsVersion = "33.0.0"
|
||||
defaultConfig {
|
||||
applicationId = "com.lt2333.simplicitytools"
|
||||
minSdk = 31
|
||||
targetSdk = 32
|
||||
versionCode = 42
|
||||
versionName = "1.4.1"
|
||||
targetSdk = 33
|
||||
versionCode = 67
|
||||
versionName = "1.6.6"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
setProguardFiles(listOf("proguard-rules.pro")
|
||||
)
|
||||
setProguardFiles(listOf("proguard-rules.pro"))
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
@@ -44,23 +43,21 @@ android {
|
||||
}
|
||||
applicationVariants.all {
|
||||
outputs.all {
|
||||
(this as BaseVariantOutputImpl).outputFileName =
|
||||
"Simplicity_Tools_Xposed-$versionName-$name.apk"
|
||||
(this as BaseVariantOutputImpl).outputFileName = "WooBoxForMIUI-$versionName-$name.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
|
||||
//API
|
||||
compileOnly("de.robv.android.xposed:api:82")
|
||||
implementation("com.github.kyuubiran:EzXHelper:0.9.2")
|
||||
//UI
|
||||
implementation(project(":blockmiui"))
|
||||
|
||||
val appCenterSdkVersion = "4.3.1"
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
|
||||
//APP Center
|
||||
val appCenterSdkVersion = "4.4.3"
|
||||
implementation("com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}")
|
||||
implementation("com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}")
|
||||
|
||||
implementation("com.github.kyuubiran:EzXHelper:0.7.4")
|
||||
|
||||
implementation("androidx.core:core-splashscreen:1.0.0-rc01")
|
||||
}
|
||||
6
app/proguard-rules.pro
vendored
6
app/proguard-rules.pro
vendored
@@ -23,6 +23,12 @@
|
||||
public void *(de.robv.android.xposed.callbacks.XC_LoadPackage$LoadPackageParam);
|
||||
}
|
||||
|
||||
-keep class * implements de.robv.android.xposed.IXposedHookZygoteInit {
|
||||
public void *(de.robv.android.xposed.IXposedHookZygoteInit$StartupParam);
|
||||
}
|
||||
|
||||
-keep class * extends com.lt2333.simplicitytools.util.xposed.EasyXposedInit
|
||||
|
||||
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||
public static void check*(...);
|
||||
public static void throw*(...);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
</activity>
|
||||
|
||||
<activity-alias
|
||||
android:label="WooBox"
|
||||
android:name=".launcher"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
|
||||
@@ -1 +1 @@
|
||||
com.lt2333.simplicitytools.hook.MainHook
|
||||
com.lt2333.simplicitytools.hook.XposedEntry
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 45 KiB |
File diff suppressed because it is too large
Load Diff
@@ -1,38 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
|
||||
import com.lt2333.simplicitytools.BuildConfig
|
||||
import com.lt2333.simplicitytools.hook.app.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XSharedPreferences
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
|
||||
class MainHook : IXposedHookLoadPackage {
|
||||
private var prefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "config")
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
if (prefs.getBoolean("main_switch", true)) {
|
||||
EzXHelperInit.initHandleLoadPackage(lpparam)
|
||||
EzXHelperInit.setEzClassLoader(lpparam.classLoader)
|
||||
when (lpparam.packageName) {
|
||||
//Android
|
||||
"android" -> Android().handleLoadPackage(lpparam)
|
||||
//系统界面
|
||||
"com.android.systemui" -> SystemUI().handleLoadPackage(lpparam)
|
||||
//电量与性能
|
||||
"com.miui.powerkeeper" -> PowerKeeper().handleLoadPackage(lpparam)
|
||||
//桌面
|
||||
"com.miui.home" -> MiuiHome().handleLoadPackage(lpparam)
|
||||
//手机管家
|
||||
"com.miui.securitycenter" -> SecurityCenter().handleLoadPackage(lpparam)
|
||||
//相册编辑
|
||||
"com.miui.mediaeditor" -> MediaEditor().handleLoadPackage(lpparam)
|
||||
//系统更新
|
||||
"com.android.updater" -> Updater().handleLoadPackage(lpparam)
|
||||
//设置
|
||||
"com.android.settings" -> Settings().handleLoadPackage(lpparam)
|
||||
//主题壁纸
|
||||
"com.android.thememanager" -> ThemeManager().handleLoadPackage(lpparam)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.lt2333.simplicitytools.hook
|
||||
|
||||
import com.lt2333.simplicitytools.BuildConfig
|
||||
import com.lt2333.simplicitytools.hook.app.*
|
||||
import com.lt2333.simplicitytools.hook.app.android.corepatch.CorePatch
|
||||
import com.lt2333.simplicitytools.util.xposed.EasyXposedInit
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.IXposedHookZygoteInit
|
||||
import de.robv.android.xposed.XSharedPreferences
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class XposedEntry : EasyXposedInit() {
|
||||
private var prefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "config")
|
||||
|
||||
override val registeredApp: List<AppRegister> = listOf(
|
||||
Android, // Android
|
||||
SystemUI, // 系统界面
|
||||
PowerKeeper, // 电量与性能
|
||||
MiuiHome, // 桌面
|
||||
SecurityCenter, // 手机管家
|
||||
MediaEditor, // 相册编辑
|
||||
Updater, // 系统更新
|
||||
Settings, // 设置
|
||||
ThemeManager, // 主题壁纸
|
||||
ScreenShot, // 截屏
|
||||
Cast, //投屏
|
||||
RearDisplay, //背屏
|
||||
)
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||
if (prefs.getBoolean("main_switch", true)) {
|
||||
super.handleLoadPackage(lpparam)
|
||||
}
|
||||
}
|
||||
|
||||
override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam?) {
|
||||
super.initZygote(startupParam)
|
||||
CorePatch().initZygote(startupParam)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.android.DeleteOnPostNotification
|
||||
import com.lt2333.simplicitytools.hook.app.android.DisableFlagSecure
|
||||
import com.lt2333.simplicitytools.hook.app.android.MaxWallpaperScale
|
||||
import com.lt2333.simplicitytools.hook.app.android.RemoveSmallWindowRestrictions
|
||||
import com.lt2333.simplicitytools.hook.app.android.*
|
||||
import com.lt2333.simplicitytools.hook.app.android.corepatch.CorePatch
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class Android : IXposedHookLoadPackage {
|
||||
object Android : AppRegister() {
|
||||
override val packageName: String = "android"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//核心破解
|
||||
CorePatch().handleLoadPackage(lpparam)
|
||||
//允许截图
|
||||
DisableFlagSecure().handleLoadPackage(lpparam)
|
||||
//上层显示
|
||||
DeleteOnPostNotification().handleLoadPackage(lpparam)
|
||||
//解除小窗限制
|
||||
RemoveSmallWindowRestrictions().handleLoadPackage(lpparam)
|
||||
//壁纸缩放比例
|
||||
MaxWallpaperScale().handleLoadPackage(lpparam)
|
||||
|
||||
autoInitHooks(
|
||||
lpparam,
|
||||
DisableFlagSecure, //允许截图
|
||||
DeleteOnPostNotification, //上层显示
|
||||
RemoveSmallWindowRestrictions, //解除小窗限制
|
||||
MaxWallpaperScale, //壁纸缩放比例
|
||||
SystemPropertiesHook, //SystemPropertiesHook
|
||||
AllowUntrustedTouches, //允许不受信任的触摸
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.cast.ForceSupportSendApp
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
object Cast: AppRegister() {
|
||||
override val packageName: String = "com.milink.service"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
ForceSupportSendApp, //强制允许所有应用接力
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.mediaeditor.UnlockUnlimitedCropping
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class MediaEditor : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//解锁裁切最小值
|
||||
UnlockUnlimitedCropping().handleLoadPackage(lpparam)
|
||||
object MediaEditor: AppRegister() {
|
||||
override val packageName: String = "com.miui.mediaeditor"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
UnlockUnlimitedCropping, //解锁裁切最小值
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.miuihome.AlwaysDisplayTime
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import com.lt2333.simplicitytools.hook.app.miuihome.DoubleTapToSleep
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class MiuiHome : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//时钟显示时钟
|
||||
AlwaysDisplayTime().handleLoadPackage(lpparam)
|
||||
object MiuiHome: AppRegister() {
|
||||
override val packageName: String = "com.miui.home"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
AlwaysDisplayTime, //时钟显示时钟
|
||||
DoubleTapToSleep, //双击锁屏
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,16 @@ package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.powerkeeper.LockMaxFps
|
||||
import com.lt2333.simplicitytools.hook.app.powerkeeper.PreventRecoveryOfBatteryOptimizationWhitelist
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class PowerKeeper : IXposedHookLoadPackage {
|
||||
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//锁定最高刷新率
|
||||
LockMaxFps().handleLoadPackage(lpparam)
|
||||
//防止恢复电池优化白名单
|
||||
PreventRecoveryOfBatteryOptimizationWhitelist().handleLoadPackage(lpparam)
|
||||
object PowerKeeper: AppRegister() {
|
||||
override val packageName: String = "com.miui.powerkeeper"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
LockMaxFps, //锁定最高刷新率
|
||||
PreventRecoveryOfBatteryOptimizationWhitelist, //防止恢复电池优化白名单
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.reardisplay.RearDisplayWeather
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
object RearDisplay: AppRegister() {
|
||||
override val packageName: String = "com.xiaomi.misubscreenui"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
RearDisplayWeather, //背屏显示天气
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.screenshot.UnlockUnlimitedCropping
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
object ScreenShot: AppRegister() {
|
||||
override val packageName: String = "com.miui.screenshot"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
UnlockUnlimitedCropping, //锁定最高刷新率
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,19 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.LockOneHundred
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.RemoveMacroBlacklist
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.ShowBatteryTemperature
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.SkipWaitingTime
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.*
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class SecurityCenter : IXposedHookLoadPackage {
|
||||
object SecurityCenter: AppRegister() {
|
||||
override val packageName: String = "com.miui.securitycenter"
|
||||
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//跳过 5/10秒等待时间
|
||||
SkipWaitingTime().handleLoadPackage(lpparam)
|
||||
//锁定 100分
|
||||
LockOneHundred().handleLoadPackage(lpparam)
|
||||
//去除自动连招黑名单
|
||||
RemoveMacroBlacklist().handleLoadPackage(lpparam)
|
||||
//显示电池温度
|
||||
ShowBatteryTemperature().handleLoadPackage(lpparam)
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
SkipWaitingTime, //跳过 5/10秒等待时间
|
||||
LockOneHundred, //锁定 100分
|
||||
RemoveMacroBlacklist, //去除自动连招黑名单
|
||||
ShowBatteryTemperature, //显示电池温度
|
||||
RemoveOpenAppConfirmationPopup, //去除打开应用弹窗
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.settings.ShowNotificationImportance
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class Settings: IXposedHookLoadPackage {
|
||||
object Settings: AppRegister() {
|
||||
override val packageName: String = "com.android.settings"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
ShowNotificationImportance().handleLoadPackage(lpparam)
|
||||
autoInitHooks(lpparam,
|
||||
ShowNotificationImportance, //显示通知重要程度
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,75 +1,45 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.systemui.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class SystemUI : IXposedHookLoadPackage {
|
||||
object SystemUI: AppRegister() {
|
||||
override val packageName: String = "com.android.systemui"
|
||||
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//隐藏飞行模式图标
|
||||
HideAirplaneIcon().handleLoadPackage(lpparam)
|
||||
//隐藏闹钟图标
|
||||
HideAlarmIcon().handleLoadPackage(lpparam)
|
||||
//隐藏电池
|
||||
HideBatteryIcon().handleLoadPackage(lpparam)
|
||||
//隐藏蓝牙电量
|
||||
HideBluetoothHandsfreeBatteryIcon().handleLoadPackage(lpparam)
|
||||
//隐藏蓝牙图标
|
||||
HideBluetoothIcon().handleLoadPackage(lpparam)
|
||||
//隐藏GPS图标
|
||||
HideGPSIcon().handleLoadPackage(lpparam)
|
||||
//隐藏HD图标
|
||||
HideHDIcon().handleLoadPackage(lpparam)
|
||||
//隐藏耳机图标
|
||||
HideHeadsetIcon().handleLoadPackage(lpparam)
|
||||
//隐藏热点图标
|
||||
HideHotspotIcon().handleLoadPackage(lpparam)
|
||||
//隐藏无SIM卡图标
|
||||
HideNoSimIcon().handleLoadPackage(lpparam)
|
||||
//隐藏SIM卡图标
|
||||
HideSimIcon().handleLoadPackage(lpparam)
|
||||
//隐藏移动箭头图标
|
||||
HideMobileActivityIcon().handleLoadPackage(lpparam)
|
||||
//隐藏移动类型图标
|
||||
HideMobileTypeIcon().handleLoadPackage(lpparam)
|
||||
//隐藏辅助WIFI图标
|
||||
HideSlaveWifiIcon().handleLoadPackage(lpparam)
|
||||
//隐藏状态栏网速/s
|
||||
HideStatusBarNetworkSpeedSecond().handleLoadPackage(lpparam)
|
||||
//隐藏音量勿扰图标
|
||||
HideVolumeZenIcon().handleLoadPackage(lpparam)
|
||||
//隐藏VPN图标
|
||||
HideVpnIcon().handleLoadPackage(lpparam)
|
||||
//隐藏WIFI图标
|
||||
HideWifiIcon().handleLoadPackage(lpparam)
|
||||
//隐藏WIFI活动箭头图标
|
||||
HideWifiActivityIcon().handleLoadPackage(lpparam)
|
||||
//移除通知图标上限
|
||||
RemoveTheMaximumNumberOfNotificationIcons().handleLoadPackage(lpparam)
|
||||
//状态栏网速秒刷新
|
||||
StatusBarNetworkSpeedRefreshSpeed().handleLoadPackage(lpparam)
|
||||
//状态栏时钟自定义
|
||||
StatusBarTimeCustomization().handleLoadPackage(lpparam)
|
||||
//移除锁屏负一屏功能
|
||||
RemoveTheLeftSideOfTheLockScreen().handleLoadPackage(lpparam)
|
||||
//移除锁屏相机功能
|
||||
RemoveLockScreenCamera().handleLoadPackage(lpparam)
|
||||
//通知面板天气
|
||||
NotificationWeather().handleLoadPackage(lpparam)
|
||||
OldNotificationWeather().handleLoadPackage(lpparam)
|
||||
//控制中心天气
|
||||
ControlCenterWeather().handleLoadPackage(lpparam)
|
||||
//TODO:状态栏电流
|
||||
//StatusBarCurrent().handleLoadPackage(lpparam)
|
||||
//状态栏布局
|
||||
StatusBarLayout().handleLoadPackage(lpparam)
|
||||
//隐藏时钟与实时网速之间的分隔符
|
||||
HideNetworkSpeedSplitter().handleLoadPackage(lpparam)
|
||||
//Alpha充电动画
|
||||
WaveCharge().handleLoadPackage(lpparam)
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
HideStatusBarIcon, //隐藏状态栏图标
|
||||
HideBatteryIcon, //隐藏电池
|
||||
HideHDIcon, //隐藏HD图标
|
||||
HideSimIcon, //隐藏SIM卡图标
|
||||
HideMobileActivityIcon, //隐藏移动箭头图标
|
||||
HideMobileTypeIcon, //隐藏移动类型图标
|
||||
HideStatusBarNetworkSpeedSecond, //隐藏状态栏网速/s
|
||||
HideWifiActivityIcon, //隐藏WIFI活动箭头图标
|
||||
MaximumNumberOfNotificationIcons, //通知图标上限
|
||||
StatusBarNetworkSpeedRefreshSpeed, //状态栏网速秒刷新
|
||||
StatusBarTimeCustomization, //状态栏时钟自定义
|
||||
RemoveTheLeftSideOfTheLockScreen, //移除锁屏负一屏功能
|
||||
RemoveLockScreenCamera, //移除锁屏相机功能
|
||||
NotificationWeather, //通知面板天气
|
||||
OldNotificationWeather,
|
||||
ControlCenterWeather, //控制中心天气
|
||||
//StatusBarCurrent, //TODO:状态栏电流
|
||||
StatusBarLayout, //状态栏布局
|
||||
HideNetworkSpeedSplitter, //隐藏时钟与实时网速之间的分隔符
|
||||
WaveCharge, //Alpha充电动画
|
||||
LockScreenCurrent, //锁屏电流
|
||||
LockScreenDoubleTapToSleep, //锁屏下双击锁屏
|
||||
StatusBarDoubleTapToSleep, //双击状态栏锁屏
|
||||
OldQSCustom, //旧版快速设置自定义
|
||||
DoubleLineNetworkSpeed, //双排网速
|
||||
StatusBarBigMobileTypeIcon, //大移动类型
|
||||
BatteryPercentage, //电量百分比
|
||||
CustomMobileTypeText, //自定义移动类型文本
|
||||
CanNotificationSlide, //允许下滑通知打开小窗
|
||||
LockScreenClockDisplaySeconds, // 锁屏时钟显示秒
|
||||
ShowWifiStandard, // 显示 WIFI 角标
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.hook.app.thememanager.RemoveAds
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class ThemeManager : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
//移除主题壁纸的广告
|
||||
RemoveAds().handleLoadPackage(lpparam)
|
||||
object ThemeManager: AppRegister() {
|
||||
override val packageName: String = "com.android.thememanager"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
autoInitHooks(lpparam,
|
||||
RemoveAds, //移除主题壁纸的广告
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,23 @@
|
||||
package com.lt2333.simplicitytools.hook.app
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookReturnConstant
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClassOrNull
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class Updater : IXposedHookLoadPackage {
|
||||
object Updater : AppRegister() {
|
||||
override val packageName: String = "com.android.updater"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (XSPUtils.getBoolean("remove_ota_validate", false)) {
|
||||
var letter = 'a'
|
||||
for (i in 0..25) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.updater.common.utils.$letter", lpparam.classLoader
|
||||
) ?: continue
|
||||
if (classIfExists.declaredFields.size >= 9 && classIfExists.declaredMethods.size > 60) {
|
||||
classIfExists.hookBeforeMethod("T") {
|
||||
it.result = false
|
||||
}
|
||||
return
|
||||
}
|
||||
letter++
|
||||
}
|
||||
|
||||
hasEnable("remove_ota_validate") {
|
||||
Array(26) { "com.android.updater.common.utils.${'a' + it}" }
|
||||
.mapNotNull { loadClassOrNull(it) }
|
||||
.firstOrNull() { it.declaredFields.size >= 9 && it.declaredMethods.size > 60 }
|
||||
?.findMethod { name == "T" && returnType == Boolean::class.java }
|
||||
?.hookReturnConstant(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import android.content.Context
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookReturnConstant
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object AllowUntrustedTouches : HookRegister() {
|
||||
override fun init() = hasEnable("allow_untrusted_touches") {
|
||||
findMethod("android.hardware.input.InputManager") {
|
||||
name == "getBlockUntrustedTouchesMode" && parameterTypes[0] == Context::class.java
|
||||
}.hookReturnConstant(0)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class DeleteOnPostNotification : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.server.wm.AlertWindowNotification".hookBeforeMethod(lpparam.classLoader, "onPostNotification") {
|
||||
object DeleteOnPostNotification : HookRegister() {
|
||||
override fun init() {
|
||||
findMethod("com.android.server.wm.AlertWindowNotification") {
|
||||
name == "onPostNotification"
|
||||
}.hookBefore {
|
||||
hasEnable("delete_on_post_notification") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class DisableFlagSecure : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.server.wm.WindowState".hookBeforeMethod(lpparam.classLoader, "isSecureLocked") {
|
||||
object DisableFlagSecure : HookRegister() {
|
||||
override fun init() {
|
||||
findMethod("com.android.server.wm.WindowState") {
|
||||
name == "isSecureLocked"
|
||||
}.hookBefore {
|
||||
hasEnable("disable_flag_secure") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,19 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import android.app.Service
|
||||
import android.icu.text.DisplayContext
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import com.lt2333.simplicitytools.util.setFloatField
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class MaxWallpaperScale : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.server.wm.WallpaperController".hookAfterMethod(lpparam.classLoader, "WallpaperController", Service::class.java, DisplayContext::class.java
|
||||
) {
|
||||
object MaxWallpaperScale : HookRegister() {
|
||||
override fun init() {
|
||||
findMethod("com.android.server.wm.WallpaperController") {
|
||||
name == "zoomOutToScale" && parameterTypes[0] == Float::class.java
|
||||
}.hookBefore {
|
||||
val value = XSPUtils.getFloat("max_wallpaper_scale", 1.1f)
|
||||
it.thisObject.setFloatField("mMaxWallpaperScale", value)
|
||||
}
|
||||
"com.android.server.wm.WallpaperController".hookBeforeMethod(lpparam.classLoader, "zoomOutToScale", Float::class.java) {
|
||||
val value = XSPUtils.getFloat("max_wallpaper_scale", 1.1f)
|
||||
it.thisObject.setFloatField("mMaxWallpaperScale", value)
|
||||
it.thisObject.putObject("mMaxWallpaperScale", value)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +1,46 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import android.content.Context
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveSmallWindowRestrictions : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object RemoveSmallWindowRestrictions : HookRegister() {
|
||||
override fun init() {
|
||||
// 强制所有活动设为可以调整大小
|
||||
"com.android.server.wm.Task".hookBeforeMethod(lpparam.classLoader, "isResizeable") {
|
||||
findMethod("com.android.server.wm.Task") {
|
||||
name == "isResizeable"
|
||||
}.hookBefore {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
|
||||
"android.util.MiuiMultiWindowAdapter".hookAfterMethod(lpparam.classLoader, "getFreeformBlackList") {
|
||||
findMethod("android.util.MiuiMultiWindowAdapter") {
|
||||
name == "getFreeformBlackList"
|
||||
}.hookAfter {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = (it.result as MutableList<*>).apply { clear() }
|
||||
}
|
||||
}
|
||||
|
||||
"android.util.MiuiMultiWindowAdapter".hookAfterMethod(lpparam.classLoader, "getFreeformBlackListFromCloud", Context::class.java) {
|
||||
findMethod("android.util.MiuiMultiWindowAdapter") {
|
||||
name == "getFreeformBlackListFromCloud" && parameterTypes[0] == Context::class.java
|
||||
}.hookAfter {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = (it.result as MutableList<*>).apply { clear() }
|
||||
}
|
||||
}
|
||||
|
||||
"android.util.MiuiMultiWindowUtils".hookAfterMethod(lpparam.classLoader, "supportFreeform") {
|
||||
findMethod("android.util.MiuiMultiWindowUtils") {
|
||||
name == "supportFreeform"
|
||||
}.hookAfter {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object SystemPropertiesHook : HookRegister() {
|
||||
override fun init() {
|
||||
val mediaStepsSwitch = XSPUtils.getBoolean("media_volume_steps_switch", false)
|
||||
val mediaSteps = XSPUtils.getInt("media_volume_steps", 15)
|
||||
|
||||
findMethod("android.os.SystemProperties") {
|
||||
name == "getInt" && returnType == Int::class.java
|
||||
}.hookBefore {
|
||||
when (it.args[0] as String) {
|
||||
"ro.config.media_vol_steps" -> if (mediaStepsSwitch) it.result = mediaSteps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
package com.lt2333.simplicitytools.hook.app.android.corepatch;
|
||||
|
||||
import android.app.AndroidAppHelper;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
|
||||
import com.lt2333.simplicitytools.BuildConfig;
|
||||
@@ -14,18 +17,22 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage;
|
||||
import de.robv.android.xposed.IXposedHookZygoteInit;
|
||||
import de.robv.android.xposed.XC_MethodHook;
|
||||
import de.robv.android.xposed.XC_MethodReplacement;
|
||||
import de.robv.android.xposed.XSharedPreferences;
|
||||
import de.robv.android.xposed.XposedBridge;
|
||||
import de.robv.android.xposed.XposedHelpers;
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage;
|
||||
|
||||
public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, IXposedHookZygoteInit {
|
||||
XSharedPreferences prefs = new XSharedPreferences(BuildConfig.APPLICATION_ID, "config");
|
||||
String TAG = "ST-CorePatch";
|
||||
|
||||
@Override
|
||||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||
@@ -35,27 +42,37 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
"checkDowngrade",
|
||||
"com.android.server.pm.parsing.pkg.AndroidPackage",
|
||||
"android.content.pm.PackageInfoLite",
|
||||
new ReturnConstant(prefs, "corepatch", null));
|
||||
new ReturnConstant(prefs, "downgrade", null));
|
||||
|
||||
// exists on flyme 9(Android 11) only
|
||||
findAndHookMethod("com.android.server.pm.PackageManagerService", loadPackageParam.classLoader,
|
||||
"checkDowngrade",
|
||||
"android.content.pm.PackageInfoLite",
|
||||
"android.content.pm.PackageInfoLite",
|
||||
new ReturnConstant(prefs, "downgrade", true));
|
||||
|
||||
|
||||
// apk内文件修改后 digest校验会失败
|
||||
hookAllMethods("android.util.jar.StrictJarVerifier", loadPackageParam.classLoader, "verifyMessageDigest",
|
||||
new ReturnConstant(prefs, "corepatch", true));
|
||||
new ReturnConstant(prefs, "authcreak", true));
|
||||
hookAllMethods("android.util.jar.StrictJarVerifier", loadPackageParam.classLoader, "verify",
|
||||
new ReturnConstant(prefs, "corepatch", true));
|
||||
new ReturnConstant(prefs, "authcreak", true));
|
||||
hookAllMethods("java.security.MessageDigest", loadPackageParam.classLoader, "isEqual",
|
||||
new ReturnConstant(prefs, "corepatch", true));
|
||||
new ReturnConstant(prefs, "authcreak", true));
|
||||
|
||||
// Targeting R+ (version " + Build.VERSION_CODES.R + " and above) requires"
|
||||
// + " the resources.arsc of installed APKs to be stored uncompressed"
|
||||
// + " and aligned on a 4-byte boundary
|
||||
// target >=30 的情况下 resources.arsc 必须是未压缩的且4K对齐
|
||||
hookAllMethods("android.content.res.AssetManager", loadPackageParam.classLoader, "containsAllocatedTable",
|
||||
new ReturnConstant(prefs, "corepatch", false));
|
||||
new ReturnConstant(prefs, "authcreak", false));
|
||||
|
||||
// No signature found in package of version " + minSignatureSchemeVersion
|
||||
// + " or newer for package " + apkPath
|
||||
findAndHookMethod("android.util.apk.ApkSignatureVerifier", loadPackageParam.classLoader, "getMinimumSignatureSchemeVersionForTargetSdk", int.class,
|
||||
new ReturnConstant(prefs, "corepatch", 0));
|
||||
new ReturnConstant(prefs, "authcreak", 0));
|
||||
findAndHookMethod("com.android.apksig.ApkVerifier", loadPackageParam.classLoader, "getMinimumSignatureSchemeVersionForTargetSdk", int.class,
|
||||
new ReturnConstant(prefs, "authcreak", 0));
|
||||
|
||||
// Package " + packageName + " signatures do not match previously installed version; ignoring!"
|
||||
// public boolean checkCapability(String sha256String, @CertCapabilities int flags) {
|
||||
@@ -66,7 +83,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
// Don't handle PERMISSION (grant SIGNATURE permissions to pkgs with this cert)
|
||||
// Or applications will have all privileged permissions
|
||||
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/content/pm/PackageParser.java;l=5947?q=CertCapabilities
|
||||
if (prefs.getBoolean("corepatch", true)) {
|
||||
if (prefs.getBoolean("authcreak", true)) {
|
||||
if ((Integer) param.args[1] != 4) {
|
||||
param.setResult(true);
|
||||
}
|
||||
@@ -91,20 +108,45 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
error.setAccessible(true);
|
||||
Object[] signingDetailsArgs = new Object[2];
|
||||
signingDetailsArgs[1] = 1;
|
||||
|
||||
hookAllMethods("android.util.jar.StrictJarVerifier", loadPackageParam.classLoader, "verifyBytes", new XC_MethodHook() {
|
||||
public void afterHookedMethod(MethodHookParam param) throws Throwable {
|
||||
super.afterHookedMethod(param);
|
||||
if (prefs.getBoolean("digestCreak", true)) {
|
||||
if(!prefs.getBoolean("UsePreSig", false)) {
|
||||
final Object block = constructor.newInstance(param.args[0]);
|
||||
Object[] infos = (Object[]) XposedHelpers.callMethod(block, "getSignerInfos");
|
||||
Object info = infos[0];
|
||||
List<X509Certificate> verifiedSignerCertChain = (List<X509Certificate>) XposedHelpers.callMethod(info, "getCertificateChain", block);
|
||||
param.setResult(verifiedSignerCertChain.toArray(
|
||||
new X509Certificate[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
hookAllMethods("android.util.apk.ApkSignatureVerifier", loadPackageParam.classLoader, "verifyV1Signature", new XC_MethodHook() {
|
||||
public void afterHookedMethod(MethodHookParam methodHookParam) throws Throwable {
|
||||
super.afterHookedMethod(methodHookParam);
|
||||
if (prefs.getBoolean("corepatch", true)) {
|
||||
if (prefs.getBoolean("authcreak", true)) {
|
||||
Throwable throwable = methodHookParam.getThrowable();
|
||||
if (throwable != null) {
|
||||
Signature[] lastSigs = null;
|
||||
if (prefs.getBoolean("corepatch", true)) {
|
||||
if(prefs.getBoolean("UsePreSig", false)) {
|
||||
PackageManager PM = AndroidAppHelper.currentApplication().getPackageManager();
|
||||
if(PM == null){
|
||||
XposedBridge.log("E: " + BuildConfig.APPLICATION_ID + " Cannot get the Package Manager... Are you using MiUI?");
|
||||
}else {
|
||||
PackageInfo pI = PM.getPackageArchiveInfo((String) methodHookParam.args[0], 0);
|
||||
PackageInfo InstpI = PM.getPackageInfo(pI.packageName, PackageManager.GET_SIGNATURES);
|
||||
lastSigs = InstpI.signatures;
|
||||
}
|
||||
}else {
|
||||
if(prefs.getBoolean("digestCreak", true)) {
|
||||
final Object origJarFile = constructorExact.newInstance(methodHookParam.args[0], true, false);
|
||||
final ZipEntry manifestEntry = (ZipEntry) XposedHelpers.callMethod(origJarFile, "findEntry", "AndroidManifest.xml");
|
||||
final Certificate[][] lastCerts = (Certificate[][]) XposedHelpers.callStaticMethod(ASV, "loadCertificates", origJarFile, manifestEntry);
|
||||
lastSigs = (Signature[]) XposedHelpers.callStaticMethod(ASV, "convertToSignatures", (Object) lastCerts);
|
||||
}
|
||||
}
|
||||
if (lastSigs != null) {
|
||||
signingDetailsArgs[0] = lastSigs;
|
||||
} else {
|
||||
@@ -117,7 +159,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
if (signingDetailsWithDigests != null) {
|
||||
Constructor<?> signingDetailsWithDigestsConstructorExact = XposedHelpers.findConstructorExact(signingDetailsWithDigests, signingDetails, Map.class);
|
||||
signingDetailsWithDigestsConstructorExact.setAccessible(true);
|
||||
newInstance = signingDetailsWithDigestsConstructorExact.newInstance(newInstance, null);
|
||||
newInstance = signingDetailsWithDigestsConstructorExact.newInstance(new Object[]{newInstance, null});
|
||||
}
|
||||
|
||||
Throwable cause = throwable.getCause();
|
||||
@@ -145,7 +187,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
// Don't handle PERMISSION (grant SIGNATURE permissions to pkgs with this cert)
|
||||
// Or applications will have all privileged permissions
|
||||
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/content/pm/PackageParser.java;l=5947?q=CertCapabilities
|
||||
if (((Integer) param.args[1] != 4) && prefs.getBoolean("corepatch", true)) {
|
||||
if (((Integer) param.args[1] != 4) && prefs.getBoolean("digestCreak", true)) {
|
||||
param.setResult(true);
|
||||
}
|
||||
}
|
||||
@@ -155,7 +197,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
@Override
|
||||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
||||
super.beforeHookedMethod(param);
|
||||
if (prefs.getBoolean("corepatch", true)) {
|
||||
if (prefs.getBoolean("digestCreak", true)) {
|
||||
ApplicationInfo info = (ApplicationInfo) param.thisObject;
|
||||
if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0
|
||||
|| (info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
|
||||
@@ -164,6 +206,36 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
});
|
||||
if (prefs.getBoolean("digestCreak", true) && prefs.getBoolean("UsePreSig", false)) {
|
||||
Class<?> pmClass = findClass("com.android.server.pm.PackageManagerService", loadPackageParam.classLoader);
|
||||
Class<?> pPClass = findClass("com.android.server.pm.parsing.pkg.ParsedPackage", loadPackageParam.classLoader);
|
||||
XposedHelpers.findAndHookMethod(pmClass, "doesSignatureMatchForPermissions", String.class, pPClass, int.class, new XC_MethodHook() {
|
||||
@Override
|
||||
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
||||
//If we decide to crack this then at least make sure they are same apks, avoid another one that tries to impersonate.
|
||||
if (param.getResult().equals(false)) {
|
||||
String pPname = (String) XposedHelpers.callMethod(param.args[1], "getPackageName");
|
||||
if (pPname.contentEquals((String) param.args[0])) {
|
||||
param.setResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initZygote(StartupParam startupParam) {
|
||||
|
||||
hookAllMethods("android.content.pm.PackageParser", null, "getApkSigningVersion", XC_MethodReplacement.returnConstant(1));
|
||||
hookAllConstructors("android.util.jar.StrictJarVerifier", new XC_MethodHook() {
|
||||
@Override
|
||||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
||||
if (prefs.getBoolean("enhancedMode", false)) {
|
||||
super.beforeHookedMethod(param);
|
||||
param.args[3] = Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class ReturnConstant extends XC_MethodHook {
|
||||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
||||
super.beforeHookedMethod(param);
|
||||
prefs.reload();
|
||||
if (prefs.getBoolean(prefsKey, true)) {
|
||||
if (prefs.getBoolean(prefsKey, false)) {
|
||||
param.setResult(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app.cast
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object ForceSupportSendApp : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("force_support_send_app") {
|
||||
findMethod("com.xiaomi.mirror.synergy.MiuiSynergySdk") {
|
||||
name == "isSupportSendApp"
|
||||
}.hookAfter {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,29 @@
|
||||
package com.lt2333.simplicitytools.hook.app.mediaeditor
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class UnlockUnlimitedCropping :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
object UnlockUnlimitedCropping : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
//解锁图库裁切最小值
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"calculateMinSize",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("unlock_unlimited_cropping",false)) {
|
||||
param.result = 0
|
||||
findMethod("com.miui.gallery.editor.photo.core.imports.obsoletes.Crop\$ResizeDetector") {
|
||||
name == "calculateMinSize"
|
||||
}.hookBefore {
|
||||
hasEnable("unlock_unlimited_cropping") {
|
||||
it.result = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
//截图无限裁切
|
||||
val classIfExists2 = XposedHelpers.findClassIfExists(
|
||||
"com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector",
|
||||
lpparam.classLoader
|
||||
)
|
||||
findMethod("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$ResizeDetector") {
|
||||
name == "calculateMinSize"
|
||||
}.hookBefore {
|
||||
hasEnable("unlock_unlimited_cropping") {
|
||||
it.result = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists2,
|
||||
"calculateMinSize",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("unlock_unlimited_cropping",false)) {
|
||||
param.result = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hook.app.miuihome
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class AlwaysDisplayTime : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.miui.home.launcher.Workspace",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"isScreenHasClockGadget", Long::class.javaPrimitiveType,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("home_time", false)) {
|
||||
param.result = false
|
||||
object AlwaysDisplayTime : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.miui.home.launcher.Workspace") {
|
||||
name == "isScreenHasClockGadget" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("home_time") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.lt2333.simplicitytools.hook.app.miuihome
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
import kotlin.math.abs
|
||||
|
||||
class DoubleTapController internal constructor(mContext: Context) {
|
||||
|
||||
private val maxDuration: Long = 500
|
||||
private var mActionDownRawX: Float = 0f
|
||||
private var mActionDownRawY: Float = 0f
|
||||
private var mClickCount: Int = 0
|
||||
private var mFirstClickRawX: Float = 0f
|
||||
private var mFirstClickRawY: Float = 0f
|
||||
private var mLastClickTime: Long = 0
|
||||
private val mTouchSlop: Int = ViewConfiguration.get(mContext).scaledTouchSlop * 2
|
||||
fun isDoubleTapEvent(motionEvent: MotionEvent): Boolean {
|
||||
val action = motionEvent.actionMasked
|
||||
return when {
|
||||
action == MotionEvent.ACTION_DOWN -> {
|
||||
mActionDownRawX = motionEvent.rawX
|
||||
mActionDownRawY = motionEvent.rawY
|
||||
false
|
||||
}
|
||||
action != MotionEvent.ACTION_UP -> false
|
||||
else -> {
|
||||
val rawX = motionEvent.rawX
|
||||
val rawY = motionEvent.rawY
|
||||
if (abs(rawX - mActionDownRawX) <= mTouchSlop.toFloat() && abs(rawY - mActionDownRawY) <= mTouchSlop.toFloat()) {
|
||||
if (SystemClock.elapsedRealtime() - mLastClickTime > maxDuration || rawY - mFirstClickRawY > mTouchSlop.toFloat() || rawX - mFirstClickRawX > mTouchSlop.toFloat()) mClickCount =
|
||||
0
|
||||
mClickCount++
|
||||
if (mClickCount == 1) {
|
||||
mFirstClickRawX = rawX
|
||||
mFirstClickRawY = rawY
|
||||
mLastClickTime = SystemClock.elapsedRealtime()
|
||||
return false
|
||||
} else if (abs(rawY - mFirstClickRawY) <= mTouchSlop.toFloat() && abs(rawX - mFirstClickRawX) <= mTouchSlop.toFloat() && SystemClock.elapsedRealtime() - mLastClickTime <= maxDuration
|
||||
) {
|
||||
mClickCount = 0
|
||||
return true
|
||||
}
|
||||
}
|
||||
mClickCount = 0
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.lt2333.simplicitytools.hook.app.miuihome
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.MotionEvent
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
|
||||
object DoubleTapToSleep : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("double_tap_to_sleep") {
|
||||
hookAllConstructorAfter("com.miui.home.launcher.Workspace") {
|
||||
var mDoubleTapControllerEx =
|
||||
XposedHelpers.getAdditionalInstanceField(it.thisObject, "mDoubleTapControllerEx")
|
||||
if (mDoubleTapControllerEx != null) return@hookAllConstructorAfter
|
||||
mDoubleTapControllerEx = DoubleTapController((it.args[0] as Context))
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
it.thisObject,
|
||||
"mDoubleTapControllerEx",
|
||||
mDoubleTapControllerEx
|
||||
)
|
||||
}
|
||||
findMethod("com.miui.home.launcher.Workspace") {
|
||||
name == "dispatchTouchEvent" && parameterTypes[0] == MotionEvent::class.java
|
||||
}.hookBefore {
|
||||
val mDoubleTapControllerEx = XposedHelpers.getAdditionalInstanceField(
|
||||
it.thisObject,
|
||||
"mDoubleTapControllerEx"
|
||||
) as DoubleTapController
|
||||
if (!mDoubleTapControllerEx.isDoubleTapEvent(it.args[0] as MotionEvent)) return@hookBefore
|
||||
val mCurrentScreenIndex = it.thisObject.getObject("mCurrentScreenIndex") as Int
|
||||
val cellLayout = it.thisObject.invokeMethodAuto("getCellLayout", mCurrentScreenIndex)
|
||||
if (cellLayout != null) if (cellLayout.invokeMethodAuto("lastDownOnOccupiedCell") as Boolean) return@hookBefore
|
||||
if (it.thisObject.invokeMethodAuto("isInNormalEditingMode") as Boolean) return@hookBefore
|
||||
val context = it.thisObject.invokeMethodAuto("getContext") as Context
|
||||
context.sendBroadcast(
|
||||
Intent("com.miui.app.ExtraStatusBarManager.action_TRIGGER_TOGGLE").putExtra(
|
||||
"com.miui.app.ExtraStatusBarManager.extra_TOGGLE_ID",
|
||||
10
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hook.app.powerkeeper
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class LockMaxFps : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.miui.powerkeeper.statemachine.DisplayFrameSetting",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"setScreenEffect",
|
||||
String::class.java, Int::class.javaPrimitiveType, Int::class.javaPrimitiveType,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
super.beforeHookedMethod(param)
|
||||
if (XSPUtils.getBoolean("lock_max_fps", false)) {
|
||||
param.result = null
|
||||
object LockMaxFps : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.miui.powerkeeper.statemachine.DisplayFrameSetting") {
|
||||
name == "setScreenEffect" && parameterCount == 3
|
||||
}.hookBefore {
|
||||
hasEnable("lock_max_fps") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +1,22 @@
|
||||
package com.lt2333.simplicitytools.hook.app.powerkeeper
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class PreventRecoveryOfBatteryOptimizationWhitelist : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.miui.powerkeeper.statemachine.ForceDozeController",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"restoreWhiteListAppsIfQuitForceIdle",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
super.beforeHookedMethod(param)
|
||||
if (XSPUtils.getBoolean(
|
||||
"prevent_recovery_of_battery_optimization_white_list",
|
||||
false
|
||||
)
|
||||
object PreventRecoveryOfBatteryOptimizationWhitelist : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod(
|
||||
"com.miui.powerkeeper.statemachine.ForceDozeController"
|
||||
) {
|
||||
param.result = null
|
||||
name == "restoreWhiteListAppsIfQuitForceIdle"
|
||||
}.hookBefore {
|
||||
hasEnable("prevent_recovery_of_battery_optimization_white_list") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.lt2333.simplicitytools.hook.app.reardisplay
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.view.WeatherView
|
||||
|
||||
object RearDisplayWeather : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("rear_show_weather") {
|
||||
findMethod("com.xiaomi.misubscreenui.light.aod.view.VerticalClockView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
|
||||
//获取原组件
|
||||
val gradientLayoutID =
|
||||
context.resources.getIdentifier("gradient_layout", "id", context.packageName)
|
||||
val gradientLayout: ViewGroup = viewGroup.findViewById(gradientLayoutID)
|
||||
val dateID = context.resources.getIdentifier("date", "id", context.packageName)
|
||||
val date: TextView = viewGroup.findViewById(dateID)
|
||||
|
||||
//创建天气组件
|
||||
val mWeatherView = WeatherView(context, false).apply {
|
||||
gravity = Gravity.END
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"Sub_Screen_Aod_date_s",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
typeface = Typeface.create("mipro-medium", Typeface.NORMAL)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12f)
|
||||
}
|
||||
gradientLayout.addView(mWeatherView, (gradientLayout.indexOfChild(date) + 1))
|
||||
}
|
||||
|
||||
findMethod("com.xiaomi.misubscreenui.light.aod.view.HorizontalClockView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookBefore { param ->
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
|
||||
//获取原组件
|
||||
val gradientLayoutID =
|
||||
context.resources.getIdentifier("gradient_layout", "id", context.packageName)
|
||||
val gradientLayout: RelativeLayout = viewGroup.findViewById(gradientLayoutID)
|
||||
val dateID = context.resources.getIdentifier("date", "id", context.packageName)
|
||||
val date: TextView = viewGroup.findViewById(dateID)
|
||||
val dateParentLayout: ViewGroup = date.parent as ViewGroup
|
||||
|
||||
//创建天气组件
|
||||
val mWeatherView = WeatherView(context, false).apply {
|
||||
id = View.generateViewId()
|
||||
gravity = Gravity.CENTER
|
||||
maxLines = 1
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"Sub_Screen_Aod_date_s_horizontal",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
typeface = Typeface.create("mipro-medium", Typeface.NORMAL)
|
||||
layoutParams = RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
||||
dp2px(context, 30f)
|
||||
).also {
|
||||
it.addRule(RelativeLayout.END_OF, dateID)
|
||||
it.marginStart = dp2px(context, 3f)
|
||||
it.marginEnd = dp2px(context, 3f)
|
||||
}
|
||||
}
|
||||
dateParentLayout.addView(mWeatherView, (dateParentLayout.indexOfChild(date) + 1))
|
||||
|
||||
//电池位置
|
||||
val batteryID =
|
||||
context.resources.getIdentifier("battery_container", "id", context.packageName)
|
||||
val battery: ViewGroup = viewGroup.findViewById(batteryID)
|
||||
|
||||
battery.layoutParams = RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
||||
dp2px(context, 30f)
|
||||
).also {
|
||||
it.addRule(RelativeLayout.END_OF, mWeatherView.id)
|
||||
}
|
||||
gradientLayout.setPadding(0, dp2px(context, 5f), 0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lt2333.simplicitytools.hook.app.screenshot
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object UnlockUnlimitedCropping : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
//截图无限裁切
|
||||
findMethod("com.miui.gallery.editor.photo.screen.crop.ScreenCropView\$b") {
|
||||
name == "a" && parameterCount == 0 && returnType == Int::class.java
|
||||
}.hookBefore {
|
||||
hasEnable("unlock_unlimited_cropping") {
|
||||
it.result = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +1,31 @@
|
||||
package com.lt2333.simplicitytools.hook.app.securitycenter
|
||||
|
||||
import android.view.View
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class LockOneHundred : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
object LockOneHundred : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
//防止点击重新检测
|
||||
val mainContentFrameClass = "com.miui.securityscan.ui.main.MainContentFrame".findClass(lpparam.classLoader)
|
||||
mainContentFrameClass.hookBeforeMethod("onClick", View::class.java) {
|
||||
if (XSPUtils.getBoolean("lock_one_hundred", false)) {
|
||||
findMethod("com.miui.securityscan.ui.main.MainContentFrame") {
|
||||
name == "onClick" && parameterTypes[0] == View::class.java
|
||||
}.hookBefore {
|
||||
hasEnable("lock_one_hundred") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
|
||||
//锁定100分
|
||||
var scoreManagerClass = "com.miui.securityscan.scanner.ScoreManager".findClass(lpparam.classLoader)
|
||||
scoreManagerClass.hookBeforeMethod("B") {
|
||||
if (XSPUtils.getBoolean("lock_one_hundred", false)) {
|
||||
findMethod("com.miui.securityscan.scanner.ScoreManager") {
|
||||
name == "B"
|
||||
}.hookBefore {
|
||||
hasEnable("lock_one_hundred") {
|
||||
it.result = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.lt2333.simplicitytools.hook.app.securitycenter
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveMacroBlacklist : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
object RemoveMacroBlacklist : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
if (XSPUtils.getBoolean("remove_macro_blacklist", false)) {
|
||||
var letter = 'a'
|
||||
for (i in 0..25) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.miui.gamebooster.v.$letter" + "0", lpparam.classLoader
|
||||
"com.miui.gamebooster.v.$letter" + "0", getDefaultClassLoader()
|
||||
) ?: continue
|
||||
if (classIfExists.declaredMethods.size in 6..12 && classIfExists.fields.isEmpty() && classIfExists.declaredFields.size >= 2) {
|
||||
XposedHelpers.findAndHookMethod(classIfExists, "c", String::class.java,
|
||||
@@ -27,4 +27,5 @@ class RemoveMacroBlacklist : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.lt2333.simplicitytools.hook.app.securitycenter
|
||||
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object RemoveOpenAppConfirmationPopup : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("android.widget.TextView") {
|
||||
name == "setText" && parameterTypes[0] == CharSequence::class.java
|
||||
}.hookAfter {
|
||||
hasEnable("remove_open_app_confirmation_popup") {
|
||||
val textView = it.thisObject as TextView
|
||||
if (it.args.isNotEmpty() && it.args[0]?.toString().equals(
|
||||
textView.context.resources.getString(
|
||||
textView.context.resources.getIdentifier(
|
||||
"button_text_accept",
|
||||
"string",
|
||||
textView.context.packageName
|
||||
)
|
||||
)
|
||||
)
|
||||
) {
|
||||
textView.performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,56 +13,92 @@ import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import java.lang.reflect.Field
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class ShowBatteryTemperature: IXposedHookLoadPackage {
|
||||
object ShowBatteryTemperature : HookRegister() {
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (!XSPUtils.getBoolean("battery_life_function", false)) return
|
||||
val a = "com.miui.powercenter.a\$a".findClass(lpparam.classLoader)
|
||||
"com.miui.powercenter.a".hookBeforeMethod(lpparam.classLoader, "b", Context::class.java) {
|
||||
it.result = getBatteryTemperature(it.args[0] as Context).toString()
|
||||
}
|
||||
a.hookAfterMethod("run") {
|
||||
val context = AndroidAppHelper.currentApplication().applicationContext
|
||||
val isDarkMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
val currentTemperatureValue = context.resources.getIdentifier("current_temperature_value", "id", "com.miui.securitycenter")
|
||||
val field = a.getDeclaredField("a") as Field
|
||||
field.isAccessible = true
|
||||
val view = field.get(it.thisObject) as View
|
||||
val textView = view.findViewById<TextView>(currentTemperatureValue)
|
||||
(textView.layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 25f)
|
||||
(textView.layoutParams as LinearLayout.LayoutParams).topMargin = 0
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f)
|
||||
textView.setPadding(0, 0, 0, 0)
|
||||
textView.gravity = Gravity.NO_GRAVITY
|
||||
textView.typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
|
||||
textView.height = dp2px(context, 49.099983f)
|
||||
textView.textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
val tempView = TextView(context)
|
||||
tempView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, dp2px(context, 49.099983f))
|
||||
(tempView.layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 3.599976f)
|
||||
tempView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.099977f)
|
||||
tempView.setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
|
||||
tempView.setPadding(0, dp2px(context, 25f), 0, 0)
|
||||
tempView.text = "℃"
|
||||
tempView.typeface = Typeface.create(null, 500, false)
|
||||
tempView.textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
val tempeValueContainer = context.resources.getIdentifier("tempe_value_container", "id", "com.miui.securitycenter")
|
||||
val linearLayout = view.findViewById<LinearLayout>(tempeValueContainer)
|
||||
linearLayout.addView(tempView)
|
||||
}
|
||||
}
|
||||
private fun getBatteryTemperature(context: Context): Int {
|
||||
return context.registerReceiver(
|
||||
null as BroadcastReceiver?,
|
||||
IntentFilter("android.intent.action.BATTERY_CHANGED")
|
||||
)!!.getIntExtra("temperature", 0) / 10
|
||||
}
|
||||
|
||||
override fun init() = hasEnable("battery_life_function") {
|
||||
try {
|
||||
findMethod("com.miui.powercenter.a") {
|
||||
name == "b" && parameterTypes[0] == Context::class.java
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
findMethod("com.miui.powercenter.BatteryFragment") {
|
||||
name == "b" && parameterTypes[0] == Context::class.java
|
||||
}
|
||||
}.hookBefore {
|
||||
it.result = getBatteryTemperature(it.args[0] as Context).toString()
|
||||
}
|
||||
|
||||
try {
|
||||
findMethod("com.miui.powercenter.a\$a") {
|
||||
name == "run"
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
findMethod("com.miui.powercenter.BatteryFragment\$a") {
|
||||
name == "run"
|
||||
}
|
||||
}.hookAfter {
|
||||
val context = AndroidAppHelper.currentApplication().applicationContext
|
||||
val isDarkMode =
|
||||
context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
val currentTemperatureValue = context.resources.getIdentifier(
|
||||
"current_temperature_value",
|
||||
"id",
|
||||
"com.miui.securitycenter"
|
||||
)
|
||||
|
||||
val view = it.thisObject.getObjectAs<View>("a")
|
||||
|
||||
val textView = view.findViewById<TextView>(currentTemperatureValue)
|
||||
textView.apply {
|
||||
(layoutParams as LinearLayout.LayoutParams).marginStart = dp2px(context, 25f)
|
||||
(layoutParams as LinearLayout.LayoutParams).topMargin = 0
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36.399998f)
|
||||
setPadding(0, 0, 0, 0)
|
||||
gravity = Gravity.NO_GRAVITY
|
||||
typeface = Typeface.defaultFromStyle(Typeface.NORMAL)
|
||||
height = dp2px(context, 49.099983f)
|
||||
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
}
|
||||
|
||||
val tempView = TextView(context)
|
||||
tempView.apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
dp2px(context, 49.099983f)
|
||||
)
|
||||
(layoutParams as LinearLayout.LayoutParams).marginStart =
|
||||
dp2px(context, 3.599976f)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13.099977f)
|
||||
setTextColor(Color.parseColor(if (isDarkMode) "#e6e6e6" else "#333333"))
|
||||
setPadding(0, dp2px(context, 25f), 0, 0)
|
||||
text = "℃"
|
||||
typeface = Typeface.create(null, 500, false)
|
||||
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
|
||||
}
|
||||
|
||||
val tempeValueContainer = context.resources.getIdentifier(
|
||||
"tempe_value_container",
|
||||
"id",
|
||||
"com.miui.securitycenter"
|
||||
)
|
||||
|
||||
val linearLayout = view.findViewById<LinearLayout>(tempeValueContainer)
|
||||
linearLayout.addView(tempView)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app.securitycenter
|
||||
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class SkipWaitingTime : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
object SkipWaitingTime : HookRegister() {
|
||||
|
||||
val textViewClass = "android.widget.TextView".findClass(lpparam.classLoader)
|
||||
textViewClass.hookBeforeMethod(
|
||||
"setText",
|
||||
CharSequence::class.java,
|
||||
TextView.BufferType::class.java,
|
||||
Boolean::class.java,
|
||||
Int::class.java
|
||||
) {
|
||||
if (XSPUtils.getBoolean("skip_waiting_time", false)) {
|
||||
override fun init() {
|
||||
findMethod("android.widget.TextView") {
|
||||
name == "setText" && parameterCount == 4
|
||||
}.hookBefore {
|
||||
hasEnable("skip_waiting_time") {
|
||||
if (it.args.isNotEmpty() && it.args[0]?.toString()?.startsWith("确定(") == true
|
||||
) {
|
||||
it.args[0] = "确定"
|
||||
@@ -26,13 +19,13 @@ class SkipWaitingTime : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
|
||||
textViewClass.hookBeforeMethod(
|
||||
"setEnabled",
|
||||
Boolean::class.java
|
||||
) {
|
||||
if (XSPUtils.getBoolean("skip_waiting_time", false)) {
|
||||
findMethod("android.widget.TextView") {
|
||||
name == "setEnabled" && parameterTypes[0] == Boolean::class.java
|
||||
}.hookBefore {
|
||||
hasEnable("skip_waiting_time") {
|
||||
it.args[0] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +1,50 @@
|
||||
package com.lt2333.simplicitytools.hook.app.settings
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class ShowNotificationImportance : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val channelNotificationSettingsClass = "com.android.settings.notification.ChannelNotificationSettings".findClass(lpparam.classLoader)
|
||||
channelNotificationSettingsClass.hookBeforeMethod("removeDefaultPrefs") {
|
||||
if (!XSPUtils.getBoolean("show_notification_importance", false)) return@hookBeforeMethod
|
||||
val importance = it.thisObject.callMethod("findPreference", "importance") ?: return@hookBeforeMethod
|
||||
val mChannel = it.thisObject.getObjectField("mChannel") as NotificationChannel
|
||||
val index = importance.callMethod("findSpinnerIndexOfValue", mChannel.importance.toString()) as Int
|
||||
if (index < 0) return@hookBeforeMethod
|
||||
importance.callMethod("setValueIndex", index)
|
||||
XposedHelpers.setAdditionalInstanceField(importance, "channelNotificationSettings", it.thisObject)
|
||||
object ShowNotificationImportance : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.settings.notification.ChannelNotificationSettings"){
|
||||
name == "removeDefaultPrefs"
|
||||
}.hookBefore {
|
||||
if (!XSPUtils.getBoolean("show_notification_importance", false)) return@hookBefore
|
||||
val importance =
|
||||
it.thisObject.invokeMethodAuto("findPreference", "importance") ?: return@hookBefore
|
||||
val mChannel = it.thisObject.getObject("mChannel") as NotificationChannel
|
||||
val index = importance.invokeMethodAutoAs<Int>(
|
||||
"findSpinnerIndexOfValue",
|
||||
mChannel.importance.toString()
|
||||
) as Int
|
||||
if (index < 0) return@hookBefore
|
||||
importance.invokeMethodAuto("setValueIndex", index)
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
importance,
|
||||
"channelNotificationSettings",
|
||||
it.thisObject
|
||||
)
|
||||
it.result = null
|
||||
}
|
||||
|
||||
val dropDownPreferenceClass = XposedHelpers.findClass("androidx.preference.Preference", lpparam.classLoader)
|
||||
dropDownPreferenceClass.hookAfterMethod("callChangeListener", Any::class.java) {
|
||||
val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField(it.thisObject, "channelNotificationSettings") ?: return@hookAfterMethod
|
||||
val mChannel = channelNotificationSettings.getObjectField("mChannel") as NotificationChannel
|
||||
mChannel.callMethod("setImportance", (it.args[0] as String).toInt())
|
||||
val mBackend = channelNotificationSettings.getObjectField("mBackend") ?: return@hookAfterMethod
|
||||
val mPkg = channelNotificationSettings.getObjectField("mPkg") as String
|
||||
val mUid = channelNotificationSettings.getIntField("mUid")
|
||||
mBackend.callMethod("updateChannel", mPkg, mUid, mChannel)
|
||||
findMethod("androidx.preference.Preference"){
|
||||
name == "callChangeListener" && parameterTypes[0] == Any::class.java
|
||||
}.hookAfter {
|
||||
val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField(
|
||||
it.thisObject,
|
||||
"channelNotificationSettings"
|
||||
) ?: return@hookAfter
|
||||
val mChannel = channelNotificationSettings.getObject("mChannel") as NotificationChannel
|
||||
mChannel.invokeMethodAuto("setImportance", (it.args[0] as String).toInt())
|
||||
val mBackend =
|
||||
channelNotificationSettings.getObjectOrNull("mBackend") ?: return@hookAfter
|
||||
val mPkg = channelNotificationSettings.getObjectAs<String>("mPkg")
|
||||
val mUid = channelNotificationSettings.getObjectAs<Int>("mUid")
|
||||
mBackend.invokeMethodAuto("updateChannel", mPkg, mUid, mChannel)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object BatteryPercentage : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
val size = XSPUtils.getFloat("battery_percentage_font_size", 0f)
|
||||
if (size == 0f) return
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiBatteryMeterView") {
|
||||
name == "updateResources"
|
||||
}.hookAfter {
|
||||
(it.thisObject.getObjectAs<TextView>("mBatteryPercentView")).setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_DIP, size
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object CanNotificationSlide: HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.notification.NotificationSettingsManager") {
|
||||
name == "canSlide"
|
||||
}.hookAfter {
|
||||
hasEnable("can_notification_slide") {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,40 +4,136 @@ import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClass
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.SystemProperties
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.view.WeatherView
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class ControlCenterWeather : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("control_center_weather") {
|
||||
object ControlCenterWeather : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("control_center_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
var mConstraintLayout: ConstraintLayout? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("control_center_weather_city", false)
|
||||
"com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView".hookAfterMethod(
|
||||
lpparam.classLoader,
|
||||
"onFinishInflate"
|
||||
) {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
findMethod("com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter { param ->
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 &&
|
||||
!SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
//获取原组件
|
||||
val big_time_ID =
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
val big_time: TextView = viewGroup.findViewById(big_time_ID)
|
||||
|
||||
val date_time_ID =
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
val date_time: TextView = viewGroup.findViewById(date_time_ID)
|
||||
|
||||
//创建新布局
|
||||
val mConstraintLayoutLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.topMargin = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"qs_control_header_tiles_margin_top",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout =
|
||||
ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp }
|
||||
|
||||
(big_time.parent as ViewGroup).addView(mConstraintLayout, 0)
|
||||
|
||||
//从原布局中删除组件
|
||||
(big_time.parent as ViewGroup).removeView(big_time)
|
||||
(date_time.parent as ViewGroup).removeView(date_time)
|
||||
|
||||
//添加组件至新布局
|
||||
mConstraintLayout!!.addView(big_time)
|
||||
mConstraintLayout!!.addView(date_time)
|
||||
|
||||
//组件属性
|
||||
val date_time_LP = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = big_time_ID
|
||||
it.bottomToBottom = 0
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
it.bottomMargin = dp2px(context, 5f)
|
||||
}
|
||||
date_time.layoutParams = date_time_LP
|
||||
|
||||
|
||||
//创建天气组件
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
mConstraintLayout!!.addView(mWeatherView)
|
||||
|
||||
val mWeatherView_LP = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = big_time_ID
|
||||
it.bottomToTop = date_time_ID
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).layoutParams = mWeatherView_LP
|
||||
|
||||
} else {
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
.getConstructor(Int::class.java, Int::class.java).newInstance(
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams").getConstructor(
|
||||
Int::class.java,
|
||||
Int::class.java
|
||||
).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.setObjectField(
|
||||
layoutParam.putObject(
|
||||
"bottomToTop",
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.setObjectField(
|
||||
layoutParam.putObject(
|
||||
"startToEnd",
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
)
|
||||
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
@@ -45,7 +141,6 @@ class ControlCenterWeather : IXposedHookLoadPackage {
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
@@ -57,6 +152,7 @@ class ControlCenterWeather : IXposedHookLoadPackage {
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
@@ -73,12 +169,25 @@ class ControlCenterWeather : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//解决横屏重叠
|
||||
"com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView".hookAfterMethod(
|
||||
lpparam.classLoader,
|
||||
"updateLayout"
|
||||
findMethod("com.android.systemui.controlcenter.phone.widget.QSControlCenterHeaderView") {
|
||||
name == "updateLayout"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val mOrientation = viewGroup.getObject("mOrientation") as Int
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith(
|
||||
"DEV"
|
||||
) && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
val mOrientation = it.thisObject.getObjectField("mOrientation") as Int
|
||||
if (mOrientation == 1) {
|
||||
mConstraintLayout!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mConstraintLayout!!.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
if (mOrientation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
@@ -87,4 +196,5 @@ class ControlCenterWeather : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object CustomMobileTypeText : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("custom_mobile_type_text_switch") {
|
||||
findMethod("com.android.systemui.statusbar.policy.MobileSignalController") {
|
||||
name == "getMobileTypeName" && parameterTypes[0] == Int::class.java
|
||||
}.hookAfter {
|
||||
it.result = XSPUtils.getString("custom_mobile_type_text", "5G")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.net.TrafficStats
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.init.InitFields
|
||||
import com.github.kyuubiran.ezxhelper.utils.findConstructor
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.R
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import java.text.DecimalFormat
|
||||
|
||||
object DoubleLineNetworkSpeed : HookRegister() {
|
||||
|
||||
private var mLastTotalUp: Long = 0
|
||||
private var mLastTotalDown: Long = 0
|
||||
|
||||
private var lastTimeStampTotalUp: Long = 0
|
||||
private var lastTimeStampTotalDown: Long = 0
|
||||
|
||||
private var upIcon = ""
|
||||
private var downIcon = ""
|
||||
|
||||
private val getDualSize = XSPUtils.getInt("status_bar_network_speed_dual_row_size", 0)
|
||||
private val getDualAlign = XSPUtils.getInt("status_bar_network_speed_dual_row_gravity", 0)
|
||||
|
||||
override fun init() = hasEnable("status_bar_dual_row_network_speed") {
|
||||
|
||||
val none = InitFields.moduleRes.getString(R.string.none)
|
||||
|
||||
if (XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) != none) {
|
||||
upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)
|
||||
?.firstOrNull().toString()
|
||||
downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)
|
||||
?.lastOrNull().toString()
|
||||
}
|
||||
|
||||
findConstructor("com.android.systemui.statusbar.views.NetworkSpeedView") {
|
||||
parameterCount == 2
|
||||
}.hookAfter {
|
||||
val mView = it.thisObject as TextView
|
||||
mView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 7f)
|
||||
if (getDualSize != 0) {
|
||||
mView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, getDualSize.toFloat())
|
||||
}
|
||||
mView.isSingleLine = false
|
||||
mView.setLineSpacing(0F, 0.8F)
|
||||
if (getDualAlign == 0) {
|
||||
mView.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
} else {
|
||||
mView.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.policy.NetworkSpeedController") {
|
||||
name == "formatSpeed" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
if (getDualAlign == 0) {
|
||||
it.result =
|
||||
"$upIcon ${getTotalUpSpeed(it.args[0] as Context)}\n${downIcon} ${
|
||||
getTotalDownloadSpeed(it.args[0] as Context)
|
||||
}"
|
||||
} else {
|
||||
it.result =
|
||||
"${getTotalUpSpeed(it.args[0] as Context)} ${upIcon}\n${
|
||||
getTotalDownloadSpeed(
|
||||
it.args[0] as Context
|
||||
)
|
||||
} $downIcon"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取总的上行速度
|
||||
private fun getTotalUpSpeed(context: Context): String {
|
||||
val totalUpSpeed: Float
|
||||
|
||||
val currentTotalTxBytes = TrafficStats.getTotalTxBytes()
|
||||
val nowTimeStampTotalUp = System.currentTimeMillis()
|
||||
|
||||
//计算上传速度
|
||||
val bytes =
|
||||
(currentTotalTxBytes - mLastTotalUp) * 1000 / (nowTimeStampTotalUp - lastTimeStampTotalUp).toFloat()
|
||||
val unit: String
|
||||
|
||||
if (bytes >= 1048576) {
|
||||
totalUpSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1048576).toFloat()
|
||||
unit = context.resources.getString(
|
||||
context.resources.getIdentifier(
|
||||
"megabyte_per_second",
|
||||
"string",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
} else {
|
||||
totalUpSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1024).toFloat()
|
||||
unit = context.resources.getString(
|
||||
context.resources.getIdentifier(
|
||||
"kilobyte_per_second",
|
||||
"string",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
//保存当前的流量总和和上次的时间戳
|
||||
mLastTotalUp = currentTotalTxBytes
|
||||
lastTimeStampTotalUp = nowTimeStampTotalUp
|
||||
|
||||
return if (totalUpSpeed >= 100) {
|
||||
"" + totalUpSpeed.toInt() + unit
|
||||
} else {
|
||||
"" + totalUpSpeed + unit
|
||||
}
|
||||
}
|
||||
|
||||
//获取总的下行速度
|
||||
private fun getTotalDownloadSpeed(context: Context): String {
|
||||
val totalDownSpeed: Float
|
||||
val currentTotalRxBytes = TrafficStats.getTotalRxBytes()
|
||||
val nowTimeStampTotalDown = System.currentTimeMillis()
|
||||
|
||||
//计算下行速度
|
||||
val bytes =
|
||||
(currentTotalRxBytes - mLastTotalDown) * 1000 / (nowTimeStampTotalDown - lastTimeStampTotalDown).toFloat()
|
||||
|
||||
val unit: String
|
||||
|
||||
if (bytes >= 1048576) {
|
||||
totalDownSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1048576).toFloat()
|
||||
unit = context.resources.getString(
|
||||
context.resources.getIdentifier(
|
||||
"megabyte_per_second",
|
||||
"string",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
} else {
|
||||
totalDownSpeed =
|
||||
DecimalFormat("0.0").format(bytes / 1024).toFloat()
|
||||
unit = context.resources.getString(
|
||||
context.resources.getIdentifier(
|
||||
"kilobyte_per_second",
|
||||
"string",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
//保存当前的流量总和和上次的时间戳
|
||||
mLastTotalDown = currentTotalRxBytes
|
||||
lastTimeStampTotalDown = nowTimeStampTotalDown
|
||||
|
||||
return if (totalDownSpeed >= 100) {
|
||||
"" + totalDownSpeed.toInt() + unit
|
||||
} else {
|
||||
"" + totalDownSpeed + unit
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideAirplaneIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.policy.NetworkController\$IconState"
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "setIsAirplaneMode", iconState) {
|
||||
hasEnable("hide_airplane_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideAlarmIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "onMiuiAlarmChanged") {
|
||||
hasEnable("hide_alarm_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,41 +4,48 @@ import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObject
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class HideBatteryIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.views.MiuiBatteryMeterView".hookAfterMethod(lpparam.classLoader, "updateResources") {
|
||||
object HideBatteryIcon : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiBatteryMeterView") {
|
||||
name == "updateResources"
|
||||
}.hookAfter {
|
||||
//隐藏电池图标
|
||||
hasEnable("hide_battery_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryIconView") as ImageView).visibility = View.GONE
|
||||
if (it.thisObject.getObjectField("mBatteryStyle") == 1) {
|
||||
(it.thisObject.getObjectField("mBatteryDigitalView") as FrameLayout).visibility = View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mBatteryIconView")).visibility = View.GONE
|
||||
if (it.thisObject.getObject("mBatteryStyle") == 1) {
|
||||
(it.thisObject.getObjectAs<FrameLayout>("mBatteryDigitalView")).visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏电池内的百分比
|
||||
hasEnable("hide_battery_percentage_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryPercentMarkView") as TextView).textSize = 0F
|
||||
(it.thisObject.getObjectAs<TextView>("mBatteryPercentMarkView")).textSize = 0F
|
||||
}
|
||||
|
||||
//隐藏电池百分号
|
||||
hasEnable("hide_battery_percentage_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryPercentMarkView") as TextView).textSize = 0F
|
||||
(it.thisObject.getObjectAs<TextView>("mBatteryPercentMarkView")).textSize = 0F
|
||||
}
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.views.MiuiBatteryMeterView".hookAfterMethod(lpparam.classLoader, "updateChargeAndText") {
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiBatteryMeterView") {
|
||||
name == "updateChargeAndText"
|
||||
}.hookAfter {
|
||||
//隐藏电池充电图标
|
||||
hasEnable("hide_battery_charging_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryChargingInView") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectField("mBatteryChargingView") as ImageView).visibility = View.GONE
|
||||
}
|
||||
(it.thisObject.getObjectAs<ImageView>("mBatteryChargingInView")).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mBatteryChargingView")).visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Intent
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideBluetoothHandsfreeBatteryIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateBluetoothHandsfreeBattery", Intent::class.java) {
|
||||
hasEnable("hide_bluetooth_battery_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideBluetoothIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateBluetooth", String::class.java) {
|
||||
hasEnable("hide_bluetooth_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideGPSIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateLocationFromController") {
|
||||
hasEnable("hide_gps_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,39 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
class HideHDIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_big_hd_icon") {
|
||||
(it.thisObject.getObjectField("mVolte") as ImageView).visibility = View.GONE
|
||||
object HideHDIcon : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
hasEnable("hide_small_hd_icon") {
|
||||
(it.thisObject.getObjectField("mSmallHd") as ImageView).visibility = View.GONE
|
||||
}
|
||||
hasEnable("hide_hd_no_service_icon") {
|
||||
(it.thisObject.getObjectField("mVolteNoService") as ImageView).visibility = View.GONE
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
private fun hide(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_big_hd_icon") {
|
||||
(it.thisObject.getObjectField("mVolte") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mVolte")).visibility = View.GONE
|
||||
}
|
||||
hasEnable("hide_small_hd_icon") {
|
||||
(it.thisObject.getObjectField("mSmallHd") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mSmallHd")).visibility = View.GONE
|
||||
}
|
||||
hasEnable("hide_hd_no_service_icon") {
|
||||
(it.thisObject.getObjectField("mVolteNoService") as ImageView).visibility = View.GONE
|
||||
}
|
||||
(it.thisObject.getObjectAs<ImageView>("mVolteNoService")).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Intent
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideHeadsetIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateHeadsetPlug", Intent::class.java) {
|
||||
hasEnable("hide_headset_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideHotspotIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarPolicy\$2".hookBeforeMethod(lpparam.classLoader, "onHotspotChanged", Boolean::class.java, Int::class.java) {
|
||||
hasEnable("hide_hotspot_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,34 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
class HideMobileActivityIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_mobile_activity_icon") {
|
||||
(it.thisObject.getObjectField("mLeftInOut") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectField("mRightInOut") as ImageView).visibility = View.GONE
|
||||
object HideMobileActivityIcon : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
private fun hide(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_mobile_activity_icon") {
|
||||
(it.thisObject.getObjectField("mLeftInOut") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectField("mRightInOut") as ImageView).visibility = View.GONE
|
||||
}
|
||||
(it.thisObject.getObjectAs<ImageView>("mLeftInOut")).visibility = View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mRightInOut")).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,29 +3,50 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
class HideMobileTypeIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility = View.INVISIBLE
|
||||
object HideMobileTypeIcon : HookRegister() {
|
||||
|
||||
private val isBigType = XSPUtils.getBoolean("big_mobile_type_icon", false)
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hideMobileTypeIcon(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hideMobileTypeIcon(it)
|
||||
}
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
private fun hideMobileTypeIcon(it: XC_MethodHook.MethodHookParam) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility = View.INVISIBLE
|
||||
if (isBigType) {
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileType")).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectAs<ImageView>("mMobileTypeImage")).visibility =
|
||||
View.GONE
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileTypeSingle")).visibility =
|
||||
View.GONE
|
||||
} else {
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileType")).visibility =
|
||||
View.INVISIBLE
|
||||
(it.thisObject.getObjectAs<ImageView>("mMobileTypeImage")).visibility =
|
||||
View.INVISIBLE
|
||||
(it.thisObject.getObjectAs<TextView>("mMobileTypeSingle")).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class HideNetworkSpeedSplitter : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val networkSpeedSplitterClass = "com.android.systemui.statusbar.views.NetworkSpeedSplitter".findClass(lpparam.classLoader)
|
||||
networkSpeedSplitterClass.hookAfterMethod("init") {
|
||||
if (XSPUtils.getBoolean("hide_network_speed_splitter", false)) {
|
||||
object HideNetworkSpeedSplitter : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.views.NetworkSpeedSplitter") {
|
||||
name == "init"
|
||||
}.hookAfter {
|
||||
hasEnable("hide_network_speed_splitter") {
|
||||
val textView = it.thisObject as TextView
|
||||
textView.text = " "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideNoSimIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.MiuiStatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "setNoSims", Boolean::class.javaPrimitiveType, Boolean::class.javaPrimitiveType) {
|
||||
hasEnable("hide_no_sim_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class HideSimIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "hasCorrectSubs", MutableList::class.java) {
|
||||
object HideSimIcon : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy") {
|
||||
name == "hasCorrectSubs" && parameterTypes[0] == MutableList::class.java
|
||||
}.hookBefore {
|
||||
val list = it.args[0] as MutableList<*>
|
||||
val size = list.size
|
||||
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) {
|
||||
@@ -18,4 +21,5 @@ class HideSimIcon :IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideSlaveWifiIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.policy.SlaveWifiSignalController".hookBeforeMethod(lpparam.classLoader, "updateIconState") {
|
||||
hasEnable("hide_slave_wifi_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
object HideStatusBarIcon : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarIconControllerImpl") {
|
||||
name == "setIconVisibility" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
hideIcon(it)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.phone.MiuiDripLeftStatusBarIconControllerImpl") {
|
||||
name == "setIconVisibility" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
hideIcon(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideIcon(it: XC_MethodHook.MethodHookParam) {
|
||||
//Log.d("图标名字", "handleLoadPackage: " + it.args[0])
|
||||
when (it.args[0] as String) {
|
||||
//隐藏蓝牙
|
||||
"bluetooth" -> hasEnable("hide_bluetooth_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏蓝牙电量
|
||||
"bluetooth_handsfree_battery" -> hasEnable("hide_bluetooth_battery_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏勿扰
|
||||
"zen" -> hasEnable("hide_zen_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏声音
|
||||
"volume" -> hasEnable("hide_volume_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏WIFI
|
||||
"wifi" -> hasEnable("hide_wifi_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏WIFI辅助
|
||||
"slave_wifi" -> hasEnable("hide_slave_wifi_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏飞行模式
|
||||
"airplane" -> hasEnable("hide_airplane_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏闹钟
|
||||
"alarm_clock" -> hasEnable("hide_alarm_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏定位
|
||||
"location" -> hasEnable("hide_gps_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏热点
|
||||
"hotspot" -> hasEnable("hide_hotspot_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏耳机
|
||||
"headset" -> hasEnable("hide_headset_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏VPN
|
||||
"vpn" -> hasEnable("hide_vpn_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏无SIM卡
|
||||
"no_sim" -> hasEnable("hide_no_sim_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
//隐藏NFC图标
|
||||
"nfc" -> hasEnable("hide_nfc_icon") {
|
||||
it.args[1] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,24 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import com.lt2333.simplicitytools.util.isNonNull
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class HideStatusBarNetworkSpeedSecond :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.views.NetworkSpeedView".hookBeforeMethod(lpparam.classLoader, "setNetworkSpeed", String::class.java) {
|
||||
object HideStatusBarNetworkSpeedSecond : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.views.NetworkSpeedView") {
|
||||
name == "setNetworkSpeed" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("hide_status_bar_network_speed_second") {
|
||||
it.args[0].isNonNull { s ->
|
||||
it.args[0] = (s as String)
|
||||
if (it.args[0] != null) {
|
||||
val mText = (it.args[0] as String)
|
||||
.replace("/", "")
|
||||
.replace("s", "")
|
||||
.replace("'", "")
|
||||
.replace("\'", "")
|
||||
.replace("วิ", "")
|
||||
it.args[0] = mText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideVolumeZenIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateVolumeZen") {
|
||||
hasEnable("hide_volume_zen_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideVpnIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "updateVpn") {
|
||||
hasEnable("hide_vpn_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,35 +3,40 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
|
||||
class HideWifiActivityIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState"
|
||||
"com.android.systemui.statusbar.StatusBarWifiView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
//隐藏WIFI箭头
|
||||
hasEnable("hide_wifi_activity_icon") {
|
||||
(it.thisObject.getObjectField("mWifiActivityView") as ImageView).visibility = View.INVISIBLE
|
||||
object HideWifiActivityIcon : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
//隐藏WIFI标准图标
|
||||
hasEnable("hide_wifi_standard_icon") {
|
||||
(it.thisObject.getObjectField("mWifiStandardView") as TextView).visibility = View.INVISIBLE
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookAfter {
|
||||
hide(it)
|
||||
}
|
||||
}
|
||||
|
||||
"com.android.systemui.statusbar.StatusBarWifiView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
private fun hide(it: XC_MethodHook.MethodHookParam) {
|
||||
//隐藏WIFI箭头
|
||||
hasEnable("hide_wifi_activity_icon") {
|
||||
(it.thisObject.getObjectField("mWifiActivityView") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectAs<ImageView>("mWifiActivityView")).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
//隐藏WIFI标准图标
|
||||
hasEnable("hide_wifi_standard_icon") {
|
||||
(it.thisObject.getObjectField("mWifiStandardView") as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
(it.thisObject.getObjectAs<TextView>("mWifiStandardView")).visibility =
|
||||
View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideWifiIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState"
|
||||
"com.android.systemui.statusbar.phone.MiuiStatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "updateWifiIconWithState", iconState) {
|
||||
hasEnable("hide_wifi_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import java.lang.reflect.Method
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
object LockScreenClockDisplaySeconds : HookRegister() {
|
||||
|
||||
private var nowTime: Date = Calendar.getInstance().time
|
||||
|
||||
override fun init() = hasEnable("lock_screen_clock_display_seconds") {
|
||||
findConstructor("com.miui.clock.MiuiBaseClock") {
|
||||
paramCount == 2
|
||||
}.hookAfter {
|
||||
try {
|
||||
val viewGroup = it.thisObject as LinearLayout
|
||||
val d: Method = viewGroup.javaClass.getDeclaredMethod("updateTime")
|
||||
val r = Runnable {
|
||||
d.isAccessible = true
|
||||
d.invoke(viewGroup)
|
||||
}
|
||||
|
||||
class T : TimerTask() {
|
||||
override fun run() {
|
||||
Handler(viewGroup.context.mainLooper).post(r)
|
||||
}
|
||||
}
|
||||
Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.miui.clock.MiuiLeftTopClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, false) }
|
||||
|
||||
findMethod("com.miui.clock.MiuiCenterHorizontalClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, false) }
|
||||
|
||||
findMethod("com.miui.clock.MiuiLeftTopLargeClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, false) }
|
||||
|
||||
findMethod("com.miui.clock.MiuiVerticalClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter { updateTime(it, true) }
|
||||
}
|
||||
|
||||
private fun updateTime(it: XC_MethodHook.MethodHookParam, isVertical: Boolean) {
|
||||
val textV = it.thisObject.getObjectAs<TextView>("mTimeText")
|
||||
val c: Context = textV.context
|
||||
|
||||
Log.d(
|
||||
"lock_screen_clock_display_seconds",
|
||||
"updateTime: " + it.thisObject.javaClass.simpleName
|
||||
)
|
||||
val is24 = Settings.System.getString(
|
||||
c.contentResolver,
|
||||
Settings.System.TIME_12_24
|
||||
) == "24"
|
||||
|
||||
nowTime = Calendar.getInstance().time
|
||||
|
||||
textV.text = getTime(is24, isVertical)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getTime(is24: Boolean, isVertical: Boolean): String {
|
||||
var timePattern = ""
|
||||
timePattern += if (isVertical) { //垂直
|
||||
if (is24) "HH\nmm\nss" else "hh\nmm\nss"
|
||||
} else { //水平
|
||||
if (is24) "HH:mm:ss" else "h:mm:ss"
|
||||
}
|
||||
timePattern = SimpleDateFormat(timePattern).format(nowTime)
|
||||
return timePattern
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.init.InitFields
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObject
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.lt2333.simplicitytools.R
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import java.io.BufferedReader
|
||||
import java.io.FileReader
|
||||
import java.lang.reflect.Method
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
object LockScreenCurrent : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("lock_screen_charging_current") {
|
||||
findMethod("com.android.keyguard.charge.ChargeUtils") {
|
||||
name == "getChargingHintText" && parameterCount == 3
|
||||
}.hookAfter {
|
||||
it.result = getCurrent() + "\n" + it.result
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
(it.thisObject.getObject(
|
||||
"mIndicationText"
|
||||
) as TextView).isSingleLine = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 原始代码来自 CSDN
|
||||
* https://blog.csdn.net/zhangyongfeiyong/article/details/53641809
|
||||
*/
|
||||
@SuppressLint("PrivateApi")
|
||||
private fun getCurrent(): String {
|
||||
var result = ""
|
||||
try {
|
||||
val systemProperties = Class.forName("android.os.SystemProperties")
|
||||
val get = systemProperties.getDeclaredMethod("get", String::class.java) as Method
|
||||
val platName = get.invoke(null, "ro.hardware") as String
|
||||
if (platName.startsWith("mt") || platName.startsWith("MT")) {
|
||||
val filePath =
|
||||
"/sys/class/power_supply/battery/device/FG_Battery_CurrentConsumption"
|
||||
val current = (-getMeanCurrentVal(filePath, 5, 0) / 1000.0f).roundToInt()
|
||||
result = "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA"
|
||||
} else if (platName.startsWith("qcom")) {
|
||||
val filePath = "/sys/class/power_supply/battery/current_now"
|
||||
val current = (-getMeanCurrentVal(filePath, 5, 0) / 1000.0f).roundToInt()
|
||||
result = "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平均电流值
|
||||
* 获取 filePath 文件 totalCount 次数的平均值,每次采样间隔 intervalMs 时间
|
||||
*/
|
||||
private fun getMeanCurrentVal(filePath: String, totalCount: Int, intervalMs: Int): Float {
|
||||
var meanVal = 0.0f
|
||||
if (totalCount <= 0) {
|
||||
return 0.0f
|
||||
}
|
||||
for (i in 0 until totalCount) {
|
||||
try {
|
||||
val f: Float = readFile(filePath, 0).toFloat()
|
||||
meanVal += f / totalCount
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
if (intervalMs <= 0) {
|
||||
continue
|
||||
}
|
||||
try {
|
||||
Thread.sleep(intervalMs.toLong())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return meanVal
|
||||
}
|
||||
|
||||
private fun readFile(path: String, defaultValue: Int): Int {
|
||||
try {
|
||||
val bufferedReader = BufferedReader(FileReader(path))
|
||||
val i: Int = bufferedReader.readLine().toInt(10)
|
||||
bufferedReader.close()
|
||||
return i
|
||||
} catch (_: java.lang.Exception) {
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.View.OnTouchListener
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import kotlin.math.abs
|
||||
|
||||
object LockScreenDoubleTapToSleep : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("lock_screen_double_tap_to_sleep") {
|
||||
findMethod("com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer") {
|
||||
name == "onFinishInflate"
|
||||
}.hookBefore {
|
||||
val view = it.thisObject as View
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchTime", 0L)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", 0f)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", 0f)
|
||||
view.setOnTouchListener(OnTouchListener { v, event ->
|
||||
if (event.action != MotionEvent.ACTION_DOWN) return@OnTouchListener false
|
||||
var currentTouchTime =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchTime") as Long
|
||||
var currentTouchX =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchX") as Float
|
||||
var currentTouchY =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchY") as Float
|
||||
val lastTouchTime = currentTouchTime
|
||||
val lastTouchX = currentTouchX
|
||||
val lastTouchY = currentTouchY
|
||||
currentTouchTime = System.currentTimeMillis()
|
||||
currentTouchX = event.x
|
||||
currentTouchY = event.y
|
||||
if (currentTouchTime - lastTouchTime < 250L && abs(currentTouchX - lastTouchX) < 100f && abs(
|
||||
currentTouchY - lastTouchY
|
||||
) < 100f
|
||||
) {
|
||||
val keyguardMgr =
|
||||
v.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (keyguardMgr.isKeyguardLocked) {
|
||||
XposedHelpers.callMethod(
|
||||
v.context.getSystemService(Context.POWER_SERVICE),
|
||||
"goToSleep",
|
||||
SystemClock.uptimeMillis()
|
||||
)
|
||||
}
|
||||
currentTouchTime = 0L
|
||||
currentTouchX = 0f
|
||||
currentTouchY = 0f
|
||||
}
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
view,
|
||||
"currentTouchTime",
|
||||
currentTouchTime
|
||||
)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", currentTouchX)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", currentTouchY)
|
||||
v.performClick()
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookReplace
|
||||
import com.github.kyuubiran.ezxhelper.utils.invokeMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object MaximumNumberOfNotificationIcons : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
val icons = XSPUtils.getInt("maximum_number_of_notification_icons", 3)
|
||||
val dots = XSPUtils.getInt("maximum_number_of_notification_dots", 3)
|
||||
findMethod("com.android.systemui.statusbar.phone.NotificationIconContainer") {
|
||||
name == "miuiShowNotificationIcons" && parameterCount == 1
|
||||
}.hookReplace {
|
||||
if (it.args[0] as Boolean) {
|
||||
it.thisObject.putObject("MAX_DOTS", dots)
|
||||
it.thisObject.putObject("MAX_STATIC_ICONS", icons)
|
||||
it.thisObject.putObject("MAX_VISIBLE_ICONS_ON_LOCK", icons)
|
||||
} else {
|
||||
it.thisObject.putObject("MAX_DOTS", 0)
|
||||
it.thisObject.putObject("MAX_STATIC_ICONS", 0)
|
||||
it.thisObject.putObject("MAX_VISIBLE_ICONS_ON_LOCK", 0)
|
||||
}
|
||||
it.thisObject.invokeMethod("updateState")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,36 +4,167 @@ import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClass
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.SystemProperties
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.view.WeatherView
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class NotificationWeather : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("notification_weather") {
|
||||
object NotificationWeather : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("notification_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
var mConstraintLayout: ConstraintLayout? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
"com.android.systemui.qs.MiuiNotificationHeaderView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
findMethod("com.android.systemui.qs.MiuiNotificationHeaderView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter { param ->
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val layoutParam = loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams").getConstructor(Int::class.java, Int::class.java).newInstance(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.setObjectField("bottomToTop", context.resources.getIdentifier("date_time", "id", context.packageName))
|
||||
layoutParam.setObjectField("startToEnd", context.resources.getIdentifier("big_time", "id", context.packageName))
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(context.resources.getIdentifier("notification_panel_time_date_space", "dimen", context.packageName))
|
||||
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 &&
|
||||
!SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
//获取原组件
|
||||
val big_time_ID =
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
val big_time: TextView = viewGroup.findViewById(big_time_ID)
|
||||
|
||||
val date_time_ID =
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
val date_time: TextView = viewGroup.findViewById(date_time_ID)
|
||||
|
||||
//创建新布局
|
||||
val mConstraintLayoutLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.topMargin = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"qs_control_header_tiles_margin_top",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout =
|
||||
ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp }
|
||||
|
||||
(big_time.parent as ViewGroup).addView(mConstraintLayout, 0)
|
||||
|
||||
|
||||
//从原布局中删除组件
|
||||
(big_time.parent as ViewGroup).removeView(big_time)
|
||||
(date_time.parent as ViewGroup).removeView(date_time)
|
||||
|
||||
|
||||
//添加组件至新布局
|
||||
mConstraintLayout!!.addView(big_time)
|
||||
mConstraintLayout!!.addView(date_time)
|
||||
|
||||
//组件属性
|
||||
|
||||
val date_time_LP = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = big_time_ID
|
||||
it.bottomToBottom = 0
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
it.bottomMargin = dp2px(context, 5f)
|
||||
}
|
||||
date_time.layoutParams = date_time_LP
|
||||
|
||||
|
||||
//创建天气组件
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(context.resources.getIdentifier("TextAppearance.QSControl.Date", "style", context.packageName))
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
mConstraintLayout!!.addView(mWeatherView)
|
||||
|
||||
val mWeatherView_LP = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.startToEnd = big_time_ID
|
||||
it.bottomToTop = date_time_ID
|
||||
it.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).layoutParams = mWeatherView_LP
|
||||
|
||||
} else {
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams").getConstructor(
|
||||
Int::class.java,
|
||||
Int::class.java
|
||||
).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.putObject(
|
||||
"bottomToTop",
|
||||
context.resources.getIdentifier("date_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"startToEnd",
|
||||
context.resources.getIdentifier("big_time", "id", context.packageName)
|
||||
)
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
}
|
||||
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName("com.miui.weather2", "com.miui.weather2.ActivityWeatherMain")
|
||||
component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
@@ -41,9 +172,24 @@ class NotificationWeather : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
//解决横屏重叠
|
||||
"com.android.systemui.qs.MiuiNotificationHeaderView".hookAfterMethod(lpparam.classLoader, "updateLayout") {
|
||||
val mOrientation = it.thisObject.getObjectField("mOrientation") as Int
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiNotificationHeaderView") {
|
||||
name == "updateLayout"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val mOrientation = viewGroup.getObject("mOrientation") as Int
|
||||
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
|
||||
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith(
|
||||
"DEV"
|
||||
) && !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
|
||||
) {
|
||||
if (mOrientation == 1) {
|
||||
mConstraintLayout!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mConstraintLayout!!.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
if (mOrientation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
|
||||
@@ -6,30 +6,63 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClass
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import com.lt2333.simplicitytools.view.WeatherView
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class OldNotificationWeather : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("notification_weather") {
|
||||
object OldNotificationWeather : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("notification_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
||||
findMethod("com.android.systemui.qs.MiuiQSHeaderView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val layoutParam = loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
val layoutParam =
|
||||
loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
.getConstructor(Int::class.java, Int::class.java)
|
||||
.newInstance(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) as ViewGroup.MarginLayoutParams
|
||||
.newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
|
||||
layoutParam.setObjectField("engToStart", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
||||
layoutParam.setObjectField("topToTop", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
||||
layoutParam.setObjectField("bottomToBottom", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
||||
layoutParam.putObject(
|
||||
"endToStart",
|
||||
context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"topToTop",
|
||||
context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParam.putObject(
|
||||
"bottomToBottom",
|
||||
context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(context.resources.getIdentifier("TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate", "style", context.packageName))
|
||||
setTextAppearance(
|
||||
context.resources.getIdentifier(
|
||||
"TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate",
|
||||
"style",
|
||||
context.packageName
|
||||
)
|
||||
)
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
@@ -37,7 +70,10 @@ class OldNotificationWeather : IXposedHookLoadPackage {
|
||||
try {
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName("com.miui.weather2", "com.miui.weather2.ActivityWeatherMain")
|
||||
component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
@@ -45,9 +81,12 @@ class OldNotificationWeather : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//解决横屏重叠
|
||||
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(lpparam.classLoader, "updateLayout") {
|
||||
val mOritation = it.thisObject.getObjectField("mOrientation") as Int
|
||||
findMethod("com.android.systemui.qs.MiuiQSHeaderView") {
|
||||
name == "updateLayout"
|
||||
}.hookAfter {
|
||||
val mOritation = it.thisObject.getObject("mOrientation") as Int
|
||||
if (mOritation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
@@ -55,6 +94,5 @@ class OldNotificationWeather : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.view.ViewGroup
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object OldQSCustom : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("old_qs_custom_switch") {
|
||||
val mRows = XSPUtils.getInt("qs_custom_rows", 3)
|
||||
val mRowsHorizontal = XSPUtils.getInt("qs_custom_rows_horizontal", 2)
|
||||
val mColumns = XSPUtils.getInt("qs_custom_columns", 4)
|
||||
val mColumnsUnexpanded = XSPUtils.getInt("qs_custom_columns_unexpanded", 5)
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiQuickQSPanel") {
|
||||
name == "setMaxTiles" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
//未展开时的列数
|
||||
it.args[0] = mColumnsUnexpanded
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiTileLayout") {
|
||||
name == "updateColumns"
|
||||
}.hookAfter {
|
||||
//展开时的列数
|
||||
it.thisObject.putObject("mColumns", mColumns)
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.qs.MiuiTileLayout") {
|
||||
name == "updateResources"
|
||||
}.hookAfter {
|
||||
//展开时的行数
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val mConfiguration: Configuration = viewGroup.context.resources.configuration
|
||||
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
viewGroup.putObject("mMaxAllowedRows", mRows)
|
||||
} else {
|
||||
viewGroup.putObject("mMaxAllowedRows", mRowsHorizontal)
|
||||
}
|
||||
viewGroup.requestLayout()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,34 +2,42 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObject
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class RemoveLockScreenCamera : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
object RemoveLockScreenCamera : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
//屏蔽右下角组件显示
|
||||
"com.android.systemui.statusbar.phone.KeyguardBottomAreaView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
||||
findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookAfter {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
(it.thisObject.getObjectField("mRightAffordanceViewLayout") as LinearLayout).visibility = View.GONE
|
||||
(it.thisObject.getObject("mRightAffordanceViewLayout") as LinearLayout).visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
//屏蔽滑动撞墙动画
|
||||
"com.android.keyguard.KeyguardMoveRightController".hookBeforeMethod(lpparam.classLoader, "onTouchMove", Float::class.java, Float::class.java) {
|
||||
findMethod("com.android.keyguard.KeyguardMoveRightController") {
|
||||
name == "onTouchMove" && parameterCount == 2
|
||||
}.hookBefore {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
"com.android.keyguard.KeyguardMoveRightController".hookBeforeMethod(lpparam.classLoader, "reset") {
|
||||
findMethod("com.android.keyguard.KeyguardMoveRightController") {
|
||||
name == "reset"
|
||||
}.hookBefore {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class RemoveTheLeftSideOfTheLockScreen : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.keyguard.negative.MiuiKeyguardMoveLeftViewContainer".hookBeforeMethod(lpparam.classLoader, "inflateLeftView") {
|
||||
object RemoveTheLeftSideOfTheLockScreen : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.keyguard.negative.MiuiKeyguardMoveLeftViewContainer") {
|
||||
name == "inflateLeftView"
|
||||
}.hookBefore {
|
||||
hasEnable("remove_the_left_side_of_the_lock_screen") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.callMethod
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.replaceMethod
|
||||
import com.lt2333.simplicitytools.util.setIntField
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveTheMaximumNumberOfNotificationIcons : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("remove_the_maximum_number_of_notification_icons") {
|
||||
"com.android.systemui.statusbar.phone.NotificationIconContainer".replaceMethod(lpparam.classLoader, "miuiShowNotificationIcons", Boolean::class.java) {
|
||||
if (it.args[0] as Boolean) {
|
||||
it.thisObject.setIntField("MAX_DOTS", 30)
|
||||
it.thisObject.setIntField("MAX_STATIC_ICONS", 30)
|
||||
it.thisObject.setIntField("MAX_VISIBLE_ICONS_ON_LOCK", 30)
|
||||
} else {
|
||||
it.thisObject.setIntField("MAX_DOTS", 0)
|
||||
it.thisObject.setIntField("MAX_STATIC_ICONS", 0)
|
||||
it.thisObject.setIntField("MAX_VISIBLE_ICONS_ON_LOCK", 0)
|
||||
}
|
||||
it.thisObject.callMethod("updateState")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.getObjectAs
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
object ShowWifiStandard : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "initViewState" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("show_wifi_standard") {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState") {
|
||||
name == "copyTo" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
val wifiStandard = it.thisObject.getObjectAs<Int>("wifiStandard")
|
||||
it.thisObject.putObject("showWifiStandard", wifiStandard != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.StatusBarWifiView") {
|
||||
name == "updateState" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("show_wifi_standard") {
|
||||
findMethod("com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState") {
|
||||
name == "copyTo" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
val wifiStandard = it.thisObject.getObjectAs<Int>("wifiStandard")
|
||||
it.thisObject.putObject("showWifiStandard", wifiStandard != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Typeface
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookReturnConstant
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
|
||||
object StatusBarBigMobileTypeIcon : HookRegister() {
|
||||
|
||||
private val upAndDownPosition = XSPUtils.getInt("big_mobile_type_icon_up_and_down_position", 0)
|
||||
private val leftAndRightMargin =
|
||||
XSPUtils.getInt("big_mobile_type_icon_left_and_right_margins", 0)
|
||||
private val isBold = XSPUtils.getBoolean("big_mobile_type_icon_bold", true)
|
||||
private val size = XSPUtils.getFloat("big_mobile_type_icon_size", 12.5f)
|
||||
|
||||
override fun init() = hasEnable("big_mobile_type_icon") {
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "init"
|
||||
}.hookAfter { param ->
|
||||
val statusBarMobileView = param.thisObject as ViewGroup
|
||||
val context: Context = statusBarMobileView.context
|
||||
val res: Resources = context.resources
|
||||
|
||||
//获取组件
|
||||
val mobileContainerLeftId: Int =
|
||||
res.getIdentifier("mobile_container_left", "id", "com.android.systemui")
|
||||
val mobileContainerLeft =
|
||||
statusBarMobileView.findViewById<ViewGroup>(mobileContainerLeftId)
|
||||
|
||||
val mobileTypeId: Int =
|
||||
res.getIdentifier("mobile_type", "id", "com.android.systemui")
|
||||
val mobileType = statusBarMobileView.findViewById<TextView>(mobileTypeId)
|
||||
|
||||
val mobileLeftMobileInoutId: Int = res.getIdentifier(
|
||||
"mobile_left_mobile_inout",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val mobileLeftMobileInout =
|
||||
statusBarMobileView.findViewById<ImageView>(mobileLeftMobileInoutId)
|
||||
|
||||
|
||||
//获取插入位置
|
||||
val mobileContainerRightId: Int = res.getIdentifier(
|
||||
"mobile_container_right",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val mobileContainerRight =
|
||||
statusBarMobileView.findViewById<ViewGroup>(mobileContainerRightId)
|
||||
val rightParentLayout = mobileContainerRight.parent as ViewGroup
|
||||
val mobileContainerRightIndex =
|
||||
rightParentLayout.indexOfChild(mobileContainerRight)
|
||||
|
||||
//创建新布局
|
||||
val newLinearLayoutLP = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
val newLinearlayout = LinearLayout(context).also {
|
||||
it.layoutParams = newLinearLayoutLP
|
||||
it.id = mobileContainerLeftId
|
||||
it.setPadding(leftAndRightMargin, 0, leftAndRightMargin, 0)
|
||||
}
|
||||
param.thisObject.putObject("mMobileLeftContainer", newLinearlayout)
|
||||
rightParentLayout.addView(
|
||||
newLinearlayout,
|
||||
mobileContainerRightIndex
|
||||
)
|
||||
|
||||
//将组件插入新的布局
|
||||
(mobileType.parent as ViewGroup).removeView(mobileType)
|
||||
(mobileLeftMobileInout.parent as ViewGroup).removeView(mobileLeftMobileInout)
|
||||
(mobileContainerLeft.parent as ViewGroup).removeView(mobileContainerLeft)
|
||||
|
||||
|
||||
newLinearlayout.addView(mobileType) //类型
|
||||
val mobileTypeLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).also {
|
||||
it.gravity = Gravity.CENTER_VERTICAL
|
||||
it.topMargin = upAndDownPosition
|
||||
}
|
||||
mobileType.also {
|
||||
it.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size)
|
||||
if (isBold) {
|
||||
it.typeface = Typeface.DEFAULT_BOLD
|
||||
}
|
||||
it.layoutParams = mobileTypeLp
|
||||
}
|
||||
|
||||
|
||||
newLinearlayout.addView(mobileLeftMobileInout) //箭头
|
||||
val mobileLeftMobileInoutLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mobileLeftMobileInout.also {
|
||||
it.layoutParams = mobileLeftMobileInoutLp
|
||||
}
|
||||
|
||||
//屏蔽更新布局
|
||||
findMethod("com.android.systemui.statusbar.StatusBarMobileView") {
|
||||
name == "updateMobileTypeLayout" && parameterTypes[0] == String::class.java
|
||||
}.hookReturnConstant(null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class StatusBarCurrent :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val miuiPhoneStatusBarViewClass =
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarView".findClass(lpparam.classLoader)
|
||||
miuiPhoneStatusBarViewClass.hookAfterMethod("onFinishInflate") { param ->
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
val textView = TextView(viewGroup.context).also {
|
||||
it.text = "Text"
|
||||
it.textSize = 14F
|
||||
}
|
||||
viewGroup.addView(textView)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View.OnTouchListener
|
||||
import android.view.ViewGroup
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import kotlin.math.abs
|
||||
|
||||
object StatusBarDoubleTapToSleep : HookRegister() {
|
||||
|
||||
override fun init() = hasEnable("status_bar_double_tap_to_sleep") {
|
||||
findMethod("com.android.systemui.statusbar.phone.MiuiPhoneStatusBarView") {
|
||||
name == "onFinishInflate"
|
||||
}.hookBefore {
|
||||
val view = it.thisObject as ViewGroup
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchTime", 0L)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", 0f)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", 0f)
|
||||
view.setOnTouchListener(OnTouchListener { v, event ->
|
||||
if (event.action != MotionEvent.ACTION_DOWN) return@OnTouchListener false
|
||||
var currentTouchTime =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchTime") as Long
|
||||
var currentTouchX =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchX") as Float
|
||||
var currentTouchY =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchY") as Float
|
||||
val lastTouchTime = currentTouchTime
|
||||
val lastTouchX = currentTouchX
|
||||
val lastTouchY = currentTouchY
|
||||
currentTouchTime = System.currentTimeMillis()
|
||||
currentTouchX = event.x
|
||||
currentTouchY = event.y
|
||||
if (currentTouchTime - lastTouchTime < 250L && abs(currentTouchX - lastTouchX) < 100f && abs(
|
||||
currentTouchY - lastTouchY
|
||||
) < 100f
|
||||
) {
|
||||
XposedHelpers.callMethod(
|
||||
v.context.getSystemService(Context.POWER_SERVICE),
|
||||
"goToSleep",
|
||||
SystemClock.uptimeMillis()
|
||||
)
|
||||
currentTouchTime = 0L
|
||||
currentTouchX = 0f
|
||||
currentTouchY = 0f
|
||||
}
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
view,
|
||||
"currentTouchTime",
|
||||
currentTouchTime
|
||||
)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", currentTouchX)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", currentTouchY)
|
||||
v.performClick()
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,172 +1,422 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import cn.fkj233.ui.activity.dp2px
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class StatusBarLayout : IXposedHookLoadPackage {
|
||||
object StatusBarLayout : HookRegister() {
|
||||
|
||||
private var mLeftLayout: LinearLayout? = null
|
||||
private var mRightLayout: LinearLayout? = null
|
||||
private var mCenterLayout: LinearLayout? = null
|
||||
private var status_bar: ViewGroup? = null
|
||||
private val getMode = XSPUtils.getInt("status_bar_layout_mode", 0)
|
||||
private val getHoleLocation = XSPUtils.getInt("screen_hole_location", 0)
|
||||
|
||||
private var status_bar_left = 0
|
||||
private var status_bar_top = 0
|
||||
private var status_bar_right = 0
|
||||
private var status_bar_bottom = 0
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (!XSPUtils.getBoolean("status_bar_time_center", false)) return
|
||||
|
||||
val collapsedStatusBarFragmentClass =
|
||||
"com.android.systemui.statusbar.phone.CollapsedStatusBarFragment".findClass(lpparam.classLoader)
|
||||
|
||||
collapsedStatusBarFragmentClass.hookAfterMethod(
|
||||
"onViewCreated",
|
||||
View::class.java,
|
||||
Bundle::class.java
|
||||
) { param ->
|
||||
val MiuiPhoneStatusBarView: ViewGroup =
|
||||
param.thisObject.getObjectField("mStatusBar") as ViewGroup
|
||||
val context: Context = MiuiPhoneStatusBarView.context
|
||||
val res: Resources = MiuiPhoneStatusBarView.resources
|
||||
val status_bar_ID: Int = res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val status_bar_contents_ID: Int =
|
||||
res.getIdentifier("status_bar_contents", "id", "com.android.systemui")
|
||||
val system_icon_area_ID: Int =
|
||||
res.getIdentifier("system_icon_area", "id", "com.android.systemui")
|
||||
val clock_ID: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val phone_status_bar_left_container_ID: Int =
|
||||
res.getIdentifier("phone_status_bar_left_container", "id", "com.android.systemui")
|
||||
val fullscreen_notification_icon_area_ID: Int =
|
||||
res.getIdentifier("fullscreen_notification_icon_area", "id", "com.android.systemui")
|
||||
status_bar = MiuiPhoneStatusBarView.findViewById(status_bar_ID)
|
||||
val status_bar_contents: ViewGroup =
|
||||
MiuiPhoneStatusBarView.findViewById(status_bar_contents_ID)
|
||||
if (status_bar == null) return@hookAfterMethod
|
||||
val Clock: View = MiuiPhoneStatusBarView.findViewById(clock_ID)
|
||||
val phone_status_bar_left_container: ViewGroup =
|
||||
MiuiPhoneStatusBarView.findViewById(phone_status_bar_left_container_ID)
|
||||
val fullscreen_notification_icon_area: ViewGroup =
|
||||
MiuiPhoneStatusBarView.findViewById(fullscreen_notification_icon_area_ID)
|
||||
val system_icon_area: ViewGroup =
|
||||
MiuiPhoneStatusBarView.findViewById(system_icon_area_ID)
|
||||
|
||||
(Clock.parent as ViewGroup).removeView(Clock)
|
||||
(phone_status_bar_left_container.parent as ViewGroup).removeView(
|
||||
phone_status_bar_left_container
|
||||
)
|
||||
(fullscreen_notification_icon_area.parent as ViewGroup).removeView(
|
||||
fullscreen_notification_icon_area
|
||||
)
|
||||
(system_icon_area.parent as ViewGroup).removeView(system_icon_area)
|
||||
|
||||
val mConstraintLayoutLp = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
val mConstraintLayout =
|
||||
ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp }
|
||||
|
||||
mConstraintLayout.addView(fullscreen_notification_icon_area)
|
||||
|
||||
val fullscreen_notification_icon_area_lp = FrameLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
fullscreen_notification_icon_area.layoutParams = fullscreen_notification_icon_area_lp
|
||||
|
||||
//增加一个左对齐布局
|
||||
mLeftLayout = LinearLayout(context)
|
||||
val LeftLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mLeftLayout!!.layoutParams = LeftLp
|
||||
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个居中布局
|
||||
mCenterLayout = LinearLayout(context)
|
||||
val CenterLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mCenterLayout!!.layoutParams = CenterLp
|
||||
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
|
||||
mRightLayout = LinearLayout(context)
|
||||
val RightLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mRightLayout!!.layoutParams = RightLp
|
||||
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
mLeftLayout!!.addView(phone_status_bar_left_container)
|
||||
mLeftLayout!!.addView(mConstraintLayout)
|
||||
|
||||
mCenterLayout!!.addView(Clock)
|
||||
mRightLayout!!.addView(system_icon_area)
|
||||
status_bar_contents.addView(mLeftLayout, 0)
|
||||
status_bar_contents.addView(mCenterLayout)
|
||||
status_bar_contents.addView(mRightLayout)
|
||||
|
||||
status_bar_left = status_bar!!.paddingLeft
|
||||
status_bar_top = status_bar!!.paddingTop
|
||||
status_bar_right = status_bar!!.paddingRight
|
||||
status_bar_bottom = status_bar!!.paddingBottom
|
||||
|
||||
|
||||
if (XSPUtils.getBoolean("layout_compatibility_mode", false)) {
|
||||
val custom_left_margin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (custom_left_margin != 0) {
|
||||
status_bar_left = custom_left_margin
|
||||
}
|
||||
|
||||
val custom_right_margin = XSPUtils.getInt("status_bar_right_margin", 0)
|
||||
if (custom_right_margin != 0) {
|
||||
status_bar_right = custom_right_margin
|
||||
}
|
||||
updateLayout(context)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val phoneStatusBarViewClass =
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarView".findClass(lpparam.classLoader)
|
||||
|
||||
phoneStatusBarViewClass.hookAfterMethod("updateLayoutForCutout") {
|
||||
if (XSPUtils.getBoolean("layout_compatibility_mode", false)) {
|
||||
val context = (it.thisObject as ViewGroup).context
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
private var statusBarLeft = 0
|
||||
private var statusBarTop = 0
|
||||
private var statusBarRight = 0
|
||||
private var statusBarBottom = 0
|
||||
|
||||
override fun init() {
|
||||
var mLeftLayout: LinearLayout? = null
|
||||
var mRightLayout: LinearLayout? = null
|
||||
var mCenterLayout: LinearLayout?
|
||||
var statusBar: ViewGroup? = null
|
||||
|
||||
fun updateLayout(context: Context) {
|
||||
//判断屏幕方向
|
||||
val mConfiguration: Configuration = context.resources.configuration
|
||||
if (mConfiguration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
mLeftLayout!!.setPadding(status_bar_left, 0, 0, 0)
|
||||
mRightLayout!!.setPadding(0, 0, status_bar_right, 0)
|
||||
status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom)
|
||||
mLeftLayout!!.setPadding(statusBarLeft, 0, 0, 0)
|
||||
mRightLayout!!.setPadding(0, 0, statusBarRight, 0)
|
||||
statusBar!!.setPadding(0, statusBarTop, 0, statusBarBottom)
|
||||
} else {
|
||||
//横屏状态
|
||||
mLeftLayout!!.setPadding(175, 0, 0, 0)
|
||||
mRightLayout!!.setPadding(0, 0, 175, 0)
|
||||
status_bar!!.setPadding(0, status_bar_top, 0, status_bar_bottom)
|
||||
statusBar!!.setPadding(0, statusBarTop, 0, statusBarBottom)
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否开启居中挖孔兼容模式
|
||||
if (getHoleLocation == 1) {
|
||||
findMethod("com.android.systemui.ScreenDecorations\$DisplayCutoutView") {
|
||||
name == "boundsFromDirection" && parameterCount == 3 && isStatic
|
||||
}.hookBefore {
|
||||
it.args[1] = 0
|
||||
}
|
||||
}
|
||||
|
||||
when (getMode) {
|
||||
//默认
|
||||
0 -> return
|
||||
//时钟居中
|
||||
1 -> {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter { param ->
|
||||
val miuiPhoneStatusBarView =
|
||||
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val context: Context = miuiPhoneStatusBarView.context
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val statusBarId: Int =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val statusBarContentsId: Int =
|
||||
res.getIdentifier("status_bar_contents", "id", "com.android.systemui")
|
||||
val systemIconAreaId: Int =
|
||||
res.getIdentifier("system_icon_area", "id", "com.android.systemui")
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val phoneStatusBarLeftContainerId: Int =
|
||||
res.getIdentifier(
|
||||
"phone_status_bar_left_container",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val notificationIconAreaInnerId: Int =
|
||||
res.getIdentifier(
|
||||
"notification_icon_area_inner",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
|
||||
val statusBarContents: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(statusBarContentsId)
|
||||
if (statusBar == null) return@hookAfter
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
val phoneStatusBarLeftContainer: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(phoneStatusBarLeftContainerId)
|
||||
val notificationIconAreaInner: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(notificationIconAreaInnerId)
|
||||
val systemIconArea: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(systemIconAreaId)
|
||||
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
(phoneStatusBarLeftContainer.parent as ViewGroup).removeView(
|
||||
phoneStatusBarLeftContainer
|
||||
)
|
||||
(notificationIconAreaInner.parent as ViewGroup).removeView(
|
||||
notificationIconAreaInner
|
||||
)
|
||||
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
|
||||
|
||||
val mConstraintLayout =
|
||||
ConstraintLayout(context).also {
|
||||
it.layoutParams = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout.addView(notificationIconAreaInner)
|
||||
|
||||
val fullscreen_notification_icon_area_lp = LinearLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
notificationIconAreaInner.layoutParams = fullscreen_notification_icon_area_lp
|
||||
|
||||
//增加一个左对齐布局
|
||||
mLeftLayout = LinearLayout(context)
|
||||
val leftLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mLeftLayout!!.layoutParams = leftLp
|
||||
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个居中布局
|
||||
mCenterLayout = LinearLayout(context)
|
||||
val centerLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mCenterLayout!!.layoutParams = centerLp
|
||||
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
|
||||
mRightLayout = LinearLayout(context)
|
||||
val rightLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mRightLayout!!.layoutParams = rightLp
|
||||
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
mLeftLayout!!.addView(phoneStatusBarLeftContainer)
|
||||
mLeftLayout!!.addView(mConstraintLayout)
|
||||
|
||||
mCenterLayout!!.addView(clock)
|
||||
mRightLayout!!.addView(systemIconArea)
|
||||
statusBarContents.addView(mLeftLayout, 0)
|
||||
statusBarContents.addView(mCenterLayout)
|
||||
statusBarContents.addView(mRightLayout)
|
||||
|
||||
statusBarLeft = statusBar!!.paddingLeft
|
||||
statusBarTop = statusBar!!.paddingTop
|
||||
statusBarRight = statusBar!!.paddingRight
|
||||
statusBarBottom = statusBar!!.paddingBottom
|
||||
|
||||
|
||||
if (getHoleLocation == 2) {
|
||||
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (customLeftMargin != 0) {
|
||||
statusBarLeft = customLeftMargin
|
||||
}
|
||||
|
||||
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
|
||||
if (customRightMargin != 0) {
|
||||
statusBarRight = customRightMargin
|
||||
}
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
|
||||
name == "updateLayoutForCutout"
|
||||
}.hookAfter {
|
||||
hasEnable("layout_compatibility_mode") {
|
||||
val context = (it.thisObject as ViewGroup).context
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
//时钟居右
|
||||
2 -> {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter { param ->
|
||||
val miuiPhoneStatusBarView =
|
||||
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val context: Context = miuiPhoneStatusBarView.context
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
|
||||
//组件ID
|
||||
val statusBarId: Int =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val batteryId: Int = res.getIdentifier("battery", "id", "com.android.systemui")
|
||||
|
||||
//查找组件
|
||||
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
|
||||
if (statusBar == null) return@hookAfter
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
val battery: ViewGroup = miuiPhoneStatusBarView.findViewById(batteryId)
|
||||
|
||||
//新建布局
|
||||
val rightLp = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
).also {
|
||||
it.marginStart = dp2px(context, 5f)
|
||||
}
|
||||
mRightLayout = LinearLayout(context).also {
|
||||
it.layoutParams = rightLp
|
||||
}
|
||||
|
||||
//添加布局与组件
|
||||
battery.addView(mRightLayout)
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
mRightLayout!!.addView(clock)
|
||||
}
|
||||
}
|
||||
//时钟居中+图标居左
|
||||
3 -> {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter { param ->
|
||||
val miuiPhoneStatusBarView =
|
||||
param.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val context: Context = miuiPhoneStatusBarView.context
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val statusBarId: Int =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val statusBarContentsId: Int =
|
||||
res.getIdentifier("status_bar_contents", "id", "com.android.systemui")
|
||||
val systemIconAreaId: Int =
|
||||
res.getIdentifier("system_icon_area", "id", "com.android.systemui")
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val phoneStatusBarLeftContainerId: Int =
|
||||
res.getIdentifier(
|
||||
"phone_status_bar_left_container",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val fullscreenNotificationIconAreaId: Int =
|
||||
res.getIdentifier(
|
||||
"fullscreen_notification_icon_area",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val statusIconsId: Int =
|
||||
res.getIdentifier(
|
||||
"statusIcons",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val systemIconsId: Int =
|
||||
res.getIdentifier(
|
||||
"system_icons",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
val batteryId: Int =
|
||||
res.getIdentifier(
|
||||
"battery",
|
||||
"id",
|
||||
"com.android.systemui"
|
||||
)
|
||||
|
||||
statusBar = miuiPhoneStatusBarView.findViewById(statusBarId)
|
||||
val statusBarContents: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(statusBarContentsId)
|
||||
if (statusBar == null) return@hookAfter
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
val phoneStatusBarLeftContainer: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(phoneStatusBarLeftContainerId)
|
||||
val fullscreenNotificationIconArea: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(fullscreenNotificationIconAreaId)
|
||||
val systemIconArea: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(systemIconAreaId)
|
||||
val statusIcons: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(statusIconsId)
|
||||
val systemIcons: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(systemIconsId)
|
||||
val battery: ViewGroup =
|
||||
miuiPhoneStatusBarView.findViewById(batteryId)
|
||||
|
||||
(clock.parent as ViewGroup).removeView(clock)
|
||||
(phoneStatusBarLeftContainer.parent as ViewGroup).removeView(
|
||||
phoneStatusBarLeftContainer
|
||||
)
|
||||
(systemIconArea.parent as ViewGroup).removeView(systemIconArea)
|
||||
(statusIcons.parent as ViewGroup).removeView(statusIcons)
|
||||
(systemIcons.parent as ViewGroup).removeView(systemIcons)
|
||||
(battery.parent as ViewGroup).removeView(battery)
|
||||
(fullscreenNotificationIconArea.parent as ViewGroup).removeView(
|
||||
fullscreenNotificationIconArea
|
||||
)
|
||||
|
||||
val mConstraintLayout =
|
||||
ConstraintLayout(context).also {
|
||||
it.layoutParams = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
|
||||
mConstraintLayout.addView(fullscreenNotificationIconArea)
|
||||
mConstraintLayout.addView(battery)
|
||||
|
||||
|
||||
battery.layoutParams = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
).also {
|
||||
it.endToEnd = 0
|
||||
}
|
||||
|
||||
|
||||
fullscreenNotificationIconArea.layoutParams = ConstraintLayout.LayoutParams(
|
||||
0,
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT
|
||||
).also {
|
||||
it.startToEnd = batteryId
|
||||
it.endToEnd = 0
|
||||
}
|
||||
fullscreenNotificationIconArea.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
||||
|
||||
|
||||
//增加一个左对齐布局
|
||||
mLeftLayout = LinearLayout(context)
|
||||
val leftLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mLeftLayout!!.layoutParams = leftLp
|
||||
mLeftLayout!!.gravity = Gravity.START or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个居中布局
|
||||
mCenterLayout = LinearLayout(context)
|
||||
val centerLp: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
mCenterLayout!!.layoutParams = centerLp
|
||||
mCenterLayout!!.gravity = Gravity.CENTER or Gravity.CENTER_VERTICAL
|
||||
|
||||
//增加一个右布局
|
||||
mRightLayout = LinearLayout(context)
|
||||
val rightLp: LinearLayout.LayoutParams =
|
||||
LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f)
|
||||
mRightLayout!!.layoutParams = rightLp
|
||||
mRightLayout!!.gravity = Gravity.END or Gravity.CENTER_VERTICAL
|
||||
|
||||
|
||||
mLeftLayout!!.addView(phoneStatusBarLeftContainer)
|
||||
mLeftLayout!!.addView(statusIcons)
|
||||
statusIcons.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
||||
|
||||
mCenterLayout!!.addView(clock)
|
||||
|
||||
mRightLayout!!.addView(mConstraintLayout)
|
||||
fullscreenNotificationIconArea.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
||||
|
||||
|
||||
statusBarContents.addView(mLeftLayout, 0)
|
||||
statusBarContents.addView(mCenterLayout)
|
||||
statusBarContents.addView(mRightLayout)
|
||||
|
||||
|
||||
|
||||
statusBarLeft = statusBar!!.paddingLeft
|
||||
statusBarTop = statusBar!!.paddingTop
|
||||
statusBarRight = statusBar!!.paddingRight
|
||||
statusBarBottom = statusBar!!.paddingBottom
|
||||
|
||||
|
||||
if (getHoleLocation == 2) {
|
||||
val customLeftMargin = XSPUtils.getInt("status_bar_left_margin", 0)
|
||||
if (customLeftMargin != 0) {
|
||||
statusBarLeft = customLeftMargin
|
||||
}
|
||||
|
||||
val customRightMargin = XSPUtils.getInt("status_bar_right_margin", 0)
|
||||
if (customRightMargin != 0) {
|
||||
statusBarRight = customRightMargin
|
||||
}
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
//兼容模式
|
||||
findMethod("com.android.systemui.statusbar.phone.PhoneStatusBarView") {
|
||||
name == "updateLayoutForCutout"
|
||||
}.hookAfter {
|
||||
if (getHoleLocation == 2) {
|
||||
val context = (it.thisObject as ViewGroup).context
|
||||
updateLayout(context)
|
||||
}
|
||||
}
|
||||
|
||||
//解决重叠
|
||||
findMethod("com.android.systemui.statusbar.phone.MiuiCollapsedStatusBarFragment") {
|
||||
name == "showClock" && parameterTypes[0] == Boolean::class.java
|
||||
}.hookAfter {
|
||||
val miuiPhoneStatusBarView = it.thisObject.getObjectAs<ViewGroup>("mStatusBar")
|
||||
val res = miuiPhoneStatusBarView.resources
|
||||
val status_bar_ID =
|
||||
res.getIdentifier("status_bar", "id", "com.android.systemui")
|
||||
val status_bar = miuiPhoneStatusBarView.findViewById<ViewGroup>(status_bar_ID)
|
||||
//非锁屏下整个状态栏布局
|
||||
val keyguardMgr =
|
||||
status_bar.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (keyguardMgr.isKeyguardLocked) {
|
||||
status_bar!!.visibility = View.GONE
|
||||
} else {
|
||||
status_bar!!.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class StatusBarNetworkSpeedRefreshSpeed :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.systemui.statusbar.policy.NetworkSpeedController".hookBeforeMethod(lpparam.classLoader, "postUpdateNetworkSpeedDelay", Long::class.java) {
|
||||
object StatusBarNetworkSpeedRefreshSpeed : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.systemui.statusbar.policy.NetworkSpeedController") {
|
||||
name == "postUpdateNetworkSpeedDelay" && parameterTypes[0] == Long::class.java
|
||||
}.hookBefore {
|
||||
hasEnable("status_bar_network_speed_refresh_speed") {
|
||||
it.args[0] = 1000L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,23 +2,25 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.os.Handler
|
||||
import android.provider.Settings
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.github.kyuubiran.ezxhelper.utils.*
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hookAfterConstructor
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
import java.lang.reflect.Method
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
object StatusBarTimeCustomization : HookRegister() {
|
||||
|
||||
private val getMode = XSPUtils.getInt("custom_clock_mode", 0)
|
||||
private val getClockSize = XSPUtils.getInt("status_bar_clock_size", 0)
|
||||
private val getClockDoubleSize = XSPUtils.getInt("status_bar_clock_double_line_size", 0)
|
||||
private val isYear = XSPUtils.getBoolean("status_bar_time_year", false)
|
||||
private val isMonth = XSPUtils.getBoolean("status_bar_time_month", false)
|
||||
private val isDay = XSPUtils.getBoolean("status_bar_time_day", false)
|
||||
@@ -28,33 +30,45 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
private val isSecond = XSPUtils.getBoolean("status_bar_time_seconds", false)
|
||||
private val isDoubleHour = XSPUtils.getBoolean("status_bar_time_double_hour", false)
|
||||
private val isPeriod = XSPUtils.getBoolean("status_bar_time_period", true)
|
||||
private val getClockSize = XSPUtils.getInt("status_bar_clock_size", 0)
|
||||
private val isOpen = XSPUtils.getBoolean("custom_clock_switch", false)
|
||||
private val getClockDoubleSize = XSPUtils.getInt("status_bar_clock_double_line_size", 0)
|
||||
private var now_time: Date? = null
|
||||
private val isCenterAlign =
|
||||
XSPUtils.getBoolean("status_bar_time_double_line_center_align", false)
|
||||
|
||||
//极客模式
|
||||
private val getGeekClockSize = XSPUtils.getInt("status_bar_clock_size_geek", 0)
|
||||
private val getGeekFormat = XSPUtils.getString("custom_clock_format_geek", "HH:mm:ss")
|
||||
private val isGeekCenterAlign =
|
||||
XSPUtils.getBoolean("status_bar_time_center_align_geek", false)
|
||||
|
||||
private lateinit var nowTime: Date
|
||||
private var str = ""
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (isOpen) {
|
||||
override fun init() {
|
||||
when (getMode) {
|
||||
//预设模式
|
||||
1 -> {
|
||||
var c: Context? = null
|
||||
val miuiClockClass = "com.android.systemui.statusbar.views.MiuiClock".findClass(lpparam.classLoader)
|
||||
miuiClockClass.hookAfterConstructor(Context::class.java, AttributeSet::class.java, Integer.TYPE) {
|
||||
|
||||
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
paramCount == 3
|
||||
}.hookAfter {
|
||||
try {
|
||||
c = it.args[0] as Context
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfter
|
||||
textV.isSingleLine = false
|
||||
if (isDoubleLine) {
|
||||
str = "\n"
|
||||
var clock_double_line_size = 7F
|
||||
var clockDoubleLineSize = 7F
|
||||
if (getClockDoubleSize != 0) {
|
||||
clock_double_line_size = getClockDoubleSize.toFloat()
|
||||
clockDoubleLineSize = getClockDoubleSize.toFloat()
|
||||
}
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clock_double_line_size)
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockDoubleLineSize)
|
||||
textV.setLineSpacing(0F, 0.8F)
|
||||
} else {
|
||||
if (getClockSize != 0) {
|
||||
val clock_size = getClockSize.toFloat()
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clock_size)
|
||||
val clockSize = getClockSize.toFloat()
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockSize)
|
||||
}
|
||||
}
|
||||
val d: Method = textV.javaClass.getDeclaredMethod("updateTime")
|
||||
@@ -62,33 +76,121 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
d.isAccessible = true
|
||||
d.invoke(textV)
|
||||
}
|
||||
|
||||
class T : TimerTask() {
|
||||
override fun run() {
|
||||
Handler(textV.context.mainLooper).post(r)
|
||||
}
|
||||
}
|
||||
if (textV.resources.getResourceEntryName(textV.id) == "clock")
|
||||
Timer().scheduleAtFixedRate(T(), 1000 - System.currentTimeMillis() % 1000, 1000)
|
||||
} catch (e: java.lang.Exception) {
|
||||
Timer().scheduleAtFixedRate(
|
||||
T(),
|
||||
1000 - System.currentTimeMillis() % 1000,
|
||||
1000
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
miuiClockClass.hookAfterMethod("updateTime") {
|
||||
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter {
|
||||
try {
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
|
||||
val t = Settings.System.getString(c!!.contentResolver, Settings.System.TIME_12_24)
|
||||
now_time = Calendar.getInstance().time
|
||||
textV.text = getDate(c!!, t) + str + getTime(c!!, t)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
val t = Settings.System.getString(
|
||||
c!!.contentResolver,
|
||||
Settings.System.TIME_12_24
|
||||
)
|
||||
val is24 = t == "24"
|
||||
nowTime = Calendar.getInstance().time
|
||||
textV.text = getDate(c!!) + str + getTime(c!!, is24)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCenterAlign) {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter {
|
||||
val miuiPhoneStatusBarView =
|
||||
it.thisObject.getObject("mStatusBar") as ViewGroup
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
clock.gravity = Gravity.CENTER
|
||||
}
|
||||
}
|
||||
}
|
||||
//极客模式
|
||||
2 -> {
|
||||
var c: Context? = null
|
||||
|
||||
findConstructor("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
paramCount == 3
|
||||
}.hookAfter {
|
||||
try {
|
||||
c = it.args[0] as Context
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) != "clock") return@hookAfter
|
||||
textV.isSingleLine = false
|
||||
textV.setLineSpacing(0F, 0.8F)
|
||||
if (getGeekClockSize != 0) {
|
||||
val clockSize = getGeekClockSize.toFloat()
|
||||
textV.setTextSize(TypedValue.COMPLEX_UNIT_DIP, clockSize)
|
||||
}
|
||||
|
||||
val d: Method = textV.javaClass.getDeclaredMethod("updateTime")
|
||||
val r = Runnable {
|
||||
d.isAccessible = true
|
||||
d.invoke(textV)
|
||||
}
|
||||
|
||||
class T : TimerTask() {
|
||||
override fun run() {
|
||||
Handler(textV.context.mainLooper).post(r)
|
||||
}
|
||||
}
|
||||
Timer().scheduleAtFixedRate(
|
||||
T(),
|
||||
1000 - System.currentTimeMillis() % 1000,
|
||||
1000
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
findMethod("com.android.systemui.statusbar.views.MiuiClock") {
|
||||
name == "updateTime"
|
||||
}.hookAfter {
|
||||
try {
|
||||
val textV = it.thisObject as TextView
|
||||
if (textV.resources.getResourceEntryName(textV.id) == "clock") {
|
||||
nowTime = Calendar.getInstance().time
|
||||
textV.text = SimpleDateFormat(getGeekFormat).format(nowTime)
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isGeekCenterAlign) {
|
||||
findMethod("com.android.systemui.statusbar.phone.CollapsedStatusBarFragment") {
|
||||
name == "onViewCreated" && parameterCount == 2
|
||||
}.hookAfter {
|
||||
val miuiPhoneStatusBarView =
|
||||
it.thisObject.getObject("mStatusBar") as ViewGroup
|
||||
val res: Resources = miuiPhoneStatusBarView.resources
|
||||
val clockId: Int = res.getIdentifier("clock", "id", "com.android.systemui")
|
||||
val clock: TextView = miuiPhoneStatusBarView.findViewById(clockId)
|
||||
clock.gravity = Gravity.CENTER
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getDate(context: Context, t: String): String {
|
||||
private fun getDate(context: Context): String {
|
||||
var datePattern = ""
|
||||
val isZh = isZh(context)
|
||||
|
||||
@@ -124,17 +226,17 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
if (!isHideSpace) datePattern = "$datePattern "
|
||||
}
|
||||
}
|
||||
datePattern = SimpleDateFormat(datePattern).format(now_time)
|
||||
datePattern = SimpleDateFormat(datePattern).format(nowTime)
|
||||
return datePattern
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun getTime(context: Context, t: String): String {
|
||||
private fun getTime(context: Context, t: Boolean): String {
|
||||
var timePattern = ""
|
||||
val isZh = isZh(context)
|
||||
timePattern += if (t == "24") "HH:mm" else "h:mm"
|
||||
timePattern += if (t) "HH:mm" else "h:mm"
|
||||
if (isSecond) timePattern += ":ss"
|
||||
timePattern = SimpleDateFormat(timePattern).format(now_time)
|
||||
timePattern = SimpleDateFormat(timePattern).format(nowTime)
|
||||
if (isZh) timePattern = getPeriod(isZh) + timePattern else timePattern += getPeriod(isZh)
|
||||
timePattern = getDoubleHour() + timePattern
|
||||
return timePattern
|
||||
@@ -145,7 +247,7 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
var period = ""
|
||||
if (isPeriod) {
|
||||
if (isZh) {
|
||||
when (SimpleDateFormat("HH").format(now_time)) {
|
||||
when (SimpleDateFormat("HH").format(nowTime)) {
|
||||
"00", "01", "02", "03", "04", "05" -> {
|
||||
period = "凌晨"
|
||||
}
|
||||
@@ -166,7 +268,7 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
period = SimpleDateFormat("a").format(now_time)
|
||||
period = SimpleDateFormat("a").format(nowTime)
|
||||
if (!isHideSpace) {
|
||||
period = " $period"
|
||||
}
|
||||
@@ -180,7 +282,7 @@ class StatusBarTimeCustomization : IXposedHookLoadPackage {
|
||||
private fun getDoubleHour(): String {
|
||||
var doubleHour = ""
|
||||
if (isDoubleHour) {
|
||||
when (SimpleDateFormat("HH").format(now_time)) {
|
||||
when (SimpleDateFormat("HH").format(nowTime)) {
|
||||
"23", "00" -> {
|
||||
doubleHour = "子时"
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookAfter
|
||||
import com.github.kyuubiran.ezxhelper.utils.putObject
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class WaveCharge : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||
object WaveCharge: HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
hasEnable("enable_wave_charge_animation") {
|
||||
findMethod("com.android.keyguard.charge.ChargeUtils") {
|
||||
name == "supportWaveChargeAnimation"
|
||||
}.hookMethod {
|
||||
after { param ->
|
||||
}.hookAfter {
|
||||
val ex = Throwable()
|
||||
val stackElement = ex.stackTrace
|
||||
var mResult = false
|
||||
@@ -29,16 +28,14 @@ class WaveCharge : IXposedHookLoadPackage {
|
||||
}
|
||||
}
|
||||
}
|
||||
param.result = mResult
|
||||
}
|
||||
it.result = mResult
|
||||
}
|
||||
findMethod("com.android.keyguard.charge.wave.WaveView") {
|
||||
name == "updateWaveHeight"
|
||||
}.hookMethod {
|
||||
after { param ->
|
||||
XposedHelpers.setIntField(param.thisObject, "mWaveXOffset", 0)
|
||||
}
|
||||
}.hookAfter {
|
||||
it.thisObject.putObject("mWaveXOffset", 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package com.lt2333.simplicitytools.hook.app.thememanager
|
||||
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.github.kyuubiran.ezxhelper.utils.findMethod
|
||||
import com.github.kyuubiran.ezxhelper.utils.hookBefore
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
|
||||
|
||||
class RemoveAds : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
"com.android.thememanager.basemodule.ad.model.AdInfoResponse".hookBeforeMethod(lpparam.classLoader, "isAdValid", "com.android.thememanager.basemodule.ad.model.AdInfo".findClass(lpparam.classLoader)) {
|
||||
object RemoveAds : HookRegister() {
|
||||
|
||||
override fun init() {
|
||||
findMethod("com.android.thememanager.basemodule.ad.model.AdInfoResponse") {
|
||||
name == "isAdValid" && parameterCount == 1
|
||||
}.hookBefore {
|
||||
hasEnable("remove_thememanager_ads") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,12 @@ package com.lt2333.simplicitytools.tile
|
||||
import android.service.quicksettings.Tile
|
||||
import android.service.quicksettings.TileService
|
||||
|
||||
class AllowScreenshots : TileService(){
|
||||
class AllowScreenshots : TileService() {
|
||||
val key = "disable_flag_secure"
|
||||
|
||||
override fun onClick() {
|
||||
super.onClick()
|
||||
try {
|
||||
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
|
||||
val prefEditor = pref.edit()
|
||||
if (pref.getBoolean(key, false)) {
|
||||
@@ -19,10 +20,13 @@ class AllowScreenshots : TileService(){
|
||||
}
|
||||
prefEditor.commit()
|
||||
qsTile.updateTile()
|
||||
} catch (e: SecurityException) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartListening() {
|
||||
super.onStartListening()
|
||||
try {
|
||||
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
|
||||
if (pref.getBoolean(key, false)) {
|
||||
qsTile.state = Tile.STATE_ACTIVE
|
||||
@@ -30,5 +34,7 @@ class AllowScreenshots : TileService(){
|
||||
qsTile.state = Tile.STATE_INACTIVE
|
||||
}
|
||||
qsTile.updateTile()
|
||||
} catch (e: SecurityException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ class LockMaxFpsTile : TileService() {
|
||||
|
||||
override fun onClick() {
|
||||
super.onClick()
|
||||
try {
|
||||
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
|
||||
val prefEditor = pref.edit()
|
||||
if (pref.getBoolean(key, false)) {
|
||||
@@ -20,10 +21,13 @@ class LockMaxFpsTile : TileService() {
|
||||
}
|
||||
prefEditor.commit()
|
||||
qsTile.updateTile()
|
||||
} catch (e: SecurityException) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartListening() {
|
||||
super.onStartListening()
|
||||
try {
|
||||
val pref = getSharedPreferences("config", MODE_WORLD_READABLE)
|
||||
if (pref.getBoolean(key, false)) {
|
||||
qsTile.state = Tile.STATE_ACTIVE
|
||||
@@ -31,6 +35,7 @@ class LockMaxFpsTile : TileService() {
|
||||
qsTile.state = Tile.STATE_INACTIVE
|
||||
}
|
||||
qsTile.updateTile()
|
||||
} catch (e: SecurityException) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,502 +0,0 @@
|
||||
package com.lt2333.simplicitytools.util
|
||||
|
||||
import android.content.res.XResources
|
||||
import android.util.Log
|
||||
import dalvik.system.BaseDexClassLoader
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XC_MethodReplacement
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LayoutInflated
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Member
|
||||
import java.util.*
|
||||
|
||||
const val TAG = "SimplicityTools"
|
||||
|
||||
fun log(any: Any?, online: Boolean = false) {
|
||||
val msg: String = if (any is Throwable) Log.getStackTraceString(any) else any.toString()
|
||||
// Log.d(TAG, msg)
|
||||
XposedBridge.log("$TAG: $msg")
|
||||
}
|
||||
|
||||
typealias MethodHookParam = XC_MethodHook.MethodHookParam
|
||||
typealias Replacer = (XC_MethodHook.MethodHookParam) -> Any?
|
||||
typealias Hooker = (XC_MethodHook.MethodHookParam) -> Unit
|
||||
|
||||
fun Class<*>.hookMethod(method: String?, vararg args: Any?) = try {
|
||||
XposedHelpers.findAndHookMethod(this, method, *args)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
fun Member.hookMethod(callback: XC_MethodHook) = try {
|
||||
XposedBridge.hookMethod(this, callback)
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun XC_MethodHook.MethodHookParam.callHooker(crossinline hooker: Hooker) = try {
|
||||
hooker(this)
|
||||
} catch (e: Throwable) {
|
||||
log("Error occurred calling hooker on ${this.method}")
|
||||
log(e)
|
||||
}
|
||||
|
||||
inline fun XC_MethodHook.MethodHookParam.callReplacer(crossinline replacer: Replacer) = try {
|
||||
replacer(this)
|
||||
} catch (e: Throwable) {
|
||||
log("Error occurred calling replacer on ${this.method}")
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun Member.replaceMethod(crossinline replacer: Replacer) =
|
||||
hookMethod(object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callReplacer(replacer)
|
||||
})
|
||||
|
||||
inline fun Member.hookAfterMethod(crossinline hooker: Hooker) =
|
||||
hookMethod(object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Member.hookBeforeMethod(crossinline hooker: (XC_MethodHook.MethodHookParam) -> Unit) =
|
||||
hookMethod(object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookBeforeMethod(
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = hookMethod(method, *args, object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookAfterMethod(
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = hookMethod(method, *args, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceMethod(
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline replacer: Replacer
|
||||
) = hookMethod(method, *args, object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callReplacer(replacer)
|
||||
})
|
||||
|
||||
fun Class<*>.hookAllMethods(methodName: String?, hooker: XC_MethodHook): Set<XC_MethodHook.Unhook> =
|
||||
try {
|
||||
XposedBridge.hookAllMethods(this, methodName, hooker)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
emptySet()
|
||||
}
|
||||
|
||||
inline fun Class<*>.hookBeforeAllMethods(methodName: String?, crossinline hooker: Hooker) =
|
||||
hookAllMethods(methodName, object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookAfterAllMethods(methodName: String?, crossinline hooker: Hooker) =
|
||||
hookAllMethods(methodName, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceAfterAllMethods(methodName: String?, crossinline replacer: Replacer) =
|
||||
hookAllMethods(methodName, object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callReplacer(replacer)
|
||||
})
|
||||
|
||||
fun Class<*>.hookConstructor(vararg args: Any?) = try {
|
||||
XposedHelpers.findAndHookConstructor(this, *args)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun Class<*>.hookBeforeConstructor(vararg args: Any?, crossinline hooker: Hooker) =
|
||||
hookConstructor(*args, object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookAfterConstructor(vararg args: Any?, crossinline hooker: Hooker) =
|
||||
hookConstructor(*args, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceConstructor(vararg args: Any?, crossinline hooker: Hooker) =
|
||||
hookConstructor(*args, object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
fun Class<*>.hookAllConstructors(hooker: XC_MethodHook): Set<XC_MethodHook.Unhook> = try {
|
||||
XposedBridge.hookAllConstructors(this, hooker)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
emptySet()
|
||||
}
|
||||
|
||||
inline fun Class<*>.hookAfterAllConstructors(crossinline hooker: Hooker) =
|
||||
hookAllConstructors(object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookBeforeAllConstructors(crossinline hooker: Hooker) =
|
||||
hookAllConstructors(object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceAfterAllConstructors(crossinline hooker: Hooker) =
|
||||
hookAllConstructors(object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
fun String.hookMethod(classLoader: ClassLoader, method: String?, vararg args: Any?) = try {
|
||||
findClass(classLoader).hookMethod(method, *args)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun String.hookBeforeMethod(
|
||||
classLoader: ClassLoader,
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = try {
|
||||
findClass(classLoader).hookBeforeMethod(method, *args, hooker = hooker)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun String.hookAfterMethod(
|
||||
classLoader: ClassLoader,
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = try {
|
||||
findClass(classLoader).hookAfterMethod(method, *args, hooker = hooker)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun String.replaceMethod(
|
||||
classLoader: ClassLoader,
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline replacer: Replacer
|
||||
) = try {
|
||||
findClass(classLoader).replaceMethod(method, *args, replacer = replacer)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
fun XC_MethodHook.MethodHookParam.invokeOriginalMethod(): Any? =
|
||||
XposedBridge.invokeOriginalMethod(method, thisObject, args)
|
||||
|
||||
inline fun <T, R> T.runCatchingOrNull(func: T.() -> R?) = try {
|
||||
func()
|
||||
} catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
|
||||
fun Any.getObjectField(field: String?): Any? = XposedHelpers.getObjectField(this, field)
|
||||
|
||||
fun Any.getObjectFieldOrNull(field: String?): Any? = runCatchingOrNull {
|
||||
XposedHelpers.getObjectField(this, field)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getObjectFieldAs(field: String?) = XposedHelpers.getObjectField(this, field) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getObjectFieldOrNullAs(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getObjectField(this, field) as T
|
||||
}
|
||||
|
||||
fun Any.getIntField(field: String?) = XposedHelpers.getIntField(this, field)
|
||||
|
||||
fun Any.getIntFieldOrNull(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getIntField(this, field)
|
||||
}
|
||||
|
||||
fun Any.getLongField(field: String?) = XposedHelpers.getLongField(this, field)
|
||||
|
||||
fun Any.getLongFieldOrNull(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getLongField(this, field)
|
||||
}
|
||||
|
||||
fun Any.getBooleanFieldOrNull(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getBooleanField(this, field)
|
||||
}
|
||||
|
||||
fun Any.callMethod(methodName: String?, vararg args: Any?): Any? =
|
||||
XposedHelpers.callMethod(this, methodName, *args)
|
||||
|
||||
fun Any.callMethodOrNull(methodName: String?, vararg args: Any?): Any? = runCatchingOrNull {
|
||||
XposedHelpers.callMethod(this, methodName, *args)
|
||||
}
|
||||
|
||||
fun Class<*>.callStaticMethod(methodName: String?, vararg args: Any?): Any? =
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args)
|
||||
|
||||
fun Class<*>.callStaticMethodOrNull(methodName: String?, vararg args: Any?): Any? =
|
||||
runCatchingOrNull {
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.callStaticMethodAs(methodName: String?, vararg args: Any?) =
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.callStaticMethodOrNullAs(methodName: String?, vararg args: Any?) =
|
||||
runCatchingOrNull {
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args) as T
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.getStaticObjectFieldAs(field: String?) = XposedHelpers.getStaticObjectField(
|
||||
this,
|
||||
field
|
||||
) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.getStaticObjectFieldOrNullAs(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getStaticObjectField(this, field) as T
|
||||
}
|
||||
|
||||
fun Class<*>.getStaticObjectField(field: String?): Any? =
|
||||
XposedHelpers.getStaticObjectField(this, field)
|
||||
|
||||
fun Class<*>.getStaticObjectFieldOrNull(field: String?): Any? = runCatchingOrNull {
|
||||
XposedHelpers.getStaticObjectField(this, field)
|
||||
}
|
||||
|
||||
fun Class<*>.setStaticObjectField(field: String?, obj: Any?) = apply {
|
||||
XposedHelpers.setStaticObjectField(this, field, obj)
|
||||
}
|
||||
|
||||
fun Class<*>.setStaticObjectFieldIfExist(field: String?, obj: Any?) = apply {
|
||||
try {
|
||||
XposedHelpers.setStaticObjectField(this, field, obj)
|
||||
} catch (ignored: Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T> Class<*>.findFieldByExactType(): Field? =
|
||||
XposedHelpers.findFirstFieldByExactType(this, T::class.java)
|
||||
|
||||
fun Class<*>.findFieldByExactType(type: Class<*>): Field? =
|
||||
XposedHelpers.findFirstFieldByExactType(this, type)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.callMethodAs(methodName: String?, vararg args: Any?) =
|
||||
XposedHelpers.callMethod(this, methodName, *args) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.callMethodOrNullAs(methodName: String?, vararg args: Any?) = runCatchingOrNull {
|
||||
XposedHelpers.callMethod(this, methodName, *args) as T
|
||||
}
|
||||
|
||||
fun Any.callMethod(methodName: String?, parameterTypes: Array<Class<*>>, vararg args: Any?): Any? =
|
||||
XposedHelpers.callMethod(this, methodName, parameterTypes, *args)
|
||||
|
||||
fun Any.callMethodOrNull(
|
||||
methodName: String?,
|
||||
parameterTypes: Array<Class<*>>,
|
||||
vararg args: Any?
|
||||
): Any? = runCatchingOrNull {
|
||||
XposedHelpers.callMethod(this, methodName, parameterTypes, *args)
|
||||
}
|
||||
|
||||
fun Class<*>.callStaticMethod(
|
||||
methodName: String?,
|
||||
parameterTypes: Array<Class<*>>,
|
||||
vararg args: Any?
|
||||
): Any? = XposedHelpers.callStaticMethod(this, methodName, parameterTypes, *args)
|
||||
|
||||
fun Class<*>.callStaticMethodOrNull(
|
||||
methodName: String?,
|
||||
parameterTypes: Array<Class<*>>,
|
||||
vararg args: Any?
|
||||
): Any? = runCatchingOrNull {
|
||||
XposedHelpers.callStaticMethod(this, methodName, parameterTypes, *args)
|
||||
}
|
||||
|
||||
fun String.findClass(classLoader: ClassLoader?): Class<*> =
|
||||
XposedHelpers.findClass(this, classLoader)
|
||||
|
||||
fun String.findClassOrNull(classLoader: ClassLoader?): Class<*>? =
|
||||
XposedHelpers.findClassIfExists(this, classLoader)
|
||||
|
||||
fun Class<*>.new(vararg args: Any?): Any = XposedHelpers.newInstance(this, *args)
|
||||
|
||||
fun Class<*>.new(parameterTypes: Array<Class<*>>, vararg args: Any?): Any =
|
||||
XposedHelpers.newInstance(this, parameterTypes, *args)
|
||||
|
||||
fun Class<*>.findField(field: String?): Field = XposedHelpers.findField(this, field)
|
||||
|
||||
fun Class<*>.findFieldOrNull(field: String?): Field? = XposedHelpers.findFieldIfExists(this, field)
|
||||
|
||||
fun <T> T.setIntField(field: String?, value: Int) = apply {
|
||||
XposedHelpers.setIntField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setLongField(field: String?, value: Long) = apply {
|
||||
XposedHelpers.setLongField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setFloatField(field: String?, value: Float) = apply {
|
||||
XposedHelpers.setFloatField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setObjectField(field: String?, value: Any?) = apply {
|
||||
XposedHelpers.setObjectField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setBooleanField(field: String?, value: Boolean) = apply {
|
||||
XposedHelpers.setBooleanField(this, field, value)
|
||||
}
|
||||
|
||||
inline fun XResources.hookLayout(
|
||||
id: Int,
|
||||
crossinline hooker: (XC_LayoutInflated.LayoutInflatedParam) -> Unit
|
||||
) {
|
||||
try {
|
||||
hookLayout(id, object : XC_LayoutInflated() {
|
||||
override fun handleLayoutInflated(liparam: LayoutInflatedParam) {
|
||||
try {
|
||||
hooker(liparam)
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun XResources.hookLayout(
|
||||
pkg: String,
|
||||
type: String,
|
||||
name: String,
|
||||
crossinline hooker: (XC_LayoutInflated.LayoutInflatedParam) -> Unit
|
||||
) {
|
||||
try {
|
||||
val id = getIdentifier(name, type, pkg)
|
||||
hookLayout(id, hooker)
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun Class<*>.findFirstFieldByExactType(type: Class<*>): Field =
|
||||
XposedHelpers.findFirstFieldByExactType(this, type)
|
||||
|
||||
fun Class<*>.findFirstFieldByExactTypeOrNull(type: Class<*>?): Field? = runCatchingOrNull {
|
||||
XposedHelpers.findFirstFieldByExactType(this, type)
|
||||
}
|
||||
|
||||
fun Any.getFirstFieldByExactType(type: Class<*>): Any? =
|
||||
javaClass.findFirstFieldByExactType(type).get(this)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getFirstFieldByExactTypeAs(type: Class<*>) =
|
||||
javaClass.findFirstFieldByExactType(type).get(this) as? T
|
||||
|
||||
inline fun <reified T : Any> Any.getFirstFieldByExactType() =
|
||||
javaClass.findFirstFieldByExactType(T::class.java).get(this) as? T
|
||||
|
||||
fun Any.getFirstFieldByExactTypeOrNull(type: Class<*>?): Any? = runCatchingOrNull {
|
||||
javaClass.findFirstFieldByExactTypeOrNull(type)?.get(this)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getFirstFieldByExactTypeOrNullAs(type: Class<*>?) =
|
||||
getFirstFieldByExactTypeOrNull(type) as? T
|
||||
|
||||
inline fun <reified T> Any.getFirstFieldByExactTypeOrNull() =
|
||||
getFirstFieldByExactTypeOrNull(T::class.java) as? T
|
||||
|
||||
fun ClassLoader.allClassesList(): List<String> {
|
||||
var classLoader = this
|
||||
while (classLoader !is BaseDexClassLoader) {
|
||||
if (classLoader.parent != null) classLoader = classLoader.parent
|
||||
else return emptyList()
|
||||
}
|
||||
return classLoader.getObjectField("pathList")
|
||||
?.getObjectFieldAs<Array<Any>>("dexElements")
|
||||
?.flatMap {
|
||||
it.getObjectField("dexFile")?.callMethodAs<Enumeration<String>>("entries")?.toList()
|
||||
.orEmpty()
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
inline fun ClassLoader.findDexClassLoader(): BaseDexClassLoader? {
|
||||
var classLoader = this
|
||||
while (classLoader !is BaseDexClassLoader) {
|
||||
if (classLoader.parent != null) classLoader = classLoader.parent
|
||||
else return null
|
||||
}
|
||||
return classLoader
|
||||
}
|
||||
|
||||
inline fun <T> T?.isNull(crossinline isNull: () -> Unit):T? {
|
||||
if (this == null) isNull()
|
||||
return this
|
||||
}
|
||||
|
||||
inline fun <T> T?.isNonNull(crossinline nonNull: (T) -> Unit): T? {
|
||||
if (this != null) nonNull(this)
|
||||
return this
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class ShellUtils {
|
||||
* @see ShellUtils#execCommand(String[], boolean, boolean)
|
||||
*/
|
||||
public static CommandResult execCommand(String command, boolean isRoot) {
|
||||
return execCommand(new String[] {command}, isRoot, true);
|
||||
return execCommand(new String[]{command}, isRoot, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ public class ShellUtils {
|
||||
* @see ShellUtils#execCommand(String[], boolean, boolean)
|
||||
*/
|
||||
public static CommandResult execCommand(List<String> commands, boolean isRoot) {
|
||||
return execCommand(commands == null ? null : commands.toArray(new String[] {}), isRoot, true);
|
||||
return execCommand(commands == null ? null : commands.toArray(new String[]{}), isRoot, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public class ShellUtils {
|
||||
* @see ShellUtils#execCommand(String[], boolean, boolean)
|
||||
*/
|
||||
public static CommandResult execCommand(String command, boolean isRoot, boolean isNeedResultMsg) {
|
||||
return execCommand(new String[] {command}, isRoot, isNeedResultMsg);
|
||||
return execCommand(new String[]{command}, isRoot, isNeedResultMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ public class ShellUtils {
|
||||
* @see ShellUtils#execCommand(String[], boolean, boolean)
|
||||
*/
|
||||
public static CommandResult execCommand(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
|
||||
return execCommand(commands == null ? null : commands.toArray(new String[] {}), isRoot, isNeedResultMsg);
|
||||
return execCommand(commands == null ? null : commands.toArray(new String[]{}), isRoot, isNeedResultMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,11 +184,17 @@ public class ShellUtils {
|
||||
*/
|
||||
public static class CommandResult {
|
||||
|
||||
/** result of command **/
|
||||
/**
|
||||
* result of command
|
||||
**/
|
||||
public int result;
|
||||
/** success message of command result **/
|
||||
/**
|
||||
* success message of command result
|
||||
**/
|
||||
public String successMsg;
|
||||
/** error message of command result **/
|
||||
/**
|
||||
* error message of command result
|
||||
**/
|
||||
public String errorMsg;
|
||||
|
||||
public CommandResult(int result) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.lt2333.simplicitytools.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
|
||||
object SystemProperties {
|
||||
@SuppressLint("PrivateApi")
|
||||
operator fun get(context: Context, key: String?): String? {
|
||||
var ret = ""
|
||||
try {
|
||||
val cl = context.classLoader
|
||||
val systemProperties = cl.loadClass("android.os.SystemProperties")
|
||||
//参数类型
|
||||
val paramTypes: Array<Class<*>?> = arrayOfNulls(1)
|
||||
paramTypes[0] = String::class.java
|
||||
val get = systemProperties.getMethod("get", *paramTypes)
|
||||
//参数
|
||||
val params = arrayOfNulls<Any>(1)
|
||||
params[0] = key
|
||||
ret = get.invoke(systemProperties, *params) as String
|
||||
} catch (iAE: IllegalArgumentException) {
|
||||
throw iAE
|
||||
} catch (e: Exception) {
|
||||
ret = ""
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ object XSPUtils {
|
||||
}
|
||||
return prefs.getBoolean(key, defValue)
|
||||
}
|
||||
|
||||
fun getInt(key: String, defValue: Int): Int {
|
||||
if (prefs.hasFileChanged()) {
|
||||
prefs.reload()
|
||||
@@ -25,9 +26,21 @@ object XSPUtils {
|
||||
}
|
||||
return prefs.getFloat(key, defValue)
|
||||
}
|
||||
|
||||
fun getString(key: String, defValue: String): String? {
|
||||
if (prefs.hasFileChanged()) {
|
||||
prefs.reload()
|
||||
}
|
||||
return prefs.getString(key, defValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun hasEnable(key: String, default: Boolean = false, noinline extraCondition: (() -> Boolean)? = null, crossinline block: () -> Unit) {
|
||||
inline fun hasEnable(
|
||||
key: String,
|
||||
default: Boolean = false,
|
||||
noinline extraCondition: (() -> Boolean)? = null,
|
||||
crossinline block: () -> Unit
|
||||
) {
|
||||
val conditionResult = if (extraCondition != null) extraCondition() else true
|
||||
if (XSPUtils.getBoolean(key, default) && conditionResult) {
|
||||
block()
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lt2333.simplicitytools.util.xposed
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
|
||||
import com.github.kyuubiran.ezxhelper.utils.Log.logexIfThrow
|
||||
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.IXposedHookZygoteInit
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
abstract class EasyXposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
||||
|
||||
private lateinit var packageParam: XC_LoadPackage.LoadPackageParam
|
||||
abstract val registeredApp: List<AppRegister>
|
||||
private val TAG = "WooBox"
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
|
||||
|
||||
packageParam = lpparam!!
|
||||
registeredApp.forEach { app ->
|
||||
if (app.packageName == lpparam.packageName) {
|
||||
EzXHelperInit.apply {
|
||||
setLogXp(true)
|
||||
setLogTag(TAG)
|
||||
setToastTag(TAG)
|
||||
initHandleLoadPackage(lpparam)
|
||||
}
|
||||
runCatching { app.handleLoadPackage(lpparam) }.logexIfThrow("Failed call handleLoadPackage, package: ${app.packageName}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam?) {
|
||||
EzXHelperInit.initZygote(startupParam!!)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.lt2333.simplicitytools.util.xposed.base
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.utils.Log.logexIfThrow
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
abstract class AppRegister: IXposedHookLoadPackage {
|
||||
|
||||
abstract val packageName: String
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {}
|
||||
|
||||
protected fun autoInitHooks(lpparam: XC_LoadPackage.LoadPackageParam, vararg hook: HookRegister) {
|
||||
hook.also {
|
||||
XposedBridge.log("WooBox: Try to Hook [$packageName]")
|
||||
}.forEach {
|
||||
runCatching {
|
||||
if (it.isInit) return@forEach
|
||||
it.setLoadPackageParam(lpparam)
|
||||
it.init()
|
||||
it.isInit = true
|
||||
}.logexIfThrow("Failed to Hook [$packageName]")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lt2333.simplicitytools.util.xposed.base
|
||||
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
abstract class HookRegister {
|
||||
private lateinit var lpparam: XC_LoadPackage.LoadPackageParam
|
||||
var isInit: Boolean = false
|
||||
abstract fun init()
|
||||
|
||||
fun setLoadPackageParam(loadPackageParam: XC_LoadPackage.LoadPackageParam) {
|
||||
lpparam = loadPackageParam
|
||||
}
|
||||
|
||||
protected fun getLoadPackageParam(): XC_LoadPackage.LoadPackageParam {
|
||||
if (!this::lpparam.isInitialized) {
|
||||
throw RuntimeException("lpparam should be initialized")
|
||||
}
|
||||
return lpparam
|
||||
}
|
||||
|
||||
protected fun getDefaultClassLoader(): ClassLoader {
|
||||
return getLoadPackageParam().classLoader
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user