Nexus 4

From Segfault
Jump to navigation Jump to search

Root

Android#Root

Unroot

TBD...

Restore

After almost bricking[1] this Nexus 4, let's try to document the a restore process[2].

  • Download factory image from Google, verify the checksum
  • Reboot into the bootloader:
fastboot reboot-bootloader               # Use adb reboot-bootloader if fastboot does not work!

Or via holding Vol- while powering on the device. If this is not working either, try holding both Vol- AND Vol+ down while powering on the device.

Erase all partitions:

fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata

Flash with the stock image:

fastboot flash bootloader bootloader-mako-makoz20i.img
fastboot reboot-bootloader

fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.84.img
fastboot reboot-bootloader

fastboot -w update image-occam-jwr66v.zip

The last command should also reboot the device.

Additionally, if we want to lock the device again:

fastboot oem lock
fastboot reboot-bootloader

CyanogenMod

Installing CM on the Nexus 4[3] was pretty straightforward.

The device needs a custom recovery image, see above. Once this is installed, we can install CyanogenMod.

  • Download CyanogenMod[4]
  • Download SuperSU, to enable root access[5]
  • Download Google Apps, if needed[6]
adb push cm-NN-XXX-mako.zip /sdcard/
adb push UPDATE-SuperSU-v*.zip /sdcard/
adb push gapps-kk-**.zip /sdcard/

Be sure to verify the checksums of these files!

Boot into the bootloader:

adb reboot bootloader
  1. Select "Recovery", we should now be in our recovery mode.
  2. Select "wipe" or "factory reset"
  3. Select "install from SDcard" and then point to the CyanogenMod zip file - and select install
  4. Repeat 4) for other zip files as well (the GoogleApps or the SuperSU package)
  5. Reboot the phone, now CyanogenMod should boot.

Postinstall

  • As CyanogenMod comes up, it might ask if we want to run "Launcher" or "Launcher3". Apparently, "Launcher" has more Google features and "Launcher3" seems to be its basic variant[7]
  • As documented in the CyanogenMod wiki[8], some features might not work with:
    • In low signal zones (remote house at the mountain for example) CM 10.1.3 mako on Nexus 4 throw a song and 2 vibrations when the null signal notification appears.
    • Native camera app is not available, photosphere feature is not available too.
    • Impossible to take normal photos using flash. Camera app is usable only for daylight photography.
The last two issues apparently have been fixed, but the Wiki cannot be edited at the moment to document that.[9]

Update

To update an encrypted device, we have to take a few precautions because we have to decrypt the device before we can update the operating system. The easiest way is to use adb sideload:

Select Wipe Dalvik Cache and Wipe Cache and select Swipe to Start Sideload:

adb push cm-NN-YYYYMMDD-SNAPSHOT-Mx-mako.zip.md5  /sdcard/sideload.zip.md5
adb sideload cm-NN-YYYYMMDD-SNAPSHOT-Mx-mako.zip

Reboot the phone, CyanogenMod should now be updated.

Without adb sideload, the procedure is somewhat more complex[11]. In short:

adb reboot recovery
adb shell

Mount a 500 MB tmpfs onto /sdcard:

mount -t tmpfs -o size=500m tmpfs /sdcard
exit

Push the update image to the phone:

adb push cm-NN-YYYYMMDD-SNAPSHOT-Mx-mako.zip /sdcard/update.zip

On the phone, navigate to "Install update from sdcard", select /sdcard/update.zip we just uploaded. After the update is complete, reboot the phone.

Sometimes this doesn't work[12] and the tmpfs should be mounted over /data instead:

mount -t tmpfs tmpfs /data
mkdir /data/media
exit

On the computer again:

adb push cm-NN-YYYYMMDD-SNAPSHOT-Mx-mako.zip /data/media/update.zip

Then continue as above, but selecting /data/media/update.zip instead of /sdcard/update.zip.

LineageOS

LineageOS has been discontinued for the Nexus 4, but images can be built manually. However, the source trees only provide only sources up to lineage-15.1 (Android 8.1) for the mako models, so we cannot upgrade to more current Android versions this way.

CarbonROM

CarbonROM appears to still provide weekly builds for the Nexus 4 and are maintaining an Android 10 (CR-8.0) tree for mako. Installation should have been pretty straightforward, starting with:

Download the latest TWRP and flash with:

adb reboot bootloader
fastboot flash recovery twrp-3.4.0-0-mako.img

Boot into recovery, push both the CarbonROM image and (if needed) the Open GApps image (ARM, pico) to the SD card. In TWRP, select install and select both files, but the actual installation failed early on with:

Too small /system partition detected (must be at least 1333788672 bytes).
You need to repartition your device before installing this rom. (ERROR: 7)

Luckily, the XDA forum explained[13][14] how to do just that. In short:

Flash Recovery with a special TWRP version:

  1. Boot into recovery (TWRP)
  2. Install mako_clamor_repartition.zip
  3. Open Terminal and execute "modify". This can also be done via adb if needed.

This modify script will basically call parted and remove and then re-create some partitions, but this time with a bigger /system partition. If needed, this can be done manually:

# parted /dev/block/mmcblk0
> print
[...]
21      159MB   1040MB  881MB   ext4         system
22      1040MB  1627MB  587MB   ext4         cache
23      1627MB  7817MB  6190MB  ext4         userdata

