Friday, February 15, 2013

Nexus 4 Android Development Guides

I will first start off by having a dedicated post for all Nexus 4 related custom development or rather any software related topics, issues, guides, etc. I will update it on a regular basis again when I have the chance.

So here I go.

PLEASE NOTE: I AM NOT RESPONSIBLE FOR WHATEVER HAPPENS TO YOUR DEVICE. PLEASE DO SO AT YOUR OWN RISK

Android Customization/Development Guides:


ENABLING LTE ON YOUR NEXUS 4:

If you are on 4.2.2, please download the Radio/Baseband for 4.2.1 in order to get the following working. Otherwise if you are on the 4.2.2 Radio/Baseband it will not work.

You can find the link to the 4.2.1 Radio Baseband Here

Ensure you have a LTE data plan + an activated LTE micro sim before you continue.

1. Open up dialer
2. Enter *#*#4636#*#*
3. Go to Phone Information
4. Scroll down till you see WDCDMA preferred aka a drop down box
5. Select LTE/GSM/CDMA auto (PRL)
6. Go back and you should have LTE enabled.
7. You can recognize this by seeing a "4G" symbol at the top.

Here are some screen caps:





HOW TO PERMANENTLY HAVE LTE ENABLED WITHOUT REBOOTING THE PHONE
*Special Thanks to plisk3n from RFD*

1. Make sure your phone is rooted
2. Download your build.prop file (in CMD prompt type this "adb pull /system/build.prop")
3. Edit your build.prop file (use a *nix compatible text editor if you're in Windows, I recommend Notepad2) and add these lines to the end:

telephony.lteOnGsmDevice=1
ro.telephony.default_network=9
ro.ril.def.preferred.network=9

4. Push the file back to /system (adb push build.prop /system/build.prop)

After you've done that, perform a FACTORY reset. Don't forget to add the APN settings back if you're on Rogers or Bell or whatever.




HOW TO GET LTE TETHERING HOTSPOT WORKING *Special Thanks to plisk3n from RFD*

Root Access is Required as usual FYI

1. Save the following as UNIX text file (I called mine lte-tether.sh)

iptables -A bw_FORWARD -i !lo+
iptables -A natctrl_FORWARD -j RETURN -i rmnet+ -o wlan0 -m state --state RELATED,ESTABLISHED
iptables -A natctrl_FORWARD -j DROP -i wlan0 -o rmnet+ -m state --state INVALID
iptables -A natctrl_FORWARD -j RETURN -i wlan0 -o rmnet+
iptables -A natctrl_FORWARD -j DROP
iptables -A natctrl_nat_POSTROUTING -t nat -o rmnet+ -j MASQUERADE


2. Copy this file to your phone's root directory or where ever you want. Install / Load up Root Browser Lite(or any other file manager program).. 

3. Setup your LTE hotspot..

4. Browse to your file using Root Browser, and make sure the permissions are set to EXECUTE (Unix 644 works for me).. once you do that.. you need to click on that file and choose execute. You're good!
You can take it one step further by making a 'command' shortcut as a widget to this file. I use Widgetsoid for that.. GOOD LUCK!

ENABLING DEVELOPER OPTIONS ON ANDROID 4.2 and UP

a) Go to Settings
b) Click on About Phone
c) Then scroll down to Build Number
d) Tap on Build Number 7 times until you unlock the Developer Options. It will notify you when you have successfully done so.


UNLOCKING THE NEXUS 4's BOOTLOADER

a) This is the same as always with the Galaxy Nexus
b) Make sure adb/fastboot files are set up + drivers 
c) If using the Command Prompt method, power your phone into bootloader mode: VOL DOWN + POWER BUTTON. Make sure to press it really hard. 
d) If not with the normal method to turn the phone on into bootloader mode, open up Command Prompt and type in adb devices to ensure your phone is recognized via the serial #.
e) Then type in adb reboot-bootloader to boot into the bootloader mode
f) Then type in fastboot devices to ensure that the phone is recognized in fastboot mode.
g) If all a go, then type in fastboot oem-unlock and follow the prompts to unlock the bootloader

*Your bootloader is now officially unlocked. Remember it is key to unlock the bootloader from the get go as soon as you receive your Nexus 4. This way, you don't lose any files.*

ROOTING THE NEXUS 4

1) Wug's Toolkit: http://www.wugfresh.com/
His method is pretty straight forward. It also unlocks your bootloader as well, etc. Highly recommended for new users. 

2) The Good Ol Fashion Method:

VIDEO FOR ROOTING THE NEXUS 4 ON STOCK 4.2.2. Its the same procedure normally BUT with the exception of new ADB files + new USB debugging security feature built into 4.2.2

Enjoy :) 

a) Again ensuring your drivers, adb and fastboot files are set up properly, open up Command Prompt
b) Download the appropriate Recovery Image:

CWM
Regular: http://download2.clockworkmod.com/recoveries/recovery-clockwork-6.0.2.3-mako.img
Touch: http://download2.clockworkmod.com/recoveries/recovery-clockwork-touch-6.0.2.3-mako.img

TWRP
http://teamw.in/project/twrp2/129 

c) Download SuperSu v1.04.zip from here :http://download.chainfire.eu/310/SuperSU/UPDATE-SuperSU-v1.04.zip?retrieve_file=1

d) Assuming you have an unlocked bootloader you may proceed. If not please read #2 under "Unlocking the bootloader"

e) Now go ahead and flash the CWM or TWRP image by typing fastboot flash recovery *insert recovery file name.img*

fa) Type in fastboot erase cache

fb) Type in fastboot reboot-bootloader
*NOTE TO TEST OUT RECOVERY - Use the vol keys while in Bootloader mode and select Recovery. Then press the Power button to select Recovery Mode. If you boot either into CWM or TWRP then you're good to go! 

