Sunday, October 2, 2011

WT..! Where's my recovery? ;)

Now, the title explains it all! You have taken great pains and care to put a nice and warm recovery into the recovery partition only to reboot your phone and find it missing! :)

That's the feeling that rises out of this situation! Fret not! Not your mistake. That's how Android boot process works!

It took me some digging to find this out and overcome this feeling I mentioned! :) So here goes!

As part of the boot process and init, android runs a script that erases any custom bootloader and replaces it with Google, not much helpful recovery (or should I even call a scary, exclamated picture, a recovery?! :))


The script being at /system/etc/install-recovery.sh
and the patch at /system/recovery-from-boot.p

Now that you're God, nothing prevents you from killing these two little mortals.
Install ES file manager, an open source, root enabled file manager from the market and delete these two files and your reign is now safe! or you could run this zip from the recovery to do this deletion for you.

Being a rooted phone, you can henceforth install the ClockWorkMod recovery from Android market itself. It's called ROM Manager. And from within it, you can flash the recovery whenever you need. You can explore ROM manager to find more useful tools (rom installation, fixing file permissions, flashing any other versions of the recovery, etc.)

Now why not install CyanogenMod and have some fun!? huh?

3. Install the super user binary

After you are done with

1. Unlocking the bootloader
2. Flashing a custom Recovery into Nexus S,
follows the final step in the rooting process!

1. Download super-user app (a zip file) from my dropbox (v2.3.6.1). This's just a backup, in case you can't find it's latest version online.

2. Move it to the root of the SD card

3. Reboot the phone into the recovery, by shutting down and turning on with Vol Down + Power button.

4. On boot screen, select recovery with vol down and confirm with power button.

5. Once into the recovery, select 'Install zip from SD card'.
(Remember, the only button you can use are vol up/down and power buttons.)

6. Select the super-user zip file (su-2.3.6.1-ef-signed, in my case) and confirm installation.

Kudos! You've successfully rooted you Nexus S! Give yourself a tap on your back! :)

Into your phone, you will find the Super User app in your Appdrawer (for your use) and the super user binary will be in the path of your device (for other apps requiring root permissions to use)

Now for the tiny glitch - loss of custom recovery after reboot!




Monday, September 19, 2011

Numbered buffers in Vi

Been so long since the last post on Vi! Now time for another post! especially after my colleagues had trouble with named and numbered buffers!

If you haven't already taken a look at the earlier posts on Vi, here's what you need!

Named buffers are already discussed. It's now time for the numbered ones. I haven't  elucidated on the numbered ones.. so here goes!

Unlike named buffers, in numbered ones you can't decide, into which of the numbered (1-9) buffers your text goes. Because it's done automatically. When you delete or yank(copy) text without mentioning the named buffers, it automatically gets pushed into the 1st buffer referred by 1. So the recent buffer is always 1.

When another operation of yanking or deleting follows at a later time, whatever was already in 1, goes to 2 and the most recent one gets to 1. More like a stack!

Good! Now what if whatever was in 1 has gone down to 9... after 9 successive cuts/copies?! The 10th ie the recent most copy will move to 1 as said and whatever was in 9 gets lost, since 8 has now moved over to 9! Now that end is a FIFO!

Why do I need something over which I don't have control of! "What use?" you shall ask?! Now it's very much useful because if you happen to need your 2nd to recent cut/copied text... (previous to the recent cut)

Simple!

"2p

Done! third?!

"3p

and down to 9! Happy coding! or rather editing (who says vi is for coding only ;) )! 

2. Flashing a Custom Recovery into Nexus S

A typical Android device contains a few partition, the most important being
  1. boot
  2. recovery
  3. system
  4. cache
  5. userdata
The recovery partition can be flashed with a .img file. The basic recovery that comes with stock android has nothing more than the android mascot image with an exclamation symbol!

Replacing this with powerful recoveries like Amun-Ra or Clockwork Mod(CWM) gives you opportunities beyond imagination to play with your device!

The procedure mentioned below uses CWM. You can obtain it for free from the official site. Just get the latest version for 'crespa' the code name of Nexus S.

Flashing custom recovery from within Android requires the phone to be rooted and it's no more different and installing an app from the Android market itself. You could search and download it off Google Android market and follow the simple UI provided.

Although since now, we consider the phone out-of-the-box unrooted, it requires the phone to be in fastboot mode as mentioned in the previous post. (Unlocking the bootloader)

Once in fastboot mode, run the following command on your desktop's terminal.
 
fastboot flash recovery path_to_recovery

That should do the magic. Once done, you can scroll down to the 'recovery mode' in the bootloader menu using the volume button and selecting it with the power button.

Voila! There's you CWM recovery.
 
btw fastboot reboot on your terminal will also remote reboot your phone just like the 
reboot on your bootloader menu.




Just a word of caution: This recovery isn't going to remain here forever. After a complete reboot, this recovery will be lost due to an android-script that runs at boot time, which will replace the stock recovery. A couple of system files will have to be deleted to prevent that. That can be achieved after rooting the device.








