Enable Xposed modules from shell
Asked Answered
S

2

5

Is there an API to enable an Xposed module in Android from the shell (using ADB) and not through the device's UI.

This is constantly a bother for automation, when we need to install our module on a clean test emulator. This is currently the only step that we are required to do manually.

A simple google search + overview of the XPosed documentation didn't yield anything worth while.

Sublimate answered 7/4, 2015 at 14:49 Comment(0)
S
6

As you already know, this is approach disfavored for end-users, but for testing, you have to echo the path of the apk to Xposed config file:

Pre-Lollipop:

adb shell "echo '/data/app/com.xyz.example-1.apk' >> /data/data/de.robv.android.xposed.installer/conf/modules.list"

Lollipop and newer:

adb shell "echo '/data/app/com.xyz.example-1 OR -2/base.apk' >> /data/data/de.robv.android.xposed.installer/conf/modules.list"

For these commands you need to have your emulator support root adb, type

adb root

into the command line. If your emulator doesn't support rooted/insecure adbd, you can also add a su -c before the echo to get root rights.

EDIT: the easiest way to find which number you have to use in directory name would be what @brendan suggested.

Southern answered 6/5, 2015 at 18:9 Comment(2)
doesn't work for me. The module is still not enabled after adding it to the modules.list fileSublimate
Did you reboot then and check the file after that again? Also be sure it was actually written to the file. Maybe you even need to reboot twice?Southern
Y
1

This worked for me on KitKat:

(1) Update shared_pres xml file:

If you look at the /data/data/de.robv.android.xposed.installer/shared_prefs/ directory. You will see an enabled_modules.xml file.

In my case I was only working with a single module so I would just overwrite the file. If you have several modules you may wish to do an edit/update.

I would have a local enabled_modules.xml file that looked like this:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<map>
  <int name="com.companyname.xposedmodule" value="1" />
</map>

...where com.companyname.xposedmodule is the name of your module.

Then post build you can execute a simple:

adb push enabled_modules.xml /data/data/de.robv.android.xposed.installer/shared_prefs/

(2) Update modules.list config file:

You also need to do what @Maxr1998 suggested. I scripted it this way:

adb shell "[ -f /data/app/com.companyname.xposedmodule-1.apk ] && echo '/data/app/com.companyname.xposedmodule-1.apk' >> /data/data/de.robv.android.xposed.installer/conf/modules.list
adb shell "[ -f /data/app/com.companyname.xposedmodule-2.apk ] && echo '/data/app/com.companyname.xposedmodule-2.apk' >> /data/data/de.robv.android.xposed.installer/conf/modules.list
Yonne answered 21/7, 2015 at 16:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.