Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Xposed modules from shell

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.

like image 371
eladidan Avatar asked Apr 07 '15 14:04

eladidan


People also ask

Can I install xposed without root?

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.


2 Answers

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.

like image 200
Maxr1998 Avatar answered Oct 27 '22 14:10

Maxr1998


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
like image 23
brendan Avatar answered Oct 27 '22 12:10

brendan