4

I am trying to change few things programatically on the navigation bar on an Embedded system that uses an old Android OS. I narrowed down to the class that handles the navigation bar which is below.

https://android.googlesource.com/platform/frameworks/base/+/7d8abae/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

the object seems to be declared here:

https://android.googlesource.com/platform/frameworks/base/+/598a7aedfb6b77fc98bace9f420968a6f3ed637e/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

line 238

private NavigationBarView mNavigationBarView = null;

Is there a way to get the pointer to this object programatically? The only thing I can find is code to get the bigger container like when you hide the navigation bar programatically.

        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);

yet, this is not enough. I want to drill down to the navbar drawables.

any clues are greatly appreciated.

thank you.

P.S. Since it is an embedded system, so if I change the OS is it fine since it will never be at the Google store anyway.

gmmo
  • 2,577
  • 3
  • 30
  • 56
  • Did you try (https://stackoverflow.com/questions/1196192/how-do-i-read-a-private-field-in-java)? – VanDir Jul 02 '17 at 11:00
  • I know how to get stuff by reflection, by this is not the question. I want to get the Navbar pointer by reflection, this is the main issue. Thanks for reading in all cases. – gmmo Jul 02 '17 at 11:04

1 Answers1

1

There's no way to get the mNavigationBarView object in PhoneStatusBar by reflection. This object is living in process com.android.systemui, you own process can not access another process's object using reflection.

A possible way is to use Xposed framework. With some hooks in PhoneStatusBar's method, you can get access to the mNavigationBarView object.

There are already some modules that modify the navigationBar, eg: Xperia/AOSP NavBar Buttons . You can follow this tutorial that modify SystemUI's clock style using Xposed framework.

wrkwrk
  • 2,261
  • 15
  • 21
  • if it can't be done, how are they doing it? I believe it is possible, it is just a matter of re-build and import the correct .jar. – gmmo Jul 10 '17 at 16:33
  • @gmmo Not possible by reflection. It is possible by using Xposed framework, its hooks run in SystemUI's process, so you can access the mNavigationBarView object and do what ever you want. Another way is to decompile SystemUI.apk and modify the smali file(decompiled source code file), then recompile and sign the apk with platform key. You probably not have the key, so you will need to decompile and modify services.jar to trust your own key. It's complicated but possible, I had done something like this before. Both xposed framework and modify apk need a rooted device. – wrkwrk Jul 11 '17 at 06:00