[Galaxy S II General] droidphile:
Exclusive Features

We will explore some of the exclusive features in ICS kernels, ofcourse brought in by XDA devs and not Samsung themselves.

Any feature is best explained through answers for different kind of questions. Atleast, that's what i believe :)

We have dual-booting and bln breathing to start with. Features are originally brought in by gokhanmoral and is available in a few kernels like Siyah as of now.

1. Dual Booting

1) "So what's dual booting?"

A. Option to boot into either of two ICS roms - aosp or sammy. Immediately after the boot logo, there is a 3 seconds time-out where you can boot into secondary rom by pressing the home key/volume down key. To boot into primary rom, wait for 3 seconds time-out to complete. If you don't like to wait - touch the screen, or press power key or press volume up key.

2) "What's the basic architecture behind dual booting?"

A. Any rom will have /system, /data, /cache partitions and requires a kernel to boot. Primary rom has all these partitions on the same location and partitions as if you were single-booting. ie, /dev/block/mmcblk0p09 for /system and rootfs for /data and /cache. Secondary rom uses a hidden partition (/dev/block/mmcblk0p12) for /system and sdcard to store /data and /cache partitions. They're stored in /sdcard/.secondrom directory as mountable ext4 block device images (data.img and cache.img).

Kernel partition is shared, so same kernel boots both the roms. If you switch from Siyah to a different kernel, dual booting will not be available even though there's a clone of secondary rom. Internal sdcard, external plastic sdcard, /efs, /emmc, other kernel related virtual filesystem directories, etc are shared among roms.

3) "I have just one rom now. How do i setup one more rom to dual boot?"

A.

-To use current rom as primary: Assuming the other rom is downloaded and copied to phone memory

Easy Method

i) Flash latest Siyah that supports dual boot.

ii) Wipe data and cache of second rom using format /secondrom_cache and format /secondrom_data options under dual boot menu in recovery.

iii) Flash rom zip as second rom directly using "Install zip to 2ndROM from internal SD" or "Install zip to 2ndROM from external SD" under dual-boot options in Recovery.

Old/Alternative Method if Easy Method fails

i) Flash latest Siyah that supports dual boot.

ii) Nandroid backup your existing rom.

iii) Full wipe, install the rom you need to dual boot into.

iv) Boot into that rom, perform initial setups, flash whatever zip you need to flash on that rom - gapps, themes, mods, etc.

v) Flash latest Siyah on this rom.

vi) Boot into recovery, under dual-boot options, select "Clone Primary ROM to Secondary". Be patient and wait about 6-7 minutes. Now the new rom is secondary rom.

vii) Within recovery, restore nandroid backup. Now, the existing rom becomes primary.

viii) Just to be sure, flash latest Siyah again.

-To use current rom as secondary: Assuming the other rom is downloaded and copied to phone memory

Easy Method

i) Flash latest Siyah that supports dual boot.

ii) Boot into recovery, under dual-boot options, select "Clone Primary ROM to Secondary". Now your existing rom becomes secondary.

iii) Full wipe and install the Rom you want to use as primary.

iv) Flash latest Siyah just to be sure.

Alternative Method

i) Flash latest Siyah that supports dual boot.

ii) Wipe data and cache of second rom using format /secondrom_cache and format /secondrom_data options under dual boot menu in recovery.

iii) Flash rom zip as second rom directly using "Install zip to 2ndROM from internal SD" or "Install zip to 2ndROM from external SD" under dual-boot options in Recovery.

iv) Select "Swap 1st Rom and 2nd Rom" under dual-boot options in recovery.

Now you have two roms. Press home key to boot into second rom when time-out is displayed.

4) "How much time was it to clone a rom?"

A. There's /system, /data/ and /cache to clone. 2 GB data + 103mb cache + 513 mb system = 2.6 gb

Shell prompt read speed = 7mb per second.

Total Time = 2.6*(1024/7) = 380 secs = 6/7 minutes.

5) "If i reboot to recovery from power-off state using 3 button method, to which rom's recovery it's booted into?"

A. Unified kernel, same recovery. And remember - flashing zips to second rom is not possible as of now.

6) "Any solution to flashing zips to secondary rom?"

A.

Yes. Use Install zip to 2ndROM from internal SD" or "Install zip to 2ndROM from external SD" under dual-boot options in Recovery.

