As yet, there's no working jailbreak available for iPhone 4 running on iOS 4.0.2 -- but it's currently possible to jailbreak iPhone 4 4.0.1.
If - for whatever reason - you upgraded your iPhone 4 to version 4.0.2 and you now want it jailbroken, then you might want to first downgrade to the previous iOS firmware.
Here's how you do that:
Needless to say, proceed with caution.
DISCLAIMER: TechPinas can NOT be held responsible for any damage that may be caused by this downgrade procedure. Please consult several downgrade guides online before proceeding. Downgrade your iPhone 4 to 4.0.1 at your own risk.
*** This downgrade procedure will only work for iDevices with SHSH blobs or ECID SHSH saved on Cydia for the 3.0.1 firmware. If you don't have the necessary SHSH files saved, I'm sorry but you can't downgrade your device. As such, if you're downgrading because you intend to jailbreak your device, I would suggest that you just wait for a working 4.0.2 jailbreak to be released.
1. Download iOS 4.0.1 here.
2. Edit the Hosts file
a.) Under Accessories, right click on Notepad and choose Run as Administrator. Just keep Notepad open.
b.) Navigate to C:/Windows/System32/drivers/etc and look for Hosts file
c.) Open Hosts file by dragging it to Notepad
d.) Add this line below the last line of Hosts file content:
e.) Save new Hosts file
Using Mac OS X
a.) Navigate to "/etc/" directory by clicking on "Go –> Go to Folder" from Finder.
b.) Open Hosts file using TextEdit
c.) Add "18.104.22.168 gs.apple.com" at the bottom of the document and save new Hosts file.
4. Select your iPhone 4 in iTunes.
5. Press the power and home buttons of your iPhone 4 for 10 seconds. Release the power button but keep pressing the home button until iTunes recognizes that the iPhone is trying to enter DFU Mode. To know if you're already in DFU mode, check the iPhone screen. Must be blank or black.
6. Once your iPhone 4 is in DFU mode, press and hold down Option Key in OS X or Shift Key in Windows, then click Restore button.
7. iTunes will then prompt you to select the location of the 4.0.1 firmware file that you downloaded earlier. Select the ipsw file and click "Open". Let iTunes do its thing. Now at some point during the installation process, iTunes may show you 1015, 1013 or 1011 error. This is normal, just ignore the error message.
8. Now exit recovery mode using Recboot (download the software here and install it on your computer) and reboot your iPhone 4.
There you go. I hope you find this helpful.