Enable On-screen navigation in CM12 (Lollipop) using shell? Device: OnePlus One (OPO); running CM12, is rooted, and has Xposed Framework installed.



I need to enable On-screen navigation (it disables Hardware (HW) keys and shows soft keys at the screen; like this) in OPO. I'm able to do it via Settings but my objective requires a command-line solution through shell. 

(Note that this is not a development/programming question, simply an Android question.)


Objective: To disable Back(HW) key  when main activity of an app (random) is in foreground, but without a reboot. 
I found On-screen nav. to be a good choice which doesn't require a reboot. I'll use an automation app to trigger the disabling action.
There are manual ways to disable HW keys (by editing .kl files) and enabling Soft keys (by editing build.prop), or using tools like Xposed modules to disable or swap HW keys. But they all require reboot (soft/hard) at least once which I cannot afford.
I experimented  and found that when On-screen nav. is enabled, the value for dev_force_show_navbar changes to 1 from 0. Similarly. button_brightness changes to 0 from 255. Both names are under Settings.db (Table:secure)
Also, there is no special activity assigned for Settings &rarr; Buttons(it enables On-screen nav). I used dumpsys activity | grep mFocusedActivity to see activity related to Buttons. The result was:

com.android.settings/.SubSettings

dumpsys activity activities or dumpsys activity recents also has nothing more to tell here.
I logged my actions using logcat when enabling On-screen nav. and here is the log file.


So, how do I enable On-screen nav. through command line, irrespective of whether it requires superuser access or not?

Edit: Is there any other way using which I can achieve the objective precisely?



Only thing that comes to my mind is to use  input  &lt;keyevent&gt; but that's counterproductive to me. The other way is to trigger an Xposed module like Xposed Additions but I'm unable to use it with shell.
I experimented and found that when On-screen nav. is enabled, the value for dev_force_show_navbar changes to 1 from 0... Both names are under Settings.db (Table:secure).


You actually mentioned the key to the answer but somehow (I suppose) didn't know how to use it. Many thanks to Andrew T. and DavisNT for this answer since it would lead to a solution for your problem.

I myself is a owner of OnePlus One running stock CM12 so you may now expect a working answer.

From the shell, be it adb, or a Terminal app, or Tasker's "Run Shell" action, enter the following command with root privileges:

settings put secure dev_force_show_navbar 1


You would now see that On-screen navigation bar is enabled just like in your pic posted here.

Don't worry about button_brightness since the changes in its value would be reflected automatically by the above command.

I tested that command in Tasker by manual execution of action "Code -> Run Shell -> command" with "Use Root", and its working good. 

The changes are exactly same as doing it from "Settings -> Buttons" so nothing to worry, i.e. only Soft-keys are visible and Hard keys are disabled. Coolest part -- no reboot needed. 

You can revert back by using 0 in place of 1 in the aforesaid command.