Wednesday, January 18, 2012

CyanogenMod and Android Debug Bridge

After many tries, I finally got CyanogenMod (7.2 PlayfulGod 20110913 using ClockWorkMod 3.0.2.8) on my (old) Huawei Ascend using these instructions and the "600" CM ROM from these handy links. Note that you need to install both the CM ROM zip and the gapps zip. And you must be rooted and have ClockWorkMod installed first. It is certainly a huge improvement over stock. It's as fast as what you get by removing all the bloatware plus there are a ton of extra customization options that aren't in the regular Android release. I'm not going to go into all the details, but I will say that I found being familiar with Android Debug Bridge (adb) to be extremely helpful. Most (if not all) "mod" packages include both adb and fastboot. The adb tool can be used to put files on the phone, install applications (using the .apk file rather than from Market), and execute arbitrary commands on the phone using the shell functionality of adb. I found it educational to run the shell and poke around at the filesystem (ls and cd work).

For reference:

  • VOLUME UP + SEND/CALL + POWER: boots the Ascend into "recovery" mode
  • VOLUME DOWN + HANG UP + POWER: boots the Ascend into "fastboot" mode (only "Huawei" screen will display---remove battery to turn phone off)

Sunday, January 8, 2012

How I Rooted my Samsung Galaxy Nexus

After seeing my battery in the "red" barely more than 24 hours after a full charge, I decided it was time to take action. I had previously rooted two phones and managed to significantly extend the battery life from 1-2 days to 5+ days. So, last night I sat down to root my Galaxy Nexus. Rooting the Nexus is a bit different from other phones I had rooted. Instead of running a special app (like Gingerbreak), the idea is to unlock the bootloader, then boot to a special image that gives you read/write access to /system, and install the su binary and Superuser app.

I used scary alien's HowTo as my guide. The first thing I did was to see whether I could run the adb utility. I downloaded the sdk-tools.zip package, and made the linux versions of the tools executable. But, when I ran ./adb devices, I got "???????? no permissions". I found that I could make it work with "sudo", but searched for and found a better way---give myself USB permissions to the device. Information can be found under "Configuring USB Access" in the Initializing a Build Environment document. (After editing "<username>",) I copied the two "Galaxy Nexus" lines to /etc/udev/rules.d/51-android.rules (new file), disconnected and reconnected my phone, and was then able to detect my device with ./adb devices.

The next step for me was to unlock the bootloader. This was as easy as described by the HowTo guide. I booted my phone into "fastboot" mode by powering down my phone, then holding down the VOLUME UP, VOLUME DOWN, and POWER buttons. Once I was in "fastboot", I confirmed that the fastboot utility could "see" my device, then issued the ./fastboot oem unlock command from my computer. At the bottom of the phone's screen I could see that the bootloader had been unlocked. From there I had a decision to make---what method to use? After realizing that the essential file for the "manual" method was missing, I decided on the ClockworkMod method.

I downloaded the su.zip and recovery-clockwork-5.5.0.2-maguro.img, then soft-booted into the ClockworkMod: ./fastboot boot recovery-clockwork-5.5.0.2-maguro.img. I followed the instructions to ensure that /sdcard was mounted, but kept getting the error message: "E:can't mount /sdcard/". I read that restarting might fix the problem, so I opted to reboot ClockworkMod (under "advanced" menu). Bad idea. I ended-up with my phone in a frozen state---a green robot on its back with its chest open with a red triangle with exclamation point floating above. I had to remove the battery and leave it out for appx. 60 seconds (until the screen went blank) before I could then restart the phone.

The restart took a while. As the HowTo describes, it goes through the startup sequence, then restarts and goes through the startup sequence again. When it was done, it led me through the new phone tutorial I got when I first turned-on the device. All my settings had been reset (as expected). After going through the tutorial, I tried the ClockworkMod method again. This time I did not get the /sdcard errors and the su.zip install appeared successful. But, when I restarted back into "normal" mode, I couldn't get root privileges.

My phone otherwise seemed to be fine, so I moved on to the Superboot method. After downloading the superboot package and unzipping it, I booted my phone into "fastboot" mode, checked that the fastboot utility recognized my phone, and ran install-superboot-linux.sh (from my computer). My phone restarted and I checked that I had root privileges by trying to change settings via the Autostarts app. Yes! It worked!

I used Autostarts to turn off a ton of automatic startups, being careful to avoid things like "Contacts", "Phone", "Android System", "Calendar Storage", "Download Manager", "Media Storage", "SIM Toolkit", "System UI", "Google One Time Init" and "Google Services Framework". However, I may have turned-off too many services since I later lost my ability to get root (the error message was something like "Superuser has stopped running"). But, a fix wasn't difficult. From "Settings", I went to the "Apps" menu, selected the Superuser app, cleared its data, "Force Close"d, then restarted Superuser. After that, I was able to get root privileges via the Superuser app as usual.

P.S. In addition to modifying auto-start settings, I also removed a few apps using Titanium Backup: Music, MusicFX, Videos, YouTube, and Voice Search.