Skip to content

Commit df6955a

Browse files
committed
1.0.1
1 parent 30bd35e commit df6955a

File tree

97 files changed

+4655
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4655
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://afdian.net/a/YifePlayte

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties
11+
/app/release
12+
/app/debug
13+
.androidide/

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "blockmiui"]
2+
path = blockmiui
3+
url = https://github.com/Block-Network/blockmiui.git

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle.kts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import java.time.LocalDateTime
2+
import java.time.format.DateTimeFormatter
3+
4+
plugins {
5+
id("com.android.application")
6+
id("org.jetbrains.kotlin.android")
7+
}
8+
9+
android {
10+
compileSdk = 34
11+
buildFeatures {
12+
prefab = true
13+
buildConfig = true
14+
viewBinding = true
15+
resValues = true
16+
}
17+
defaultConfig {
18+
applicationId = "com.setoskins.hook"
19+
minSdk = 26
20+
targetSdk = 34
21+
versionCode = 1
22+
versionName = "1.1.0"
23+
buildConfigField("String", "BUILD_TIME", "\"${System.currentTimeMillis()}\"")
24+
}
25+
26+
buildTypes {
27+
named("release") {
28+
isShrinkResources = true
29+
isMinifyEnabled = true
30+
proguardFiles("proguard-rules.pro")
31+
}
32+
named("debug") {
33+
versionNameSuffix = "-debug-" +
34+
DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now())
35+
}
36+
}
37+
38+
androidResources {
39+
additionalParameters("--allow-reserved-package-id", "--package-id", "0x45")
40+
}
41+
42+
packagingOptions {
43+
resources {
44+
excludes += "/META-INF/**"
45+
excludes += "/kotlin/**"
46+
excludes += "/*.txt"
47+
excludes += "/*.bin"
48+
}
49+
}
50+
51+
compileOptions {
52+
sourceCompatibility = JavaVersion.VERSION_11
53+
targetCompatibility = JavaVersion.VERSION_11
54+
}
55+
kotlinOptions {
56+
jvmTarget = JavaVersion.VERSION_11.toString()
57+
}
58+
namespace = "com.setoskins.hook"
59+
}
60+
61+
dependencies {
62+
implementation(project(":blockmiui"))
63+
implementation("com.github.kyuubiran:EzXHelper:2.0.7")
64+
implementation("org.luckypray:DexKit:1.1.8")
65+
implementation ("androidx.appcompat:appcompat:1.3.1")
66+
implementation ("androidx.core:core-ktx:1.6.0")
67+
implementation ("androidx.appcompat:appcompat:1.3.1")
68+
implementation ("androidx.preference:preference-ktx:1.1.1")
69+
//UI
70+
implementation(project(":blockmiui"))
71+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
72+
implementation ("com.scottyab:rootbeer-lib:0.1.0")
73+
//APP Center
74+
val appCenterSdkVersion = "4.4.3"
75+
implementation("com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}")
76+
implementation("com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}")
77+
compileOnly(files("libs\\compile_only\\xposed-api-82_compileonly.jar"))
78+
// implementation("org.lsposed.hiddenapibypass:hiddenapibypass:4.3")
79+
}
Binary file not shown.

app/proguard-rules.pro

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-keep class com.setoskins.hook.hook.MainHook { <init>(); }-keep class com.setoskins.hook.hook.hooks.**.** { <init>(); }-keepattributes RuntimeVisibleAnnotations

app/src/main/AndroidManifest.xml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<uses-permission
8+
android:name="android.permission.QUERY_ALL_PACKAGES"
9+
tools:ignore="QueryAllPackagesPermission" />
10+
<uses-permission
11+
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
12+
tools:node="remove" />
13+
14+
<permission
15+
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
16+
tools:node="remove" />
17+
18+
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
19+
<application
20+
android:allowBackup="true"
21+
android:icon="@mipmap/ic_launcher_seto"
22+
android:label="@string/app_name"
23+
android:theme="@style/Theme.SetoHook"
24+
25+
android:supportsRtl="true">
26+
<meta-data
27+
android:name="xposeddescription"
28+
android:value="@string/xposed_description" />
29+
<meta-data
30+
android:name="xposedscope"
31+
android:resource="@array/xposed_scope" />
32+
<meta-data
33+
android:name="xposedminversion"
34+
android:value="93" />
35+
36+
<activity
37+
android:name="com.setoskins.hook.activity.MainActivity"
38+
android:exported="true"
39+
android:launchMode="singleTop">
40+
<intent-filter>
41+
<action android:name="android.intent.action.MAIN" />
42+
43+
<category android:name="android.intent.category.DEFAULT" />
44+
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
45+
</intent-filter>
46+
</activity>
47+
48+
<activity-alias
49+
android:name="com.setoskins.hook.launcher"
50+
android:enabled="true"
51+
android:exported="true"
52+
android:label="@string/app_name"
53+
android:targetActivity="com.setoskins.hook.activity.MainActivity">
54+
<intent-filter>
55+
<action android:name="android.intent.action.MAIN" />
56+
<category android:name="android.intent.category.LAUNCHER" />
57+
58+
</intent-filter>
59+
</activity-alias>
60+
</application>
61+
62+
</manifest>

