Unlock bootloader
With a locked bootloader, one cannot install custom roms.To gain power over bootloader one should unlock it.
Now this is the most simple and easy way to get ye bootloader by following small simple steps.
Download Files for Fastboot
Extract the file to a new folder naming say Unlock.(Do it neatly as you wont get confused while entering into CMD).
Go to unlockbootloader.sonyericsson.com (We will do the unlocking in the official way).
Read the instructions carefully and click Continue/Proceed whatever they ask,note down ye IMEI (The place where the website ask to paste it,enter in exactly first 14 digits,not 15digits) and after submitting ye Name, IMEI and mail click Submit and note down the code they produce(Copy that in a notepad).
Enter in fastboot mode(Press Volume up and connect USB cable simultaneously and blue light should come up,otherwise something has gone wrong).
Install the drivers for your device from the drivers folder
Go to fastboot directory and Ctrl+Shift+Right Click (or on Windows 7 open a CMD shell end go into the fastboot directory)
Type in
fastboot.exe -i 0x0fce getvar version
and hit enter
Type in
fastboot.exe -i 0x0fce oem unlock 0x<your_code>
(use directly by your code that you have already copied in notepad) and hit Enter
You are done. When you start your Phone you will have fresh factory reset Android.
Note: Official method says about installing latest Android SDK package which is of more than 60MB and this method will do everything within 20MB via downloading the file which I mentioned at the beginning
Rooting
In order to root do the following.
Prerequisites:
1.Flashtool
2.Kernel
3.Rooting Toolkit
4.Go to settings > Security > Mark ”Unknown sources”
5.Settings > Developer options > Mark USB debugging
6.Kernal
A. Trying to flash the Kernel(4.1.A.0.562) with the help of Flashtool, download and install the software. Copy the FTF file and go to the Flashtool folder you extracted. Paste it inside the ‘firmware’ folder.
B. Launch the software and click the ‘Flash’ button (the button with the lightning icon.). Select the ‘Flashmode’ option and click OK.
1.Once you are done with installing new kernel, restart your device. Rooting toolkit will let you root your device (make sure you are done with prerequisites 4 and 5).
2.Rooting your mobile via Rooting toolkit is very simple. Click on the .bat file and follow the on-screen instructions. Your mobile may restart more than twice, never mind it. Once you see “You are done” in the command mode, disconnect your device and make sure you see Superuser icon in menu.
3.Step 6 in prerequisites is purely optional and if you want to update your kernel after rooting you can repeat step 1 with 4.1.B.0.587 Kernel.
Summary
As there is no direct way to root your ICS built Smartphone (xperia ray) ,this is a different approach in which flashing a kernel which enables us to root mobile in a single shot. That is we flash 4.1.A.0.562 kernel, do necessary steps in rooting and then revert it to latest kernel by flashing 4.1.B.0.587.At the end of the day we will have an ICS built Ray with latest kernel inside with SU permission.
Unroot
If you want to unroot your mobile, then after flashing kernel with 4.1.A.0.562 download this and run the .bat file after extracting it to some location. This script will remove the SU files and make it unrooted so that you could bring back the guarantee thing.
Source:
1,2
NOTE: I'm not responsible for any of your act. Do this at your own RISK