From f8d70079678a6b5ccb6c0d8363c5415be75cc7ed Mon Sep 17 00:00:00 2001 From: qhy040404 Date: Sat, 9 Nov 2024 10:51:36 +0800 Subject: [PATCH] fix Android 15 / HyperOS 2 --- .gitignore | 7 +--- .idea/compiler.xml | 6 ---- .idea/deploymentTargetDropDown.xml | 10 ------ .idea/discord.xml | 7 ---- .idea/gradle.xml | 20 ----------- .idea/kotlinc.xml | 6 ---- .idea/migrations.xml | 10 ------ .idea/misc.xml | 10 ------ .idea/vcs.xml | 6 ---- app/build.gradle.kts | 10 +++--- .../com/qhy040404/fxxkmiuiad/utils/OsUtils.kt | 5 +++ .../fxxkmiuiad/utils/PackageUtils.kt | 34 ++++++++++++++----- build.gradle.kts | 4 +-- gradle.properties | 30 ++++------------ hidden-api/build.gradle.kts | 3 +- .../android/content/pm/IPackageManager.java | 11 +++--- 16 files changed, 53 insertions(+), 126 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/deploymentTargetDropDown.xml delete mode 100644 .idea/discord.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/kotlinc.xml delete mode 100644 .idea/migrations.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 064067c..c8e233a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,6 @@ *.iml .gradle /local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml .DS_Store **/build /captures @@ -14,3 +8,4 @@ .cxx local.properties app/release +/.idea/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index b589d56..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 0c0c338..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index 30bab2a..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 7799d53..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index d4b7acc..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml deleted file mode 100644 index f8051a6..0000000 --- a/.idea/migrations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 0ad17cb..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8fbb077..3bc1a02 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,14 +6,14 @@ plugins { android { namespace = "com.qhy040404.fxxkmiuiad" - compileSdk = 34 + compileSdk = 35 defaultConfig { applicationId = "com.qhy040404.fxxkmiuiad" minSdk = 29 - targetSdk = 34 - versionCode = 7 - versionName = "1.2.3" + targetSdk = 35 + versionCode = 9 + versionName = "1.3.1" } buildFeatures { @@ -54,7 +54,7 @@ configurations.all { dependencies { compileOnly(project(":hidden-api")) - implementation("androidx.annotation:annotation:1.9.0") + implementation("androidx.annotation:annotation:1.9.1") implementation("com.google.android.material:material:1.12.0") implementation("dev.rikka.rikkax.appcompat:appcompat:1.6.1") implementation("dev.rikka.shizuku:api:13.1.5") diff --git a/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/OsUtils.kt b/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/OsUtils.kt index 23f84e0..d0fc306 100644 --- a/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/OsUtils.kt +++ b/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/OsUtils.kt @@ -12,6 +12,11 @@ object OsUtils { return Build.VERSION.SDK_INT >= 33 } + @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.VANILLA_ICE_CREAM) + fun atLeastV(): Boolean { + return Build.VERSION.SDK_INT >= 35 + } + fun isMiui(context: Context): Boolean { return context.packageManager.asCompat().getPackageInfo(Constants.MIUI_ROM, 0) != null } diff --git a/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/PackageUtils.kt b/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/PackageUtils.kt index 5c7ed0a..cfb8324 100644 --- a/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/PackageUtils.kt +++ b/app/src/main/java/com/qhy040404/fxxkmiuiad/utils/PackageUtils.kt @@ -56,16 +56,32 @@ object PackageUtils { fun setPackagesSuspendedAsUser(packageName: String, suspended: Boolean) { HiddenApiBypass.addHiddenApiExemptions("") - IPackageManager.Stub.asInterface( + val mInterface = IPackageManager.Stub.asInterface( ShizukuBinderWrapper(SystemServiceHelper.getSystemService("package")) - ).setPackagesSuspendedAsUser( - arrayOf(packageName), - suspended, - null, - null, - null, - "com.android.shell", - 0 ) + + if (OsUtils.atLeastV()) { + mInterface.setPackagesSuspendedAsUser( + arrayOf(packageName), + suspended, + null, + null, + null, + 0, + "com.android.shell", + 0, + 0 + ) + } else { + mInterface.setPackagesSuspendedAsUser( + arrayOf(packageName), + suspended, + null, + null, + null, + "com.android.shell", + 0 + ) + } } } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 60380e8..1b46d42 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.7.1" apply false - id("com.android.library") version "8.7.1" apply false + id("com.android.application") version "8.7.2" apply false + id("com.android.library") version "8.7.2" apply false id("org.jetbrains.kotlin.android") version "2.0.21" apply false id("dev.rikka.tools.refine") version "4.4.0" apply false } diff --git a/gradle.properties b/gradle.properties index 3c5031e..e0a6e73 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,7 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g +org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configuration-cache=true +android.enableAppCompileTimeRClass=true +android.enableBuildConfigAsBytecode=true +android.useAndroidX=true \ No newline at end of file diff --git a/hidden-api/build.gradle.kts b/hidden-api/build.gradle.kts index 4a96ea9..b488087 100644 --- a/hidden-api/build.gradle.kts +++ b/hidden-api/build.gradle.kts @@ -4,10 +4,11 @@ plugins { android { namespace = "com.qhy040404.fxxkmiuiad.hidden_api" - compileSdk = 34 + compileSdk = 35 } dependencies { annotationProcessor("dev.rikka.tools.refine:annotation-processor:4.4.0") compileOnly("dev.rikka.tools.refine:annotation:4.4.0") + compileOnly("androidx.annotation:annotation:1.9.1") } diff --git a/hidden-api/src/main/java/android/content/pm/IPackageManager.java b/hidden-api/src/main/java/android/content/pm/IPackageManager.java index 8c2b92a..ae4ecfd 100644 --- a/hidden-api/src/main/java/android/content/pm/IPackageManager.java +++ b/hidden-api/src/main/java/android/content/pm/IPackageManager.java @@ -1,20 +1,21 @@ package android.content.pm; import android.os.Binder; +import android.os.Build; import android.os.IBinder; import android.os.IInterface; import android.os.PersistableBundle; import android.os.RemoteException; +import androidx.annotation.ChecksSdkIntAtLeast; + public interface IPackageManager extends IInterface { void setApplicationEnabledSetting(String packageName, int newState, int flags, int userId, String callingPackage); -// String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, -// PersistableBundle appExtras, PersistableBundle launcherExtras, -// SuspendDialogInfo dialogInfo, String suspendingPackage,int flags); - - String[] setPackagesSuspendedAsUser(String[] strArr, boolean z, PersistableBundle persistableBundle, PersistableBundle persistableBundle2, SuspendDialogInfo suspendDialogInfo, String str, int i) throws RemoteException; + String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, PersistableBundle appExtras, PersistableBundle launcherExtras, SuspendDialogInfo dialogInfo, String callingPackage, int userId) throws RemoteException; + @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.VANILLA_ICE_CREAM) + String[] setPackagesSuspendedAsUser(String[] packageNames, boolean suspended, PersistableBundle appExtras, PersistableBundle launcherExtras, SuspendDialogInfo dialogInfo, int flags, String callingPackage, int suspendingUserId, int targetUserId) throws RemoteException; abstract class Stub extends Binder implements IPackageManager { public static IPackageManager asInterface(IBinder obj) {