zhuowei / MCPELauncher

Source code for BlockLauncher, a launcher that patches Minecraft for Android
Apache License 2.0
670 stars 193 forks source link

ABI override no longer works on Android 13 #1522

Open cinit opened 8 months ago

cinit commented 8 months ago

ABI override with IActivityManager.startInstrumentation(..., abiOverride = ...) will no longer work since Android 13 because of the following check in ActivityManagerService.java.

            if (!Build.IS_DEBUGGABLE && callingUid != ROOT_UID && callingUid != SHELL_UID
                    && callingUid != SYSTEM_UID && !hasActiveInstrumentationLocked(callingPid)) {
                // If it's not debug build and not called from root/shell/system uid, reject it.
                final String msg = "Permission Denial: instrumentation test "
                        + className + " from pid=" + callingPid + ", uid=" + callingUid
                        + ", pkgName=" + mInternal.getPackageNameByPid(callingPid)
                        + " not allowed because it's not started from SHELL";
                Slog.wtfQuiet(TAG, msg);
                reportStartInstrumentationFailureLocked(watcher, className, msg);
                throw new SecurityException(msg);
            }

Attempts to call startInstrumentation will fail with the following exception.

java.lang.SecurityException: Permission Denial: instrumentation test ComponentInfo{net.zhuoweizhang.mcpelauncher/net.zhuoweizhang.mcpelauncher.RelaunchInstrumentation} from pid=15401, uid=10591, pkgName=net.zhuoweizhang.mcpelauncher not allowed because it's not started from SHELL
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3040)
    at android.os.Parcel.createException(Parcel.java:3024)
    at android.os.Parcel.readException(Parcel.java:3007)
    at android.os.Parcel.readException(Parcel.java:2949)
    at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5500)

This disables any attempt to run Instrumentation without a shell/system/root uid on a production device.

Any possible solutions/alternative for that?

nikolayKeniston commented 8 months ago

the blocklauncher does not work not only on android 13, but on all its versions above the eighth for a variety of different problems, and obviously no one is going to fix it. if you need scripting functionality so much, then it's easier to write your own launcher from scratch using a relay system and android capabilities.

nikolayKeniston commented 8 months ago

Blocklauncher is very outdated and it is not possible to use it now

cinit commented 8 months ago

Frankly, I'm not going to run Minecraft or load scripts. I'm just looking for an approach about dynamically switching ABI in my own app, and that is not much related with Minecraft. The only implementation I have ever seen is MCPELauncher and sadly the method it uses doesn't work on Android 13. I hadn't ever seen any other applications being able to archive this.

For your information, this is a bug fix for CVE-2023-21089. This bug fix may be backported to Android 11 and 12 so that older versions may be also affected.