Google

2012-07-20

Upgrading Android Nexus S to Jelly Bean 4.1.1

It's been quite a while since I embarked on getting my Nexus S upgrade to ICS early. I blogged that journey here. For the last 1.5 months I am carrying both my Nexus S and an iPhone 4S, and frankly I prefer using iPhone for battery life if not for anything else. My favorite activity on Nexus S is tethering my iPad Wi-Fi during my work commute. Anyway, iPhone 4S vs Android 4.x Nexus S discussion is for another day.

Today, Google released 4.1.1 for Nexus S (T-Mobile) and it's officially available if you want to download the binaries: http://android.clients.google.com/packages/ota/google_crespo/9ZGgDXDi.zip

I downloaded the zip file and renamed it to update.zip (renaming is optional)
Then connected phone to my pc and transferred the update.zip to SD Card
Powered off the phone
Pressed Power + Volume Up keys to bring the boot menu
Selected recovery
...and wait for it...

No cigar! I got the infamous red triangle with a black  exclamation mark on a green Android picture.

Apparently, one of the updates from 4.0 to 4.0.4 changed the boot files I had for custom booting before.

Interestingly, I found out that I was able to bypass this screen if I keep on trying to press Power + Volume UP key a couple of times (usually the 3rd was the charm).

I then got into the recovery mode where I was presented with the option I was looking for:
"apply update from /sdcard" (to select the option use Power button. Volume up/down to go up/down)

After selecting update.zip, install started and ...



-- Install /sdcard ...
Finding update package...
Opening update package...
Verifying update package...
Installing update...
Verifying current system...
assert failed: apply_patch_space(16570800)
E:Error in /tmp/sideload/package.zip
(Status 7)
Installation aborted.

failed :(

At this point, I thought I might be low on sdcard space and perhaps that was causing this issue. I did some clean up and free space jumped up from 700MB to 5GB. Unfortunately, the next attempt did not result in anything different.

So tried a couple of other options, all failed:

  • Wiped cache partition... 
  • Wiped cache partition + Wiped data/factory reset (which means you lose everything on the phone!)...
  • Wiped SDCard...


At this point, I started looking at Nexus S XDA forums. People suggested using ClockWorkMod to patch. I used it before, it's a great tool but instead I chose to use this trick to get official OTA update from Google. Steps (I changed the order a bit) are as follows:


  1. System settings
  2. Apps > All (If "all" is not displayed, pull the top bar that reads "running" to the left)
  3. Google-Service-Framework
  4. Force stop
  5. Clear Data
  6. Go to Homescreen
  7. System settings
  8. About Phone
  9. System updates (last time of update checking should be before 1970)
  10. Check now
  11. if you do not get the update, go to step 1.


After the second try I got offered the update. Rest, as they say, is history:





I am dying to try this trick, which is clearly quite harmless, on my wife's nexus S but she explicitly prohibited me from installing Jelly Bean / 4.1.1 until I confirm that it had been working without any hiccups on my phone for about a week :)

Now it's time check out  Highlights and read what's new?

2012-07-07

New Features in PowerShell 3.0

MS PowerShell Team blogged about some of the upcoming features in PowerShell 3.0 here.

I think there are some terrific improvements in the syntax that will make PowerShell more consistent or less unpredictable, if you prefer.

In my tests, some of the features are not yet fully working on Windows 7 but once the final release is out, current issues should go away.

Improved Custom PSObject Creation
One of the cool changes is about creating a custom object. It was already improved in Version 2.0 and now it got even better. Here is a common way of creating one:

Powershell 1.0

$MyCustomObject = New Object PSObject
$MyCustomObject | add-member NoteProperty name "Adil"
$MyCustomObject | add-member NoteProperty lastname "Hindistan"

PowerShell 2.0
$MyCustomObject = new-object PSObject -Property @{name="Adil";lastname="Hindistan"}

PowerShell 3.0
$MyCustomObject = [PsCustomObject]@{name="Adil";lastname="Hindistan"}

So basically you are now simply casting 'PsCustomObject' type like any other.

Local Variables with $using
Another feature I liked seeing is about using local variables. I had written a function a while ago to remove an application given its uninstall string. I needed that to remove unwanted VNC installations from an environment.
It goes something like this:
function remove-app {

    ## E.g. $vnc |%{ remove-app $_ '"C:\Program Files\RealVNC\VNC4\unins000.exe" /SILENT' }, where $vnc holds list of machines

    param ($computer="$env:ComputerName",
       [string]$UninstallString   ## Use QuietUninstallString when possible
        )

    $result="Encountered an error, sorry!"
 if (test-connection $computer -count 1) {
     "Pinging $computer successful"
     
     if ($UninstallString) {

          ## we have to use param and argumentlist in the script block to pass variable to the remote computers

      $result = invoke-command -computer $computer { param($UninstallString);&cmd /c $UninstallString} -ArgumentList $UninstallString

          ## New in PowerShell 3.0:

          ## $result = invoke-command -computer $computer { &cmd /c $using:$UninstallString}

     "...Done"

    }

 } else { "Pinging $computer failed"}

    $result

}

You see that invoke-command line over there? I had to use $UninstallString 3 times in that command to pass it to the remove machine. This got much simpler with PowerShell 3.0 with the addition of "$using:" :

$result = invoke-command -computer $computer { &cmd /c $using:$UninstallString}

By the way, I used that function together with another here that returned a list of uninstall strings from the registry:


function get-appsreg {

    param ($computer="$env:ComputerName",

       [string]$product

        )

    $result="Encountered an error, sorry!"

 if (test-connection $computer -count 1) {

        if ($product) {

            ## we have to use param and argumentlist in the script block to pass variable to the remote computers

   $result = invoke-command -computer $computer { param($product);get-itemproperty hklm:\software\microsoft\windows\currentversion\uninstall\* |?{$_.DisplayName -match $product}|Select DisplayName,UninstallString,QuietUninstallString } -ArgumentList $product

        } else {   

   $result = invoke-command -computer $computer { get-itemproperty hklm:\software\microsoft\windows\currentversion\uninstall\*,hklm:\software\wow6432node\microsoft\windows\currentversion\uninstall\* |Select DisplayName,UninstallString,QuietUninstallString } -erroraction silentlycontinue
       }
 }
    $result
}

Count and Length
With PowerShell 3.0 "count" and "length" properties are also becoming universal. I.e. even if an object does not have these properties currently, you will be able to use them in the new version.

Indexing
Similarly, every object is getting 'indexing'. So, using the custom object example above, it will be possible to use the following syntax:

$MyCustomObject[0]   ## returns the object itself. Other indexes return nothing

It does not look useful really but it does improve the consistency!