tiann / KernelSU

A Kernel based root solution for Android
https://kernelsu.org
GNU General Public License v3.0
9.97k stars 1.62k forks source link

ANXCamera Magisk Module #719

Closed Theo-user closed 1 year ago

Theo-user commented 1 year ago

Describe the bug After installing the module without errors the ANX camera apk crashes when launching. Errors here: https://paste.crdroid.net/jgWxeP

To Reproduce Steps to reproduce the behavior: Install module here: https://androidfilehost.com/?fid=14655340768118463076 Restart and run ANXCamera

Expected behavior Load the camera like when using Magisk.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information): Poco F3 Crdroid 9.14 InfiniR_Alioth_v2.67 kernel

Additional context I have an issue when using Magisk without Zygist and and with MagiskHide. I need to allow SU for the camera apk. Doing this with KernelSU doesn't resolve the issue like with Magisk. It's most likely permissions but I've not been able to pinpoint it.

tiann commented 1 year ago

Disable the "umount modules by default" in settings and try it again.

Theo-user commented 1 year ago

Same error https://paste.crdroid.net/ljOhZA

Theo-user commented 1 year ago

Still not working with 0.6.2

tiann commented 1 year ago

What if you grant root permission to the camera?

Theo-user commented 1 year ago

I did both as you suggested but the error persists. Root permission is required for the camera with Magisk if I use Magisk hide and enforced root. No such luck with KernelSU.

tiann commented 1 year ago

Please upload the bugreport in KernelSU manager.

Theo-user commented 1 year ago

KernelSU_bugreport_2023-07-11_16_23.tar.gz

tiann commented 1 year ago

I think this is a module issue, the log show that:

open libmialgoengine.so failed

But the module don't have any file named that.

tiann commented 1 year ago

Please exec ls -alZ /vendor

Theo-user commented 1 year ago

~ $ ls -alZ /vendor ls: cannot access '/vendor/build.prop': Permission denied ls: cannot access '/vendor/firmware_mnt': Permission denied ls: cannot access '/vendor/ueventd.rc': Permission denied ls: cannot access '/vendor/bt_firmware': Permission denied ls: cannot access '/vendor/firmware': Permission denied total 84 drwxr-xr-x 1 root root ? 1024 Jul 11 16:22 . drwxr-xr-x 26 root root ? 4096 Jan 1 2009 .. drwxr-xr-x 8 root shell ? 4096 Jan 1 2009 app drwxr-x--x 3 root shell ? 8192 Jan 1 2009 bin d????????? ? ? ? ? ? ? bt_firmware -????????? ? ? ? ? ? ? build.prop drwxr-xr-x 4 root shell ? 4096 Jan 1 2009 camera drwxr-xr-x 6 root root ? 4096 Jan 1 1970 dsp drwxr-xr-x 19 root shell ? 4096 Jan 1 2009 etc d????????? ? ? ? ? ? ? firmware d????????? ? ? ? ? ? ? firmware_mnt drwxr-xr-x 10 root shell ? 16384 Jan 1 2009 lib drwxr-xr-x 1 root root ? 1024 Jul 11 16:22 lib64 drwx------ 2 root root ? 16384 Jan 1 2009 lost+found lrw-r--r-- 1 root root ? 4 Jan 1 2009 odm -> /odm drwxr-xr-x 3 root shell ? 4096 Jan 1 2009 odm_dlkm drwxr-xr-x 3 root shell ? 4096 Jan 1 2009 overlay drwxr-xr-x 3 root shell ? 4096 Jan 1 2009 radio drwxr-xr-x 5 root shell ? 4096 Jan 1 2009 rfs -????????? ? ? ? ? ? ? ueventd.rc drwxr-xr-x 3 root shell ? 4096 Jan 1 2009 vendor_dlkm

Screenshot_20230711-173619_Termux

tiann commented 1 year ago

Please use adb shell and su to list the files:

  1. adb shell
  2. su
  3. ls -alZ /vendor/lib64
Theo-user commented 1 year ago

Will this suffice?

output.txt

tiann commented 1 year ago

Did you use su to execute it?

Theo-user commented 1 year ago

I believe I did now.

output.txt

Thanks.

tiann commented 1 year ago

Please use adb shell or other terminal emulator, the SELinux context is missing.

Theo-user commented 1 year ago

output.txt

tiann commented 1 year ago

the logcat file of your bugreport is empty.

Theo-user commented 1 year ago

Please check this one

KernelSU_bugreport_2023-07-12_04_21.tar.gz

tiann commented 1 year ago

Please use adb shell execute setprop debug.ld.all dlopen,dlerror and reproduce the bug and then upload the bugreport.

tiann commented 1 year ago

I believe this is a module issue.

Your logcat shows that:

