Saturday, February 16, 2013

How to access USB debugging setting in Android 4.2.2

My Nexus 4 was upgraded to 4.2.2 last night. This morning, I decided to turn on USB debugging. But, I couldn't find it after searching all of the settings. Apparently, there is a good reason why: it's not there! In order to have "Developer options" added to the "Settings" menu, I had to "About phone" and touch "Build number" at the bottom seven times. After a few touches, I saw a countdown message (it was something like "3 more before you're a developer"). After "becoming a developer", I found "Developer options" 2nd-to-last in the "Settings" menu, right before "About phone".

After turning on "USB debugging", adb recognized my phone:

List of devices attached 
00839b0e89da57d7        offline
But, I can't use adb yet because of a new security feature in 4.2.2. Time to upgrade my developer kit...

Wednesday, August 22, 2012

How to install android debug bridge (adb)

Google is making it a challenge to use basic Android tools. The swiss-army knife of Android tinkering is adb. Where do you find it? Not in the SDK. If you download-and-install the r20 SDK, you'll find a note in the tools directory:

The adb tool has moved to platform-tools/

If you don't see this directory in your SDK,
launch the SDK and AVD Manager (execute the android tool)
and install "Android SDK Platform-tools"
I couldn't find anything named "SDK and AVD Manager" in the SDK, but I found the android tool in the tools directory. I even found a suggestion for how to get platform-tools without opening a UI. But...
jason@pinot:~/android/sdk-r20$ ./tools/android update sdk --no-ui
./tools/android: 1: ./tools/android: java: not found
./tools/android: 1: ./tools/android: java: not found
./tools/android: 110: exec: java: not found
After searching around the Ubuntu packages site, I realized I needed to:
sudo apt-get install openjdk-7-jre
Then I reran the android update command (above). Yes, I got the platform-tools (including adb), but I'm also getting tons of other crap I don't want. Maybe running ./tools/android without any arguments would have been better...

Now, the moment of truth:

jason@pinot:~/android/sdk-r20$ ./platform-tools/adb 
./platform-tools/adb: error while loading shared libraries: cannot open shared object file: No such file or directory
You've got to be kidding me.
jason@pinot:~/android/sdk-r20$ sudo apt-get install libncurses5
libncurses5 is already the newest version.
Ah, adb is a 32-bit binary. Do 32-bit Linux installs even exist any more? Anyway,
sudo apt-get install lib32ncurses5 lib32stdc++6
Phew! What a workout! Finally, the reward:
jason@pinot:~/android/sdk-r20$ ./platform-tools/adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
0146B5BB04002013 device
Ah, what a lovely device number.

Saturday, August 11, 2012

Android GSM Reception Icons

Since I got my Galaxy Nexus and hooked it up to T-Mobile service, I've been wondering about the abbreviations next to the mobile signal reception strength icon. Everyone knows that more bars is good, but what about "E" versus "H"? After having very poor download speeds with an "E" status, I finally did some searching to find out.

The abbreviations refer to the technology of the network you are connected to:

  • H - HSPA - this is the fastest connection, with up to 14 Mbit/s download speeds (or up to 84 Mbit/s for HSPA+)
  • 3G - most likely refers to W-CDMA, the predecessor to HSPA, with speeds up to 2 Mbit/s
  • E - EDGE - a predecessor to 3G networks, with speeds up to 384 kbit/s (non-Enhanced)
So, even a week "H" connection can be much better than a strong "E" connection. Keep that in mind the next time you are checking reception!

Thursday, April 19, 2012

Easy Galaxy Nexus Root

I recently discovered an easy way to root the Galaxy Nexus. I just got my wife a GN and needed to root it so that she'd have decent battery life. While scanning posts I had used for my previous GN rooting, I noticed a new, "simple" approach which did not require unlocking the bootloader. As noted, the major caveat is that this only works with ICS 4.0.2 or earlier. Since my wife's phone came with 4.0.4, I decided to flash it back to 4.0.2 before proceeding. See the nexus factory images page and my post on flashing to stock. I used the 4.0.2 build (ICL53F). After flashing, I re-locked the bootloader by re-entering fastboot mode (power off, then hold VOLUME UP + VOLUME DOWN while pressing POWER until you feel the phone vibrate) and issuing fastboot oem lock from my computer.

Once you are on 4.0.2, download the simple root package referenced at the bottom of the Android Forums post. Don't forget to turn on USB Debugging on your phone (under "Developer options" in Settings). Before running the root script, I checked that adb was working properly by running adb devices and observing a (16-digit hex) device id. See my original Nexus rooting post if you get nothing or lots of question marks. I found that rooting was as simple as running the script that came with the "simple" package. Kudos to scary alien for making it so easy. Leave me a comment if it doesn't work for you---I'll try to help.

Tuesday, February 7, 2012

Flashing the Galaxy Nexus to Stock

After rooting my Galaxy Nexus and removing some "system" apps, I learned that once you do that, you can no longer take system updates. Also, if you install an alternative "recovery" ROM (like ClockWorkMod), my understanding is that you cannot take updates. Yet, the phone will still prompt you for system updates, attempt to install them, and then fail upon reboot, leaving you with what seems to be a dead phone (you'll see a robot on it's back with chest open and a floating red exclamation point within a triangle). Not exactly what I'd call a great user experience.

My primary goal with rooting was to extend battery life and I believe most of my battery savings came from disabling services using the Autostarts app. IIUC, using the Autostarts app does not disable the ability to take updates. So, I decided to flash my GN back to stock so that I could once again take system updates and get rid of the annoying update reminders.

To get back to stock, I grabbed the 4.0.1 (ITL41D) yakju package from the factory images page (since I have a GSM Nexus) and unzipped it.

Note that I'm running Linux---I would not recommend trying this unless you are also running Linux and are generally familiar with the Linux command line. I would also recommend that you have adb and fastboot installed in a location that is part of your $PATH. fastboot is necessary; adb will help make sure you can access your phone.

After unpacking, I checked whether I could access my phone:

$ adb devices
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached 
0146B5BB04002013        device
So far, so good. If you don't get any devices or get "???????????", see my post on rooting the GN. Next, I shut down my phone, then booted into "fastboot" mode by holding VOLUME UP and VOLUME DOWN buttons, then pressing the POWER button. Fastboot mode shows a large green robot with his chest open. It also says "Fastboot mode" in small print toward the bottom. Next, checked that I could access the phone:
$ fastboot devices
0146B5BB04002013        fastboot
Finally, I ran the script from the 4.0.1 stock package. Well, actually, I copied the commands from one-by-one. The first two "flash" commands went quickly. The last took a while as it had to copy and install the 181M image. I watched as my phone finished installing then went through its boot sequence a twice. Finally, I got the new user tutorial. My phone is back to 4.0.1 stock. Yeah!

Note: I previously tried using the 4.0.2 stock image, but found that I wasn't able to root my phone with that image.

Note: After rooting and turning off many services via Autostarts, I was successfully able to apply a system update (ITL41F) to my phone.

Note: I successfully used the manual method to root my phone this time.

Wednesday, January 18, 2012

CyanogenMod and Android Debug Bridge

After many tries, I finally got CyanogenMod (7.2 PlayfulGod 20110913 using ClockWorkMod 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 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 and recovery-clockwork-, then soft-booted into the ClockworkMod: ./fastboot boot recovery-clockwork- 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 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 (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.