Alternative 1:

If you know what the updater script in the zip is doing, you can do that manually using Root Explorer (replacing/copy files, setting permissions, etc).

Alternative2:

i) Swap 1st Rom and 2nd Rom using Dual-boot options in recovery. Now your 2nd rom becomes primary for time being.

ii) Install zips like normal.

ii) Swap again.

7) "Should i have same versions of kernels on both roms? If not, from which rom should i flash the kernel"

A. Flash kernel from any rom (if cwm app/darkyota is used). Both uses the same kernel partition anyway.

8) "Will i get a prompt to dual-boot if i'm not using dual boot, as in i haven't cloned any rom to use as secondary?"

A. NO

9) "I don't like waiting for 3 seconds to boot into primary rom."

A. Touch the screen/press volume up key immediately upon prompt.

10) "How to undo dual booting?"

A. Use "Remove 2ndRom" from dual-boot options in recovery.

11) "How to remove secondary rom if "Remove 2ndRom" in touch recovery fails for some reason?"

A. Format 2nrom /system partition from dualboot options in recovery, remove data.img and cache.img under /sdcard/.secondrom directory manually by booting into primary rom. Also delete /secondrom directory.

12) "So if at all i format /sdcard, my second rom is gone?"

A. Yes

13) "Is the size of /system partition of secondary rom re-sizable from user space?"

A. NO

14) "Can i have both aosp roms/both samsung roms/first aosp, second samsung/first samsung,second aosp?"

A. Yes

15) "Can i have one GB rom and second ICS rom?"

A. No

16) "Why?"

A. Kernel partition is shared between roms. Dual boot functionality is implemented in ICS kernel. ICS kernel can run only ICS roms.

17) "Can i have different kernels for the two roms?"

A. NO. Kernel partition is shared.

18) "USB mass storage works?"

A. Yes. Both cards will be mounted for primary and secondary roms. MTP works too.

19) "If i had the same /data partition shared between roms, i could use same apps on both roms."

A. Data partition can not be shared as they're incompatible between roms. (Sometimes dev asks you to perform full wipe even if you're switching between versions of the same rom right). Even if they were shared, separate dalvik caches has to be used and hence every boot will take a long time to rebuild dalvik.

20) "How do i swap primary and secondary roms?"

A.

Easy Way:

In recovery, select "Swap 1stRom and 2ndRom". It may take upto 20 minutes. Be patient and watch the progress bar.

Difficult way: If the "swap" in recovery fails,

i) Select "Backup secondary rom" under dual boot options.

ii) Under original Backup and Restore option, select "Backup" to nandroid backup your primary rom.

iii) Under dual boot options, "Restore as secondary rom" or "Restore as secondary rom from internal sd" and select the nandroid backup of what was actually your primary rom.

iv) Under original Backup and Restore option, select "Restore" to restore the rom you backed up as secondary.

21) "How to upgrade primary rom?"

A. As usual, goto recovery, wipe whatever you need to wipe and install the new version. Remember to flash latest Siyah after upgrading if the Rom comes with a different kernel.

22) "How to upgrade secondary rom?"

A. Use "Install zip to 2ndROM from internal SD" or "Install zip to 2ndROM from external SD" under dual-boot options in Recovery. to flash the Rom zip. If any wipe is required, use format /secondrom_cache, format /secondrom_dalivkcache, format /secondrom_data and format /secondrom_system under Mounts & Storage in recovery.

Alternative 1, if the above fails:

Temporarily convert secondary rom to primary (by swapping them in recovery), flash rom zip revert primary back to secondary by swapping again. Remember to flash latest Siyah after upgrading. (This is just to be sure. Flashing zip to second rom does not change kernel)

23) "How to replace secondary rom with another?"

A.

Easy Way:

i) Wipe second rom partitions using format /secondrom_cache, format /secondrom_dalivkcache, format /secondrom_data and format /secondrom_system.

ii) Install Rom zip using Install Zip to 2ndROM from internal SD or external SD from dual-boot options in recovery.

Difficult Way:

Perform the steps to setup dual boot as if you had only one rom which is going to be used as primary rom.

24) "How to replace primary rom with another?"

A. Normal procedure - wipe, install from recovery.

