rovo89 / android_art

Android ART with modifications for the Xposed framework.
Other
371 stars 211 forks source link

Zenfone2/x86: initZygote not called, neither handleLoadPackage("android") called. #6

Closed sorgelig closed 9 years ago

sorgelig commented 9 years ago

As i've told in my previous issue, it looked like Xposed successfully compiled and worked on X86(Zenfone2). Even some xposed module worked. Now i'm trying to modify my old xposed module to lollipop and found that initZygote not called. I don't see my debug message:

    public void initZygote(StartupParam startupParam) throws Throwable 
    {
        Util.log(Log.INFO, String.format("load %s", startupParam.modulePath));
    }

Also, i've discovered from logcat, there are no any initial startup xposed messages. handleLoadPackage() called with packages, but there is no handleLoadPackage("android") call.

I'm not sure if this problem belongs to not correctly worked xposed binaries/libraries, or simply my module not correctly updated to lollipop (although, it worked fine in KitKat/ARM). That's why I post it here instead of module forum.

So, where i have to check?

Can it be due to SELinux with restrictive mode? Although, i don't see selinux messages about xposed in logcat.

sorgelig commented 9 years ago

There is one exception from Xposed i see. Not sure if this is the reason:

05-05 23:50:40.090 E/Xposed  ( 9618): java.lang.NoSuchMethodError: android.content.res.ResourcesKey(java.lang.String,java.lang.Integer,null,java.lang.Float,null,java.lang.Boolean)#bestmatch
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedHelpers.findConstructorBestMatch(XposedHelpers.java:469)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedHelpers.findConstructorBestMatch(XposedHelpers.java:476)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedHelpers.newInstance(XposedHelpers.java:1032)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.AndroidAppHelper.createResourcesKey(AndroidAppHelper.java:90)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.AndroidAppHelper.addActiveResource(AndroidAppHelper.java:108)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.content.res.XModuleResources.createInstance(XModuleResources.java:33)
05-05 23:50:40.090 E/Xposed  ( 9618):   at com.sorg.sandbox.HookFactory$AppSettings.hook(HookFactory.java:918)
05-05 23:50:40.090 E/Xposed  ( 9618):   at com.sorg.sandbox.HookFactory$loader.handleInitPackageResources(HookFactory.java:944)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.IXposedHookInitPackageResources$Wrapper.handleInitPackageResources(IXposedHookInitPackageResources.java:20)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.callbacks.XC_InitPackageResources.call(XC_InitPackageResources.java:28)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:70)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge$7.afterHookedMethod(XposedBridge.java:369)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:698)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ResourcesManager.getTopLevelResources(Unknown Source)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1630)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:929)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:684)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ApplicationPackageManager.getResourcesForApplication(Unknown Source)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:945)
05-05 23:50:40.090 E/Xposed  ( 9618):   at eu.chainfire.supersu.Settings.f(Unknown Source)
05-05 23:50:40.090 E/Xposed  ( 9618):   at eu.chainfire.supersu.Application.v(Unknown Source)
05-05 23:50:40.090 E/Xposed  ( 9618):   at eu.chainfire.supersu.Application.onCreate(Unknown Source)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4550)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:684)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ActivityThread.handleBindApplication(Unknown Source)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ActivityThread.access$1500(ActivityThread.java:147)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.os.Handler.dispatchMessage(Handler.java:102)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.os.Looper.loop(Looper.java:135)
05-05 23:50:40.090 E/Xposed  ( 9618):   at android.app.ActivityThread.main(ActivityThread.java:5253)
05-05 23:50:40.090 E/Xposed  ( 9618):   at java.lang.reflect.Method.invoke(Native Method)
05-05 23:50:40.090 E/Xposed  ( 9618):   at java.lang.reflect.Method.invoke(Method.java:372)
05-05 23:50:40.090 E/Xposed  ( 9618):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
05-05 23:50:40.090 E/Xposed  ( 9618):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
05-05 23:50:40.090 E/Xposed  ( 9618):   at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117) 

I've found that XposedBridge wants constructor which is different. So, i've modified the source code of XposedBridge: (I've removed other versions, to eliminate wrong branch while trying to fix the problem)

    /* For SDK 19+ */
    private static Object createResourcesKey(String resDir, int displayId, Configuration overrideConfiguration, float scale, IBinder token, boolean isThemeable) {
        try {
            return newInstance(CLASS_RESOURCES_KEY, resDir, displayId, overrideConfiguration, scale, token, isThemeable);
        } catch (Throwable t) {
            XposedBridge.log(t);
            return null;
        }
    }

this is constructor of Landroid/content/res/ResourcesKey from ZF2 ROM:

# direct methods
.method public constructor <init>(Ljava/lang/String;ILandroid/content/res/Configuration;FLandroid/os/IBinder;Z)V
    .locals 4
    .param p1, "resDir"    # Ljava/lang/String;
    .param p2, "displayId"    # I
    .param p3, "overrideConfiguration"    # Landroid/content/res/Configuration;
    .param p4, "scale"    # F
    .param p5, "token"    # Landroid/os/IBinder;
    .param p6, "isThemeable"    # Z

    .prologue

So, it looks like i request correct parameters from constructor, right? But still have exception. The exception text above is already after my edition. You can see parameters in exception. Why Xposed still cannot find constructor? Does xposed handle simple/objected versions of parameters correctly? I mean Int == Integer, boolean == Boolean, float == Float, etc.?

sorgelig commented 9 years ago

got correct parameter list through logging:

(java.lang.String,int,android.content.res.Configuration,float,android.os.IBinder,boolean,android.content.res.ThemePack)

So, i've fixed this exception. No more exceptions in xposed log, but still neither initZygote() nor handleLoadPackage("android") get called.

rovo89 commented 9 years ago

Also, i've discovered from logcat, there are no any initial startup xposed messages.

That sounds more like an issue with the logging itself, e.g. https://github.com/rovo89/Xposed/issues/34 If you execute logcat yourself, the startup logging might have already gone out of the buffer. And the daemon that writes the logcat output to the Xposed log file doesn't some to work reliably on some ROMs. Do you get any output in that file?

Can it be due to SELinux with restrictive mode? Although, i don't see selinux messages about xposed in logcat.

Maybe. Have you made sure that the SELinux context for all the files you have installed are set correctly? Do they match the original contexts? Maybe Zygote and system_server are not allowed to write to logcat.

I suggest you try something else than logging in initZygote() directly. Declare a static variable in your module and change its value in initZygote(). Then log this value in handleLoadPackage().

rovo89 commented 9 years ago

I mean Int == Integer, boolean == Boolean, float == Float, etc.?

int != Integer. int can be autoboxed by the VM to an Integer. Anyway, findConstructorBestMatch() considers this as well.

So, i've fixed this exception.

OK, then please open an issue in https://github.com/rovo89/XposedBridge/ with this. Please also post (a link to) the full, decompiled ResourcesKey class.

sorgelig commented 9 years ago

I've posted issue in XposedBridge. About this issue: it's fixed after bumping Android SDK to 21, XposedBridge to 60 and manifest settings.

rovo89 commented 9 years ago

Thanks. So you just needed to change something in your module? Maybe it would have worked if you had called XposedBridge.log() directly? Have you verified that you don't include the XposedBridge classes in your module's APK?