├── .gitattributes ├── .github └── workflows │ └── android.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── app ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ ├── .gitignore │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── top │ │ └── yukonga │ │ └── hapticFeedBack │ │ └── ModuleMain.kt │ ├── res │ └── values │ │ ├── array.xml │ │ └── strings.xml │ └── resources │ └── META-INF │ └── xposed │ ├── java_init.list │ ├── module.prop │ └── scope.list ├── build.gradle.kts ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libxposed ├── AndroidManifest.xml └── build.gradle.kts └── settings.gradle.kts /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | workflow_dispatch: 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Setup JDK 17 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: 17 19 | distribution: 'temurin' 20 | cache: 'gradle' 21 | 22 | - name: Build with Gradle 23 | run: | 24 | echo ${{ secrets.SIGNING_KEY }} | base64 -d > keystore.jks 25 | bash ./gradlew assemble 26 | env: 27 | KEYSTORE_PATH: "../keystore.jks" 28 | KEYSTORE_PASS: ${{ secrets.KEY_STORE_PASSWORD }} 29 | KEY_ALIAS: ${{ secrets.ALIAS }} 30 | KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} 31 | 32 | - name: Upload Release Snapshot 33 | uses: actions/upload-artifact@v4 34 | with: 35 | name: HapticFeedBack-Release-Snapshot 36 | path: app/build/outputs/apk/release 37 | compression-level: 9 38 | 39 | - name: Upload Debug Snapshot 40 | uses: actions/upload-artifact@v4 41 | with: 42 | name: HapticFeedBack-Debug-Snapshot 43 | path: app/build/outputs/apk/debug 44 | compression-level: 9 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/java,linux,macos,gradle,kotlin,android,windows,jetbrains,androidstudio,visualstudiocode 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=java,linux,macos,gradle,kotlin,android,windows,jetbrains,androidstudio,visualstudiocode 3 | 4 | ### Android ### 5 | # Gradle files 6 | .gradle/ 7 | build/ 8 | 9 | # Local configuration file (sdk path, etc) 10 | local.properties 11 | 12 | # Log/OS Files 13 | *.log 14 | 15 | # Android Studio generated files and folders 16 | captures/ 17 | .externalNativeBuild/ 18 | .cxx/ 19 | *.apk 20 | output.json 21 | 22 | # IntelliJ 23 | *.iml 24 | .idea/ 25 | misc.xml 26 | deploymentTargetDropDown.xml 27 | render.experimental.xml 28 | 29 | # Keystore files 30 | *.jks 31 | *.keystore 32 | 33 | # Google Services (e.g. APIs or Firebase) 34 | google-services.json 35 | 36 | # Android Profiling 37 | *.hprof 38 | 39 | ### Android Patch ### 40 | gen-external-apklibs 41 | 42 | # Replacement of .externalNativeBuild directories introduced 43 | # with Android Studio 3.5. 44 | 45 | ### Java ### 46 | # Compiled class file 47 | *.class 48 | 49 | # Log file 50 | 51 | # BlueJ files 52 | *.ctxt 53 | 54 | # Mobile Tools for Java (J2ME) 55 | .mtj.tmp/ 56 | 57 | # Package Files # 58 | *.jar 59 | *.war 60 | *.nar 61 | *.ear 62 | *.zip 63 | *.tar.gz 64 | *.rar 65 | 66 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 67 | hs_err_pid* 68 | replay_pid* 69 | 70 | ### JetBrains ### 71 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 72 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 73 | 74 | # User-specific stuff 75 | .idea/**/workspace.xml 76 | .idea/**/tasks.xml 77 | .idea/**/usage.statistics.xml 78 | .idea/**/dictionaries 79 | .idea/**/shelf 80 | 81 | # AWS User-specific 82 | .idea/**/aws.xml 83 | 84 | # Generated files 85 | .idea/**/contentModel.xml 86 | 87 | # Sensitive or high-churn files 88 | .idea/**/dataSources/ 89 | .idea/**/dataSources.ids 90 | .idea/**/dataSources.local.xml 91 | .idea/**/sqlDataSources.xml 92 | .idea/**/dynamic.xml 93 | .idea/**/uiDesigner.xml 94 | .idea/**/dbnavigator.xml 95 | 96 | # Gradle 97 | .idea/**/gradle.xml 98 | .idea/**/libraries 99 | 100 | # Gradle and Maven with auto-import 101 | # When using Gradle or Maven with auto-import, you should exclude module files, 102 | # since they will be recreated, and may cause churn. Uncomment if using 103 | # auto-import. 104 | # .idea/artifacts 105 | # .idea/compiler.xml 106 | # .idea/jarRepositories.xml 107 | # .idea/modules.xml 108 | # .idea/*.iml 109 | # .idea/modules 110 | # *.iml 111 | # *.ipr 112 | 113 | # CMake 114 | cmake-build-*/ 115 | 116 | # Mongo Explorer plugin 117 | .idea/**/mongoSettings.xml 118 | 119 | # File-based project format 120 | *.iws 121 | 122 | # IntelliJ 123 | out/ 124 | 125 | # mpeltonen/sbt-idea plugin 126 | .idea_modules/ 127 | 128 | # JIRA plugin 129 | atlassian-ide-plugin.xml 130 | 131 | # Cursive Clojure plugin 132 | .idea/replstate.xml 133 | 134 | # SonarLint plugin 135 | .idea/sonarlint/ 136 | 137 | # Crashlytics plugin (for Android Studio and IntelliJ) 138 | com_crashlytics_export_strings.xml 139 | crashlytics.properties 140 | crashlytics-build.properties 141 | fabric.properties 142 | 143 | # Editor-based Rest Client 144 | .idea/httpRequests 145 | 146 | # Android studio 3.1+ serialized cache file 147 | .idea/caches/build_file_checksums.ser 148 | 149 | ### JetBrains Patch ### 150 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 151 | 152 | # *.iml 153 | # modules.xml 154 | # .idea/misc.xml 155 | # *.ipr 156 | 157 | # Sonarlint plugin 158 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 159 | .idea/**/sonarlint/ 160 | 161 | # SonarQube Plugin 162 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 163 | .idea/**/sonarIssues.xml 164 | 165 | # Markdown Navigator plugin 166 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 167 | .idea/**/markdown-navigator.xml 168 | .idea/**/markdown-navigator-enh.xml 169 | .idea/**/markdown-navigator/ 170 | 171 | # Cache file creation bug 172 | # See https://youtrack.jetbrains.com/issue/JBR-2257 173 | .idea/$CACHE_FILE$ 174 | 175 | # CodeStream plugin 176 | # https://plugins.jetbrains.com/plugin/12206-codestream 177 | .idea/codestream.xml 178 | 179 | # Azure Toolkit for IntelliJ plugin 180 | # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij 181 | .idea/**/azureSettings.xml 182 | 183 | ### Kotlin ### 184 | /.kotlin 185 | # Compiled class file 186 | 187 | # Log file 188 | 189 | # BlueJ files 190 | 191 | # Mobile Tools for Java (J2ME) 192 | 193 | # Package Files # 194 | 195 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 196 | 197 | ### Linux ### 198 | *~ 199 | 200 | # temporary files which can be created if a process still has a handle open of a deleted file 201 | .fuse_hidden* 202 | 203 | # KDE directory preferences 204 | .directory 205 | 206 | # Linux trash folder which might appear on any partition or disk 207 | .Trash-* 208 | 209 | # .nfs files are created when an open file is removed but is still being accessed 210 | .nfs* 211 | 212 | ### macOS ### 213 | # General 214 | .DS_Store 215 | .AppleDouble 216 | .LSOverride 217 | 218 | # Icon must end with two \r 219 | Icon 220 | 221 | 222 | # Thumbnails 223 | ._* 224 | 225 | # Files that might appear in the root of a volume 226 | .DocumentRevisions-V100 227 | .fseventsd 228 | .Spotlight-V100 229 | .TemporaryItems 230 | .Trashes 231 | .VolumeIcon.icns 232 | .com.apple.timemachine.donotpresent 233 | 234 | # Directories potentially created on remote AFP share 235 | .AppleDB 236 | .AppleDesktop 237 | Network Trash Folder 238 | Temporary Items 239 | .apdisk 240 | 241 | ### macOS Patch ### 242 | # iCloud generated files 243 | *.icloud 244 | 245 | ### VisualStudioCode ### 246 | .vscode/* 247 | !.vscode/settings.json 248 | !.vscode/tasks.json 249 | !.vscode/launch.json 250 | !.vscode/extensions.json 251 | !.vscode/*.code-snippets 252 | 253 | # Local History for Visual Studio Code 254 | .history/ 255 | 256 | # Built Visual Studio Code Extensions 257 | *.vsix 258 | 259 | ### VisualStudioCode Patch ### 260 | # Ignore all local history of files 261 | .history 262 | .ionide 263 | 264 | ### Windows ### 265 | # Windows thumbnail cache files 266 | Thumbs.db 267 | Thumbs.db:encryptable 268 | ehthumbs.db 269 | ehthumbs_vista.db 270 | 271 | # Dump file 272 | *.stackdump 273 | 274 | # Folder config file 275 | [Dd]esktop.ini 276 | 277 | # Recycle Bin used on file shares 278 | $RECYCLE.BIN/ 279 | 280 | # Windows Installer files 281 | *.cab 282 | *.msi 283 | *.msix 284 | *.msm 285 | *.msp 286 | 287 | # Windows shortcuts 288 | *.lnk 289 | 290 | ### Gradle ### 291 | .gradle 292 | **/build/ 293 | !src/**/build/ 294 | 295 | # Ignore Gradle GUI config 296 | gradle-app.setting 297 | 298 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 299 | !gradle-wrapper.jar 300 | 301 | # Avoid ignore Gradle wrappper properties 302 | !gradle-wrapper.properties 303 | 304 | # Cache of project 305 | .gradletasknamecache 306 | 307 | # Eclipse Gradle plugin generated files 308 | # Eclipse Core 309 | .project 310 | # JDT-specific (Eclipse Java Development Tools) 311 | .classpath 312 | 313 | ### Gradle Patch ### 314 | # Java heap dump 315 | 316 | ### AndroidStudio ### 317 | # Covers files to be ignored for android development using Android Studio. 318 | 319 | # Built application files 320 | *.ap_ 321 | *.aab 322 | 323 | # Files for the ART/Dalvik VM 324 | *.dex 325 | 326 | # Java class files 327 | 328 | # Generated files 329 | bin/ 330 | gen/ 331 | 332 | # Gradle files 333 | 334 | # Signing files 335 | .signing/ 336 | 337 | # Local configuration file (sdk path, etc) 338 | 339 | # Proguard folder generated by Eclipse 340 | proguard/ 341 | 342 | # Log Files 343 | 344 | # Android Studio 345 | /*/build/ 346 | /*/local.properties 347 | /*/out 348 | /*/*/build 349 | /*/*/production 350 | .navigation/ 351 | *.ipr 352 | *.swp 353 | 354 | # Keystore files 355 | 356 | # Google Services (e.g. APIs or Firebase) 357 | # google-services.json 358 | 359 | # Android Patch 360 | 361 | # External native build folder generated in Android Studio 2.2 and later 362 | .externalNativeBuild 363 | 364 | # NDK 365 | obj/ 366 | 367 | # IntelliJ IDEA 368 | /out/ 369 | 370 | # User-specific configurations 371 | .idea/caches/ 372 | .idea/libraries/ 373 | .idea/shelf/ 374 | .idea/workspace.xml 375 | .idea/tasks.xml 376 | .idea/.name 377 | .idea/compiler.xml 378 | .idea/copyright/profiles_settings.xml 379 | .idea/encodings.xml 380 | .idea/misc.xml 381 | .idea/modules.xml 382 | .idea/scopes/scope_settings.xml 383 | .idea/dictionaries 384 | .idea/vcs.xml 385 | .idea/jsLibraryMappings.xml 386 | .idea/datasources.xml 387 | .idea/dataSources.ids 388 | .idea/sqlDataSources.xml 389 | .idea/dynamic.xml 390 | .idea/uiDesigner.xml 391 | .idea/assetWizardSettings.xml 392 | .idea/gradle.xml 393 | .idea/jarRepositories.xml 394 | .idea/navEditor.xml 395 | 396 | # Legacy Eclipse project files 397 | .cproject 398 | .settings/ 399 | 400 | # Mobile Tools for Java (J2ME) 401 | 402 | # Package Files # 403 | 404 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 405 | 406 | ## Plugin-specific files: 407 | 408 | # mpeltonen/sbt-idea plugin 409 | 410 | # JIRA plugin 411 | 412 | # Mongo Explorer plugin 413 | .idea/mongoSettings.xml 414 | 415 | # Crashlytics plugin (for Android Studio and IntelliJ) 416 | 417 | ### AndroidStudio Patch ### 418 | 419 | !/gradle/wrapper/gradle-wrapper.jar 420 | 421 | # End of https://www.toptal.com/developers/gitignore/api/java,linux,macos,gradle,kotlin,android,windows,jetbrains,androidstudio,visualstudiocode -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libxposed/api"] 2 | path = libxposed/api 3 | url = https://github.com/libxposed/api 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 YuKongA 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /release -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | import com.android.build.gradle.internal.api.BaseVariantOutputImpl 4 | import java.util.Properties 5 | 6 | plugins { 7 | alias(libs.plugins.android.application) 8 | alias(libs.plugins.kotlin.android) 9 | } 10 | 11 | android { 12 | namespace = "top.yukonga.hapticFeedBack" 13 | compileSdk = 35 14 | defaultConfig { 15 | applicationId = namespace 16 | minSdk = 35 17 | targetSdk = 35 18 | versionCode = 110 19 | versionName = "1.1.0" 20 | } 21 | val properties = Properties() 22 | runCatching { properties.load(project.rootProject.file("local.properties").inputStream()) } 23 | val keystorePath = properties.getProperty("KEYSTORE_PATH") ?: System.getenv("KEYSTORE_PATH") 24 | val keystorePwd = properties.getProperty("KEYSTORE_PASS") ?: System.getenv("KEYSTORE_PASS") 25 | val alias = properties.getProperty("KEY_ALIAS") ?: System.getenv("KEY_ALIAS") 26 | val pwd = properties.getProperty("KEY_PASSWORD") ?: System.getenv("KEY_PASSWORD") 27 | if (keystorePath != null) { 28 | signingConfigs { 29 | register("github") { 30 | storeFile = file(keystorePath) 31 | storePassword = keystorePwd 32 | keyAlias = alias 33 | keyPassword = pwd 34 | enableV3Signing = true 35 | enableV4Signing = true 36 | } 37 | } 38 | } else { 39 | signingConfigs { 40 | register("release") { 41 | enableV3Signing = true 42 | enableV4Signing = true 43 | } 44 | } 45 | } 46 | buildFeatures.buildConfig = true 47 | buildTypes { 48 | release { 49 | isMinifyEnabled = true 50 | isShrinkResources = true 51 | vcsInfo.include = false 52 | proguardFiles("proguard-rules.pro") 53 | signingConfig = signingConfigs.getByName(if (keystorePath != null) "github" else "release") 54 | } 55 | debug { 56 | if (keystorePath != null) signingConfig = signingConfigs.getByName("github") 57 | } 58 | } 59 | kotlin.jvmToolchain(21) 60 | packaging { 61 | resources.merges += "META-INF/xposed/**" 62 | resources.excludes += "**" 63 | applicationVariants.all { 64 | outputs.all { 65 | (this as BaseVariantOutputImpl).outputFileName = "HapticFeedBack-$versionName.apk" 66 | } 67 | } 68 | } 69 | } 70 | 71 | dependencies { 72 | compileOnly(project(":libxposed")) 73 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Xposed 2 | -adaptresourcefilecontents META-INF/xposed/java_init.list 3 | -keepattributes RuntimeVisibleAnnotations 4 | -keep,allowobfuscation,allowoptimization public class * extends io.github.libxposed.api.XposedModule { 5 | public (...); 6 | public void onPackageLoaded(...); 7 | public void onSystemServerLoaded(...); 8 | } 9 | -keep,allowshrinking,allowoptimization,allowobfuscation class ** implements io.github.libxposed.api.XposedInterface$Hooker 10 | -keepclassmembers,allowoptimization class ** implements io.github.libxposed.api.XposedInterface$Hooker { 11 | public *** before(***); 12 | public *** after(***); 13 | public static *** before(); 14 | public static *** before(io.github.libxposed.api.XposedInterface$BeforeHookCallback); 15 | public static void after(); 16 | public static void after(io.github.libxposed.api.XposedInterface$AfterHookCallback); 17 | public static void after(io.github.libxposed.api.XposedInterface$AfterHookCallback, ***); 18 | } 19 | 20 | # Kotlin 21 | -assumenosideeffects class kotlin.jvm.internal.Intrinsics { 22 | public static void check*(...); 23 | public static void throw*(...); 24 | } 25 | -assumenosideeffects class java.util.Objects { 26 | public static ** requireNonNull(...); 27 | } 28 | 29 | # Strip debug log 30 | -assumenosideeffects class android.util.Log { 31 | public static int v(...); 32 | public static int d(...); 33 | } 34 | 35 | # Obfuscation 36 | -repackageclasses 37 | -allowaccessmodification -------------------------------------------------------------------------------- /app/src/.gitignore: -------------------------------------------------------------------------------- 1 | /androidTest 2 | /test -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/top/yukonga/hapticFeedBack/ModuleMain.kt: -------------------------------------------------------------------------------- 1 | package top.yukonga.hapticFeedBack 2 | 3 | import android.os.Handler 4 | import io.github.libxposed.api.XposedInterface 5 | import io.github.libxposed.api.XposedModule 6 | import io.github.libxposed.api.XposedModuleInterface 7 | import java.lang.reflect.Method 8 | import java.util.Arrays 9 | 10 | private lateinit var module: ModuleMain 11 | private lateinit var loadedPackageParam: XposedModuleInterface.PackageLoadedParam 12 | 13 | class ModuleMain(base: XposedInterface, param: XposedModuleInterface.ModuleLoadedParam) : XposedModule(base, param) { 14 | 15 | init { 16 | module = this 17 | } 18 | 19 | override fun onPackageLoaded(param: XposedModuleInterface.PackageLoadedParam) { 20 | super.onPackageLoaded(param) 21 | loadedPackageParam = param 22 | if (param.packageName == "com.miui.home") { 23 | val hapticFeedbackCompatV2 = "com.miui.home.launcher.common.HapticFeedbackCompatV2" 24 | val gestureStubView = "com.miui.home.recents.GestureStubView" 25 | val gestureStubViewClass = param.classLoader.loadClass(gestureStubView) 26 | val hapticFeedbackCompatV2Class = param.classLoader.loadClass(hapticFeedbackCompatV2) 27 | hookMethods(hapticFeedbackCompatV2Class, PerformGestureReadyBackHook::class.java, "performGestureReadyBack") 28 | hookMethods(hapticFeedbackCompatV2Class, PerformGestureReadyBackLambdaHook::class.java, "lambda\$performGestureReadyBack\$11") 29 | hookMethods(hapticFeedbackCompatV2Class, PerformGestureBackHandUpHook::class.java, "performGestureBackHandUp") 30 | hookMethods(hapticFeedbackCompatV2Class, PerformGestureBackHandUpLambdaHook::class.java, "lambda\$performGestureBackHandUp\$12") 31 | hookMethods(gestureStubViewClass, InjectKeyEventHook::class.java, "injectKeyEvent") 32 | } 33 | } 34 | 35 | private fun hookMethods(clazz: Class<*>, hooker: Class, vararg names: String) { 36 | val list = listOf(*names) 37 | Arrays.stream(clazz.declaredMethods) 38 | .filter { method: Method -> list.contains(method.name) } 39 | .forEach { method: Method? -> hook(method!!, hooker) } 40 | } 41 | 42 | } 43 | 44 | class PerformGestureReadyBackHook : XposedInterface.Hooker { 45 | companion object { 46 | @JvmStatic 47 | fun before() { 48 | if (BuildConfig.DEBUG) module.log("hooking performGestureReadyBack") 49 | val timeOutBlocker = "com.miui.home.recents.util.TimeOutBlocker" 50 | val backgroundThread = "com.miui.home.launcher.common.BackgroundThread" 51 | val getHandlerMethod = loadedPackageParam.classLoader.loadClass(backgroundThread).getDeclaredMethod("getHandler") 52 | val getHandler = getHandlerMethod.invoke(null) // getHandler is a static method 53 | val startCountDownMethod = loadedPackageParam.classLoader.loadClass(timeOutBlocker) 54 | .getDeclaredMethod("startCountDown", Handler::class.java, Long::class.java, String::class.java) 55 | startCountDownMethod.invoke(null, getHandler, 140L, "BLOCKER_ID_FOR_HAPTIC_GESTURE_BACK") // startCountDown is a static method 56 | } 57 | } 58 | } 59 | 60 | class PerformGestureReadyBackLambdaHook : XposedInterface.Hooker { 61 | companion object { 62 | @JvmStatic 63 | fun before(callback: XposedInterface.BeforeHookCallback) { 64 | if (BuildConfig.DEBUG) module.log("hooking lambda\$performGestureReadyBack\$11") 65 | val mHapticHelperField = callback.getThisObject()?.javaClass?.getDeclaredField("mHapticHelper") 66 | mHapticHelperField?.isAccessible = true 67 | val mHapticHelper = mHapticHelperField?.get(callback.getThisObject()) 68 | val performExtHapticFeedback = mHapticHelper?.javaClass?.getDeclaredMethod("performExtHapticFeedback", Int::class.java) 69 | performExtHapticFeedback?.invoke(mHapticHelper, 0) 70 | callback.returnAndSkip(null) 71 | } 72 | } 73 | } 74 | 75 | class PerformGestureBackHandUpHook : XposedInterface.Hooker { 76 | companion object { 77 | @JvmStatic 78 | fun before(callback: XposedInterface.BeforeHookCallback) { 79 | if (BuildConfig.DEBUG) module.log("hooking performGestureBackHandUp") 80 | val timeOutBlocker = "com.miui.home.recents.util.TimeOutBlocker" 81 | val isBlockedMethod = loadedPackageParam.classLoader.loadClass(timeOutBlocker).getDeclaredMethod("isBlocked", String::class.java) 82 | val isBlocked = isBlockedMethod.invoke(null, "BLOCKER_ID_FOR_HAPTIC_GESTURE_BACK") as Boolean // isBlocked is a static method 83 | if (isBlocked) callback.returnAndSkip(null) 84 | } 85 | } 86 | } 87 | 88 | class PerformGestureBackHandUpLambdaHook : XposedInterface.Hooker { 89 | companion object { 90 | @JvmStatic 91 | fun before(callback: XposedInterface.BeforeHookCallback) { 92 | if (BuildConfig.DEBUG) module.log("hooking lambda\$performGestureBackHandUp\$12") 93 | val mHapticHelperField = callback.getThisObject()?.javaClass?.getDeclaredField("mHapticHelper") 94 | mHapticHelperField?.isAccessible = true 95 | val mHapticHelper = mHapticHelperField?.get(callback.getThisObject()) 96 | val performExtHapticFeedback = mHapticHelper?.javaClass?.getDeclaredMethod("performExtHapticFeedback", Int::class.java) 97 | performExtHapticFeedback?.invoke(mHapticHelper, 1) 98 | callback.returnAndSkip(null) 99 | } 100 | } 101 | } 102 | 103 | class InjectKeyEventHook : XposedInterface.Hooker { 104 | companion object { 105 | @JvmStatic 106 | fun before(callback: XposedInterface.BeforeHookCallback) { 107 | if (BuildConfig.DEBUG) module.log("hooking injectKeyEvent") 108 | callback.getArgs()[1] = true 109 | } 110 | } 111 | } 112 | 113 | -------------------------------------------------------------------------------- /app/src/main/res/values/array.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.miui.home 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | HapticFeedBack 3 | Added haptic feedback for HapticV2 devices when releasing the back gesture. 4 | -------------------------------------------------------------------------------- /app/src/main/resources/META-INF/xposed/java_init.list: -------------------------------------------------------------------------------- 1 | top.yukonga.hapticFeedBack.ModuleMain -------------------------------------------------------------------------------- /app/src/main/resources/META-INF/xposed/module.prop: -------------------------------------------------------------------------------- 1 | minApiVersion=100 2 | targetApiVersion=100 3 | staticScope=true -------------------------------------------------------------------------------- /app/src/main/resources/META-INF/xposed/scope.list: -------------------------------------------------------------------------------- 1 | com.miui.home -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.android.application) apply false 3 | alias(libs.plugins.android.library) apply false 4 | alias(libs.plugins.kotlin.android) apply false 5 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 2 | android.useAndroidX=true 3 | kotlin.code.style=official 4 | android.nonTransitiveRClass=true 5 | android.useMinimalKeepRules=true 6 | org.gradle.caching=true 7 | org.gradle.configureondemand=true 8 | org.gradle.configuration-cache=true 9 | org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | agp = "8.7.2" 3 | kotlin = "2.0.21" 4 | 5 | [libraries] 6 | androidx-annotation = { module = "androidx.annotation:annotation", version = "1.9.1" } 7 | 8 | [plugins] 9 | android-application = { id = "com.android.application", version.ref = "agp" } 10 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } 11 | android-library = { id = "com.android.library", version.ref = "agp" } 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuKongA/HapticFeedBack-GestureBack/ee452d163115185fb86f73cc457f1f6b9d345b65/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /libxposed/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libxposed/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | alias(libs.plugins.android.library) 3 | } 4 | 5 | android { 6 | namespace = "io.github.libxposed.api" 7 | sourceSets { 8 | val main by getting 9 | main.apply { 10 | manifest.srcFile("AndroidManifest.xml") 11 | java.setSrcDirs(listOf("api/api/src/main/java")) 12 | } 13 | } 14 | 15 | defaultConfig { 16 | minSdk = 35 17 | compileSdk = 35 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility = JavaVersion.VERSION_21 22 | targetCompatibility = JavaVersion.VERSION_21 23 | } 24 | 25 | dependencies { 26 | compileOnly(libs.androidx.annotation) 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | pluginManagement { 4 | repositories { 5 | google { 6 | content { 7 | includeGroupByRegex("com\\.android.*") 8 | includeGroupByRegex("com\\.google.*") 9 | includeGroupByRegex("androidx.*") 10 | } 11 | } 12 | mavenCentral() 13 | gradlePluginPortal() 14 | maven("https://api.xposed.info/") 15 | } 16 | } 17 | 18 | dependencyResolutionManagement { 19 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 20 | repositories { 21 | google() 22 | mavenCentral() 23 | maven("https://api.xposed.info/") 24 | } 25 | } 26 | 27 | rootProject.name = "HapticFeedBack" 28 | include(":app") 29 | include(":libxposed:api") --------------------------------------------------------------------------------