More sutainable Android Software with Project Treble and 6-y LTS Kernels on Android O?

Recently, we could read and hear about Google putting some effort in facilitating easier updates for android devices:

So, even though three years are not the promised four years, we can still see a trend of increasing years of guaranteed software support on Android phones.

That is a positive trend! I hope that Google takes the gloves off soon and guarantees four upgrades to a new android version, forcing other vendors to at least start guaranteeing something for their phones. As I said before, this would really be a unique selling point. Also this would really mean a big leap forward regarding sustainability of Android phones! Let’s see if any of the Oreo Phones being release now will support Android S 😉

Advertisements

Android 7 (Nougat) on a 5-year-old phone

A 5-year-old phone is not going to the kindergarden, it is more likely to be found on the phone graveryard. One important reason for this is that its manufacturer stopped caring for it at least three years ago. Fortunately, there are other caretakers – people that maintain the latest android version also for five-year-old phone grannies – in form of custom ROMs.
So, is it possible to run the latest Android version on a device that’s 5 years old? Hell, yes! This article shows how.

My old HTC One S (aka ville, the older S4 processor not the “C2” with S3 processor), launched April 2012 runs terribly laggy on its latest stock anroid 4 firmware, last update 2013 – four years ago! That’s why it was retired a long time ago. At the beginning of 2017, when the first unofficial builds of lineage OS turned up, I was surprised to see that HTC One S was among them. I was wondering, how can such an old device run the latest android version? I had to see for myself.

TLDR; Android Nougat works surprisingly well, way better than the latest Stock version but HTC makes it a hell of a way to get there. Lets see what has to be done.

Note that all files on your device will be deleted during the process!

Unlock Bootloader

To be able to flash software to our HTC devices, HTC forces us create an account on htcdev.com and register our device there. Then we receive an unlock code as zip file which we can flash on our device.


adb reboot bootloader

fastboot flash unlocktoken Unlock_code.bin

For all Windows 8 (and also Windows 10, apparently) users who have problems getting the fastboot driver to work, whereas ADB works, this little registry edit did the trick for me.

In the bootloader make sure to remember your HBoot version, it will be required during the process.

HBoot 2.16 - we're good!

HBoot 2.16 – we’re good!

Flash TWRP

Download from here to your PC and flash as follows


fastboot flash recovery twrp.img

fastboot reboot

Check HBoot version

I had to find out the hard way by flashing lineage 14.1 that there are requirements regarding the HBoot (HTC Bootloader) version:  HBoot 2.16 is required.

So better check in advance. If you’re on HBoot 2.16 flash lineage and enjoy. If not, let the games beginn.

S-OFF & root

Upgrading HBoot needs S-OFF (Security off, enables writing to /system directory). On top of unlocking our bootloader at htcdev.com we need to risk bricking our phone to enalbe writing in the /system directory of our device.
Those two things are the reasons why I most likely won’t ever buy an HTC device again.
Anyway, with the One S, we’re lucky! S-OFF takes a bit of time but not much effort and comes at almost no risk, thanks to rumrunner (a good overview of other S-OFF Mechanisms is described here). Rumrunner makes it easy to get S-OFF, but it needs root access.

What? Why are we doing this again? We want to Upgrade HBoot, that’s why we need S-OFF, in order to get S-OFF, we need root. That’s the last unpleasant surpise, promise!
Lucky again, root access can be gained easily on HTC One S. I used Superboot: Just Download, execute Script on PC while Phone phone is in bootloader mode. Root done. More detailed description here.

Then just download rumrunner follow the instructions, wait for about 10 minutes (don’t worry, your phone is restarting about one million times) and you’re S-OFF!

Upgrade HBoot

We’re getting closer. Now, with S-OFF we can flash HBoot 2.16. I followed these instructions, and found the firmware here.

Caution: After flashing HBoot 2.16, the internal memory is really small, only 50 MB left. Obviously Android 4 and Hboot 2.16 are not good friends. Don’t worry, this is solved once Android 7 is flashed.

Flash Android 7.1.2

It’s finally gonna happen. We’ll flash Lineage 14.1, Android 7.1.2 (maintained by moozon, thanks so much!). But how, the internal memory is only 50MB, but the image is almost 300MB? I copied the image to an USB thumb drive, connected it to the phone via an USB OTG adapter and flashed via TWRP Recovery. TWRP also offers ADB sideloading, which might be an alternative, it you don’t have an USB OTG Adapter at hand.