> rm 21
> rm 22
> rm 23

> mkpart primary  159383552B 1732247551B
> name 21 system

> mkpart primary 1732247552B 1994391551B
> name 22 vendor

> mkpart primary 1994391552B 2099249151B
> name 23 cache

> mkpart primary 2099249152B 7817134079B
> name 26 userdata
> quit

# make_ext4fs /dev/block/mmcblk0p21
# make_ext4fs /dev/block/mmcblk0p22
# make_ext4fs /dev/block/mmcblk0p23
# make_ext4fs /dev/block/mmcblk0p26

# reboot recovery

Once this is done (and we manged to somehow save the /sbin/parted utility), can can see that the /system is bigger now:

# parted /dev/block/mmcblk0
> print
[...]
21      159MB   1732MB  1573MB  ext4         system
22      1732MB  1994MB  262MB   ext4         vendor
23      1994MB  2099MB  105MB   ext4         cache
26      2099MB  7817MB  5718MB  ext4         userdata

In TWRP again, select Format Data. After this, 'Advanced Wipe' and wipe everything here. At this point we should be able to install CarbonROM (and OpenGapps) w/o problems.

Misc

Tethering

With Android 4 (or CyanogenMod installed), tethering should work out-of-the-box:

Settings → Wireless & Networks → Tethering & portable hotspot → Portable Wi-Fi hotspot

→ See also Tethering

Barnacle Wifi Tether

Barnacle Wifi Tether will set up a wireless ad-hoc network. For the Nexus 4, the following options needed to be set:[15]

  • "Custom Wifi Ad-hoc" → none
  • "Skip wpa_supplicant" → enabled
  • "WAN" → <empty> or rmnet_usb0

android-wifi-tether

android-wifi-tether ("Wireless Tether for Root Users") was working quite well on the HTC Sensation and it seems to work on the Nexus 4 as well.

Trying to install while connected to T-Mobile[16] resulted in "This item is not available on your carrier". However, the .apk file can be downloaded & installed manually.

Tethering only worked after setting[17] the following options:

  • Device-Profile → Generic ICS/JB (wlan0)
  • Setup-Method → Netd-Ndc (master)
  • Send Netd Max Client Cmd → enabled
  • WiFi-driver reload 2 → enabled
  • Routing fix → enabled

WiFi

The Nexus 4 supports 802.11n WiFi networks, which operate in 2.4GHz and 5 GHz bands. It does not, however support 802.11ac.[18][19].

There is an issue though with the reported "signal strength" for 5GHz WiFi networks.[20] Apparently with Android 4.3 the reported signal strength is lower for 5 GHz networks, although the bitrate seems to suggest otherwise:

  • 5GHz network, 2 bars:
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[ ID] Interval       Transfer     Bandwidth
[  4] local 10.0.0.2 port 5001 connected with 10.0.0.3 port 34313
[  4]  0.0-10.1 sec  48.1 MBytes  40.0 Mbits/sec
[  5] local 10.0.0.2 port 5001 connected with 10.0.0.3 port 34314
[  5]  0.0-10.1 sec  47.4 MBytes  39.2 Mbits/sec
  • 2.4 GHz network, 4 bars (full):
[  4] local 10.0.0.2 port 5001 connected with 10.0.0.3 port 34315
[  4]  0.0-10.4 sec  15.9 MBytes  12.8 Mbits/sec
[  5] local 10.0.0.2 port 5001 connected with 10.0.0.3 port 34316
[  5]  0.0-10.3 sec  22.9 MBytes  18.7 Mbits/sec

Phone goes black while in call

Might be related to the Proximity Sensor, which is located in the upper left of the phone. A screen protector / dirt might be in the way.

USB Mass Storage

Unfortunately, the Nexus 4 does not show up as a USB mass storage device when connected to a computer via USB cable.[21]. Alternative ways to transfer data to/off the device would be:

 adb pull /mnt/sdcard/DCIM .
 adb push local/directory /mnt/sdcard/download
  • Apply some kind of hardware hackery[21] to make USB OTG ("On The Go") work.

Contact icons

While contact icons appear just fine in the contact list, they appear blurry when displayed in incoming calls or when looked at in detail mode.

Google data connection issue

When not on WiFi, the Nexus 4 gets full bars and a "H" (for Speed Packet Access HSPA) - but the bars and the "H" are "grey". Data connection is fine, browsing works, but I can't install apps from the Google Play store.

When I connect to WiFi, the "H" vanishes (naturally) and the bars turn blue - now I'm able to install apps from the Google Play store, but data connections are handled by the WiFi connection of course.

TBD!

The last link suggests to dial *#*#4636#*#* and select "Phone information", where one can switch from "WCDMA preferred" to "WCDMA only".

Lollipop Boot loop

After updating/flashing to Android 5.0.1 ("Lollipop"), the Nexus4 can't seem to exit its boot animation and stays there for quite a while[22][23]. After it wouldn't come back after ~10 minutes, I pressed the power button and the Nexus4 rebooted just fine.

LineageOS & GApps

After installing LineageOS 15.1, even the smallest "pico" Open GApps package cannot be installed due to insufficient disk space in /system. [24] The trick is to exclude e.g. the GoogleTTS package:

cat > /sdcard/gapps-config.txt
Exclude
GoogleTTS
^D

Now it should be possible to install Open GApps alongside Lineage 15.1 and above.

References