[Nexus 7 Android Development] barrmulio:
[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:

// 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

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:

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