Xposed framework for Android: What is it and how to use it

For the average user, phone customisation usually extends no further than installing apps from Google Play. But for serious Android fans, that’s not even where it begins. Few serious users can live without their custom ROMs, ROMs that have been modified, root-accessed and rebuilt to within an inch of their lives in order to ditch the bloatware and add in must-have features. But custom ROMs don’t work for everyone and often see original device features disappear through a lack of openly-available driver code.

One example is CyanogenMod and Samsung’s Galaxy S3. The phone has included Miracast (de-facto wireless-HDMI) support in Samsung’s stock ROMs since Jelly Bean (Android 4.1), but CyanogenMod and most AOSP (Android Open Source Project) ROMs often have it missing. A reader of our sister publication, TechLife, recently tried CyanogenMod on his Samsung Galaxy S2 phone, only to find that his GPS no longer worked. He decided he wanted to go back to a stock ROM.

Custom ROMs are great at providing new features not found in stock ROMs and losing the bloatware, but for many, the cost of losing phone functionality becomes too high. However, there’s an increasingly popular alternative that allows advanced users to have the best of both worlds — stock ROMs but with ultimate control over the Android OS. It’s called the Xposed Framework.

xposed-installer

Xposed is a module manager, but is its own download manager as well.

A different kind of ‘custom’

The traditional way to get your favourite customisations into your Android device is to bake them into a custom ROM, flash it to your device and away you go. The Xposed Framework is different — it allows you to customise virtually any part of the Android OS right down to the system level without the need for a custom ROM. It works with any Android OS from 4.0 up — including stock ROMs, so you get all the functionality of your stock ROM, but the ability to modify it as though it was a custom ROM.

How it works

Xposed hacks into Android’s Dalvic runtime engine — inside the engine, there’s a process responsible for running all Android apps called Zygote and it’s launched from the /init.rc initialisation script as soon as your Android device kicks over (we looked at this script in our ‘Build your own Android ROMs’ masterclass series). Zygote is launched by the /system/bin/app_process executable and the Xposed Framework’s trick is to replace this executable with a modified version that loads up an extra file — a Java archive (.jar) called /data/xposed/XposedBridge.jar. As its name suggests, it acts as a bridge into Zygote, allowing you to run extra code as if it was part of Zygote itself.

According to Xposed’s creator, Rovo89, the framework lets you hook into Android’s ‘method’ calls (a method is Java’s version of a function in C++ or a procedure in Visual Basic). Not only that, but you can redefine anything about the Method object and even replace it with your own — all without the original app that called the method knowing about it.

You use the framework by installing ‘modules’, which are essentially just Android apps that have extra meta-data up front to indicate that they’re Xposed framework modules. The beauty of this is that you can run as many modules as you want, each one providing one or more customisations and because they tap into the Dalvic runtime engine (and importantly, do their thing at runtime), you don’t need to worry about installing a new ROM.

Security risks?

But if Xposed allows code to tap into Zygote, doesn’t that pose a security risk? Yep, it does — but then again, so does gaining root-access, installing custom ROMs and almost every other OS-level modification you can do to an Android device. But you can’t have this level of access to the runtime engine to run any code you want and expect watertight security at the same time.

What would be worse is if Xposed simply launched modules as soon as they install — if that happened, you could have seemingly harmless apps launching hidden module payloads without you knowing about it, doing untold damage.

However, Xposed prevents this from occurring by requiring you to enable every module after it’s installed. It’s similar to SuperSU asking to grant/deny execution of an app requiring shell access.

The module app will install; you can even launch it — but it won’t access the Xposed framework until you enable it to do so, ensuring (as much as possible) nothing happens without your knowledge and say-so.

Bottom line, Xposed is a potential security risk, but then, so is much of the fun stuff.

exposed-enabling-module

Enabling a module just requires ticking a checkbox and rebooting your device.

What you need

You only need three things to start running customisation modules — a device with at least Android 4.0, root-access and the Xposed Framework. For obvious reasons, you won’t find Xposed on Google Play, but you can download the latest version as a standard APK installer file from dl.xposed.info/latest.apk. Installation and setup are straightforward — install the APK, launch the app, tap ‘Framework’, then ‘Install/Update’. Once done, you reboot your device and that’s it. From there, you can begin installing modules and customising your stock ROM.

Where to get modules

Because modules are modified Android apps with added meta-data, you won’t likely find any in Google Play (Google is a bit funny about apps taking advantage of Android hacks — go figure) but you will find them over at repo.xposed.info. You’ll also find them in the Xposed Installer app once you’ve installed the framework. Launch the app and select Download. This will give you a list of ‘installed’ and ‘not installed’ modules — in effect, it’s your Google Play for modules, initially listed in alphabetical order.

Another place to find the very latest modules is the xda-developer’s forum at forum.xda-developers.com and just search for ‘Xposed’.

xposed-modules-range

The Download section provides instant access to a range of Xposed modules.

Installing modules

Installing modules is straightforward as well — select a module you want to install from the Xposed Installer app’s Download page, read the blurb, scroll down and select the Download button. Download the module APK file, install it and go back to the Xposed Installer app. Select Modules and you should now see the module in the list. Tap the checkbox next to the module to enable it, reboot and the module should be ready to go. Each module’s individual features are controlled by the module app while the Xposed Installer app is your module manager. You use Xposed Installer to enable/disable any module at any time by dialling them up in the Modules page, unchecking the relevant checkbox and rebooting your device. Sure, the constant rebooting might seem a chore, but try disabling a custom feature baked inside a custom ROM and see how you go.

