[ROOT] Natively Wake Your Droid with the CAMERA KEY

roys

New Member
Joined
Jan 14, 2010
Messages
15
Reaction score
0
Hello, I just managed to wake my milestone with the camera key:), without installing any applications but root required. The method is to modify the "keylayout" according to the Android Development Guide Keymaps and Keyboard Input | Android Open Source, by setting the "FOCUS" key with "WAKE" flag.

Before that, we can install some apps like "lockbot" to manages the camera key that can wake the phone. Not sure, but probably it will keep a "wake lock" that prevents your device to go into sleep mode, and so keep draining your battery.

By modifying the "keylayout", the camera key (focus key) can wake your device with the Android OS nativelly, therefore no extra battery drain (just press and raise an interrupt to wake the CPU like your power key !!).

******
Tutorial on this thread is provided "as is". Use at your own risk.

THIS TUTORIAL IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******

1.) Root your droid.

2.) Connect your droid with the computer in USB debugging mode.

3.) Pull the corresponding keylayout file from your device. Since I am using Motorola Milestone, as I don't know if the Droid keylayout setting is same as Milestone, so here advised to check and pull the corresponding keylayout file.
# Using "adb shell".
adb shell

# Grant the "su" right (you may need to press the button "Always" on Droid, as well as retry few times until the prompt becoming from "$" to "#").
su

# First, check out which file that your device is using.
cat /proc/device-tree/System@0/Keypad@0/name

# Copy the corresponding file to /sdcard/, as "keypad.kl".
cp /system/usr/keylayout/`cat /proc/device-tree/System@0/Keypad@0/name`.kl /sdcard/keypad.kl

# Exit and "su" and the "adb shell", so that we will go back to Windows command prompt.
exit
exit

# Pull the corresponding keylayout file from /sdcard/keypad.kl
adb pull /sdcard/keypad.kl c:\keypad.kl

4.) Modify the pulled file "c:\keypad.kl".
*** Warning: Modify the file using an text editor which support the Linux line-feed (\n), otherwise may corrupt the keypad file. ***

Find the line "key 211 FOCUS", and append the flag "WAKE" after "FOCUS", so it will becoming:
key 211 FOCUS WAKE

PS. CAMERA KEY won't work, as like VOLUME KEY not working too, probably Motorola exceptionally marked these keys in their keypad driver, in order to let the volume key working when using music player in screen off mode (don't wake the screen when playing music).

5.) Push the modified keylayout file to your sdcard.
adb push c:\keypad.kl /sdcard/keypad.kl

6.) Remount the "/system" partition with "rw" mode.
# Go into "adb shell".
adb shell

# Grant the "su" permission.
su

# Remount the /system partition with rw mode.
mount -o remount,rw -t yaffs2 /dev/block/mtdblock6 /system

7.) Copy the modified keylayout file to "/system/usr/keylayout".
cd /system/usr/keylayout

# Create backup of the existing keylayout file.
mv `cat /proc/device-tree/System@0/Keypad@0/name`.kl `cat /proc/device-tree/System@0/Keypad@0/name`.kl.bak

# Copy the modified keylayout file from /sdcard/keypad.kl
cp /sdcard/keypad.kl `cat /proc/device-tree/System@0/Keypad@0/name`.kl

# Change the permission to 644
chmod 644 `cat /proc/device-tree/System@0/Keypad@0/name`.kl

8.) Remount the "/system" partition with "ro" mode.
cd /
mount -o remount,ro -t yaffs2 /dev/block/mtdblock6 /system

9.) Exit the "adb shell" by typing "exit" few times until returning to the windows command prompt.

10.) Reboot your droid.

11.) Try to wake your droid with the camera key.:icon_ banana:
 

ibebyi

Member
Joined
Jul 26, 2010
Messages
46
Reaction score
0
Location
San Diego
Hi, I was just wondering if anyone could confirm this works? I'm afraid my power button has gone kaput. :(
 

TheOldFart

Active Member
Joined
Nov 26, 2009
Messages
962
Reaction score
27
Location
New York State
I would personally not want that feature. The camera key takes very little pressure to activate and it is natural to hit it with the palm of your hand when putting the Droid into your pants pocket. At least it is the way that I hold it. I have accidentally put the awake phone into my pocket twice and once it moved all the icons around and deleted one, the other time it opened Solitaire, which is in a games folder.
 

cherrybombaz

New Member
Joined
May 17, 2010
Messages
12
Reaction score
0
Thanks. This works great.
Is there a way for the camera key to also put the droid back to sleep?
 

nka

Member
Joined
Nov 11, 2009
Messages
144
Reaction score
0
I don't understand how to perform this step:

# First, check out which file that your device is using.
cat /proc/device-tree/System@0/Keypad@0/name

How do I check which file the device is using?

Thanks.
 

SweetVibes118

New Member
Joined
Aug 22, 2011
Messages
1
Reaction score
0
I just used it and happy to say IT WORKS!

Not sure if anyone else is running into this same problem, but changing this code was the only way i could see in fixing this problem. But its not, there is an app for $00.99 called "Button Re-mapper" This is the way changing button should be done. Quick easy and only requiring a reboot.
 

nka

Member
Joined
Nov 11, 2009
Messages
144
Reaction score
0
Wow, total time-saver!

Not sure if anyone else is running into this same problem, but changing this code was the only way i could see in fixing this problem. But its not, there is an app for $00.99 called "Button Re-mapper" This is the way changing button should be done. Quick easy and only requiring a reboot.
That would have saved me so much time. Too bad I didn't know about this app before I manually went through the trouble to alter the keypad file.
 
Top