Tuesday, September 13, 2011

Google Bookmarks in chrome

If you are like me, using a hell lotta bookmarks and use the ALL POWERFUL Google bookmarks (the same one Google toolbar uses in firefox, ie etc), then you probably hate Google's move to Google docs for chrome's bookmark sync. Sync could be good, but I can't lose my old ones at Google bookmarks.

Now, you want to use the super-chrome's super features :) and toolbar of firefox which sadly is not available with chrome. Here's the solution to all!


To Google bookmark a page in Chrome

To bookmark the current page, I click myBookmarks button. (You can see in the screenshot that I file it under Send to, but you can put it anywhere.) I optionally edit the title and add tags to make it easy to find later, and click Add bookmark.
At this point, my Google bookmark is saved and I can access it later from anywhere.

To return to a Google bookmarked page in Chrome

To find a Google bookmark page, I use search, naturally. In the address bar (a.k.a. the omnibox), I type gb (for Google Bookmark), press Tab orSpace, type search word(s) that match the bookmark name or tags, and pressEnter. On the results page, I click the bookmark I wanted.

To add these customizations to Google Chrome

To create the Bookmarks button, drag this bookmarklet to the Google Chrome bookmarks bar: Google Bookmark (or do the same thing from Google’s help page Bookmarks: Using Google Bookmarks, which is where I got it).
You can, of course, add the bookmarklet to a folder, as I did.
To add Google Bookmark search to the Chrome address bar, right-click in the address bar, choose Edit search engines…, click Add, fill out the form as follows, and click OK:
Name:
Google Bookmarks
Keyword:
gb
URL:
http://google.com/bookmarks/find?&q=%s
(In the Search Engines window there is also an option to make this the default search, if you wish.)

Rooting the Nexus!

Rooting:

Rooting is a process that allows users of mobile phones and other devices running the Android operating system to attain privileged control (known as "root access") within Android's Linux subsystem with the goal of overcoming limitations that carriers and manufacturers put on some devices. It is analogous to jailbreaking on devices running the Apple iOS operating system.

That's how Wikipedia defines it! In short, you become the admin user a.k.a God! :) and mess up things the way you love!

I understand that the word Jailbreak sounds more like an illegal activity than 'Rooting' does. And actually their intentions are similar to their phonetics and so are the companies' views on them! Apple wants to prevent Jailbreaking on their devices while Google support rooting theirs! :)

Google is in fact urging it's partners, the hardware manufacturers to impose less restriction on the hardware/software and encouraging them to let the users decide how they want their phones. Although Android is now running more than just phones. For instance Android now runs Barnes & Nobles' e-Reader 'Nook', Sony's new Z-series Music Player, just to mention a few.

On that front, HTC has now officially released instructions along with the required tools, on their websites, to help customers unlock their phones.

The Nexus S comes with an awesome bootloader from Google that makes unlocking and rooting the devices the easiest! Easier than on any other phone.

Rooting the phone requires installation of a super user application on the device. Now the super user tool comes in two pieces - the binary which does the rooting and then the app that lives in the App drawer of the phones that gives and GUI to manage grant and revocation of SU rights to any other app as and when required.

The following is the breakup of the steps and each step is explained in detail in separate posts. This is to enable you to understand what you're upto and hence not again read the lines "Don't do this if you don't know what you're doing"!!!
  1. Unlock the bootloader
  2. Install custom Recovery
  3. Install the super user binary (& app).

1. Unlocking the Bootloader

The bootloader of the Nexus S is locked initially. You'll have to unlock it using a tool called fastboot. Warning: Since unlocking the bootloader and rooting the phones gives access to all the private data, by circumventing the Android's security model based on Unix, all your phone's data and data on the internal SD card will be erased for security reasons. Hence take a backup of the important data into your computer before you proceed.


You should have Android SDK installed in your machine. For this tutorial, I use a mac. Post Android SDK installation, download and place fastboot (which is just a single binary file) in your path or if you're comfortable, run it from any directory, using a terminal.

I would prefer you to place fastboot in the 'tools' directory of your android SDK installation.

Step 1. Reboot your phone into the bootloader by shutting it down and then turning it on by holding the volume up button + power button and you should see this.

Step 2. When on the bootloader screen, connect your phone to PC/Mac and run the command

fastboot devices
which should give an output similar to

List of devices attached 
HTXXXXXXXXXX	device


Step 3. Once, it's confirmed that your device is recognizable by fastboot, run the following command to unlock the bootloader. 

fastboot oem unlock
 
Read the warning on the phone and accept it.  That's it! Now you have an unlocked phone or bootloader, perhaps! :D This can be confirmed by seeing noting the last line on the first paragraph of the bootloader screen that reads

LOCK STATE - UNLOCKED

Next you shall run  

fastboot reboot
reboot your phone. Another hint to know that your bootloader is unlocked is to reboot your phone into the os and you can notice that beneath the Google logo appearing while it boots, there should appear an unlocked-lock icon!

It should be no surprise that you can run

fastboot oem lock
to lock the bootloader if you wish!