jeudi 18 mai 2017

Google May Finally Enable Custom Themes Built on Sony’s RRO Framework

In case you aren’t already aware, Google has released the second Android O Developer Preview (Android O DP2) during yesterday’s I/O event. We’ve already done a deep dive into everything new we’ve found thus far, but there was one thing about DP2 that was bugging me. Everyone who received the beta update or manually flashed the new images were quickly met with a radically different UI in quick settings. Why in the world did Google decide to change the theme? After some more testing and digging, I’ve come to a conclusion. For whatever reason, Google has decided to make its “Inverted” theme the default theme; perhaps while the company was in the middle of testing a custom theming solution based on Sony’s Runtime Resource Overlay (RRO), they weren’t able to get the default Pixel theme working in time for the Android O Beta release.

 Default System Theme in Android O Developer Preview 2

The revelation that Android O’s theming framework is based on Sony’s RRO may seem obvious to some given that Google implemented support for RRO in Android 6.0 Marshmallow, albeit it required you to have a rooted device. However, since the source code for Android O has not been released, it would have been pure speculation to suggest that this system theme in Android O is in fact RRO. That’s why our initial coverage of this mysterious setting, as well as the coverage done by other websites, did not make this connection. But there are several pieces of evidence that link this feature to the theming framework that we believe should conclusively show that Android O’s device theme is based on RRO, and it may finally provide the theming solution for unrooted users we’ve all been waiting for.


What is Runtime Resource Overlay (RRO)?

RRO is a theming framework created by Sony’s developers that powered Sony’s Xperia Themes. The beauty of RRO is that it allows you to replace application resources without having to modify the source code of the application. This happens through the use of an overlay, which contains its own resource strings that are used to replace the overlaid application’s resources while the application is loading.

For those of you who see “RRO” and think “Layers”, you’re quite close. Layers is a slightly modified version of Sony’s RRO, but at the base level it works very similarly. RRO/Layers “installs” theme APKs to /system/vendor/overlay. At boot, the package manager reads these APKs, verifies them, then uses idmap to link it into the system resource table. You can read a more thorough FAQ by SykoPompos, the developer of the (now deprecated) Layers Manager app.

Screenshots of the Deprecated Layers Manager App


Recommended Reading: A Brief History of Theming: From OEM Themes to RRO Layers


Of course, few in the Android custom ROM community are still using a theme engine based on RRO. Most have moved on to another theming engine such as Substratum, which is an evolution of Layers now based on the Overlay Manager Service (OMS). (CyanogenMod Theme Engine (CMTE) was another popular theming framework, though its future is still up in the air.) However, even if you aren’t using a custom ROM with the OMS commits, the Substratum theme engine app still supports the ability to use “Substratum Legacy” themes which are just RRO/Layers themes. And because of this, users began to figure out that Android O’s device themes and RRO is one and the same.


Google Finally Introduces Theming Through RRO

Over on the comments section of an AndroidPolice article, XDA Recognized Developer Maxr1998 posted a screenshot claiming that Substratum Legacy themes show up in Google’s device theme chooser.

On the left, you can see a list of overlay APKs installed by Maxr1998 on Android O Developer Preview 1. On the right, you can see the two theme choices in Android O Developer Preview 2. Previously in Android O DP1, the two options were “Pixel” and “Inverted” with “Pixel” set as the default while “Inverted” resembles the gray scale look and feel that is the default in O DP2.

But take a careful look at the name of the default theme in O DP2. It is called “android.auto_generated_rro.” A very strange name indeed, but the inclusion of “RRO” in the name is what led me to first believe that this is indeed Sony’s RRO.

I then thought, if this is indeed RRO, where else can I look to corroborate this? Those thoughts led me to check /system/vendor/overlay, and as expected, there are indeed two APK files located within: framework-res__auto_generated_rro.apk and PixelThemeOverlay.apk.

Both of these match the names of the themes in the display settings. Curiously, when you select the Pixel theme in display settings, it doesn’t work. I am not an expert in developing RRO themes, so I cannot say why the Pixel theme is not working, though by performing an APK teardown of both applications it is clear that these are indeed overlay apps.

PixelThemeOverlay.apk APK Teardown

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://ift.tt/nIICcg" package="com.google.android.theme.pixel" platformBuildVersionCode="25" platformBuildVersionName="O">
<overlay android:priority="1" android:targetPackage="android"/>
<application android:hasCode="false" android:label="@string/pixel_overlay_pixel"/>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="pixel_overlay_pixel">Pixel</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="user_icon_1">#ff5e97f6</color>
<color name="user_icon_2">#ff5c6bc0</color>
<color name="user_icon_3">#ff26a69a</color>
<color name="user_icon_4">#ffec407a</color>
<color name="user_icon_5">#ff33ac71</color>
<color name="user_icon_6">#ff8bc34a</color>
<color name="user_icon_7">#ffff9800</color>
<color name="user_icon_8">#ffff7043</color>
<color name="system_error">#ffea4335</color>
<color name="primary_device_default_dark">#ff2d2d2d</color>
<color name="primary_device_default_settings">#ff2d2d2d</color>
<color name="primary_dark_device_default_dark">#ff242424</color>
<color name="primary_dark_device_default_settings">#ff242424</color>
<color name="secondary_device_default_settings">#ff3a3a3a</color>
<color name="tertiary_device_default_settings">#ff616161</color>
<color name="quaternary_device_default_settings">#ff9e9e9e</color>
<color name="accent_device_default_700">#ff3367d6</color>
<color name="accent_device_default_light">#ff4285f4</color>
<color name="accent_device_default_dark">#ff5e97f6</color>
<color name="accent_device_default_50">#ffe8f0fe</color>
</resources>

If you skim over the documentation of RRO provided by Sony, it’s clear that this is supposed to be an RRO theme. In the AndroidManifest file, the overlay line indicates that this overlay targets the framework-res.apk file (“android”) and it has a priority of “1” which is the highest priority it can be given.

On the other hand, within the framework-res__auto_generated_rro.apk file is a similar looking AndroidManifest.xml file, but there are a lot of other strings present that are unrelated to theming. But this is easily explainable by the fact that this RRO theme is basically a stripped down version of the Google Pixel‘s framework-res.apk, which I figured is true since \res\values\bools.xml has the line <bool name="config_useRoundIcon">true</bool> which I know from a post on our forum to be a line that users need to set in order to enable Round Icon support system-wide.


Conclusion

My tester hasn’t yet been able to achieve root access in O DP2 in order to try running a Substratum Legacy/RRO theme, but given my own findings and that of Maxr1998, it’s safe to say that Google may finally be preparing to bring RRO theming to the masses.

Of course, there’s no guarantee that this feature won’t be stripped in one of the later Android O builds. It’s possible that Google decides RRO isn’t working out the way they want it to and ditch the feature. However, given RRO’s extensive history both in the hands of Sony and our own development community, many of us are already familiar with the greatness that is Sony’s Runtime Resource Overlay. And since there are already a ton of RRO-compatible themes available, if Google ever decides to allow us to install custom themes, they’ll open the floodgates to an already wide-ranging market of available themes for users to enjoy.


Feature Image Credits: SonyDevWorld



from xda-developers http://ift.tt/2qvD1RZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire