[Android Software/Hacking General [Developers Only]] molesarecoming:
GUIDE FOR PA 1.5 and lower (ICS)

1. Unlock Tablet Mode for all devices

This has been already stuffend into the framework by us and if you use our files you wont need it, but i will include it nonetheless. Legacy devices crippled with hardware buttons need hacks to make tablet mode work. I dont know exactly whom to thank for this find, names that pop up in my head are Xylograph and evilisto. Ics compilant devices simply need one more entry in their build.prop: qemu.hw.mainkeys=1. You can include both, doesnt hurt.

--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5962,7 +5962,7 @@ public class WindowManagerService extends IWindowManager.S
unrotDw = dw;
unrotDh = dh;
}
- int sw = reduceConfigWidthSize(unrotDw, Surface.ROTATION_0, density, un
+ int sw = reduceConfigWidthSize((int)(unrotDw / density), Surface.ROTATI
sw = reduceConfigWidthSize(sw, Surface.ROTATION_90, density, unrotDh, u
sw = reduceConfigWidthSize(sw, Surface.ROTATION_180, density, unrotDw,
sw = reduceConfigWidthSize(sw, Surface.ROTATION_270, density, unrotDh,

build.prop

###################
# PARANOIDANDROID #
###################

ro.sf.lcd_density=192
qemu.hw.mainkeys=1

2. Find out tabletmode DPI treshold value

Tablet mode is AOSP standard functionality. ICS is will drop into tablet mode if it acknowledges a certain treshold DPI, depending on your devices screen. Changing ro.sf.lcd_density in /system/build.prop will do. You can calculate that value as follows, here's a snippet of the ICS code that decides if your UI runs in tablet mode or phone mode.

int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE;
mStatusBarCanHide = shortSizeDp < 600;

In short, you need to reach a short-side device-independend pixel number of 600. Example: Nexus has a width of 720 and a height of 1280, shortest side is 720, default density is 320. shortSizeDp = 720 * 160 / 320 = 360. lower than 600, phone mode. We need to lower the Dpi: shortSizeDp = 720 * 160 / 192 = 600. Thats it, tablet mode!

The formula is:

treshold_dpi = shortest-side-dp * 160 / 600

3. Setting up pad.prop and build.prop

/system/pad.prop is the file that defines how apps scale and in which UI they display. You should provide your users with a nice selection of everyday apps and define the system-apps well. Users should not be shocked when the phone boots up, what they are supposed to see is something that drops their jaws.

For Galaxy Nexus it looks like this:

###################
# PARANOIDANDROID #
###################

## DEFAULTS
%rom_tablet_base=192
%rom_phone_base=320
%rom_mid_base=260
%rom_mid_high_base=290
%rom_framework_dpi=250
%rom_systemui_dpi=220
%rom_launcher_dpi=290
%screen_default_width=360
%screen_default_height=567
%screen_default_layout=268435474
%screen_opposite_width=600
%screen_opposite_height=1018
%screen_opposite_layout=268435491

## CONFIGURATION
%hybrid_mode=1
%system_default_dpi=%rom_mid_base
%user_default_dpi=%rom_mid_base
%user_default_mode=1
android.dpi=%rom_framework_dpi
com.android.systemui.dpi=%rom_systemui_dpi

## PREFERENCES
com.android.phone.mode=1
com.android.inputmethod.dpi=%rom_phone_base
com.android.inputmethod.latin.mode=1
com.android.inputmethod.dpi=%rom_phone_base
com.android.camera.mode=2
com.android.camera.dpi=%rom_tablet_base
com.cyanogenmod.trebuchet.mode=1
com.cyanogenmod.trebuchet.dpi=%rom_launcher_dpi
com.anddoes.launcher.mode=1
com.anddoes.launcher.dpi=%rom_launcher_dpi
com.teslacoilsw.launcher.mode=1
com.teslacoilsw.launcher.dpi=%rom_launcher_dpi
com.android.chrome.mode=1
com.android.chrome.dpi=%rom_mid_high_base
com.android.calendar.mode=2
com.android.contacts.mode=2
com.android.email.mode=2
com.android.htmlviewer.mode=1
com.android.mms.mode=1
com.android.settings.mode=2
com.android.vending.mode=2
com.google.android.gm.mode=2
com.google.android.googlequicksearchbox.mode=2
com.google.android.talk.mode=1
com.google.android.youtube.mode=2

What is important here is that you need to set it up first with device specific informations. Here's a small rundown of these values:

%rom_tablet_base=xxx - table mode treshold dpi

%rom_phone_base=xxx - default device dpi

%rom_mid_base=xxx - a good middle value that works both for tabUI & phoneUI apps, for nexus its ~260

%rom_mid_high_base=xxx - a little bit higher than middle

%rom_framework_dpi=xxx - a good value for the lockscreen

%rom_systemui_dpi=xxx - good value for navigationbar

%rom_launcher_dpi=xxx - default value for trebuchet

%system_default_dpi=0 - sets the global density for system apps. 0 means undefined. We will probably make it obsolete soon.

%user_default_dpi=xxx - sets the global density for non-system apps, set it to default dpi as this will guarantee that all of your users apps will look stock

%user_default_mode=1 - sets the global UI for non-system apps. 1 = phoneUI, 2 = tablet UI. set it to 1, all user apps will display in mobileUI. If the user has tablet ready apps he can switch himself in the settings panel

## P.A.L PARAMETERS - these are extremely important. you get them by logging the output of Configuration in tablet mode (_opposite) and phonemode (_default) kevdliu wrote a nice little helper to make it easier for you, look here

make dead sure you get pad.prop right or you'll get bootloops or crashes!

notice that we use packagenames for apps, if you dont know the name of an app open up your shell and type:

adb shell
pm list packages -f

android - framework-res, applies to lockscreen, dialogs, powermenu, toasts

systemUI - applies to the navigationbar, makes it bigger or smaller. DO NOT APPLY an UI to these two apps. everything else is fine, set it to tablet or phoneUI all you want, but not these two!

Configuration in phone mode and tablet mode

build.prop needs to be configures like this:

###################
# PARANOIDANDROID #
###################

ro.sf.lcd_density=192
ro.cm.version=PARANOIDANDROID
ro.modversion=PARANOIDANDROID
ro.pa.version=PARANOIDANDROID-pa_maguro-1.5a-28JUN2012-180025

density to tablet treshold. versions to PA and version in that exact format because internal functions are relying on it (OTA for example). change the name of your device and the date. the last numbers, i have no idea what they are, came from the buildscript.

4. Check our sourcetrees

More and more source will be published soon. Right now we have three projects out, OTA, Backup and Trebuchet (optimized for tabletmode with cool features). Hybrid code will come out soon. Use what you can get from there: http://betadan.com/paranoid/sources/

5. Port the rom

You are ready to go. Do what you always do when porting roms. I have zero experience with that. Again, use CM9. Do not even think about using AOKP.

Check out Xylopgraph's PA porting guide

6. Link to our Google Apps

Google policy forbids you to use their market if you change your DPI. The only values allowed are 160, 240, 320. Why? No one knows why. There have been workaroundw, wiping cache, using a valid DPI, open market, reboot back, blablabla, forget it, its rubbish. It will work for a minute and then it will cease to. In our package Phonesky and GoogleServicesFramework were hacked. It has other additions aswell: http://4ndr01d.com/drcmda/common/

7. Post your port link and help out others

We will include you in our webpage and when our repo's are open you are invited to compile from source and/or submit patches and additions. We might even work together as theres still much to do. Be sure to help out others here.

​