[PATCH] True Tablet UI (Apps+GUI) w/o DPI Change for Stock & CM10 - Update Oct11 2012

Search This thread

barrmulio

Senior Member
Oct 5, 2010
357
359
[PATCH] True Tablet UI (Apps+GUI) w/o DPI Change for Stock & CM10 - Update Oct11 2012

Note: I am no longer maintaining releases due to time constraints. If someone would like to pick up the op, please pm me.

Recent Changes
10/11 - Updating CM10 nightly links - see next post
9/6 - Added nighly CM10 builds - see next post
8/1 - Cleaning to OP out a bit

Downloads
If you don't care about all the technical stuff, skip down to post 2 for downloads

Intro
Goal of thread is to share details around how the trigger for Phone UI/Phablet UI/Tablet UI works, and provide a dpi independent patch for tablet ui. Hopefully this also eliminates the misinformation that changing lcd density is the only way to get Tablet UI.

What's "true" tablet UI vs what is called tablet UI in many roms? The Tablet UI actually defines how some apps work (e.g. dual-paned settings like in the screenshots below) vs the other solutions that simply draw the standard Nexus UI with tablet navigation/system bars.

The 'Triggers'
In 4.1.x, there are two files that need to be modified:
PhoneWindowManager.java, located in frameworks/base/policy/src/com/android/internal/policy/impl contains the code that determines which UI to present. During compile this is a part of android.policy.jar
WindowManagerService.java, located in frameworks/base/services/java/com/android/server/wm contains code that specifies the lowest DP settings and has the system select from either sw600 or sw720 presentations. It is a part of services.jar

PhoneWindowManager
Click below for details regarding the source code to edit, and modifications for these releases

The source code calculates a value for shortSizeDP, and compares it to
  • shortSizeDP < 600 = PhoneUI
  • 601 720

shortSizeDP is calculated as follows:
take the short size of the screen resolution (our screen is 1280x800, so use 800) * DENSITY_DEFAULT (a constant of 160) * LCD Density (ro.sf.lcd_density value in build.prop)

example: on stock: 800 (N7 short resolution) * 160 / 213 (stock lcd_density) = 600.9
since 600.9 > 600 but less than 719, we get Phablet UI

using 170 as ro.sf.lcd_density: 800 * 160 / 170 = 752.9
since 752 > 720 we get Tablet UI

this explains why the threshold on our device is between 177 and 178

original source code:
Code:
        // SystemUI (status bar) layout policy
        int shortSizeDp = shortSize
                * DisplayMetrics.DENSITY_DEFAULT
                / DisplayMetrics.DENSITY_DEVICE;

        if (shortSizeDp < 600) {
            // 0-599dp: "phone" UI with a separate status & navigation bar
            mHasSystemNavBar = false;
            mNavigationBarCanMove = true;
        } else if (shortSizeDp < 720) {
            // 600-719dp: "phone" UI with modifications for larger screens
            mHasSystemNavBar = false;
            mNavigationBarCanMove = false;
        } else {
            // 720dp: "tablet" UI with a single combined status & navigation bar
            mHasSystemNavBar = true;
            mNavigationBarCanMove = false;
        }
        }

Modification
Given the code above, there should be many programmatic ways to force TabletUI:
Editing the values of 600 or 719, removing the Phablet UI mid section, or just commentting everything out and set mHasSystemNavBar = true; mNavigationBarCanMove = false;...and plenty of other options

Current Alphas are hardcoded to
Code:
mHasSystemNavBar = true;
mNavigationBarCanMove = false;

WindowsManagerService
Click below for details regarding the source code to edit, and modifications for these releases

Changing the values above we enough to try and force the UI to use tablet features, but since the Nexus 7 uses tvdpi (same as google TV when displaying 720p) with a fallback to xhdpi, SystemUI did not contain the requisite framework files (xml and pngs) and was force closing. Further, the sizing was mapped to the sw600 folders, which do not contain any of the tablet pngs/xmls.

Thus, we needed to edit the code that defined what the minimum screen size was to force apps to show in tablet form.

