Skip to content

Commit

Permalink
Implement hook to prevent shaking
Browse files Browse the repository at this point in the history
  • Loading branch information
pwh-pwh committed Sep 10, 2023
1 parent 58914f2 commit 454f92a
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 4 deletions.
21 changes: 18 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
}

android {
Expand All @@ -27,11 +28,17 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
freeCompilerArgs = listOf("-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions")
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.0"
}
}

Expand All @@ -40,7 +47,15 @@ dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.8.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

// 基础依赖
implementation("com.highcapable.yukihookapi:api:1.1.11")
// ❗作为 Xposed 模块使用务必添加,其它情况可选
compileOnly("de.robv.android.xposed:api:82")
// ❗作为 Xposed 模块使用务必添加,其它情况可选
ksp("com.highcapable.yukihookapi:ksp-xposed:1.1.11")
}
29 changes: 28 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">



<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -11,6 +13,31 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fuck_shake"
tools:targetApi="31" />
tools:targetApi="31">

<meta-data
android:name="xposedmodule"
android:value="true" /> <!-- 设置你的模块描述 -->
<meta-data
android:name="xposeddescription"
android:value="摇一摇fuck you" /> <!-- 最低 Xposed 版本号,若你正在使用 EdXposed/LSPosed,建议最低为 93 -->
<meta-data
android:name="xposedminversion"
android:value="93" /> <!-- 可选:配置支持 New XSharedPreferences 可无需调整 xposedminversion 为 93 -->
<meta-data
android:name="xposedsharedprefs"
android:value="true" />


<activity
android:name=".MainActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>


</manifest>
11 changes: 11 additions & 0 deletions app/src/main/java/dev/coderpwh/fuck/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.coderpwh.fuck

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/dev/coderpwh/fuck/hook/HookEntry.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dev.coderpwh.fuck.hook

import android.hardware.SensorManager
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
import com.highcapable.yukihookapi.hook.factory.configs
import com.highcapable.yukihookapi.hook.factory.encase
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit

@InjectYukiHookWithXposed(modulePackageName = "dev.coderpwh.fuck.hook")
object HookEntry:IYukiHookXposedInit {

override fun onInit() = configs {
isDebug = false
}

override fun onHook() = encase {
SensorManager::class.java.hook {
injectMember {
method {
name = "registerListener"
paramCount = 3
}
replaceToTrue()
}
}
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
plugins {
id("com.android.application") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
id("com.google.devtools.ksp") version "1.9.0-1.0.11" apply false
}

0 comments on commit 454f92a

Please sign in to comment.