07-12 04:21:31.528 4031 4031 D MiCamAlgoInterfaceJNI: static initializer: loadLibrary camera_algoup_jni.xiaomi 07-12 04:21:31.529 4031 4031 E vndksupport: Could not load /vendor/lib64/libmialgoengine.so from sphal namespace: dlopen failed: library "/vendor/lib64/libmialgoengine.so" not found. 07-12 04:21:31.529 4031 4031 E MI_Algo_JNI: init: open /vendor/lib64/libmialgoengine.so error: (null) 07-12 04:21:31.529 4031 8350 D SharedPreferencesImpl: Time required to fsync /data/user/0/com.android.camera/shared_prefs/camera_settings_global.xml: [<1: 0, <2: 0, <4: 0, <8: 0, <16: 0, <32: 0, <64: 0, <128: 0, <256: 0, <512: 1, <1024: 0, <2048: 0, <4096: 0, <8192: 0, <16384: 0, >=16384: 0] 07-12 04:21:31.529 4031 4031 D AndroidRuntime: Shutting down VM 07-12 04:21:31.530 4031 4031 E AndroidRuntime: FATAL EXCEPTION: main 07-12 04:21:31.530 4031 4031 E AndroidRuntime: Process: com.android.camera, PID: 4031 07-12 04:21:31.530 4031 4031 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.android.camera.LocalParallelService: java.lang.RuntimeException: open libmialgoengine.so failed! 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:4522) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.app.ActivityThread.access$1700(ActivityThread.java:257) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2099) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7833) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: Caused by: java.lang.RuntimeException: open libmialgoengine.so failed! 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.xiaomi.engine.MiCamAlgoInterfaceJNI.init(Native Method) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.xiaomi.engine.MiCameraAlgo.init(Unknown Source:39) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.android.camera.LocalParallelService$LocalBinder.initMiviEngine(Unknown Source:24) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.android.camera.LocalParallelService$LocalBinder.(Unknown Source:55) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at com.android.camera.LocalParallelService.onCreate(Unknown Source:31) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:4509) 07-12 04:21:31.530 4031 4031 E AndroidRuntime: ... 9 more

And i decompile your camera APK:

public class MiCamAlgoInterfaceJNI {
    public static final String LIB_NAME = "camera_algoup_jni.xiaomi";
    public static final String TAG = "MiCamAlgoInterfaceJNI";

    static {
        try {
            Log.e(MiCamAlgoInterfaceJNI.class.getSimpleName(), "start loading camera_algoup_jni.xiaomi");
            System.loadLibrary(LIB_NAME);
            Log.d(TAG, "static initializer: loadLibrary camera_algoup_jni.xiaomi");
        } catch (UnsatisfiedLinkError e) {
            String str = TAG;
            Log.e(str, "can not load library:camera_algoup_jni.xiaomi : " + Log.getStackTraceString(e));
        }
    }

    public static native long createSessionByOutputConfigurations(BufferFormat bufferFormat, List<OutputConfiguration> list, TaskSession.SessionStatusCallback sessionStatusCallback);

    public static native long createSessionWithSurfaces(BufferFormat bufferFormat, List<Surface> list, TaskSession.SessionStatusCallback sessionStatusCallback);

    public static native int deInit();

    public static native int destroySession(long j);

    public static native int flush(long j);

    public static native int getVersionCode();

    public static native int init(String str);

    public static native int processFrame(long j, FrameData frameData, TaskSession.FrameCallback frameCallback);

    public static native int processFrameWithSync(long j, List<FrameData> list, Image image, int i);

    public static native int setMiViInfo(String str);
}

And in libcamera_algoup_jni.xiaomi.so, it shows:

  else
  {
    v26 = dlerror();
    __android_log_print(6LL, "MI_Algo_JNI", "init: open %s error: %s", "/vendor/lib64/libmialgoengine.so", v26);
    v27 = (*(__int64 (__fastcall **)(__int64 *, const char *))(*v8 + 48))(v8, "java/lang/RuntimeException");
    if ( v27 )
      (*(void (__fastcall **)(__int64 *, __int64, const char *))(*v8 + 112))(v8, v27, "open libmialgoengine.so failed!");
    (*(void (__fastcall **)(__int64 *, __int64))(*v8 + 184))(v8, v27);
    result = 0xFFFFFFFFLL;
  }

This is the error cause. But in my MIUI devices, it cannot open /vendor/lib64/libmialgoengine.so too, but it don't throw the error:

  {
    v25 = sub_E978();
    sub_E750(6LL, "MI_Algo_JNI", "init: open %s error: %s", "/vendor/lib64/libmialgoengine.so", v25);
    result = 0xFFFFFFFFLL;
  }
Theo-user commented 1 year ago

I don't know why it works fine when using Magisk.