25) "Are init.d scripts and extweaks profiles shared across the roms so that i can make changes by booting into any rom and the other rom automatically inherits the settings?"

A. NO. Roms have differet /system partitions so different init.d directories. Roms uses different /data partitions so different extweaks settings since extweaks profiles are stored under /data/.siyah. Configure both separately. Initramfs scripts are shared anyway because Roms use the same kernel.

26) "Can i use titanium to backup and restore apps on both roms?"

A. Yes. With the default settings of titanium backup, it uses /sdcard/TitaniumBackup directoryto backup apps. Assume you have the same app installed in both roms and you backed up the app from both roms. Then when you restore app+data, the last backup is restored. (regardless of from which rom was it backed up last. Because the app database is overwritten for each backup). If you want to maintain exclusiveness between apps in the two roms, use a different backup directory in second rom. Reason for exclusivity could be - you need different settings for same app in the roms OR you have reached level 2 of a game in rom1 and level 6 in rom2 and you need to maintain that, etc.

27) "What're the Dual Boot options available in touch recovery?"

A.

i) View Current Status

Displays secondary rom info if found.

ii) Clone 1stRom to 2ndRom

First time, you will have only one rom. You may clone it as secondary rom (so that another rom can be used as primary). Note that what was Primary rom will remain as Primary after this. In short - you will copy of same rom and 1st and 2nd.

iii) Clone 2ndRom to 1stRom

Whatever has been cloned as second Rom is cloned to first rom. Note that what was Second rom will remain as Second after this. In short - you will copy of same rom and 1st and 2nd.

iv) Remove 2ndRom

Remove second Rom by Deleting /system, /data and /cache partitions of second rom. You will have normal booting.

v) Swap 1stROM and 2ndROM

Swaps primary and secondary roms by exclusively overwriting /system /data and /cache of both roms. This is a time consuming process. Be patient.

vi) Backup 2ndROM

Nandroid backup secondary rom to external sd.

vii) Restore as secondary rom

Restore any nandroid backup as secondary rom from external sd.

viii) Backup 2ndROM to internal SD

Nandroid backup secondary rom to internal sd.

ix) Restore as 2ndROM from internal sd

Restore any nandroid backup as secondary rom from internal sd.

x) init second rom data

Initialize /data parition of secondary rom to resize the partition to make it bigger in case you run out of space for apps. Init also wipes all the data in /data partition. So your existing apps in secondary rom will be gone.

xi) wipe second rom davik cache, xii) fix permissions in second rom - self explanatory

xiii) Install Zip to 2ndROM from Internal SD xiv) Install Zip to 2ndROM from External SD- self explanatory

xv) Wipe options for Second ROM can be found under Mounts and Storage - / format /secondrom_cache, format /secondrom_dalivkcache, format /secondrom_data and format /secondrom_system.

Mounting partition options for 2nd ROM can also be found there.

28) Why is "cloning 1stROM to 2ndROM" slower than "cloning 2ndROM to 1stROM"?

A. While cloning primary to secondary, it writes data.img and cache.img to internal sd card. While cloning secondary to primary, the images are written to device memory or rootfs. This is faster than writing to a mounted storage.

29) "Why can't internal SD be mounted with secondary rom whether it's sammy or aosp?"

A. It works now.

/data and /cache partitions of secondary rom resides in the internal sd. (/sdcard/.secondrom). So internal sd can not be unmounted to mount it to the PC. MTP works for internal SD too. Even though slower, that's the only option we got.

30) "After setting up Second Rom, i don't see a prompt to boot into second rom".

A. Try wiping Second Rom Cache and Dalvik.

31. "Before wiping 2ndROM data/cache, i had some free space on internal sdcard. During wipe it failed and that space has dissipated. Even after a successful wipe, the space is still lost."

A. Try (1). If it fails, try (2)

1) Delete files in /sdcard/.secondrom directory.

2) The space was occupied by lost.dir in /sdcard. Delete contents in that directory and you have the space back now.

32. "What's happening when i wipe /data and /cache of 2ndROM during the first time setup of dual boot?"

A. Two empty mountable EXT4 images - data.img and cache.img are created in /sdcard/.secondrom. While flashing zips to second rom, /data and /cache of second rom needs to be mounted in respective mmcblk. This empty .img files helps zip flashing without having the trouble to create them first.

