Skip to content

Commit

Permalink
fix Android 15 / HyperOS 2
Browse files Browse the repository at this point in the history
  • Loading branch information
qhy040404 committed Nov 9, 2024
1 parent 2098ea5 commit f8d7007
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 126 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
**/build
/captures
.externalNativeBuild
.cxx
local.properties
app/release
/.idea/
6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/discord.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/gradle.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/kotlinc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/migrations.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/qhy040404/fxxkmiuiad/utils/OsUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
34 changes: 25 additions & 9 deletions app/src/main/java/com/qhy040404/fxxkmiuiad/utils/PackageUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
}
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 7 additions & 23 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
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
3 changes: 2 additions & 1 deletion hidden-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
11 changes: 6 additions & 5 deletions hidden-api/src/main/java/android/content/pm/IPackageManager.java
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit f8d7007

Please sign in to comment.