Sunday, October 8, 2017

Official Xposed Framework for Android Nougat is Here – Download your Favorite Modules Now!

As the Android ecosystem has matured over the years, fewer and fewer users find reasons why they should root their device. There’s a growing trend of users choosing to stay on the stock firmware, either because they find the experience satisfactory or don’t want to play a cat-and-mouse game with Google’s SafetyNet API. But if you asked a user back in early 2016 why they rooted their phones, perhaps the number one reason that was given was so they could install the Xposed Framework. It’s been over a year since Android 7.0 Nougat was first released, but the long wait is finally over: official Xposed Framework for Android Nougat is finally available.

Throughout the past year, XDA Senior Recognized Developer rovo89, the lead developer of the Xposed Framework, has provided several updates on the progress of Xposed Framework for Android Nougat. For some, the wait has been tolerable mostly due to the sheer number of additional functionality that the Xposed Framework offers in Android Marshmallow. But many others have moved on to a life without Xposed on their devices.

We saw a glimpse of renewed excitement in the project when developer abforce released an ART submodule for AOSP 7.1.2, but as our very own GermainZ points out you were better off waiting for the official Xposed Framework release as abforce’s implementation required the framework to be integrated into custom ROMs. Furthermore, this unofficial implementation was incomplete, leading to inconsistent or buggy behavior with certain Xposed Modules.

While abforce did a great job in getting his unofficial Xposed working on Android 7.1 Nougat, his implementation went against rovo89’s vision for Xposed—that it should be a stable solution providing a reliable and easy to use contract for users and developers alike. What we mean by this is that not only should modules work without issue for users, but the way that modules are set up should be consistent among users so developers will know whether or not a Xposed Module is to blame for an app crash.

We no longer have to worry about such issues as rovo89 (after some help from XDA Recognized Developer wanam) is now ready to release an official update to the Xposed Framework and Installer—bringing compatibility with Android 7.0/7.1 Nougat. That means you won’t have to install a custom ROM or have to mess with flashing unstable versions to enjoy Xposed—just root your phone and install the latest Xposed Installer application (linked below) and the Xposed Installer will do the magic of installing Xposed for you.

Xposed Framework Installer Xposed Framework Installer

Xposed Installer Browsing the Module Repository

This might seem a bit late in some minds, especially since this release comes over a month after Android 8.0 Oreo was released. Keep in mind that very few devices will have access to a stable version of Android Oreo for many months to come. Android Oreo is only on 0.2% of all Android devices (compared to ~18% on Nougat) according to the latest statistics from Google, but many of our users are the kind who love installing custom ROMs to stay on the bleeding edge.

android oreo october distribution numbers

Android Version Distribution as of October 2017. Source: Google

Though even if you install an unofficial port of Android 8.0 available on a myriad of devices on our forums, many of these ports are not daily driver status. So unless you’re willing to shell out hundreds of dollars for a brand new Google Pixel 2/2 XL, Sony Xperia XZ1/XZ1 Compact, or an upcoming device such as the Huawei Mate 10, then you’ll probably be able to squeeze several months of use out of Xposed Framework on Android Nougat.

If that sounds like you, then head on over to the official forum thread for the Xposed Installer to get it up and running on your Android Nougat device.

Download Xposed Installer v3.1.2 from the XDA Xposed Forum

For the many newer users who are not as acquainted with what the Xposed Framework can be used for or how it works, we will briefly explain the Xposed Framework below, why you should be excited, and why development on this took as long as it did.


Why install the Xposed Framework?

Want to get custom ROM features without flashing a custom ROM? The mother of all Xposed Modules for tweaking your ROM, known as GravityBox, has you covered. Want to customize display settings on a per-app basis? Try App Settings. How about customizing certain applications like Hangouts? Or modifying Instagram so you can download whatever posts you like?

GravityBox ultimate notification control heads up

Xposed gives developers the ability to modify pretty much whatever they want—mostly aimed at individual applications but even system-wide features can be modified. The examples we listed is just the tip of the iceberg. The number of additional features you can add or apps you can modify is incredible—just search through the official Xposed Module repository to see for yourself.

How do Xposed Modules work?

The gist of it is that the Xposed Framework allows modules to “hook” into the Java methods of any application—be it user-installed or a system application. Xposed lets modules execute their own methods before, during, or in place of the original methods of the target application.

For instance, imagine a method used in the Gmail application that posts notifications for new emails. By default, the method creates a new notification with buttons to archive/delete or reply to the email. A Xposed Module could be made to hook into this method and add a new button such as “mark as read.” (Yes, there’s already a Module for just that.)

The above is an over-simplification of the end result of what the Xposed Framework allows its modules to do. The Framework itself is incredibly complex and making it work nearly universally on rooted devices—without needing a custom ROM—is why Xposed for Android Nougat has taken so long to complete.

Why does Xposed development take so long?

The magic behind Xposed—what allows Modules to hook into methods of other apps—requires deep knowledge of how Zygote and the Android Runtime (ART) works. These requirements already preclude a large number of people from contributing to the project, but the problem is exacerbated by the fact the rovo89 has been the main contributor to Xposed for the past 5 years.

That’s why calls for open sourcing his modifications made to Xposed since the last public release of Xposed have been denied. It’s his brainchild, and he’s the best at understanding it and modifying it, so adding more manpower onto the project at such a late stage could simply delay the project further.