Once flashed, you finally can enjoy the latest android version on your “antique” phone. 🥂

Optional finishing and more info

Root is built-in but disabled by default. If you want root access, you can enable it in developer options.

If you need google services, get ARM | 7.1 | pico (my recommendation) from opengapps.org and flash via TWRP.

If you need more info, you might get started here: [LINEAGE OS] HTC One S Lineage OS 14.1, Android Nougat 7.1 ROM

Final thoughts

The One S with Android 7.1.2 almost works better than my HTC One M8 with Android 6! Why must HTC make it so hard to get there? And why are manufacturers not able to support their devices longer than 2 years, while the community or even single indivudals are able to do so for more than 5 years??

[EDIT 2017/06/13: Google just published the guaranteed updates for its devices: two years of upgrades and another year of security updates. While this is at least some formal guarantee (other manufacturer just don’t guarantee anything) it still is far from the five years provided by the community for my HTC One S… ]

I’m still waiting for a manufacturer that guarantees support for its devices for many years. That would really be a unique selling point! I can’t believe no manufacturer uses this USP on the highly competitive market for mobile devices. In addition, this would be so much more sustainable, and contribute to a green(er) IT. While the whole world complaints about planned obsolescence, why is there no manufacturer that uses this fact for positive marketing?

[EDIT 2017/07/01: HMD Global (owner of the Nokia brand) just announced that they intend to provide plain vanilla android phones with support “even after two years“. I looking forward to their next anouncements. My calls might just have been heard 👂]

[EDIT 2017/10/05: Google talks about four android version upgrades being possible from Android O and releases Pixel 2 with three years of support. See More sutainable Android Software with Project Treble and 6-y LTS Kernels with Android O?]

What is Google doing, by the way? They introduce Safety Net, providing the oportunity for developers to hide their apps on Google Play from specific devices, such as the ones running custom ROMs. So now, no more Netflix, etc. for custom ROMs. Effectively, this is another punch for the custom ROM scene after the death of CyanogenMod.

Lets just hope custom ROM developers will not be discouraged by these facts and continue their imporant work, making success stories such as the one of my HTC One granny possible.

Thank you android community, XDA forums, custom ROM developers, etc. for sharing your work and never giving up! 👍

Modernizing android UIs part 2: design support library, switches, action buttons

After finishing the migration from Actionbarsherlock to appcompat described in the first Post on modernizing android UIs, it turns out there are even more things to modernize in terms of android UIs.

Tabs and design support library

If you used Tabs within the ActionBar, after migrating to appcompat-v7 API 22 you might recognize a warning, that tells you that they are now deprecated.

In order to modernize those, you should use the design support library that was added to the Android SDK with API level 22. Similar to the appcompat -v7, the design support library provides backports of material design components of Android lollipop (5.x) for older versions of Android.

Here’s the steps that rid you of the deprecation warning

  • Add the design library to your eclipse workspace and link it with your project in pretty much the same way as appcompat described in the first Post. The library can be found on the following path: <sdkdir>/extras/android/support/design.
    Import it into eclipse as Existing Android Code Into Workspace, change the build target to level 22, and link the appcompat project with it.
  • Add the following to maven
    <dependency>
    <groupId>com.android.support</groupId>
    <artifactId>design</artifactId>
    <version>${android.compatibility.version}</version>
    <type>aar</type>
    </dependency>
    
  • Change your code to use the new TabLayout as described here. A complete example is the cheesesquare app: activity_main.xml, include_list_viewpager.xml, MainActivity.java
  • Once you’re done with this and have the design support library up an running, you could modernize your app by using more of the library’s features like navigation drawers, floating labels and buttons, snackbars, collapsing toolsbars, etc. See this blog post for more features.

The screenshots bellow show a before-after comparison – deprecated tabs vs material design tabs.

Tabs: design support library, API-22

Tabs: design support library, API-22

Tabs: AppCompat-v7, API-22, deprecated

Tabs: AppCompat-v7, API-22, deprecated

 

Checkboxes to switches