app/src/main/assets/xposed_init

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.setoskins.hook.hook.MainHook
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
package com.setoskins.hook.activity
2+
3+
import android.annotation.SuppressLint
4+
import android.os.Bundle
5+
import android.content.Context
6+
import android.content.Intent
7+
import android.content.SharedPreferences
8+
import android.os.Handler
9+
import android.os.Looper
10+
import android.util.Log
11+
import android.widget.Toast
12+
import com.setoskins.hook.activity.pages.MainPage
13+
import com.setoskins.hook.activity.pages.AboutPage
14+
import com.setoskins.hook.activity.pages.MenuPage
15+
import com.setoskins.hook.activity.pages.PowerkeeperPage
16+
import com.setoskins.hook.activity.pages.SoundPage
17+
import com.setoskins.hook.activity.pages.ThankList
18+
import com.setoskins.hook.utils.key.BackupUtils.CREATE_DOCUMENT_CODE
19+
import com.setoskins.hook.utils.key.BackupUtils.OPEN_DOCUMENT_CODE
20+
import com.setoskins.hook.utils.key.BackupUtils.handleCreateDocument
21+
import com.setoskins.hook.utils.key.BackupUtils.handleReadDocument
22+
import cn.fkj233.ui.activity.MIUIActivity
23+
import cn.fkj233.ui.dialog.MIUIDialog
24+
import com.setoskins.hook.BuildConfig
25+
import com.setoskins.hook.R
26+
import com.setoskins.hook.activity.pages.BmPage
27+
import com.setoskins.hook.activity.pages.OtherPage
28+
import com.setoskins.hook.activity.pages.SecuritycenterPage
29+
import com.setoskins.hook.activity.pages.UnlockSetting
30+
import java.io.IOException
31+
32+
33+
class MainActivity : MIUIActivity() {
34+
35+
private lateinit var preferences: SharedPreferences
36+
private var showDialog = true // 初始化为 true,表示第一次打开应用时显示
37+
companion object {
38+
@SuppressLint("StaticFieldLeak")
39+
lateinit var activity: MIUIActivity
40+
private val handler by lazy { Handler(Looper.getMainLooper()) }
41+
fun showToast(string: String) {
42+
Log.d("BlockMIUI", "Show Toast: $string")
43+
handler.post {
44+
Toast.makeText(activity, string, Toast.LENGTH_LONG).show()
45+
}
46+
}
47+
}
48+
49+
override fun onCreate(savedInstanceState: Bundle?) {
50+
51+
52+
super.onCreate(savedInstanceState)
53+
preferences = getSharedPreferences("MyAppPrefs", Context.MODE_PRIVATE)
54+
val showDialogFlag = preferences.getBoolean("showDialog", true)
55+
MIUIActivity.safeSP.putAny("SafeMode", "关闭")
56+
if (BuildConfig.DEBUG) {
57+
// Do something when running in debug mode
58+
} else {
59+
checkLSPosed()
60+
checkRootPermission()
61+
}
62+
63+
64+
65+
if (showDialogFlag) { // 只在 showDialogFlag 为 true 时显示弹窗
66+
abc()
67+
}
68+
}
69+
70+
71+
72+
private fun checkRootPermission() {
73+
try {
74+
val command = "su -c 'pm clear --cache-only com.miui.securitymanager'"
75+
val process = Runtime.getRuntime().exec(arrayOf("sh", "-c", command))
76+
val exitCode = process.waitFor()
77+
78+
if (exitCode == 0) {
79+
80+
} else {
81+
// 执行失败
82+
MIUIDialog(this) {
83+
setTitle(R.string.error)
84+
setMessage(R.string.root_warning)
85+
setCancelable(false)
86+
setRButton(R.string.done) {
87+
finishAffinity()
88+
}
89+
}.show()
90+
}
91+
} catch (e: IOException) {
92+
// 捕获 IO 异常
93+
MIUIDialog(this) {
94+
setTitle(R.string.error)
95+
setMessage(R.string.root_warning)
96+
setCancelable(false)
97+
setRButton(R.string.done) {
98+
finishAffinity()
99+
}
100+
}.show()
101+
}
102+
}
103+
@SuppressLint("WorldReadableFiles")
104+
private fun checkLSPosed() {
105+
try {
106+
107+
setSP(getSharedPreferences("config", MODE_WORLD_READABLE))
108+
} catch (exception: SecurityException) {
109+
MIUIDialog(this) {
110+
setTitle(R.string.warning)
111+
setMessage(R.string.not_support)
112+
setCancelable(false)
113+
setRButton(R.string.done) {
114+
dismiss()
115+
}
116+
}.show()
117+
}
118+
}
119+
120+
121+
122+
123+
private fun abc() {
124+
showDialog = false // 设置为 false,确保之后不再显示弹窗
125+
MIUIDialog(this) {
126+
127+
setTitle(R.string.warning)
128+
setMessage(R.string.Splash_Tips)
129+
setCancelable(false)
130+
setLButton(R.string.Disagree) {
131+
System.exit(0)
132+
133+
}
134+
setRButton(R.string.Agree) {
135+
preferences.edit().putBoolean("showDialog", false).apply()
136+
dismiss()
137+
val toast = Toast.makeText(activity, "记得把APP给予Root权限", Toast.LENGTH_LONG)
138+
toast.show()
139+
}
140+
}.show()
141+
}
142+
143+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
144+
if (data != null && resultCode == RESULT_OK) {
145+
when (requestCode) {
146+
CREATE_DOCUMENT_CODE -> {
147+
handleCreateDocument(activity, data.data)
148+
}
149+
150+
OPEN_DOCUMENT_CODE -> {
151+
handleReadDocument(activity, data.data)
152+
}
153+
}
154+
}
155+
}
156+
157+
init {
158+
activity = this
159+
registerPage(MainPage::class.java)
160+
registerPage(AboutPage::class.java)
161+
registerPage(ThankList::class.java)
162+
registerPage(SoundPage::class.java)
163+
registerPage(PowerkeeperPage::class.java)
164+
registerPage(MenuPage::class.java)
165+
registerPage(UnlockSetting::class.java)
166+
registerPage(SecuritycenterPage::class.java)
167+
registerPage(OtherPage::class.java)
168+
registerPage(BmPage::class.java)
169+
170+
}
171+
}

0 commit comments

Comments
 (0)