7

I have a Nexus 5 (hammerhead) running CyanogenMod 11.

The Volume Down rocker button is damaged in such a way that it's stuck on (apparently a common failure mode after 2+ years).

The only real problem with the device is that it always boots into safe mode, due to the stuck button.

Is there any way to disable the Volume Down activation of Safe Mode, so that I can boot my phone into normal, full Android mode?

Dan
  • 440
  • 3
  • 14

1 Answers1

4

Right way to do this

Disable the broken VOLUME DOWN key by editing /system/usr/keylayout/gpio-keys.kl and /system/usr/keylayout/Generic.kl as root and commenting that key out. Longer instructions on this answer.

Dumb and hacky approach that sort of worked for me

This is an ugly solution but it works for me. It is a "tethered" solution requiring adb to do repeated "soft reboots" (restarting the Android Zygote process).

This bash script repeatedly restarts the Android Zygote process until it detects that the device isn't in safe mode. Takes about 20-50 reboots until my device randomly gets lucky and doesn't restart in safe mode…

#!/bin/sh
n=0
g=0
while true; do
    safe_mode=$(adb shell dumpsys display | egrep -o 'mSafeMode=\w+' | cut -d= -f2)
    case "$safe_mode" in
    true)
        n=$(( $n + 1 ))
        g=0
        echo "In safe mode, rebooting (try #${n}) ..."
        adb shell "su root -- killall zygote"
        ;;
    false)
        g=$(( $g + 1 ))
        [[ $g -gt 2 ]] && break;
        echo "Appears not to be in safe mode, will check again ..."
        ;;
    *)
        echo "adb shell dumpsys display failed" ;;
    esac
    sleep 15
done

adb shell dumpsys power | grep -q 'mScreenOn=false' && \
    adb shell input keyevent = POWER

echo "Escaped from safe mode after ${n} reboots. Whew."

This related question and this answer gave me what I needed to figure it out.

Dan
  • 440
  • 3
  • 14