Skip to content

Commit

Permalink
feat: fix PackageInstaller, change package name & update dependencies
Browse files Browse the repository at this point in the history
In newer versions, when certain conditions met, the `mOk` (Install) button will be disabled. This commit fixed this.

Package name changed to `krtl.xposed.iflytek` from `krtl.xposed.iflytekt10`.
  • Loading branch information
Keritial committed Jul 7, 2024
1 parent 96f5c9a commit 0c7a924
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 49 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Fuck IFlyTek T10 AI Learning Machine
# Fuck IFlyTek AI Learning Machine

Restores the normal behaviour of Package Installer.
Restore the normal behavior of the Android components, e.g., Package Installer.

## App scope

- Package Installer

## License

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ plugins {
}

android {
namespace = "krtl.xposed.iflytekt10"
namespace = "krtl.xposed.iflytek"
compileSdk = 34

defaultConfig {
applicationId = "krtl.xposed.iflytekt10"
applicationId = "krtl.xposed.iflytek"
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "v1.0.0-alpha.1"
versionName = "v1.0.0-alpha.2"

// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// vectorDrawables {
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:supportsRtl="true"
android:label="@string/app_name"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
tools:targetApi="31">
android:fullBackupContent="@xml/backup_rules">
<meta-data
android:name="xposedmodule"
android:value="true"/>
Expand All @@ -18,7 +16,6 @@
<meta-data
android:name="xposedminversion"
android:value="54"/>
<!-- 模块作用域 -->
<meta-data
android:name="xposedscope"
android:resource="@array/xposedscope"/>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -1 +1 @@
krtl.xposed.iflytekt10.MainHook
krtl.xposed.iflytek.MainHook
68 changes: 68 additions & 0 deletions app/src/main/java/krtl/xposed/iflytek/MainHook.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package krtl.xposed.iflytek

import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XC_MethodReplacement
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.XposedHelpers.findAndHookMethod
import de.robv.android.xposed.XposedHelpers.getBooleanField
import de.robv.android.xposed.XposedHelpers.getObjectField
import de.robv.android.xposed.callbacks.XC_LoadPackage

class MainHook: IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
val packageName = lpparam.packageName

when (packageName) {
"com.android.packageinstaller" -> hookPackageInstaller(lpparam)
else -> return
}
}

private fun hookPackageInstaller(lpparam: XC_LoadPackage.LoadPackageParam) {
val packageInstallerClassLoader = lpparam.classLoader
val packageInstallerActivity = "com.android.packageinstaller.PackageInstallerActivity"

// Bypass checks and initiate install
findAndHookMethod(
packageInstallerActivity,
packageInstallerClassLoader,
"checkIfAllowedAndInitiateInstall",
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
XposedHelpers.callMethod(param.thisObject, "initiateInstall")
param.result = null // Prevent original method execution
}
}
)

// Allow new app installs
findAndHookMethod(
packageInstallerActivity,
packageInstallerClassLoader,
// IFlyTek-proprietary method for preventing new app installs
"isPackageInstalled",
String::class.java,
object : XC_MethodReplacement() {
override fun replaceHookedMethod(param: MethodHookParam) = true
}
)

// Some unknown weird stuff
findAndHookMethod(
packageInstallerActivity,
packageInstallerClassLoader,
"onResume",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
val mOkButton = getObjectField(param.thisObject, "mOk")
val mEnableOk = getBooleanField(param.thisObject, "mEnableOk")

if (mOkButton != null) {
XposedHelpers.callMethod(mOkButton, "setEnabled", mEnableOk)
}
}
}
)
}
}
32 changes: 0 additions & 32 deletions app/src/main/java/krtl/xposed/iflytekt10/MainHook.kt

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">去你的科大讯飞 AI 学习机 by Keritial</string>
<string name="xposed_description">恢复包管理安装程序正常的行为。</string>
<string name="app_name">去你的科大讯飞 AI 学习机</string>
<string name="xposed_description">恢复包管理安装程序等 Android 组件正常的行为。</string>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<string name="app_name">Fuck IFlyTek T10 AI Learning Machine</string>
<string name="xposed_description">Restore the normal behaviour of Package Installer.</string>
<string name="app_name">Fuck IFlyTek AI Learning Machine</string>
<string name="xposed_description">Restore normal behaviours of Android components, e.g., Package Installer.</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.3.0" apply false
id("com.android.application") version "8.5.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Mar 16 23:23:10 HKT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 0c7a924

Please sign in to comment.