original source code:
Code:
private void computeSizeRangesAndScreenLayout(boolean rotated, int dw, int dh,
            float density, Configuration outConfig) {
        // We need to determine the smallest width that will occur under normal
        // operation.  To this, start with the base screen size and compute the
        // width under the different possible rotations.  We need to un-rotate
        // the current screen dimensions before doing this.
        int unrotDw, unrotDh;
        if (rotated) {
            unrotDw = dh;
            unrotDh = dw;
        } else {
            unrotDw = dw;
            unrotDh = dh;
        }
        mSmallestDisplayWidth = 1
 
Last edited:

barrmulio

Senior Member
Oct 5, 2010
357
359
Downloads

An now on to the part folks care about, please read the below in full

Credits:
I want to thank +aaronpoweruser, +lithium76, +cdesai for all their help and coding guidance; +Racer Of All for the zips; +the3dman for the Launcher2 fix, +z1gackly and +Nark.GA60 for their help with the CM10 patch, +Rsotbiemrptson for the odexed version

Disclaimer: I am not responsible for damaging your brand new nexus 7. Do not do this if you're not willing to brick it. Usage of the following files can cause a rift in the time-space continuum, the appearance of 20 foot android monsters in your town, turn your first-born into slime, change the gender of your significant other, tsunamis on mars, etc etc etc

Pre-requisites:
1. This is designed for Stock or AOSP JRO03D or Based CM10 (tested on Sep 6 nightly). Many folks are trying other roms that will either not boot or work. Please use the search above for your rom name before posting. Note: My development will focus on a patch to AOSP. I'm more than willing to work with devs on their roms, but the information above should suffice for them to bake the tweaks in however they want to.
2. You SHOULD BE DEODEXED. If you don't know what that means, then you likely aren't - so run a deodexer like mine or do it yourself . Update: Sept 7 - Rsotbiemrptson released a odexed version post 514
3. You MUST WIPE CACHE AND DALVIK. Formatting system and data/factory reset is not needed

READ BEFORE FLASHING List of Issues / Add Bug Reports:
Please report your issue here with all the information above.
https://docs.google.com/spreadsheet/ccc?key=0Aq1C5kjO0c_tdDFrbWVsOF9ROXJOblNFVzFYR29CQkE

Latest Downloads:
10/11 - CM10 Nightly - credits z1gackly and Nark.GA60 post 534
Download: goo.im

8/1 - Alpha 3 for STOCK ROM JRO03D: fixed launcher (patch Launcher2.apk), adds lockscreen rotation (patch framework-res.apk)
Download: Mirror 1 Mirror 2
Alpha3 creates a backup during install, restore using the following script: Mirror 1
Issues Resolved: Patched Launcher has huge borders on bottom/top fixed
Note: these new changes will likely cause compatibility issues with CM/AOKP roms and customized roms. Alpha 1 may be better for you

Reporting Issues:
Many people are not fully reporting problems. If I don't have enough details, then it's very hard or impossible to help.
Please provide:
Rom: (e.g. Stock version JRO03D, JRO03H, j5, etc) - this is found in system/about tablet
Kernel: stock or modified - this is found in system/about tablet (you will know if you modified it)
Issue Description: Exact issue, exact error message, steps to replicate, screenshot (power + vol down at same time) for visual issues. Words like 'many', 'a lot', 'often' are not helpful. If there were a lot of issues then it wouldn't have been released. If you are on another rom/kernel, please verify that any play store issues are not sourced by that rom/kernel combo first without the mod.
Bootloops, Crashes: I *need* a logcat - see my signature

Next Steps:
- Settings toggle (WIP)
- Hybrid UI (stock UI in portratit, tablet in landscape)

Prior Versions:
7/26 - Alpha 2 - thank you +Racer Of All
Download: Mirror 1 Mirror 2
MD5: 1c85cc5fe772f687ce9beaa8dab57130
Issues Resolved: credit the3dman - Stock launcher width is too long due to mods and cause overscan of ~half icon on either side. Use Apex, Nova, Go Launcher.

7/21 - Alpha 1 released - thank you again +Racer Of All
Download: Mirror 1 Mirror 2
MD5: dbf20c71544dc19ac87c5d59a03c6f12

Alpha 1 does make a backup of your original files, if something goes wrong, flash the zip below to restore the files:
Mirror 1 Mirror 2

Screenshots
2CpJE.png
j47r7.png
Ggbbs.png

jLRI7.png

pfChC.png
 
Last edited:

neilrl79

Senior Member
Aug 15, 2010
816
222
Maryland
I hope someone runs with this. I'm running a tablet ui JB rom on my Fire and love it but I didn't want to screw around with dpi changes on the N7 that make everything smaller and bork the market.
 
  • Like
Reactions: powerpoint45

oasis9389

Senior Member
Jun 30, 2010
256
31
I hope someone runs with this. I'm running a tablet ui JB rom on my Fire and love it but I didn't want to screw around with dpi changes on the N7 that make everything smaller and bork the market.

no clue where you heard it borks the market.. i am running 160 dpi and everything is perfect. 10x better than having a 7 inch galaxy nexus.
 
  • Like
Reactions: bdubs4200

neilrl79

Senior Member
Aug 15, 2010
816
222
Maryland
no clue where you heard it borks the market.. i am running 160 dpi and everything is perfect. 10x better than having a 7 inch galaxy nexus.

Every thread that discusses dpi change to allow tablet ui also has people posting how some apps begin to show as incompatible after the change, that, imo,borks the market.
 

dude2k5

Senior Member
Jul 9, 2010
763
284
www.futurenology.com
Would love to have a notification bar like the tablets do, the one they have now is ok, but I like the other one way better. Tried 160 DPI but it did not look good to me.
 

qoncept

Senior Member
Feb 1, 2010
239
38
Holy cow what a stupid way for Google to determine which UI to display. Fixed:

Code:
       // SystemUI (status bar) layout policy

        if (layoutType == 1) {
            mHasSystemNavBar = false;
            mNavigationBarCanMove = true;
        } else if (layoutType == 2) {
            mHasSystemNavBar = false;
            mNavigationBarCanMove = false;
        } else {
            mHasSystemNavBar = true;
            mNavigationBarCanMove = false;
        }

The alternative would be "screenSize"

Manipulating values, multiplying by meaningless constants and using values that are derivatives of the number that actually matters? Google's code was just stupid. Write the code so developers can tell it what they want, not so it enforces your recommended layout.
 

barrmulio

Senior Member
Oct 5, 2010
357
359
guys - kindly keep all lcd_density dpi discussion, complaints and issues to the existing threads in Q&A or general, so this thread can focus on code change development...the whole point of this thread is to offer an alternative to that already...thanks!
 

barrmulio

Senior Member
Oct 5, 2010
357
359
Holy cow what a stupid way for Google to determine which UI to display. Fixed:

Code:
       // SystemUI (status bar) layout policy

        if (layoutType == 1) {
            mHasSystemNavBar = false;
            mNavigationBarCanMove = true;
        } else if (layoutType == 2) {
            mHasSystemNavBar = false;
            mNavigationBarCanMove = false;
        } else {
            mHasSystemNavBar = true;
            mNavigationBarCanMove = false;
        }

The alternative would be "screenSize"

Manipulating values, multiplying by meaningless constants and using values that are derivatives of the number that actually matters? Google's code was just stupid. Write the code so developers can tell it what they want, not so it enforces your recommended layout.

that's the direction i was thinking as well - define a new global variable, and let devs build a toggle to set it into the settings (for user selection) or as a constant (if they just want their rom one way)
 
  • Like
Reactions: gr8hairy1

qoncept

Senior Member
Feb 1, 2010
239
38
Actually, I think it probably makes even more sense to set mHasSystemNavBar and mNavigationBarCanMove independently of each other. This bit of code doesn't need to exist; these variables should be set wherever shortSize was set. So instead of choosing whether you have a tablet or phone, you choose whether you want each option enabled.
 
Last edited:

oasis9389

Senior Member
Jun 30, 2010
256
31
Every thread that discusses dpi change to allow tablet ui also has people posting how some apps begin to show as incompatible after the change, that, imo,borks the market.

yea and my N7 is a paper weight b/c some guy has a picture of it laying on a magazine.. again i have been running at 160 for a day now with heavy use. i have 0 issues, i have installed all my apps, ran all my apps, all my widgets. i am on 160 you are not.

now i messed wtih 170 and 177.. yes those don't work well.. 160 is not 170 177

---------- Post added at 08:44 PM ---------- Previous post was at 08:41 PM ----------

guys - kindly keep all lcd_density dpi discussion, complaints and issues to the existing threads in Q&A or general, so this thread can focus on code change development...the whole point of this thread is to offer an alternative to that already...thanks!

sorry just saw this.. carry on with the development.
 

Nexcellent

Senior Member
Dec 1, 2011
420
280
Cleveland, OH
yea and my N7 is a paper weight b/c some guy has a picture of it laying on a magazine.. again i have been running at 160 for a day now with heavy use. i have 0 issues, i have installed all my apps, ran all my apps, all my widgets. i am on 160 you are not.

now i messed wtih 170 and 177.. yes those don't work well.. 160 is not 170 177

---------- Post added at 08:44 PM ---------- Previous post was at 08:41 PM ----------



sorry just saw this.. carry on with the development.

That's freaking awesome for you bro! :good:

That being said, there are people who have had things go wrong after changing DPI to 160. Plenty of threads in General and Q/A detailing this.
 

oasis9389

Senior Member
Jun 30, 2010
256
31
That's freaking awesome for you bro! :good:

That being said, there are people who have had things go wrong after changing DPI to 160. Plenty of threads in General and Q/A detailing this.

"plenty of threads"
lol lord.. there is one topic on it.. a few posts of issues with people using other than 160. 160 works, end of story.
 

barrmulio

Senior Member
Oct 5, 2010
357
359
update on development

my nexus doesn't like the the android.policy.odex that i'm compiling from aosp, even without any changes to any of the files from the repo...it will just stay on the nexus X boot screen (after the Google bootloader) until i copy the original android.policy.odex back and then it finishes booting up within a few seconds

if anyone has succesfully built a mod or otapackage from aosp for grouper (i've been using full_grouper-eng), let me know if there were any special settings for compiling that are needed to get it to boot
 

Top Liked Posts

  • There are no posts matching your filters.
  • 151
    [PATCH] True Tablet UI (Apps+GUI) w/o DPI Change for Stock & CM10 - Update Oct11 2012

    Note: I am no longer maintaining releases due to time constraints. If someone would like to pick up the op, please pm me.

    Recent Changes
    10/11 - Updating CM10 nightly links - see next post
    9/6 - Added nighly CM10 builds - see next post
    8/1 - Cleaning to OP out a bit

    Downloads
    If you don't care about all the technical stuff, skip down to post 2 for downloads

    Intro
    Goal of thread is to share details around how the trigger for Phone UI/Phablet UI/Tablet UI works, and provide a dpi independent patch for tablet ui. Hopefully this also eliminates the misinformation that changing lcd density is the only way to get Tablet UI.

    What's "true" tablet UI vs what is called tablet UI in many roms? The Tablet UI actually defines how some apps work (e.g. dual-paned settings like in the screenshots below) vs the other solutions that simply draw the standard Nexus UI with tablet navigation/system bars.

    The 'Triggers'
    In 4.1.x, there are two files that need to be modified:
    PhoneWindowManager.java, located in frameworks/base/policy/src/com/android/internal/policy/impl contains the code that determines which UI to present. During compile this is a part of android.policy.jar
    WindowManagerService.java, located in frameworks/base/services/java/com/android/server/wm contains code that specifies the lowest DP settings and has the system select from either sw600 or sw720 presentations. It is a part of services.jar

    PhoneWindowManager
    Click below for details regarding the source code to edit, and modifications for these releases

    The source code calculates a value for shortSizeDP, and compares it to
    • shortSizeDP < 600 = PhoneUI
    • 601 720

    shortSizeDP is calculated as follows:
    take the short size of the screen resolution (our screen is 1280x800, so use 800) * DENSITY_DEFAULT (a constant of 160) * LCD Density (ro.sf.lcd_density value in build.prop)

    example: on stock: 800 (N7 short resolution) * 160 / 213 (stock lcd_density) = 600.9
    since 600.9 > 600 but less than 719, we get Phablet UI

    using 170 as ro.sf.lcd_density: 800 * 160 / 170 = 752.9
    since 752 > 720 we get Tablet UI

    this explains why the threshold on our device is between 177 and 178

    original source code:
    Code:
            // SystemUI (status bar) layout policy
            int shortSizeDp = shortSize
                    * DisplayMetrics.DENSITY_DEFAULT
                    / DisplayMetrics.DENSITY_DEVICE;
    
            if (shortSizeDp < 600) {
                // 0-599dp: "phone" UI with a separate status & navigation bar
                mHasSystemNavBar = false;
                mNavigationBarCanMove = true;
            } else if (shortSizeDp < 720) {
                // 600-719dp: "phone" UI with modifications for larger screens
                mHasSystemNavBar = false;
                mNavigationBarCanMove = false;
            } else {
                // 720dp: "tablet" UI with a single combined status & navigation bar
                mHasSystemNavBar = true;
                mNavigationBarCanMove = false;
            }
            }

    Modification
    Given the code above, there should be many programmatic ways to force TabletUI:
    Editing the values of 600 or 719, removing the Phablet UI mid section, or just commentting everything out and set mHasSystemNavBar = true; mNavigationBarCanMove = false;...and plenty of other options

    Current Alphas are hardcoded to
    Code:
    mHasSystemNavBar = true;
    mNavigationBarCanMove = false;

    WindowsManagerService
    Click below for details regarding the source code to edit, and modifications for these releases

    Changing the values above we enough to try and force the UI to use tablet features, but since the Nexus 7 uses tvdpi (same as google TV when displaying 720p) with a fallback to xhdpi, SystemUI did not contain the requisite framework files (xml and pngs) and was force closing. Further, the sizing was mapped to the sw600 folders, which do not contain any of the tablet pngs/xmls.

    Thus, we needed to edit the code that defined what the minimum screen size was to force apps to show in tablet form.

    original source code:
    Code:
    private void computeSizeRangesAndScreenLayout(boolean rotated, int dw, int dh,
                float density, Configuration outConfig) {
            // We need to determine the smallest width that will occur under normal
            // operation.  To this, start with the base screen size and compute the
            // width under the different possible rotations.  We need to un-rotate
            // the current screen dimensions before doing this.
            int unrotDw, unrotDh;
            if (rotated) {
                unrotDw = dh;
                unrotDh = dw;
            } else {
                unrotDw = dw;
                unrotDh = dh;
            }
            mSmallestDisplayWidth = 1
    59
    Downloads

    An now on to the part folks care about, please read the below in full

    Credits:
    I want to thank +aaronpoweruser, +lithium76, +cdesai for all their help and coding guidance; +Racer Of All for the zips; +the3dman for the Launcher2 fix, +z1gackly and +Nark.GA60 for their help with the CM10 patch, +Rsotbiemrptson for the odexed version

    Disclaimer: I am not responsible for damaging your brand new nexus 7. Do not do this if you're not willing to brick it. Usage of the following files can cause a rift in the time-space continuum, the appearance of 20 foot android monsters in your town, turn your first-born into slime, change the gender of your significant other, tsunamis on mars, etc etc etc

    Pre-requisites:
    1. This is designed for Stock or AOSP JRO03D or Based CM10 (tested on Sep 6 nightly). Many folks are trying other roms that will either not boot or work. Please use the search above for your rom name before posting. Note: My development will focus on a patch to AOSP. I'm more than willing to work with devs on their roms, but the information above should suffice for them to bake the tweaks in however they want to.
    2. You SHOULD BE DEODEXED. If you don't know what that means, then you likely aren't - so run a deodexer like mine or do it yourself . Update: Sept 7 - Rsotbiemrptson released a odexed version post 514
    3. You MUST WIPE CACHE AND DALVIK. Formatting system and data/factory reset is not needed

    READ BEFORE FLASHING List of Issues / Add Bug Reports:
    Please report your issue here with all the information above.
    https://docs.google.com/spreadsheet/ccc?key=0Aq1C5kjO0c_tdDFrbWVsOF9ROXJOblNFVzFYR29CQkE

    Latest Downloads:
    10/11 - CM10 Nightly - credits z1gackly and Nark.GA60 post 534
    Download: goo.im

    8/1 - Alpha 3 for STOCK ROM JRO03D: fixed launcher (patch Launcher2.apk), adds lockscreen rotation (patch framework-res.apk)
    Download: Mirror 1 Mirror 2
    Alpha3 creates a backup during install, restore using the following script: Mirror 1
    Issues Resolved: Patched Launcher has huge borders on bottom/top fixed
    Note: these new changes will likely cause compatibility issues with CM/AOKP roms and customized roms. Alpha 1 may be better for you

    Reporting Issues:
    Many people are not fully reporting problems. If I don't have enough details, then it's very hard or impossible to help.
    Please provide:
    Rom: (e.g. Stock version JRO03D, JRO03H, j5, etc) - this is found in system/about tablet
    Kernel: stock or modified - this is found in system/about tablet (you will know if you modified it)
    Issue Description: Exact issue, exact error message, steps to replicate, screenshot (power + vol down at same time) for visual issues. Words like 'many', 'a lot', 'often' are not helpful. If there were a lot of issues then it wouldn't have been released. If you are on another rom/kernel, please verify that any play store issues are not sourced by that rom/kernel combo first without the mod.
    Bootloops, Crashes: I *need* a logcat - see my signature

    Next Steps:
    - Settings toggle (WIP)
    - Hybrid UI (stock UI in portratit, tablet in landscape)

    Prior Versions:
    7/26 - Alpha 2 - thank you +Racer Of All
    Download: Mirror 1 Mirror 2
    MD5: 1c85cc5fe772f687ce9beaa8dab57130
    Issues Resolved: credit the3dman - Stock launcher width is too long due to mods and cause overscan of ~half icon on either side. Use Apex, Nova, Go Launcher.

    7/21 - Alpha 1 released - thank you again +Racer Of All
    Download: Mirror 1 Mirror 2
    MD5: dbf20c71544dc19ac87c5d59a03c6f12

    Alpha 1 does make a backup of your original files, if something goes wrong, flash the zip below to restore the files:
    Mirror 1 Mirror 2

    Screenshots
    2CpJE.png
    j47r7.png
    Ggbbs.png

    jLRI7.png

    pfChC.png
    39
    Patch for 4.2 Stock Odex

    Here is a patch for 4.2 stock odex and deodexed, plus ones to revert. This doesn't include a modded launcher.

    Rsotbiemrptson
    31
    Zips for stock 4.1.1

    Hello,
    I would like to say thanks for your work, it has brought my N7 much needed changes. I had to modify the files as I am still running stock 4.1.1(JRO03D odexed). I have it working for non deodexed roms incase anyone that hasn't flashed a custom rom wants to try it. I have also uploaded a zip to revert back to stock just incase. Both can be flashed through recovery, wipe cach and dalvik after flashing.

    TabletUI
    https://www.dropbox.com/s/e63uj4l2tynfrfc/TabletUI.zip?m
    StockUI
    https://www.dropbox.com/s/27btzfayophnd9h/StockUI.zip?m

    Rsotbiemrptson
    15
    4.2.1 Patches

    Hello,
    Here are the patches for 4.2.1.

    Rsotbiemrptson