OnScreenClock migration notice

For Android TV users

Use left/right on your D-pad to switch between scroll and link mode.
Use up/down to scroll the page/jump between links.

TL;DR

Please install the new OnScreenClock app as this one will no longer be developed and does not work on Marshmallow and up. The new app name is “OnScreenClock Marshmallow”. Sorry for the inconvenience.

More elaborate explanation

Marshmallow on Android TV does not support granting the overlay permission needed for this app, so I had to downgrade the targeted android version to Lollipop. However, google does not allow that for an app already published for Marshmallow, so I had to create a new app in the play store. For a more elaborate technical rant, read this post.

Android TV, Marshmallow and Overlay permission

I recently upgraded my Nexus Player to Marshmallow and guess what, the OnScreenClock app crashed. No big deal, I thought, let’s “just” fix this by properly requesting the overlay permission using the new permission system. Reading up on the topic, I learned there are 2 types of permissions: normal and dangerous permissions. Dangerous permissions need explicit permission from the user while normal permissions are automatically granted by the system. However, a small info panel (like for tidbits) in the documentation grabbed my attention, stating (parafrased): “oh, and btw, you also have some special permissions”. So actually there are 3 kinds of permissions! Why not say that up-front 😉

Anyway, you might have guessed, the OSD clock app uses a special permission called SYSTEM_ALERT_WINDOW which allows it to create windows that draw on top of anything else. You might (as I did at first): no problem, let’s just ask the user for this OVERLAY permission. This is a nice idea in theory, and it actually works on your average Marshmallow phone. Android TV would not be Android TV if they did not add something extra to the challenge. Indeed, all Marshmallow Android TV roms that I have encountered (to be honest, so far only Nexus Player and Nvidia Shield, there are not much more at the moment), do NOT provide a GUI for allowing the user to allow the app this permission. They do have a gui for dangerous permissions but not for “special” permissions! I guess we finally know now what makes them special. 😉 A bug has been reported (originally for Android Wear which suffers the same problem) but no response from google.

So yeah, in case of my OSD clock app: no permission = no app. But wait, no problem, let’s just revert back to Lollipop target sdk and everything’s fine like Marshmallow never happened, right? Well, except if you already published a version of your app targetted for Marshmallow. In that case, you are not allowed by Google’s Play store to downgrade your target SDK. That’s really too bad.

That’s why I had no other choice than to create a new app with a similar name and update the current app to show a deprecation notice, inform the users of the new app and hope they understand what to do. So, goodbye nice reviews and stars, goodbye established user-base… Congratulations Google, you win.

OnScreenClock v0.2.0

v0.2.0  2016-02-15
==================
+ clock is now resizable
+ automatically restart clock service on app upgrade
* ClockService is now a foreground service to prevent cleanup by the system (when it tries to free up resources)
+ outline preference
* only start clock at boot when enabled
+ added support activity
+ added donation activity
* prevent crash when cancelling position dialog and the device somehow does not provide a default value
+ show version in-app

New Android app: OnScreenClock

And why it took me so long

Disclaimer: please don’t take this post too serious as I wrote it on a ranting spree, failing to keep consistence or structural coherence, using hyperboles to keep you entertained. You’ve been warned 😛 As with many funny things, there’s some truth in there though 😉

 

About a year ago, I bought an Android TV device: Nexus Player. That fact alone I could talk about for an hour, but let’s stay on-topic. 😉 Being introduced to Netflix and the concept of binge-watching, I had to protect myself from wasting all my time. Although I never used a clock on my tv before, its existence and use now became blatantly obvious to me. Unfortunately, neither my tv set nor the nexus player/android tv provide this! Android TV apps were (and still are) scarce so I took on the burden of the app dev and decided to try it myself, can’t be too difficult, riiight? 😉

After having taken the standard android and android tv specific hurdles, I quite quickly had something running that worked sufficiently for me. But what about “all” these other android Tv users? Being the empatic man I am, I put it on the app store, hoping to help others. As most often is the case, it turns out every user has different needs 😉 People want to use it on tablets, phones,.. So it had to become the super OSD clock app! Of course.

The requirements were boldly defined:

  1. Show a clock
  2. Be available on all android devices, from api level 10 (gingerbread) and up
  3. Provide easy positioning with predefined anchors for each corner
  4. Configurable font size
  5. Optional background to make the clock readable on all surfaces
  6. Configurable color (everybody likes colors, no?)
  7. Android TV specific UI’s (leanback interfaces). The Nexus Player comes with a D-pad remote. All user interfaces should be as intuitive as possible using the D-pad.
  8. Choose between digital or analog clock.

One year later, I can safely say that any of these features turned out to be much more complicated than anticipated. 🙂

1. Show a clock

Sounds simple, right? The problem is, it’s not just a clock. It should be an on-screen clock, meaning: on top of EVERYTHING at ANY TIME. I wasn’t sure if it was possible on Android. When I found out how to do it, I wasn’t sure it would work on Android TV (didn’t at first). But with some perseverance, the hurdle was taken. After that first achievement, I celebrated for a few months (ie I was lazy, development stalled and I preferred to binge-watch instead ;)). Picking it up again, I realized the journey had just begun.