xposed-framework-root-access

Xposed Framework requires root access for installation — and a reboot.

Which modules to use

Because it taps into the Android runtime engine, there really isn’t anything off limits to customisation. However, while there are plenty of modules to choose from, not all of them work on every device. Since Xposed gives you full access to virtually everything in the OS, it also includes phone-specific functions, resulting in a number of phone-specific modules. Most modules will indicate if they’re for a particular phone or can be used on any device. Just don’t be surprised if modules not meant for your device don’t work.

What can you do with Xposed? You know how Xposed works, but what to do you do with it? There are at least 200 different customisations available so far, some phone-specific as we’ve mentioned, but others that work on any device.

One we’ve taken a shine to is YouTube AdAway — it’s pretty simple: it allows you to hide YouTube ad layers, channel logos and channel suggestions. We tested it on the latest OmniROM 4.4.2 nightly with YouTube update 5.3.32 and it worked a treat — without YouTube AdAway, we saw the usual pre-start ad appear before a video clip; enable AdAway and the same clip played straight away without ads.

This isn’t a modified YouTube app; instead, it modifies your ROM’s existing YouTube app at runtime to remove the unwanted intrusions. And that’s the clever thing about Xposed — it enables modified app behaviour without having to lock into a particular app version or, in most cases, ROM version. What’s more, YouTube AdAway is one of those modules said to work with any Android device running at least Android 4.0 and the Xposed Framework.

xposed-youtube-adaway

YouTube AdAway uses Xposed to hide YouTube ads, logos and channel suggestions.

Another module that shows just how far you can burrow down into the OS and take control is XVolume. It’s a simple module with one task — to expand the granularity or number of steps for the volume buttons in both call and media mode. You can choose 15, 30 or 45 steps for each and save the settings. It may not sound all that interesting, but if you’re struggling to get your headphone volume just the way you want through too few volume steps, this is the ideal fix. We tested it on our Galaxy S3 phone, cranked it to 45 steps, fire up YouTube and sure enough, we had super-smooth volume adjustment. That said, the phone volume steps didn’t change, showing that more-generic customisations may not work perfectly on every device — but it sure beats having to find a custom ROM with everything exactly as you want it.

xposed-xvolume

XVolume increases the volume button step granularity from 15 to 45.

There are notification modules as well — one geeky one worth a look is ‘CPUtemp on StatusBar’. Yep, it could use a snappier name, but as it suggests, this module displays the device’s CPU temperature on the statusbar. Now if you’re thinking there’s an app for that, you’re right, there is — but it needs a custom kernel to work. Again, that’s the benefit of the Xposed framework — you don’t need custom kernels because you’re effectively customising your own stock kernel. It’s also well worth keeping an eye on the xda-developers.com web site for really fresh modules.

One that’s just a few weeks old is Intelli3G. This one is clever — it’s a 3G network connection manager. It automatically switches your device’s network mode from 3G/LTE to 2G whenever you’re in range of a Wi-Fi connection, but is smart enough to ensure you don’t lose data if the 3G connection is being used. The benefit? Extra battery life — the developer estimates he lost 3-4% battery life per hour on his Nexus 4 phone simply having 3G network mode idling. Switching back to 2G dropped this down to less than 1%.

Making your own modules

The whole Xposed framework is open-source and the source code is freely available. Not only that, but you can also create your own modules. Xposed developer Rovo89 has a fairly comprehensive development tutorial over at github.com/rovo89/XposedBridge/wiki/Development-tutorial and it’s well worth a read, even if you just want to further understand how Xposed works.

Since modules are just modified Android apps, you create modules the same way — using the Eclipse IDE and the Android SDK. In short, the key difference with a module is a meta-data flag the Xposed Installer looks for. You just add this codeline to the module app’s AndroidManifest.xml file:

<meta-data android:value=”true” android:name=”xposedmodule”/>

The flag is ‘xposedmodule’ and setting its value to ‘true’ indicates the app is an Xposed module.

Xposed’s future

With Google in the process of switching its runtime engine from Dalvic to ART, you can be sure there are developers galore right now looking at the changes — particularly those that hack into the OS like Xposed. For now, Xposed doesn’t run on ART. You’ll find that installing the framework on KitKat (Android 4.4+) resets the runtime engine option back to Dalvic. Without this forced change, your device would be stuck in a boot-loop, otherwise. However, it’s unlikely Dalvic will disappear any time soon, so don’t let that hold you back from trying it out.

There’s a certain level of kudos that comes from being able to develop your own customised ROM, no question — but the Xposed framework gives developers a potentially larger audience for their wares simply because users don’t have to change the device ROM. Yes, Xposed requires root-access and is arguably a security risk, but the reward of ultimate customisation of stock ROMs may well be worth it.

Warning! Use it at your own risk.

The Xposed Framework requires root access and modifies your Android device’s operating system. We recommend you make a Nandroid backup of your device and know how to restore it before installing the software in case things go wrong. While we have successfully tested the information in this article, it is provided as-is and without warranty. Use it at your own risk.

xposed-installer-logs

Xposed Installer keeps a log of all framework transactions.

  • thank you for sharing such a useful information.As there has been a rise in the numbers of mobile users, there is a demand for gaming and social networking apps noticed. There are varied platforms from the range of Android applications to Blackberry, IOS and a few more. The main usage spreads into the area of content sharing and a great deal of variation is seen in the user experience. This is not only the most loved part of all the mobile users, but also adds a great deal of variation in user experience. Content sharing not only includes sharing pictures and songs with fellow beings, but also includes notes sharing, information, and study materials through the mobile internet.