Force tablet UI on a non-tablet device?


Question

I own a large screen phone and am wondering if I could make it recognize itself as a tablet, as in:




  • The navbar should stay at the bottom instead of rotating to the sides

  • Notification shade doesn't occupy the whole screen width in portrait / doesn't stay in the middle in landscape

  • Apps that support tablet layout will use it



AFAIK, a sufficiently small DPI (LCD density) value will trigger the change, but naturally I want the UI elements to stay at a visible, comfortable size. There's supposed to be a trigger (an if-else condition?) that calculates whether tablet UI should be activated based on device metrics and the above DPI value, however I don't know where the actual trigger is or how should I change it to make it always say "tablet". I've seen similar things done to Android versions below 5.0 via Xposed modules, but those are quite outdated by now.



The answer could be using Xposed (not preferred but still alright, since I still need to stay on Nougat for a while), modifying SystemUI, or even modifying the Android source code and building (I have the know-how for that) - one just have to tell me where and how.



Any ideas?


Answer

After some digging I am able to sort out a relatively easy solution for the first and most important requirement, that is, keeping the navbar at the bottom. Requires root (of course - to pull and push files) and basic skill of using apktool.



For pre-compiled ROMs:





  1. Install apktool.

  2. Install your framework-res.apk by executing apktool if /path/to/framework-res.apk.

  3. Decompile your services.jar by executing apktool d /path/to/services.jar.

  4. Go to the decompiled services.jar.out folder and open smali/com/android/server/policy/PhoneWindowManager.smali.

  5. Search for 0x258 and replace the only occurrence of it with 0x0.

  6. Rebuild services.jar (preserve its signature) by executing apktool b -c services.jar.out.

  7. Decompile your SystemUI.apk by executing apktool d /path/to/SystemUI.apk.

  8. Go to the decompiled SystemUI folder, then go to res/layout/.

  9. Remove navigation_layout_rot90.xml.

  10. Make a copy of navigation_layout.xml and rename it to navigation_layout_rot90.xml.

  11. Rebuild SystemUI (preserve its signature) by executing apktool b -c SystemUI.

  12. Push the finished services.jar and SystemUI.apk back to where they were using a method of your choice, set correct permissions, then reboot.




For ROM makers:





  1. Open *build-folder*/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java.

  2. Search for shortSizeDp < 600 and replace the only occurrence of it with shortSizeDp < 0.

  3. Find the SystemUI layout files in *build-folder*/frameworks/base/packages/SystemUI/res/layout/ and replace, similar to the method for pre-compiled ROMs.

  4. Build the ROM.




Note that the default button layout doesn't look good under landscape mode, but one can always use the built-in navbar tuner in Android 7.0+ to tweak it to his desire.






As of Android 10, this has been simplified to a single boolean config config_navBarCanMove, which can either be set directly in the framework or separately in an overlay (recommended).


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes