├── app ├── .gitignore ├── src │ └── main │ │ ├── assets │ │ └── xposed_init │ │ ├── res │ │ ├── layout │ │ │ └── activity_settings.xml │ │ ├── values-night │ │ │ └── styles.xml │ │ ├── values │ │ │ ├── styles.xml │ │ │ ├── array.xml │ │ │ └── strings.xml │ │ ├── values-zh-rCN │ │ │ └── strings.xml │ │ └── xml │ │ │ └── prefs.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── cn │ │ └── coderstory │ │ └── miui │ │ └── water │ │ ├── SettingsActivity.kt │ │ ├── XposedHelper.kt │ │ └── MainHook.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .gitignore ├── gradle.properties ├── .github └── workflows │ └── blank.yml ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "淘米水" 2 | include ':app' 3 | -------------------------------------------------------------------------------- /app/src/main/assets/xposed_init: -------------------------------------------------------------------------------- 1 | cn.coderstory.miui.water.MainHook -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coderstory/mi_water/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | -keep class cn.coderstory.miui.water.MainHook 2 | 3 | -repackageclasses 4 | -allowaccessmodification 5 | -overloadaggressively -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mi_water 2 | a lsposed module for miui 一款基于lsposed的去除miui系统中各种不友好使用限制的模块 3 | 4 | 淘米水 5 | 一款基于lsposed开发的针对miui系统的插件 6 | 实现了去除系统自带广告,去除app安装限制等功能 7 | 8 | 基于GPLV2协议公开源码 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jun 09 21:06:45 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/array.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.android.thememanager 5 | com.miui.packageinstaller 6 | com.miui.securitycenter 7 | com.miui.analytics 8 | com.android.traceur 9 | com.miui.systemAdSolution 10 | com.android.mms 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 26 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | #org.gradle.jvmargs=-Xmx1500m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | android.enableJetifier=true 21 | #systemProp.http.proxyHost=127.0.0.1 22 | #systemProp.http.proxyPort=8889 23 | #systemProp.https.proxyHost=127.0.0.1 24 | #systemProp.https.proxyPort=8889 25 | # 26 | -------------------------------------------------------------------------------- /app/src/main/res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 淘米水 3 | MIUI广告救星 4 | 本插件兼容MIUI 13\n基于红米K40 MIUI 13.0.7版本适配\nPower By CoderStory 5 | 安装包管理器 6 | 禁用账户验证 7 | 安装非商店应用时,不再需要输入MIUI账户密码. 8 | 移除应用安装界面的广告和去除应用商店相关按钮. 9 | 主题美化 10 | 清除主题美化App中的广告 11 | 安装限制 12 | 移除一些应用安装限制,比如系统app无法直接安装,被标记为危险的应用无法安装等 13 | 开屏广告 14 | 去除系统App上的开屏广告, 需root权限 15 | 去除5s/10s限制 16 | 去掉开启无障碍等功能必须等待10秒的危险提示 17 | 短信去广告 18 | 去掉短信下方输入框位置的广告按钮和短信内容下方的推广按钮 19 | 设置 20 | 忽略 21 | 您似乎正在使用过时的 LSPosed 版本或 LSPosed 未激活,请更新 LSPosed 或者激活后再试。 22 | 23 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 33 8 | buildToolsVersion "30.0.3" 9 | 10 | defaultConfig { 11 | applicationId "cn.coderstory.miui.water" 12 | minSdkVersion 29 13 | targetSdkVersion 33 14 | versionCode 15 15 | versionName "1.7.6" 16 | } 17 | packagingOptions { 18 | jniLibs { 19 | excludes += ['META-INF/**'] 20 | } 21 | resources { 22 | excludes += ['META-INF/**'] 23 | } 24 | } 25 | 26 | 27 | buildTypes { 28 | release { 29 | minifyEnabled true 30 | shrinkResources true 31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 32 | } 33 | } 34 | compileOptions { 35 | sourceCompatibility JavaVersion.VERSION_11 36 | targetCompatibility JavaVersion.VERSION_11 37 | } 38 | kotlinOptions { 39 | jvmTarget = '11' 40 | } 41 | buildFeatures { 42 | viewBinding true 43 | } 44 | lint { 45 | abortOnError false 46 | } 47 | namespace 'cn.coderstory.miui.water' 48 | } 49 | 50 | dependencies { 51 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 52 | implementation 'androidx.preference:preference-ktx:1.2.0' 53 | compileOnly 'de.robv.android.xposed:api:82' 54 | implementation "com.github.topjohnwu.libsu:core:3.1.2" 55 | } -------------------------------------------------------------------------------- /.github/workflows/blank.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: set up JDK 11 15 | uses: actions/setup-java@v1 16 | with: 17 | java-version: 11 18 | - name: Cache Gradle 19 | uses: actions/cache@v2 20 | with: 21 | path: | 22 | ~/.gradle/caches 23 | ~/.gradle/wrapper 24 | key: gradle-manager-${{ github.sha }} 25 | restore-keys: | 26 | gradle- 27 | - name: Build with Gradle 28 | run: | 29 | echo 'org.gradle.caching=true' >> gradle.properties 30 | echo 'org.gradle.parallel=true' >> gradle.properties 31 | echo 'org.gradle.vfs.watch=true' >> gradle.properties 32 | echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties 33 | chmod 777 ./gradlew 34 | ./gradlew assembleRelease 35 | - uses: r0adkll/sign-android-release@v1 36 | name: Sign app APK 37 | # ID used to access action output 38 | id: sign_app 39 | with: 40 | releaseDirectory: app/build/outputs/apk/release 41 | signingKeyBase64: ${{ secrets.SIGNING_KEY }} 42 | alias: ${{ secrets.ALIAS }} 43 | keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} 44 | keyPassword: ${{ secrets.KEY_PASSWORD }} 45 | #env: 46 | #// override default build-tools version (29.0.3) -- optional 47 | #BUILD_TOOLS_VERSION: "30.0.2" 48 | 49 | # Example use of `signedReleaseFile` output -- not needed 50 | - uses: actions/upload-artifact@v2 51 | with: 52 | name: Signed app bundle 53 | path: ${{steps.sign_app.outputs.signedReleaseFile}} 54 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Mi Water 3 | LSPosed Module For MIUI 4 | This version is for miui 13 only. 5 | MIUI Theme 6 | Remove AD from Theme. 7 | disable verify account 8 | disable verify account when install app which not exist on the official store. 9 | Package Installer 10 | Remove AD from Package Installer. 11 | install limit 12 | remove some limits on install apk 13 | remove splash AD 14 | remove splash ad with miui app (need root permission) 15 | remove limit for enable some futures in miui 16 | Removed the restriction of having to wait 10 seconds before the function can be turned on 17 | remove ad with mms 18 | It seems ads will no longer appear with English language 19 | 260345842 20 | https://blog.coderstory.cn 21 | Settings 22 | Ignore 23 | It seems that you are using an out dated version of LSPosed or LSPosed is not activated, please update LSPosed or try again after activated. 24 | 25 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/xml/prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 10 | 16 | 22 | 28 | 34 | 40 | 46 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/java/cn/coderstory/miui/water/SettingsActivity.kt: -------------------------------------------------------------------------------- 1 | package cn.coderstory.miui.water 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.AlertDialog 5 | import android.content.DialogInterface 6 | import android.os.Bundle 7 | import androidx.fragment.app.FragmentActivity 8 | import androidx.preference.Preference 9 | import androidx.preference.PreferenceFragmentCompat 10 | import androidx.preference.SwitchPreference 11 | import com.topjohnwu.superuser.Shell 12 | 13 | class SettingsActivity : FragmentActivity() { 14 | override fun onCreate(savedInstanceState: Bundle?) { 15 | super.onCreate(savedInstanceState) 16 | setContentView(R.layout.activity_settings) 17 | checkEdXposed() 18 | if (savedInstanceState == null) { 19 | supportFragmentManager 20 | .beginTransaction() 21 | .replace(R.id.fragment_container, SettingsFragment()) 22 | .commit() 23 | } 24 | } 25 | 26 | @SuppressLint("WorldReadableFiles") 27 | private fun checkEdXposed() { 28 | try { 29 | getSharedPreferences("conf", MODE_WORLD_READABLE) 30 | } catch (exception: SecurityException) { 31 | AlertDialog.Builder(this) 32 | .setMessage(getString(R.string.not_supported)) 33 | .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> finish() } 34 | .setNegativeButton(R.string.ignore, null) 35 | .show() 36 | } 37 | } 38 | 39 | class SettingsFragment : PreferenceFragmentCompat() { 40 | override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { 41 | setPreferencesFromResource(R.xml.prefs, rootKey) 42 | } 43 | 44 | override fun onPreferenceTreeClick(preference: Preference): Boolean { 45 | if(preference.key == "removeSplashAd" ){ 46 | if((preference as SwitchPreference).isChecked){ 47 | Shell.su("rm -rf /storage/emulated/0/Android/data/com.miui.systemAdSolution/files/miad") 48 | .exec() 49 | Shell.su("touch /storage/emulated/0/Android/data/com.miui.systemAdSolution/files/miad") 50 | .exec() 51 | }else{ 52 | Shell.su("rm -rf /storage/emulated/0/Android/data/com.miui.systemAdSolution/files/miad") 53 | .exec() 54 | } 55 | } 56 | return super.onPreferenceTreeClick(preference) 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /app/src/main/java/cn/coderstory/miui/water/XposedHelper.kt: -------------------------------------------------------------------------------- 1 | package cn.coderstory.miui.water 2 | 3 | import de.robv.android.xposed.XC_MethodHook 4 | import de.robv.android.xposed.XposedBridge 5 | import de.robv.android.xposed.XposedHelpers 6 | 7 | open class XposedHelper { 8 | companion object { 9 | fun findAndHookMethod( 10 | p1: String?, 11 | lpparam: ClassLoader?, 12 | p2: String?, 13 | vararg parameterTypesAndCallback: Any? 14 | ) { 15 | try { 16 | if (findClass(p1, lpparam) != null) { 17 | XposedHelpers.findAndHookMethod(p1, lpparam, p2, *parameterTypesAndCallback) 18 | } 19 | } catch (e: Throwable) { 20 | XposedBridge.log(e) 21 | } 22 | } 23 | 24 | fun hookAllMethods( 25 | p1: String?, 26 | lpparam: ClassLoader?, 27 | methodName: String?, 28 | parameterTypesAndCallback: XC_MethodHook? 29 | ) { 30 | try { 31 | val packageParser = findClass(p1, lpparam) 32 | XposedBridge.hookAllMethods(packageParser, methodName, parameterTypesAndCallback) 33 | } catch (e: Throwable) { 34 | XposedBridge.log(e) 35 | } 36 | } 37 | 38 | private fun findClass(className: String?, classLoader: ClassLoader?): Class<*>? { 39 | try { 40 | return XposedHelpers.findClass(className,classLoader) 41 | } catch (e: Throwable) { 42 | XposedBridge.log(e) 43 | } 44 | return null 45 | } 46 | 47 | fun hookAllConstructors(p1: String?, classLoader: ClassLoader?,parameterTypesAndCallback: XC_MethodHook) { 48 | try { 49 | val packageParser = findClass(p1, classLoader) 50 | hookAllConstructors(packageParser, parameterTypesAndCallback) 51 | } catch (e: Throwable) { 52 | XposedBridge.log(e) 53 | } 54 | } 55 | 56 | private fun hookAllConstructors( 57 | hookClass: Class<*>?, 58 | callback: XC_MethodHook 59 | ): Set? { 60 | return try { 61 | XposedBridge.hookAllConstructors(hookClass, callback) 62 | } catch (e: Throwable) { 63 | XposedBridge.log(e) 64 | null 65 | } 66 | } 67 | fun findClassWithOutLog(className: String?, classLoader: ClassLoader?): Class<*>? { 68 | try { 69 | return className?.let { Class.forName(it, false, classLoader) } 70 | } catch (e: Exception) { 71 | // 忽略 72 | } 73 | return null 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/java/cn/coderstory/miui/water/MainHook.kt: -------------------------------------------------------------------------------- 1 | package cn.coderstory.miui.water 2 | 3 | import android.content.pm.ApplicationInfo 4 | import android.widget.TextView 5 | import de.robv.android.xposed.* 6 | import de.robv.android.xposed.callbacks.XC_LoadPackage 7 | import java.net.URL 8 | 9 | 10 | class MainHook : XposedHelper(), IXposedHookLoadPackage { 11 | var prefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "conf") 12 | 13 | override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { 14 | if (lpparam.packageName.equals("com.android.thememanager")) { 15 | if (prefs.getBoolean("removeThemeAd", true)) { 16 | hookAllMethods( 17 | "com.android.thememanager.basemodule.ad.model.AdInfoResponse", 18 | lpparam.classLoader, 19 | "isAdValid", 20 | XC_MethodReplacement.returnConstant(false) 21 | ) 22 | hookAllMethods( 23 | "com.android.thememanager.basemodule.ad.model.AdInfoResponse", 24 | lpparam.classLoader, 25 | "checkAndGetAdInfo", 26 | XC_MethodReplacement.returnConstant(null) 27 | ) 28 | } 29 | } 30 | 31 | if (lpparam.packageName.equals("com.miui.packageinstaller")) { 32 | if (prefs.getBoolean("removeInstallerAd", true)) { 33 | XposedHelpers.findAndHookConstructor( 34 | "com.miui.packageInstaller.model.CloudParams", 35 | lpparam.classLoader, 36 | object : XC_MethodHook() { 37 | override fun afterHookedMethod(param: MethodHookParam) { 38 | var obj = param.thisObject; 39 | XposedHelpers.setBooleanField(obj, "showAdsBefore", false); 40 | XposedHelpers.setBooleanField(obj, "showAdsAfter", false); 41 | XposedHelpers.setBooleanField(obj, "singletonAuthShowAdsBefore", false); 42 | XposedHelpers.setBooleanField(obj, "singletonAuthShowAdsAfter", true); 43 | XposedHelpers.setBooleanField(obj, "useSystemAppRules", true); 44 | XposedHelpers.setBooleanField(obj, "showSafeModeTip", false); 45 | XposedHelpers.setBooleanField(obj, "openButton", true); 46 | XposedHelpers.setObjectField(obj, "safeType", "1"); 47 | } 48 | }) 49 | } 50 | if (prefs.getBoolean("removeInstallerAuth", true)) { 51 | findAndHookMethod( 52 | "java.net.URL", 53 | lpparam.classLoader, 54 | "openConnection", 55 | object : XC_MethodHook() { 56 | override fun afterHookedMethod(param: MethodHookParam) { 57 | var obj: URL = param.thisObject as URL 58 | XposedBridge.log("current host is ${obj.host}") 59 | if (obj.host.equals("api-installer.pt.xiaomi.com") || obj.host.equals("preview-api.installer.xiaomi.com")) { 60 | XposedHelpers.setObjectField(obj, "host", "www.baidu.com"); 61 | } 62 | } 63 | }) 64 | } 65 | 66 | if (prefs.getBoolean("removeInstallerLimit", true)) { 67 | findAndHookMethod( 68 | "android.net.Uri", 69 | lpparam.classLoader, 70 | "parse", String::class.java, 71 | object : XC_MethodHook() { 72 | override fun beforeHookedMethod(param: MethodHookParam) { 73 | if (param.args[0].toString().contains("com.miui.securitycenter")) { 74 | param.args[0] = "ddddd" 75 | } 76 | } 77 | }) 78 | 79 | // return (arg2.flags & 1) > 0 || arg2.uid < 10000; 80 | findAndHookMethod( 81 | "com.android.packageinstaller.e", 82 | lpparam.classLoader, 83 | "a", ApplicationInfo::class.java, 84 | object : XC_MethodHook() { 85 | override fun beforeHookedMethod(param: MethodHookParam) { 86 | param.result = true 87 | } 88 | }) 89 | 90 | // 隐藏开启纯净模式提示 91 | // SafeModeTipViewObject safeModeTipViewObject = new SafeModeTipViewObject(h10, pureModeElderTipViewObject.f5884m, null, null, 12, null); 92 | // safeModeTipViewObject.a(); a方法里的调用 93 | findAndHookMethod( 94 | "com.miui.packageInstaller.ui.listcomponets.f0", 95 | lpparam.classLoader, 96 | "a", 97 | object : XC_MethodHook() { 98 | @Throws(Throwable::class) 99 | override fun afterHookedMethod(param: MethodHookParam) { 100 | super.afterHookedMethod(param) 101 | XposedHelpers.setBooleanField(param.thisObject, "l", false); 102 | } 103 | }) 104 | } 105 | } 106 | 107 | if (lpparam.packageName.equals("com.android.mms")) { 108 | if (prefs.getBoolean("removeMmsAd", true)) { 109 | hookAllMethods( 110 | "com.miui.smsextra.http.RequestResult", 111 | lpparam.classLoader, 112 | "data", 113 | object : XC_MethodHook() { 114 | override fun afterHookedMethod(param: MethodHookParam) { 115 | var result = param.result 116 | if (result.toString().contains("modules")) { 117 | param.result = "{}"; 118 | } 119 | } 120 | } 121 | ) 122 | hookAllMethods( 123 | "com.miui.smsextra.ui.UnderstandButton", 124 | lpparam.classLoader, 125 | "requestAD", 126 | XC_MethodReplacement.returnConstant(false) 127 | ) 128 | } 129 | } 130 | 131 | if (lpparam.packageName.equals("com.miui.systemAdSolution")) { 132 | if (prefs.getBoolean("removeSplashAd2", false)) { 133 | 134 | findAndHookMethod( 135 | "com.xiaomi.ad.entity.cloudControl.cn.CNDeskFolderControlInfo", 136 | lpparam.classLoader, 137 | "isCloseAd", 138 | XC_MethodReplacement.returnConstant(true) 139 | ) 140 | 141 | findAndHookMethod( 142 | "com.xiaomi.ad.common.pojo.AdType", 143 | lpparam.classLoader, 144 | "valueOf", 145 | Int::class.java, 146 | XC_MethodReplacement.returnConstant(0) 147 | ) 148 | } 149 | } 150 | 151 | if (lpparam.packageName.equals("com.miui.securitycenter")) { 152 | if (prefs.getBoolean("disableWaiting", true)) { 153 | findAndHookMethod("android.widget.TextView", 154 | lpparam.classLoader, 155 | "setEnabled", 156 | Boolean::class.java, 157 | object : XC_MethodHook() { 158 | override fun beforeHookedMethod(param: MethodHookParam) { 159 | param.args[0] = true 160 | } 161 | }) 162 | findAndHookMethod("android.widget.TextView", 163 | lpparam.classLoader, 164 | "setText", 165 | CharSequence::class.java, 166 | TextView.BufferType::class.java, 167 | Boolean::class.java, 168 | Int::class.java, 169 | object : XC_MethodHook() { 170 | override fun beforeHookedMethod(param: MethodHookParam) { 171 | if (param.args.isNotEmpty() && param.args[0]?.toString() 172 | ?.startsWith("确定(") == true 173 | ) { 174 | param.args[0] = "确定" 175 | } 176 | } 177 | }) 178 | } 179 | } 180 | 181 | 182 | // Global 183 | if (findClassWithOutLog("com.xiaomi.ad.server.AdLauncher", lpparam.classLoader) != null) { 184 | findAndHookMethod( 185 | "com.xiaomi.ad.server.AdLauncher", 186 | lpparam.classLoader, 187 | "initCrashMonitor", 188 | XC_MethodReplacement.returnConstant(false) 189 | ) 190 | } 191 | } 192 | } 193 | --------------------------------------------------------------------------------