g) Let the device boot up and afterwards, transfer the SuperSu vXX.zip into your internal storage of your Nexus 4. Don't place it into any sub directory for convenience purposes.

h) Reboot into ClockWorkdMod or TWRP Recovery by booting into the fastboot bootloader screen.

i) Use the volume down key to navigate until you see Recovery. Press the power button to select. *ENSURING IT WORKS AS PER the highlighted note under Step fb.*

j) Once you are in the recovery, use the volume up/down keys to navigate and select "Install zip from SD card"

k) Then select "Choose zip from SD card"

la) Then scroll down until you see the SuperSu-v1.04.zip from the list. Use the power button to select it.

lb) After its done installing the zip, you should then clear cache and clear dalvik cache either using TWRP or CWM. 

m) Let it do its thing and then select "Go Back" and then finally select "Reboot"

If for some reason you get stuck on the Nexus logo as a boot loop, boot into your recovery and perform a clear cache and dalvik cache as per step "la)" above. Or if that does not help, perform a factory reset

You are now rooted officially, and when you go into your App Drawer you will see the SuperSu app installed. 


HOW TO PRESERVE AND RESTORE ROOT ACCESS AFTER UPDATING VIA OTA

1) If you have Franco kernel OR any custom kernel, please re-flash stock kernel aka boot.img (this can be found on the first page, 2nd post). Restoring stock kernel using Franco Kernel's updater app DOES NOT help. I had to find out the hard way as it messes with the files. So please re-flash stock kernel before you go ahead.

2) By doing so, you can now receive the OTA update. Otherwise you CANNOT

3) As for Root Access, you download Voodoo's OTA Rootkeeper. Which can be found here: https://play.google.com/store/apps/d...b3RrZWVwZXIiXQ..

4) Launch Voodoo's OTA Rootkeeper and click on backup/preserve root. When you successfully update your phone via OTA, launch Voodoo's OTA rootkeeper again and click on restore root. Everything should be back to normal.

I am going to stress this out though, if it does not work - you can always a) re-install SuperSu via your custom recovery as you have when you first rooted your phone OR b) download SuperSu from the market. Either options will work. It's not that hard to root your phone again if you can't get it to work after updating via OTA. This applies to everyone, including myself.

HOW TO GET ADB WORKING AFTER 4.2.2 OTA SECURITY UPDATE + UPDATE TO LATEST ADB FILES:

Heads up to all to those who might be having their devices recognized as offline when in adb/fastboot mode. 4.2.2 enhances the USB debugging security. So it firsts ask you if you want to accept the connection to your PC. You have to click on yes, otherwise it will say device offline in fastboot mode. So you also have to update your adb files as well. This applies to Mac users as well.

http://developer.android.com/sdk/index.html

REVERTING BACK TO STOCK ANDROID + UN-ROOTING + RE-LOCKING BOOTLOADER

The following applies to 4.2.1 images. Replace 4.2.2 images from Google's Nexus Factory Image website which can be found here: https://dl.google.com/dl/android/aosp/occam-jdq39-factory-345dc199.tgz

1) Access the Bootloader by a) pressing vol down + power key OR b) typing adb reboot bootloader in CMD Prompt.
2) Please ensure you have the necessary image files from Google. See "STOCK ANDROID FILES" to download it under the 2nd post in this page. 
3) Type the following commands:

fastboot flash bootloader bootloader-mako-makoz10l.img
fastboot reboot-bootloader
fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.33
fastboot reboot-bootloader
fastboot -w update image-occam-jop40d.zip
fastboot reboot-bootloader
fastboot oem lock

THAT IS IT! YOU ARE NOW BACK TO STOCK AS THOUGH YOU JUST GOT THE PHONE BRAND NEW. THIS IS PERFECT FOR SENDING IN THE PHONE FOR REPAIRS! LET'S HOPE IT DOES NOT COME TO THAT THOUGH :)

INSTALLING CUSTOM KERNELS CAN BE FOUND HERE

http://techsideofemp.blogspot.ca/2012/12/installing-custom-kernel-on-nexus-device.html

ROMS AND CUSTOM KERNELS CAN BE FOUND HERE: 

http://forum.xda-developers.com/forumdisplay.php?f=1912

IMPORTANT FILES/APPS - MUST HAVE:

Note: I will update the list as I find more important ones. Some require Root Access.

4.2.1 Factory Images: 

Stock System: To be uploaded

4.2.2 Factory Image Link: https://developers.google.com/android/nexus/images#occamjop40c

TWRP RECOVERY:

http://teamw.in/project/twrp2/129

ClockWorkMod:

Regular: http://download2.clockworkmod.com/recoveries/recovery-clockwork-6.0.2.3-mako.img
Touch: http://download2.clockworkmod.com/recoveries/recovery-clockwork-touch-6.0.2.3-mako.img

ADB Files: http://www.mediafire.com/?2s2wdsvhawhr2ut OR http://developer.android.com/sdk/index.html

SuperSu: http://download.chainfire.eu/310/SuperSU/UPDATE-SuperSU-v1.04.zip?retrieve_file=1 OR http://download.chainfire.eu/310/SuperSU/
































3 comments:

  1. Do the LTE build.prop hack work with 4.2.2 radio or does it also need the 4.2.1 radio ?

    Thanks,

    F

    ReplyDelete
    Replies
    1. Hey, for some reason I couldn't post a reply. I am doing so with another account I have.

      Yes you need the 4.2.1 radio in order for it to work. Do note that there are some cases where people run into instability issues by flashing the 4.2.1 or an older radio onto a newer software update. Such as with the case of 4.2.2

      Delete