2

Is it possible to activate Xposed-modules automatically rather than checking them to be active in the Xposed GUI? Is the enabled status of the modules stored somewhere easily accessible (on a rooted device)...?

JohnyTex
  • 3,323
  • 5
  • 29
  • 52
  • 1
    You could achieve it with root access, but you would need to get root access first, so there isn't any real benefit to that route. This is a security feature, it's the same reason you have to manually click "Install" when you open an APK file. – Andrew Sun Sep 17 '16 at 21:42
  • That is OK for me. I have root access on the multiple devices I would like to have the Xposed modules auto-activated on. How would I go about -do you know? – JohnyTex Sep 19 '16 at 11:37
  • 1
    You can modify the `conf/modules.list` file in the Xposed Installer data directory (see [here](https://github.com/rovo89/XposedBridge/blob/fb9e5f5a95d55cf6c35bec431360b574f1b8472d/app/src/main/java/de/robv/android/xposed/XposedInit.java#L343) for the source code). Note that you still need to reboot the device afterwards. – Andrew Sun Sep 19 '16 at 19:18
  • If you put this as an answer I will mark it as such, because it was exactly what I was looking for. – JohnyTex Sep 21 '16 at 07:29

1 Answers1

2

You can achieve this by modifying the conf/modules.list file in the Xposed Installer data directory, simply add the path of your APK file to the list.

You should also modify the shared_prefs/enabled_modules.xml file, so that your change is reflected within Xposed Installer (otherwise, the module will be enabled but will show as disabled within Xposed Installer).

The device needs to be rebooted after the change.

Note that this requires root access, since the file is located in the internal data directory of another app. I strongly recommend just going the normal way and opening the Xposed Installer app, and let the user enable the module themselves:

public static boolean startXposedActivity(Context context) {
    Intent intent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION");
    intent.putExtra("section", "modules");
    try {
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        return false;
    }
}
Andrew Sun
  • 4,101
  • 6
  • 36
  • 53
  • It works and I understand the risks involved. I am working in a controlled environment. However, in conf/modules.list ; the apks are listed rather than the package names which is annoying for me because android appends -1.apk -2.apk and so on. Do you know the reasoning behind this scheme? I wan't the apks to be activated even before installation so I can't know the name yet. Is it better to copy the apk into /data/app? What does pm install apk really do other than that anyway? – JohnyTex Sep 26 '16 at 14:31
  • 1
    @JohnyTex I believe it's so that Android can update apps while running. It will alternate between -1 and -2, and after the update is complete it will swap the "active path" and delete the old version. You could probably get it to always install as -1 every time by uninstalling the app first (but you would lose your app data). – Andrew Sun Sep 26 '16 at 14:40
  • OK, so you don't believe it could ever be -3 or -4 and so on? I thought it might have something to do with multidex or something, but you believe not? – JohnyTex Sep 26 '16 at 14:41
  • 1
    @JohnyTex I have never seen -3 or -4. Another solution would be to add both file paths to the module list, invalid entries are ignored I believe. – Andrew Sun Sep 26 '16 at 14:53
  • I am finding myself getting a whole lot of bootloops when mixturing with this stuff... – JohnyTex Sep 26 '16 at 15:41
  • Actually it only seems to work if the Xposed Framework jar is installed. – JohnyTex Sep 27 '16 at 12:08
  • Thanks Andrew for pointing in the right direction. After opening modules.list, I can see there's a scheme followed for example after packageName there's a short base64 encoded string ending with ==. Any idea how to generate that an append. Here is the scheme `/data/app/package.name-yT74H9aC2ZC_UUkg==/base.apk` – Muhammad Babar Feb 20 '20 at 11:07