2. Be available on all android devices, from api level 10 (gingerbread) and up

If you ever tried making an app that works well on every device from api level 10 to 23, you know this is no mean feat. I learned compatibility layers the hard way, thinking it would be easy. 😉 Tip: use compatibility lib from the start.

3. Provide easy positioning with predefined anchors for each corner

So it turns out there are tons of ways to define the available screen estate in android, what’s next… I want my clock in the upper right corner. Can’t everybody else offset from that one corner? On tablets you want to be able to drag the clock to position it? Of course, anything is possible. But I had to narrow the scope down to be able to release. Instead of providing touch on tablets and and a DPAD nav on android TV, I just put 4 simple buttons. It’s ugly but it does the job, for now. At least I made the button press repeatable so the user doesn’t have to click it like a crazy monkey (also, I felt like the standard NP remote wouldn’t survive it ;)).

4. Configurable font size

Here too, I had some nice ideas. Preview text of different size, seeing the right size instantly without having to increase/decrease until desired. But then I realized: if you can get a live preview of the clock position (no3), why not keep it consistent and provide a live preview of the size. Done. Wait.. configurable fonts? Naaaah

5. Optional background to make the clock readable on all surfaces

I thought I would make the clock more readable on light surfaces by putting it on a semi-transparent background. One day I implemented an outline instead and never looked back. It gives nice contrast and is nicely anti-aliased. It’s perfect, right? Of course not, read next.

6. Configurable color

If your app has colors, people want to customize that. I can’t really blame them for not liking my green on black clock. I’m color blind after all. 😉 The problem is, if I want to provide nice TV interfaces for my app, how does one choose a color using a TV remote? I’m still not entirely sure about that but I have a few ideas. Stay tuned.

7. Android TV specific UI’s (leanback interfaces)

I actually just explained the challenge in no6, I know bad article structure. But hey, I’m actually on a rant and just brain dumping 😛
If you want a TV app to be user friendly, you have to redefine its interface. There are several reasons why my attempts failed to this date.
a) Android TV dev was (is) in its infancy, so standard components are barely available and the compat lib only recently saw a release containing reusable preference items.
b) I had already so many hurdles to tackle, I thought: **** it, I’ll make a phone interface until the app is more functional and the UI is used only once anyway: just one time to configure the app! Nevertheless, it remains high on my todolist as a TV app should have a TV user interface, period.

8. Choose between digital or analog clock.

Aha, I kept the easiest one for last 🙂 Thinking about all the configuration options, I thought, the user should be able to choose the clock’s appearance, of course! Be it digital, analog, binary, what-have-you… I implemented an analog clock, and while I’ll admit it was fun, I doubt anyone uses it. 🙂 Development of the analog clock stalled (missing outline for example) in favor of more pressing features. Although, in the upcoming release, it kinda works..

This is only the high level overview of why it kept me so long from releasing this app. I stumbled upon all kinds of trouble from the service that was killed because android OS deemed it unactive to trying to obfuscate my publisher’s key.

On top of that, I complicated things by wanting to develop 2 apps in tandem AND reuse common code. Software development is all about reusable components, riiiiight? 😉 Unfortunately, up until recently I had absolutely no experience with either a) modular androids app or b) modularising code in git.
a) If you have never used gradle and maven before, you’re in for a treat. Try to keep it simple and you’ll get there 😉
b) I went from submodules to subtrees to strees. Enjoy this read, thank me later 😉

So yeah, this post is rather tongue-in-cheek and while touching some pain points, fails to offer clear solutions or solutions at all. That’s because this post is already long enough and I’m too tired to pump up the quality. Sorry if I lured anyone into reading this, hoping to learn something. You had been warned though 😛

So without further ado (queue drum roll), the one and only (literally!), on-screen display (OSD) clock, without ads (but with ads if you care about the developer), for Android TV ! (*cymbal*)

OnScreenClock OSD clock on Google Play store

OnScreenClock OSD clock on Google Play store

Note: “Box art may deviate from actual in-app visuals.” 😉 The slick font is actually a residu of a dropped feature “configurable clock font”.

ADB over Ethernet v0.6

v0.6  2015-07-22
================
+ added "support me" button. Ad loading is on-demand, 
  maintaining a fast ad-free experience during normal usage.

v0.5  2015-06-22
================
* also check root access on resume (nullpointer exc 
  fix on non-rooted devices)

v0.4  2015-06-17
================
+ detect ip at every resume instead of only at startup
* better handle network transitions:
  - detect multiple ip's
  - filter invalid ip

v0.3  2015-06-15
================
- use webview to show help since Android TV has no browser 
  (requires extra internet permission)
- nicer icon for tablets
- dark theme easier on the eyes

v0.2  2015-05-23
================
check for root before running commands to avoid app crash 
on non-rooted devices

v0.1  2015-05-21
================
initial release

ADB over Ethernet

You say: “what, another adb app?!” I have my reasons. 🙂

While developing an Android TV app on my nexus player, I noticed that besides the annoying thing of constantly having to switch input on my monitor (my secondary monitor is broken), it’s also quite cumbersome to switch the microUSB cable at least once during a dev session. I use the microUSB connection to hook up a usb ethernet adapter. So when I want to debug, I have to switch the OTG cable for a regular one to enable ADB. Using the usb connection you can configure the device to enable ADB over ethernet, meaning you no longer need the usb cable but can connect to the adb daemon on the device over tcpip.

There are a dozen of existing apps for this purpose. Unfortunately, most of them are not android TV friendly. For starters, there are none in the android TV store but this is mostly an inconvenience. Secondly, they don’t offer dpad/controller navigation which renders them unusable. Thirdly, When I did find one app that offered navigation (although invisible), it required to use the wireless connection, while I have a wired connection.

Since it is only running a few commands as root, I decided to quickly mash up my own app. It offers clear button focus on android TV and is controller friendly. It tries to detect which network interface is currently in use. It is also available now in the play TV store.

Of course, the very first time you need to allow the rsa key of the connecting computer.

ADBoverEthernet on Google Play store

ADBoverEthernet on Google Play store

Activating HW acceleration for embedded YouTube videos

Ever since Google Chrome became terribly slow in gmail, drive, etc regardless of computer or platform, I’ve picked up Mozilla Firefox again. The switch didn’t go painless but I really was tired of typing a whole sentence before Chrome would display it. This problem produces itself not only on google sites but actually in about any text box I would type, be it intermittently.

The main issue with switching to Firefox was stuttering video playback. As you may know, chrome bundles its own flash plugin which is actually the same plugin but tweaked to work optimally with chrome (pepper api). At the same time google controls distribution/patching.  So, if google can tweak the plugin for good performance, why can’t we? 😉

First thing I discovered, is that somehow flash hardware acceleration was disabled. You can enable this by right-clicking on any flash video and click on “settings”. In the “Display” tab, you can check “Enable Hardware Acceleration”.

flash enable HW acceleration settingSmooth youtube vids FTW! Fullscreen video’s also showed up on the correct monitor now (dual head setup). My joy was only for limited time, as I discovered hardware acceleration dit not work for embedded youtube video’s. I was happy nevertheless as the bulk of video’s I watch are on youtube.

However, today, watching the Jolla Tablet intro movie embedded on the site, I could not help feeling the itch again. Why oh why did this play fluently in chrome but did it suck so hard in firefox? Check out this framerate:

yt_embedded_noHWaccel1I started by creating a virgin system account to avoid having my 7 year old home dir, possibly dragging along some evil deprecated setting, be the culprit. This didn’t change anything but at least I had both a blank Firefox and Chrome profile to test with.

First I was under the impression that there would have to be a global flash settings file since when right-clicking on the embedded video, it showed the “Settings” as disabled. There does indeed exist such file: /etc/adobe/mms.cfg in which you can put “EnableLinuxHWVideoDecode=1”. This only crashed my firefox. I did install an additional vdpau package but it didn’t matter. Also, looking at the “Nerd stats” (right-click on video), I learned even youtube vids didn’t have hardware accelerated decoding, only accelerated rendering. So I didn’t proceed on this path.

Now let’s check out how chrome is doing it. Pulling up the “Nerd stats” did surprise me: chrome does not use flash by default for embedded video’s, it uses WebM/VP9!

This begs the question: how is Firefox’s WebM support? Turns out it’s no problem, just change your youtube html5 setting from “default player” (=flash) to “html5”.

youtube html5 settingsSo the  chrome pepper flash tweak actually came down on not using flash. 🙂 Youtube does this by default on chrome but not on firefox. Naughty Google!

You may notice that Firefox does not support all youtube hmtl5 features yet. In particular, you will be served VP8 video’s instead of VP9 which may make a difference in the available resolutions. However, Media Source Extensions and WebM VP9 can already be activated by setting:

media.mediasource.enabled = true

in about:config. Experimental h264 support can be activated with:

media.mediasource.ignore_codecs = true

You can track the MSE support in firefox in this bug report.

Itch scratched and fixed. Finally 🙂

Firefox ctrl+backspace behavior on linux

I’ve always hated why ctrl+backspace wouldn’t do what I expected in the address bar of Mozilla Firefox. So I stopped using Firefox. However, one day I tried it by accident on a windows box and was astonished it did work as expected! I didn’t care that much anymore since my main browser became Google Chrome. However, Chrome became more and more of a resource hog and even their owns sites like gmail and google drive run slower than on firefox. I started using Firefox again and got annoyed again over this small nuisance.

So I started googling the issue and found out that, apparently, linux users want non standard behavior because they are used to different selection behavior than for example a windows user.

I agree that double clicking a path in a console should select the entire path but I don’t see why that should affect the ctrl+backspace behavior. If I press ctrl+backspace in KWrite, it deletes the last word. If I press ctrl+backspace in the address bar in Dolphin, it will delete the last part in the path. The list goes on.. but I will never expect ctrl+backspace to be equal to “select all and press delete” which it does by default on Firefox/Linux.

Luckily, it turns out there’s an option layout.word_select.stop_at_punctuation to configure this behavior 🙂 You might also be interested in layout.word_select.eat_space_to_next_word.