Android API level 14 introduces the switch component, that according to google should be used when only one option is available. For API levels < 14  there’s no such thing as switches. So we’ll have to rely on checkboxes there. Here’s how to replace checkbox preferences by switches for devices running API level 14 and above

  • In a preference XML, replace CheckBoxPreference by SwitchPreference (see commit ab16eb1997dfba743abcd488b6b20de71b5c3ff0 for an example).
  • However, If you want to keep compatibility with API levels < 14, you’re only choice is to keep redundant copies of the same preferences.xml in

    • res/xml/ that contains the preferences with CheckBoxPreferences and
    • res/xml-v14/ that contains the same file with SwitchPreferences.

Another before-after comparison is shown bellow – checkboxes vs switches.

AppCompat-v7, API-22 with checkboxes

Preferences: AppCompat-v7, with checkboxes

AppCompat-v7, API-22 with switches

AppCompat-v7, API-22 with switches

Using Action Buttons

Action Buttons are icons that realize the most important actions on the actionBar if there is enough room to display them. These could have been used in Actionbarsherlock already, but if you still didn’t modernized them then it’s about time 🙂

One reason for not using action buttons might be that you don’t have suitable icons. Here’s the solution: Google provides a huge amount of material design icons under open source (CC-BY) license. They can be found on this site, or you can just clone their git repository.

So it’s as easy as that

  • Choose proper icons for your actions and copy them to your res/drawable-xyz folders
  • Add icon tags to your menu.xml like so
        <item
            android:id="@+id/action_refresh"
            android:icon="@drawable/ic_refresh_white_24dp"
            android:title="@string/action_refresh"
            app:showAsAction="ifRoom"/>

And that’s it. See bellow for an example. For an example see the commit that realized this change.

AppCompat-v7, API-22, ActionBar with menu

AppCompat-v7, API-22, ActionBar with menu

AppCompat-v7, API-22, ActionBar with action buttons

AppCompat-v7, API-22, ActionBar with action buttons

Modernizing android UIs part 1: Migrating from Actionbarsherlock to Material Design

This post shows by example the steps that are necessary for migrating an android application from Actionbarsherlock to Material Design (introduced in android KitKat/Version 5.x/API level 21/22), while keeping compatibility with at least android Gingerbread/Version 2.3 /API level 9). It uses the appcompat-v7 library on API level 22. The app that was migrated (nusic) in this example is developed using Eclipse, Maven and RoboGuice.

Before-after comparison

Let’s begin with some before-after screenshots:

ActionBarSherlock

ActionBarSherlock

AppCompat-v7, API-22

AppCompat-v7, API-22

02-nusic-abs-prefs

Preferences: ActionBarSherlock

Preferences: AppCompat-v7, API-22

Preferences: AppCompat-v7, API-22

Basic migration (appcompat-v7)

The following lists the steps that were implemented in order to change the app as depicted in the screenshots above.

  • Update Android SDK Tools
  • Eclipse
    • Setup Eclipse project for appcompat described here.
    • Link your project with it. Right click on your project | Properties | Android | Library | Add
      eclipse-choose-appcompat
    • Remove action bar sherlock. Same menu as above.
  • Set Up Maven Build
    • <repositories>
      <repository>
      <id>android</id>
      <url>file://${env.ANDROID_HOME}/extras/android/m2repository</url>
      </repository>
      </repositories>
      
    • <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>${android.compatibility-v7.version}</version>
      <type>aar</type>
      </dependency>
      
  • Migrate from Actionbarsherlock to appcompat
    • styles.xml

      <!-- <style name="AppBaseTheme" parent="@style/Theme.Sherlock"> -->
       <style name="AppBaseTheme" parent="@style/Theme.AppCompat">
      
    • Replacing classes
      • RoboSherlockFragment -> RoboFragment
      • RoboSherlockFragmentActivity -> RoboActionBarActivity
      • RoboSherlockPreferenceActivity -> Write your own RoboAppCompatPreferenceActivity that looks like this (or as described here) but is derived from RoboPreferenceActivity (see here for the class that was used in the example).
        Then derive your class from it as before with RoboSherlockPreferenceActivity.
    • Replacing methods
      • getSherlockActivity() -> getActivity()
      • getSupportMenuInflater() -> getMenuInflater()
    • Fixing imports
      • android.view.Menu
      • android.support.v7.app.ActionBar
    • Updating proguard.cfg
      • Remove actionbarsherlock
      • Add
        # support4, appcompat-v7, design support
        -dontwarn android.support.**
        -keep class android.support.** { *; }
        -keep interface android.support.** { *; }
        