33. "Will flashing a rom zip to second rom (when i already have dual booting) change kernel? I may lose dual boot if so."

A. NO. Flashing kernel is prevented for second rom if the zip contains a kernel.

34. "I lost dual booting after i flashed primary rom via odin". I flashed kernel again. I could see files in /sdcard/.secondrom. But no dual boot. Help"

A. Some carrier branded firmwares and such may wipe and push some apks and csc stuffs to the hidden partition used as /system of second rom. About 100 MB is used i think. After first reboot, it's never used again, but now you have lost /system of second rom even though data and cache are intact in SD.

Copy data.img and cache.img of secondrom from /sdcard/.secondrom to PC. Then modify your zip installer of your second rom to install only /system of second rom. (Edit updater-script in the zip to comment out lines that write to /data).

Now full wipe second rom /data and /cache. Format second rom /system. Flash the modified zip to second rom. Copy back and replace data.img and cache.img from your PC. Second rom should be intact now.

2. BLN Breathing

Q. What's bln breathing?

A: With BLN apps like bln control pro, we could set lights to be statically lit or blink when a notification arrives. A third effect could be achieved - breathing. Lights can follow a pattern to Fade In and Fade Out. Infinite possibilities exist for pattern since the tunables that control breathing can be set from the user space.

Q. How is breathing achieved?

A: A series of incidents using three principles: Vary LED voltage level from a Min to Max and then Max to Min, Pause between voltage changes, Supply a different voltage as next voltage defined by a voltage step.

Q. Make it more clear?

A. Let's take an example.

echo "2500 3300 70 50" > /sys/class/misc/notification/breathing_steps

echo "3300 2500 70 50" > /sys/class/misc/notification/breathing_steps

First two parameters defines star and end voltages/ min and max voltage (unit millivolts). Third parameter is the period or pause (in milliseconds) between voltage changes. Last parameter is the voltage step in millivolts.

As you notice, there's on more echo statement which reverse the voltage limits. This is because breathing is asymmetric. So commands for Fade IN (light on) and Fade OUT (light off) need to be written separately.

Some points to note:

-2550 is the minimum voltage to turn LEDs On.

-3300 is the maximum voltage that's supported by regulator.

-2500 is the minimum voltage supported by kernel as the least among valid voltage.

-Period should be echoed as milli seconds.

-Voltage step should be a multiple of 50.

Small Tutorial: Suppose you need a pattern - short, long, short breathes. Let's call this .._ When a notification arrive, it will repeat until notification times out .._ .._ .._

#First enable breathing:

echo "1" > /sys/class/misc/notification/breathing

#Reset existing pattern:

echo "reset" > /sys/class/misc/notification/breathing_steps

#Now echo as many FADE INs and FADE OUTs you need. The file will parse all these without overwriting. (If you cat the file, it may return only last echoed line. Don't worry)

echo 2600 3300 30 150 > /sys/devices/virtual/misc/notification/breathing_steps //short breathe achieved using lower period and higher voltage steps

echo 3300 2600 30 150 > /sys/devices/virtual/misc/notification/breathing_steps //fade out for short breathe by swapping voltage limits

echo 2500 3300 60 50 > /sys/devices/virtual/misc/notification/breathing_steps //long breathe achieved by increasing period and decreasing voltage step

echo 3300 2500 60 50 > /sys/devices/virtual/misc/notification/breathing_steps //fade out for longer breathe

echo 2600 3300 40 150 > /sys/devices/virtual/misc/notification/breathing_steps //another short breathe

echo 3300 2600 40 150 > /sys/devices/virtual/misc/notification/breathing_steps //fade out

echo 2500 2500 400 50 > /sys/devices/virtual/misc/notification/breathing_steps //Having same voltage limit (that too 2500 which won't turn on led) and some period means a pause between breathing cycles. This will give a relaxed effect.

Q. How can i achieve blinking?

A. Echo same voltage as min and max voltage for Fade in and Fade out effects.

echo "2500 2500 500 100" > /sys/class/misc/notification/breathing_steps

echo "3300 3300 500 100" > /sys/class/misc/notification/breathing_steps

Reducing the period to a smaller number say 100, gives you a faster blinking - a pulse effect.