[Android Apps and Games] digitalhigh:
So, I have a Nexus Player, and I absolutely LOVE the way the UI for Plex looks on it. It has a number of added categories and features, and overall, it's just really pretty, and highly preferable to the regular "TV" option in the Plex app.

Unfortunately, the good folks at Plex decided to reserve this only for Android TV...which sucks. I just bought a RikoMagic V5 Rk3288-based Android on a stick to replace my aging RK2066 device, and when it arrives, I'd like the same sexy experience as I have on the Nexus player.

I can already install the leanback launcher...so why not get the plex UI to go with it?

So that's what I did.

EDIT: LOL. So, instead of modifying the APK, it looks like we can just add the permission file it's checking for to /system/etc/permissions/ I've attached it...simply download, extract, copy to /system/etc/permissions, and reboot. Presto! Pretty plex.

I'll leave the other method simply because it's good to know how to do, and can be applicable to many other situations.

HOWEVER, there's an obvious problem. You either have to have purchased the app, or have a Plex Pass to use it. I have not explored the paid version of the app yet, just the Plex Pass one...but that will be done shortly. First I wanted to share my discovery.

Basically, the check for whether or not the device is an Android TV lives in \smali\com\plexapp\plex\application\PlexApplication.smali when you decompile the APK.

In this method:

.method public B()Z
.locals 2

invoke-virtual {p0}, Lcom/plexapp/plex/application/PlexApplication;->a()Z

move-result v0

if-eqz v0, :cond_0

invoke-virtual {p0}, Lcom/plexapp/plex/application/PlexApplication;->getPackageManager()Landroid/content/pm/PackageManager;

move-result-object v0

const-string v1, "android.software.leanback"

invoke-virtual {v0, v1}, Landroid/content/pm/PackageManager;->hasSystemFeature(Ljava/lang/String;)Z

move-result v0

if-nez v0, :cond_1

:cond_0
const/4 v0, 0x0

:goto_0
return v0

:cond_1
const/4 v0, 0x1

goto :goto_0
.end method

Here, the code is obfuscated, but the original method is called isAndroidTV. Either way, searching for "android.software.leanback" should get you into the method.

Now, all this is really doing is asking the system if it has the flag "android.software.leanback", so we could probably modify build.prop? to have that flag and be right with the world. But, I haven't tried that yet.

Instead, if we read through what the method is doing, we can see that if it finds "android.software.leanback", it goes to condit_1, which sets const v0 to 0x1, or a "yes" return. So, what if it fails? It runs to cond_0, which instead sets const_v0 to 0x0, or "no".

So, the obvious fix to this is to just make cond_0 return 0x1, or the following code:

.method public B()Z
.locals 2

invoke-virtual {p0}, Lcom/plexapp/plex/application/PlexApplication;->a()Z

move-result v0

if-eqz v0, :cond_0

invoke-virtual {p0}, Lcom/plexapp/plex/application/PlexApplication;->getPackageManager()Landroid/content/pm/PackageManager;

move-result-object v0

const-string v1, "android.software.leanback"

invoke-virtual {v0, v1}, Landroid/content/pm/PackageManager;->hasSystemFeature(Ljava/lang/String;)Z

move-result v0

if-nez v0, :cond_1

[B][U] :cond_0
const/4 v0, 0x1
[/U][/B]
:goto_0
return v0

:cond_1
const/4 v0, 0x1

goto :goto_0
.end method

That's it. Just flip the 0x0 to a 0x1 and recompile the apk. Due to it being a Play Store app, it's also necessary to resign with a test key so we can install it.

Here is a link to the final output that I was able to install on my 5.0.1 (lollipop) GPE ROM running on a HTC M8. At this time, I'm unsure whether it will A. Work on a non-lollipop ROM or B. Work on a ROM that doesn't allow test-key signed apps.

However, it is a working proof of concept, and could prove useful to others who use android devices as media center devices. :D

Also, attached is a screenshot of the POC, albeit looking poor on my phone.

Feel free to try the attached APK and let me know how it works for you. Mods - this is the free Plex Pass version - aside from changing the above .smali, I have not modified or circumvented any other security features (like making it work for everybody). You must have a Plex Pass account to use this.