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.
There already are non-root implementations of xposed like Taichi which utilizes profiles and requires cloning apps into an environment that isn't capable of running at the system level.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With