Plus, if rovo89 continuously updated his source, he was worried that someone would take the unfinished code to build a semi-functioning Xposed Framework without the universal Xposed Installer to accompany it. (This exact thing happened anyways with the abforce implementation, and the resulting mess of various installation methods justified rovo89’s hesitation.)

Thus, the best thing we could do was to give rovo89 time to work on his pet project. Xposed is not his full, or even part-time, job. It’s simply a hobby, one that he’s done for the benefit of the community for 5 years. A project as complex as Xposed requires time to work and then test—time that he didn’t often have due to his other obligations. Progress was being made over the past year, just as rovo89 documented in a few of his public updates on the issue until finally both the Xposed Framework itself and the Xposed Installer are ready for release.

What did rovo89 do to get Xposed working in Nougat?

New releases of Android sometimes bring changes to the way ART works, which may require parts of Xposed to be reworked. Android 7.0 Nougat introduced a Just-in-Time compiler for ART to help improve runtime performance of applications, for instance. But the unofficial Xposed Framework by abforce simply disables many ART optimizations so that method hooking can work correctly.

Xposed Framework for Android Nougat

ART Optimizations in Android Nougat. Source: Google

In contrast, rovo89’s implementation keeps all ART optimizations in Android Nougat by recompiling a method’s caller using JIT and still having the method hooks in place. That means you can enjoy the benefits of a Xposed Module without sacrificing performance by forcefully disabling ART optimizations.

For further details of what rovo89 did to finally achieve a reliable hooking method in Xposed for Android Nougat, we recommend you read the below statement that he provided us.

Full statement from rovo89

The core of Xposed is obviously its ability to hook Java methods, i.e. let modules execute code before, after or instead of these methods. Pretty much every other functionality is based in this, so it’s critical that it’s always working as expected. The general concept has been the same since I invented Xposed five years ago, it requires changing the entry point of the method. This starts to fail when the entry point isn’t checked during execution – which is actually the case with some of the optimizations in ART.

One example is when the entry point is already known at compile time, then callers can directly jump to this address without looking it up. Another example is inlining. Consider this example:

Xposed Framework ART Optimizations

ART is smart enough to notice that the twice() method is very simple and therefore embeds the logic right into the doSomething() method, like this:

Xposed Framework ART Optimizations

You can still hook the twice() method, but it won’t be called from doSomething() anymore at runtime, and so won’t your callback. ART is even more clever: It realizes that magic is always 42 and therefore the condition can never be fulfilled. So the whole doSomething() method is actually a no-op:

Xposed Framework ART Optimization

In previous versions, Xposed used to disable these optimizations completely and forced recompilation of everything. That came with several downsides. First of all, the ART developers are doing a fantastic job in maximizing the performance with their optimizations, and disabling them partly necessarily leads to less performance (I never measured how much though). Then, the recompilation itself isn’t always easy and caused me a lot of headaches, especially in the beginning. Finally, the recompiled files take up space, in addition to the precompiled files on /system.

The unofficial versions for Nougat also disable these optimizations, but they don’t force the recompilation (because the port was originally made to be integrated into the ROM). Therefore, hooks might not be executed sometimes.

With the official version, you’ll get to keep the optimized code and still have reliable hooks. How does that work? Well, Xposed records all the calls that are made. This happens while APKs are being compiled, or in a separate pass for preoptimized code. This additional data doesn’t take up much space, but it allows Xposed to find out where a certain method might have been inlined. So when a method is hooked, all its callers will be deoptimized, i.e. their code won’t be used anymore. This ensures that the hook callback will definitely be called. And if the caller is heavily used, it will simply be recompiled with JIT, this time with the knowledge that the method is hooked and therefore some of the optimizations don’t apply. This means that the effects of hooking methods are reduced to the bare minimum. Yay!

Now go ahead and try it out. Make sure to use Xposed Installer 3.1.2, as the config path had to be changed to support File Based Encryption.

Conclusion

We hope you are as hyped as we are about the release of Xposed for Android 7.X Nougat. The wait has been long, but unavoidable given the sheer complexity of Xposed. If you’re still confused about what Xposed is or how it works, don’t worry. Very few people (us included) actually understand how it works. Developers like rovo89 do their best at packaging their work so you don’t really have to understand what’s going on underneath the hood.

Do you like the Xposed Framework? Consider donating to rovo89 for the awesome work that he does. If you think you have what it takes to contribute to the project, check out rovo89’s GitHub page below.

Donate to rovo89

Contribute to Xposed

Looking for Xposed Modules? Check out our Xposed Framework Module subforum or download the XDA Labs application and browse our collection of Xposed Modules.

Xposed Modules Forum

Download XDA Labs

Android Oreo Progress

In case you’re wondering, here’s how progress is on getting Xposed for Android Oreo:

I have already started work on Android 8.0. There are a few new language features that I’ll have to look at, but the general concept should still work. That includes all the work on invalidating compiled code of any callers when a method is hooked, which took by far the most time when I worked on Nougat. So I’m really confident that I’ll be much faster this time. Android 8.1shouldn’t be much different, so I expect not much additional work for it.

Share with short URL:

GET 25$ WITH MASTERCARD

Popular Posts