For further info please see

Android apps – nusic: Find New Music Albums

Have you ever stumbled upon a new album of one of your favorite artist and recognized they released several albums since you last checked?

nusic - your new music

nusic – your new music

Problems like this can now be solved conveniently with nusic for Android.

All you need is an Android device that contains music of all the artists you like.

After installing, nusic regularly checks if there are upcoming releases for the artists on your device and informs you about any news.

Just install the app, start it once and it will keep you up to date about new releases via android notifications. Never again miss any releases of your favorite artists!
 
You can install nusic from Google Play or get the APK from GitHub.

Get it on Google Play
If you should encounter any errors, please report them here instead of just giving a poor rating.

By the way, nusic is open source. Please contribute by forking nusic on GitHub.

 

How does it work?

nusic regularly checks MusicBrainz – the open music encyclopedia – for new releases of the artists on your device.

That’s all there is. You don’t need an account and the app is not pulling any other data from your phone!

Android: Custom Rom – Installing Google Play only (Customize GApps)

Due to license restrictions, Google’s proprietary applications (Play, Talk, YouTube, etc.) don’t come pre-installed with Android custom roms.

That leaves you with two options:

  1. Being happy you got rid of all the bloatware, effectively achieving a “google-free” android.
  2. Google-ify your custom rom by installing the complete “google stack” (GApps) separately.

But what if you prefer the google-free alternative but you purchased apps on Google Play before and want to keep using them?

Or maybe you just realized after hours of searching that a lot of apps cannot be found on other app stores?

You have no choice but to reinstall Google Play. However, using the GApps package as is, results in a bunch of apps and frameworks you don’t need, if you only want to have Play.

So the least thing you can do is to only install the apps/services you really need, avoiding the bloatware mentioned before.

To achieve this, you have to “customize” your GApps package.

This post shows how.

[EDIT 2015-02-08: Paranoid Android offers GApps in different packages sizes (Stock, Full, Mini, Micro, Nano, Pico). Using those might be easier than stripping them yourself. See [GAPPS][4.4.x] OFFICIAL Up-to-Date PA-GOOGLE APPS (All ROM’s) and [GAPPS][5.0.x][BETA] OFFICIAL Up-to-Date PA-GOOGLE APPS (All ROM’s). If those work for you please leave a comment, I’m very interested in any experience.]

[EDIT 2016-05-23: The Open GApps Project now conveniently offers different variants (“aroma” to “pico”) for different android versions (4.4 to 6.0) and different platforms (ARM, x86 and 64 Bits each).  You might want to give “pico” a try and skip the steps stated bellow 🙂 ]

Stripping Gapps

  1. Download the GApps bundle for your Android version
  2. Open the zip file (e.g. with 7-zip)
  3. Go to the system\app\ folder
  4. Delete all apks you don’t want.
    If you want Google Play only, you must keep the following ones:
    GmsCore.apk (Google Play Services)
    GoogleLoginService.apk
    GoogleServicesFramework.apk
    Phonesky.apk (Google Play Store)
    If you don’t keep all four of them, Play is not gonna work properly.
  5. Flash the zip file to your device (as described here, for example).
  6. Reboot
  7. Use Google Play

Further actions

If you’re a bit paranoid, I suggest using LBE Security Master to revoke permissions from Google Services Framework.

If you’re even more paranoid, don’t forget to delete your Google account from your device each type you’re done with Play 🙂

Additional packages worth mentioning

Before stripping GApps, you might consider using another nice feature (introduced with Android 4.1 I think) – offline voice typing. It provides robust voice recognition that doesn’t phone home and works without network connection.

To use it, just leave the VoiceSearchStub.apk within the system\app\ folder of GApps before you flash it.

Update (2013/04/29): This seems to work at first (you can download the offline dictionaries and tab the microphone button) but then the actual voice recognition doesn’t work. Epic Fail!

It’s much more easy to just install the Google Search App via Google Play (once you have got it installed as described above). It includes the option for downloading offline dictionaries and using the voice recognition.

And again, if you’re a bit paranoid, better stop the App from phoning home –  using for example LBE Security Master. 😉