Monday, April 17, 2017

Nav Bar Customization was Hidden in Stock Nougat All Along…and it never needed Root

Show of hands here: how many of you are actually running the first Android O Developer Preview? Not only is the Developer Preview only available to a handful of Google devices, but it’s really not suitable as a daily driver. Of course, it was never intended to be used by the average user, but rather as a test-bed for developers to ensure their applications will work when Android O officially does release. However, that doesn’t mean we can’t have some fun for ourselves and take a look at what’s inside. One of the most exciting features coming to Android O devices is the nav bar customization located in System UI Tuner. But what if we told you that this awesome nav bar customization isn’t only available to users on the Android O Developer Preview? That’s right, this feature actually already works on Android 7.X Nougat, and it doesn’t need root access either.

Facepalm. When I wrote my tutorials on contextually modifying the navigation bar on Android O, I had assumed that these shell commands that I was sending would only work on Android O. It turns out that that’s not true – these commands actually work just fine on Android Nougat. Now, we’ve known for nearly 9 months that navigation bar customization could be enabled in Android Nougat, however, the initial discovery required users to modify the SystemUI APK to expose the nav bar tuner preference. This was clearly a major hurdle to overcome for many users as it not only requires root access, but it also requires the SystemUI APK to be decompiled and patched for every single update. However, you don’t even need to modify SystemUI to expose this nav bar tuner activity, you can modify the nav bar manually through shell commands anyways!

We can confirm that this hidden nav bar customization in Android Nougat works on the following devices:

The nav bar customizer appears to work on any device or ROM that has not removed the AOSP implementation, so most devices that have stock, or close to stock, firmware based on Android 7.X Nougat should have it working.


Nav Bar Customization Hidden in Android Nougat

Manually modifying the navigation bar in Android Nougat works very similarly to how it works on Android O. You can either send an ADB shell command to modify the particular setting, or grant the WRITE_SECURE_SETTINGS permission to an application such as SecureTask or AutoTools so they can control the modify the Settings.Secure preference that controls the navigation bar buttons. With the use of Tasker, you can contextually modify the navigation bar as well.

Granting WRITE_SECURE_SETTINGS to either SecureTask or AutoTools is simple as all you need to do is enter either of the following ADB shell command, which doesn’t require you to be rooted.

For SecureTask:

adb shell pm grant com.balda.securetask android.permission.WRITE_SECURE_SETTINGS

For AutoTools:

adb shell pm grant com.joaomgcd.autotools android.permission.WRITE_SECURE_SETTINGS

Then the syntax to modify the navigation bar is as follows:

settings put secure sysui_nav_bar "key(KEYCODE_CONSTANT:file:///path/to/icon.png),back;home;recent,key(KEYCODE_CONSTANT:file:///path/to/icon.png)"

You can re-arrange the key layout, add spaces to the left or right to shift the buttons (typing space will add an empty slot to the nav bar) choose custom icons, change the keycodes, etc. as you please by following this syntax. For instance, here is the command I would use to add a KEYCODE_MENU button and a KEYCODE_FORWARD button to my navigation bar to enhance my Chrome browsing experience:

settings put secure sysui_nav_bar "key(82:file:///storage/emulated/0/NavIcons/menu.png),back;home;recent,key(125:file:///storage/emulated/0/NavIcons/forward.png)"

The icon paths that the command references are custom icons that I downloaded from IconsDB. I acquired the proper icon size by looking up my device’s display density on Material.io then correlating that density with the proper icon size using a reference chart.

If I want to revert my nav bar back to the default layout, I would enter this command:

settings put secure sysui_nav_bar "space,back;home;recent,space"

If you’ve been keeping up with my Android O tutorials, then this syntax will seem familiar to you. If not, then don’t worry. There’s an app for that.


Custom Navigation Bar

XDA Senior Member paphonb has developed an application called Custom Navigation Bar that does all of the legwork for you and changes the navigation bar buttons. The app is very easy to use as it’s based off of Android O’s navigation bar customizer. However, the app has been coded to allow you to use custom icons (much like in my tutorial), includes the ability to create Profiles that you can quickly switch between, and furthermore has Tasker support so you can contextually change the navigation bar based on whatever criteria you want.

All you have to do is install the app, then grant it WRITE_SECURE_SETTINGS permission by issuing the following command in ADB:

adb shell pm grant xyz.paphonb.systemuituner android.permission.WRITE_SECURE_SETTINGS

Then when you open the app, the app will determine whether or not your device supports modifying the navigation bar. It will attempt to present a “next” key centered in your nav bar. If it shows up, then you can modify your nav bar. If not, the app will tell you that you’re out of luck.

The application is free but does require you to purchase a pro version if you want to create more than 2 Profiles. This application certainly makes it easier to modify your navigation bar, so I personally think the price is worth it, but if have the know how, you can perform all of the features that this app offers through Tasker and SecureTask/AutoTools.


Customization Possibilities

There are a lot of things you can do with this app + Tasker. I’ve outlined many such cases in my tutorials, but here’s a quick list of some things you can try:

Those are what I came up with when I was playing around with the nav bar tuner in Android O, but they should work all the same with the hidden nav bar tuner in Android Nougat.

I’m absolutely astounded that it took this long for someone to figure out that this nav bar tuner works in Android Nougat without root. Thinking back on this, it makes total sense that it does work without root. After all, the SystemUI mod only exposes the preferences fragment to launch the nav bar tuner activity, it’s not like that mod actually adds the feature to SystemUI – it was always there. The shell commands just allow us to change the nav bar without exposing this SystemUI activity, and paphonb’s app just makes this all easier.


How would you like to customize your navigation bar? Let us know in the comments below!

HostGator Web Hosting

0 comments:

Post a Comment