Code to move a file to /system ? - Java for Android App Development

Im a galaxy s6 user here, I found out that the switch recent app button (the one on the left of the home button) quite annoying while playing game like vainglory because I misclicked it quite often. After doing some research I found out that it is possible to comment out the key 254 of generic.kl under system/usr/keylayout, then i come out with an idea of creating a new generic.kl which commented out the key 254, then with a click of button on my app it will move the file with the commented key to system/usr/keylayout to replace the old way, vice versa, I will make a restore button there to restore it will the original generic.kl when I wan the recent app switch to start working again. So my question here is what would be the code to move a file to system and replace it? I do have some basic android programming knowledge and my phone is rooted.
Thanks in advance.

if your phone is rooted.
step 1:get root permission
exec command : su
step 2:mount /system to writeable
exec command : mount -o rw,remount /system
step 3:replace file

Related

qwerty key not working

Hi my qwerty keys a,q and menu keys are not working.. is there any app or adb way so that i can remap my keys to unused ones.. i searched google but i could not find anything.. Please can anyone help me.. i g1 is rooted 1.6 running cyanogen 4.2.15.1..
Same here, I really don't know whats up with my phone and why it randomly changed mapping but I can't use my phone at all anymore. Anyone know anything on this problem?
my right shift key is in the same situation as you for my g1.
Sorry to say, the only way to do this is to make a custom map for the keys and rebuild the kernel. :/
How can I do that?
Hi
i just found it in some forum , sorry i could not allowed to post the link.. I have tried it its working.. below are the steps to do.. You need to backup your existing keyboard layout.. then change the layout keys then re-upload the files..
below steps are for mapping search key to call key..
1. You have to be root.
2. backup all your files from /system/usr/keylayout/ by runing the following commands in ADB:
Code:
adb shell
mkdir /sdcard/KB_BK
mkdir /sdcard/KB_MODDED
cp -f /system/usr/keylayout/* /sdcard/KB_BK
3. Mount your sdcard as Memory card and COPY the folder /sdcard/KB_BK
4. Edit with notepad++ or wordpad such the keyboard files and change the second element of the key to your likings, CHANGE
Code:
key 127 SEARCH WAKE_DROPPED
key 217 SEARCH WAKE_DROPPED
TO for ex.
Code:
key 127 CALL WAKE_DROPPED
key 217 CALL WAKE_DROPPED
5. save your modification.
6. upload the modified files in /sdcard/KB_MODDED
7. Replace your files from /system/usr/keylayout/ with your modified files from /sdcard/KB_MODDED
Code:
adb shell
su
mount -o remount,rw /dev/mtd/mtdblock6 /system
cp -f /sdcard/KB_BK/* /system/usr/keylayout/
chmod 644 /system/usr/keychars/*
chmod 644 /system/usr/keylayout/*
mount -o remount,ro /dev/mtd/mtdblock6 /system
ATTENTION WATCH OUT FOR THE FILES PERMISSIONS AND BE SURE THEY ARE THE SAME AS THE ORIGINAL
8. Reboot
9. Enjoy
Hope this will help someone..
all credits goes to Geniusdog254 and jay..
nice find
Sent from my Nexus One using the XDA mobile application powered by Tapatalk

[Q] bash shell the hell (I can t set permiss.)

RESOLVED
Dear developers,
I need to make send hardware button work for the menu, because the long press windows make me crazy recalling the current applications instead to give me the real useful menu for the app I use.
I currently use desire on hd2. So searching in the previous posts I found that I can change /system/usr/keylayout/qwerty.kl
No way, I opened Astro, did not change and save the modifications. Then I tried to download a terminal emulator. Do not give me #, but I thought was normal reading other posts(the phone is already rooted) so I tried chown and chmod, but I do not what I have to write to do the trick of edit with ASTRO the 2 lines I need to put the menu (for the apps) in SEND hw button. Furthermore trying using $ ls -latr I discovered that the qwerty.kl is a link that refer to etc/keymap directory. So I tried to use ASTRO to edit the file but also if tell me save, there are not modification, simply the file is not edited.
resolved --> I HAD TO COPY IN SDCARD THE FILE QWERTY BEFORE to MODIFY WITH ASTRO, no need of chmod && Chown

[Guide]How to disable the home key button at screen off [Root Required]

Here is a little guide on how to disable the screen from turning on in your pocket by accidentally clicking the home key. Which can set off unwanted calls/txts/homescreen changes/etc.
Perhaps there is an easier way, but this works for me, and sharing is caring
There I obtain a copy of Root Explorer, its easy for me to do. For those of you who are too cheap, scroll a bit further down this post, both methods require, obviously, root access:
I have no idea if there are free programs with the same usabilities as root explorer
Method with Root Explorer (or similar?)
Open Root Explorer
Go to /system/usr/keylayout
Click on the button ‘Mount R/W’ (upper right)
Locate, press and hold es209ra_keypad.kl file
Select ‘open in text editor’
Find this line:
key 102 HOME WAKE_DROPPED
Remove the WAKE_DROPPED, so that the end result is:
key 102 HOME
Save the file
Reboot
Done
Method without Root Explorer
You need a little understanding of adb.exe
Typ in cmd.exe:
adb pull C:\es209ra_keypad.kl /system/usr/keylayout/
Go to C:\ and open es209ra_keypad.kl in wordpad
Change:
key 102 HOME WAKE_DROPPED
to:
key 102 HOME
Save the file
Typ in cmd.exe:
adb shell
#su
#mount -o rw,remount -t yaffs2 /dev/block/mtdblock2 /system
(ONLY if you got an error, while trying to remount)
[*]Typ in adb shell:
[*]#cat /proc/mounts
[*]and search for 'system' in the mount list to check correct path for ‘/dev/block/mtdblock2 /system’. If it differs, alter the above line.
Typ in adb shell:
#exit
adb push C:\es209ra_keypad.kl /system/usr/keylayout/
Reboot your phone
This should work... if it doesn't, just leave a comment, and I'll probably try to help you.. that is, if I'm in a good mood..
I attached my es209ra_keypad.kl, just for reference purposes I guess, or for people who are too shy to pull stuff from their phone.
thanks for this!! i have been after a few key tweaks for a while!! don't suppose you have any idea how to make the back key "kill" foreground app!!
2.1 optimised 2.1.67
good idea
thanks for sharing this
[Q] Disable wakeup using home button? [SOLVED]
Use Search next time
prewed said:
[Q] Disable wakeup using home button? [SOLVED]
Use Search next time
Click to expand...
Click to collapse
Aren't you just mister friendly? Thank god we got guys like you on this forum, otherwise this place would be fun.
I did use search, so unfortunately for you. I could not find a correct guide explaining step by step how to do it WITHOUT root explorer
xx
[email protected] said:
thanks for this!! i have been after a few key tweaks for a while!! don't suppose you have any idea how to make the back key "kill" foreground app!!
2.1 optimised 2.1.67
Click to expand...
Click to collapse
no problem, ill try to find out if it is possible in 2.1, i think its in the framework though. It's already embedded in 2.2 and 2.3 (long press back), so you can try a custom ROM ?

[Q] Customize camera button function

I listen to a ton of audio books and would love it if i could turn my camera button into a pay/pause toggle when my phone is locked (much like plugging and unplugging headphones does).
I have done a lot of searching but found nothing so far. I am running stock rooted atm but will flash to anything that could pull this off.
Anyone know of such a beast?
Assuming you're rooted, go to the market and download a terminal emulator and astro file manager. From there, use astro to navigate into /system/usr/keylayout
copy s3c-keypad and stick it on your sdcard. Long click on it, choose open as, then text, then file editor. Scroll down till you hit the keys in the 40's. From there you have two options: key 46, which is the camera launcher, and key 56 which is the focus button. Modify either one of those, depending on your preference to: MEDIA_PLAY_PAUSE WAKE_DROPPED, then save the file. next, open up your terminal emulator, and type the following:
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cp -f /sdcard/s3ckeypad.kl /system/usr/keylayout
Failing that, there is something called music control lite in the market, though I've never used it so I don't know the details. You may also be able to set something up through Tasker. Good luck!
You, sir, are entitled to a cold one on me if you ever come through Memphis
The only exception to your excellent instructions that I made was to make it a WAKE function rather than WAKE_DROPPED and after a quick reboot it is working exactly as I had hoped.
Many thanks!

[Q] Remapping the external keyboard file

The Lenovo Thinkpad Tablet's keyboard folio is a neat little accessory but there is one issue that drives me nuts. (Beside the loss of the USB port). and that is that the Ctrl key also activates the menu (any menu).
So whenever one tries to do a copy and paste using the usual Ctrl + C and Ctrl + V keys, the menu (of the app you are working in) pops up.
Someone suggested to edit the Generic.kl file in /System/usr/keylayout directory and I did, but that didn't work. (Unless i did it wrong).
I'm at a loss. Would anyone have a suggestion on how to remap that key to only be a standard Ctrl and not menu key?
TS
Having the same issue.
But I'm using an external bluetooth keyboard: the logitech one, which was actually designed for the ipad.
I love it, its slim and very good quality keyboard.
Maybe some helpful links:
http://www.kandroid.org/online-pdk/guide/keymaps_keyboard_input.html
And this one has an explanation how this could be solved on a rooted thinkpad:
http://androidforums.com/ally-all-things-root/250271-re-map-key-keyboard.html
Ok, so I was able to remap some keys. Here is what I did.
The key layout files are stored in /system/usr/keylayout
The most important one seems to be Generic.kl which can be edited with a text editor, just use root explorer or the adb commands below. When I first tried my permissions were screwed up and I wrote the directions below but left them here in case they are helpful.
----------
(I edited gpio-keys.kl thinking it controlled the hard keys but it had no effect). While running the Thinkpad it seems as though I was unable to edit these files but I did get things to work using adb while booted into recovery. Here are the steps I took:
First reboot into ClockworkMod Recovery and plug in your thinkpad to your PC via USB
In CWR select Mounts and Storage then Select Mount /system (otherwise it seems adb can't access your system files)
On your computer run cmd and type adb devices (you should see a device listed, if not go check out the ADB setup guide). Now enter the following commands:
adb remount
adb pull /system/usr/keylayout/Generic.kl
This will copy the Generic.kl file to your current directory (you can see it in the command prompt, typically it is C:\Users\[Your Username]\
Browse to the file make a copy of the unedited version and save your backup somewhere and then edit Generic.kl in a txt editor (I like Notepad++)
I changed key 150 EXPLORER to say key 150 MENU, which makes the browser key open the menu instead of your web browser.
After you made your changes save it and then use the following ADB commands to push it back and set the permissions:
adb push Generic.kl /system/usr/keylayout/
adb shell
chmod 644 /system/usr/keylayout/Generic.kl
chown system.system /system/usr/keylayout/Generic.kl
exit
adb reboot
Now your keys should be remapped!
Just thought I'd add this to skip all the ADB and do it right on the tablet:
ES File Explorer (with root permission and /system writeable checked in settings)
Navigate to file, click, choose text, choose ES Note Editor, edit the file as needed, choose save when prompted.
You can change permissions with ES as well.
I like that it automatically makes a *.bak file of whatever you edit and save.
Those are the same steps I did, but it didn't work for me even after a reboot.
And although I did a backup of the existing generic.kl file, I think I may have overwritten it. So I'm going to have to go in search of a fresh one.
TS

Resources