External Bluetooth Keyboard Mapping with HTC Vivid - HTC Vivid, Raider, Velocity

Hello,
I didn't know if there was already a post for this, my searches were coming up not matching anything.
If you happen to have an external keyboard (bluetooth in my case), you might have the problem that many of the key events from the keyboard do not map nicely to the HTC Vivid. I am running 4.0.3 in my case with 3.6 sense, and other than the alpha-numerics, many of the system level keys were not working for me. Since I often play HD video from my phone to the HDTV, it's handy for me to control things like Volume_UP/Down, HOME / MENU / BACK, Pause / Play, Select Movie title, reply to Text, etc. So I had to find a way to improve the keyboard mappings to make it functional, and I was curious if others may have done similar things as what I describe here. I am still stuck on a few mappings, so would glad to have any info from others who have succeeded or failed in a similar regard.
I went and spent about $35 for this G-Cube bluetooth keyboard model BK-30 at Frye's.
h t t p :// www .gggcube .com/ Upload/ ProImgs/ smaImg/ 201303101915016774.jpg
It was a nice weight with a good feel on the keys, and good enough for a test run. The bluetooth device was discovered and paired easily on my HTC Vivid, and some of the system functions from keyboard were working, like Volume UP/Down and Mute. But I noticed right away I had no way to open a MENU option, or to perform a BACK function from a given application or settings screen. In order to change the keyboard mappings, it's necessary to boot into Recovery, un-mount /system and use ADB to re-mount /system in order to be able to edit the file called Generic.kl (keyboard layout file) which lives in the /system/usr/keylayout/ directory. Here are the steps I used to update the file.
Before editing the Generic.kl file, it's helpful to gather some information using an APP called KeyEvent Display (free in Google Play store).
1. Download, Install and Run the KeyEvent Display application, it gives you a keyEvent monitor for the Bluetooth Keyboard
2. Pick a few keys on the Bluetooth which seem to do nothing, and press them, noting their SCANCODE values in the app. I chose the PrintScr, Pause/Break, Insert and Delete keys, just as a test. These 4 keys gave me scancodes of 99, 119, 110, and 111, respectively.
Now, you can reboot the phone into Recovery, and perform operations using ADB, providing your PC has the right USB drivers. Usually installing HTC Sync will give you these drivers, or from Ubuntu Linux, you may not need them. Google to install the ADB tool
1. Make sure your Vivid is rooted with a Recovery Image for bootup
2. Boot into Recovery, Connect your USB cable from the PC, and test that your ADB tool can properly communicate:
a) to use ADB, you need to have download these files (adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll)
b) from the directory where you have ADB, test the connection with a simple 'adb devices'
c) you should get a response from the phone device like this:
[C:\Users\JohnDoe\ADB_Tool] adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached
FA27VVJ01452 device
Click to expand...
Click to collapse
3. Assuming you are successful, you can now send ADB commands to the phone as needed here below. (If you got nothing after List of devices attached, you can research this seperately - its usually and USB driver issue.) ADB commands are used to mount and unmount file systems (like /system), to send commands or open a shell to the phone, and to push and pull files back and forth.
a) adb remount (should see: remount succeeded)
NOTE: if this fails with an error, use your Recovery Developer options to un-mount /system first, then try again.
b) adb pull /system/usr/keylayout/Generic.kl
NOTE: Generic.kl is the file we want with all the mappings of keyEvents. If the file is pulled successfully, you see something like:
pull /system/usr/keylayout/Generic.kl
982 KB/s (9058 bytes in 0.009s)
Click to expand...
Click to collapse
c) Note with File Explorer in the folder with ADB, you should have a copy of the Generic.kl file.
d) Make a backup of this file, you can cause the keyboard and other items to fail with incorrect changes!
e) Edit the file with your favorite text editor, and look for sections that we want to change, for example:
key 109 PAGE_DOWN
key 110 INSERT
key 111 FORWARD_DEL
# key 112 "KEY_MACRO"
key 113 VOLUME_MUTE
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER WAKE
Click to expand...
Click to collapse
f) Change keys 110 and 111 (for example) to now look like this, and then save the file:
key 109 PAGE_DOWN
key 110 BACK
key 111 MENU
# key 112 "KEY_MACRO"
Click to expand...
Click to collapse
g) adb push Generic.kl /system/usr/keylayout/ (this places the file back to the phone)
h) adb shell (need a shell to reset the permissions of the file)
i) chmod 644 /system/usr/keylayout/Generic.kl (should be read only to group/world)
j) ls -l /system/usr/keylayout/ (check to see ownership and permissions look correct)
ls -l /system/usr/keylayout/
-rw-r--r-- 1 root root 894 Jul 12 2012 AVRCP.kl
-rw-r--r-- 1 root root 9048 Nov 12 20:59 Generic.kl
-rw-r--r-- 1 root root 1293 Jul 12 2012 Vendor_045e_Product_028e.kl
-rw-r--r-- 1 root root 1027 Jul 12 2012 Vendor_046d_Product_c216.kl
Click to expand...
Click to collapse
k) exit (exit from the ADB shell)
l) adb reboot (reboot the phone out of recovery into normal mode)
3. Now when the phone is ready, test the new key functions you have defined. For me, I had success with the MENU, BACK, CALL and ENVELOPE functions, among others. It is very helpful that I can use ALT-TAB to toggle between running apps.
The main one which I am failing to define is the 'OPEN ALL APPS'. If anyone else is performing mappings such as these for an external bluetooth keyboard, I would be interested to know which functions you have gotten to work. I am now at a state where I can control most everything, provided it is already running in the background. But I can't swipe my Sense desktop left and right, and I have trouble toggling certain switches like Wifi and Mobile data. Any suggestions or thoughts on these functions are appreciated.
Darren
Troubleshooting TIP: You can also run ADB when the phone is running in Normal Mode and you have the USB cable connected from your phoe to the PC. Then you can test certain keypresses through functions that are formatted in this way:
adb shell input keyevent 5
Click to expand...
Click to collapse
On my phone, this function will send the CALL event with brings up the phone from the desktop.
Other examples (you can also launch then from a *.cmd file):
If you have a terminal open on the phone, will send "ls -l"(includes the space-62 and enter-66):
@echo off
adb shell input keyevent 40
adb shell input keyevent 47
adb shell input keyevent 62
adb shell input keyevent 69
adb shell input keyevent 40
adb shell input keyevent 66
Click to expand...
Click to collapse
If you have a terminal open on the phone, will send "env|grep PATH":
@echo off
adb shell input text "env"
adb shell input text "|"
adb shell input text "grep"
adb shell input keyevent 62
adb shell input text "PATH"
adb shell input keyevent 66
Click to expand...
Click to collapse

Related

$50 dollars to the first solution to sideloading non market apps

I have a brand new ATT Captive.
I have it rooted.
I am on a MAC.
I am looking for a solution to allow me to sideload no market apps.
First person to post a method that will allow me to complete this will get $50 paypal as soon as I get this completed.
I have tried every solution on this board and spent 3 days trying to do this. Nothing has worked.
I begging someone to please find and post me a solution. I guarantee that I will pay to the first solution to make this possible.
Please help me out.
Don't pay people for it, there's threads all over for how to do it. This is copied from one of those threads.
"Method 2: with Root Explorer
(courtesy of kirbo20)
This is a pretty easy process. I went in to Root Explorer - dbdata - databases - com.android.providers.settings, copied settings.db to my sd card, edited it on my pc with a db editor changed 0 to a 1 next to non market apps. Copied it back to the original directory, rebooted and installed a non market app.
(added by gotfolk)
again using FF plug in..
Click Secure on the left pane
click on install_non_market_apps
click edit
number 3 states value click there and type in 1. hit ok
(/gotfolk)
Please use caution. If you want to make sure the db save properly open it on your sd card before you copy and replace the original. It should open up as a readable table. If it opens up in a txt editor its corrupt. This permanently enables non market apps. You can not toggle it on and off.
( This is a sqlite3 database file, you can find many GUI editors that will be able to handle the editing, including a FF plugin. Search "SQLite" )"
And if you don't want to use root explorer - Use the Android SDK on your mac - it is free.
You have to do your work in the terminal, but it is easy using the ADB Shell to get the file to your SD card, move it to your mac, use Firefox and SQLite manager to change the one value, put the file back, change permissions and you are done.
Most of us are not looking for $50 - just looking for people to use search and give things a try before creating a new post.
I think you can spend $4 very well on Root explorer and enable sideloading apps. And save $46.
2) Downloaded Root Explorer and SQLite Editor. Both of these are paid apps but look like they are worth owning. For instance, you can also use Root Explorer to rename and disable the AT&T bloatware, as an alternative to this method.
3) Using Root Explorer, mount the filesystem R/W and copy /dbdata/databases/com.android.providers.settings/settings.db to /sdcard/settings.db
4) Open /sdcard/settings.db in SQLite Editor
5) Open the 'secure' table
6) Long-hold on record 6, "install_non_market_apps" and select "Edit Record"
7) Change the value from 0 to 1 and save
8) Back in Root Explorer, copy /sdcard/settings.db back to /dbdata/databases/com.android.providers.settings/settings.db
9) I don't remember if I had to reboot or not, but you may as well.
Click to expand...
Click to collapse
Edit: Couldn't find the video with these intructions. Anyways you can download SQLite manager add-on on firefox, open firefox, go to tools->sqlite manager. Have the copied settings.db on your desktop, then open it up with the firefox SQLite manager(just to save you some more money). Once you're there, open up settings.db, go to secure on the left side, and then go to "browse and search" on the menu bar. Right click and edit "install_non_market_apps" and change the value from 0 to 1 like the instruction above. Then do steps 8 and 9. And you do have to reboot.
Sorry if it was confusing lol
doesnt the android central sideloading wonder work in mac?
puttingg said:
I have a brand new ATT Captive.
I have it rooted.
I am on a MAC.
I am looking for a solution to allow me to sideload no market apps.
First person to post a method that will allow me to complete this will get $50 paypal as soon as I get this completed.
I have tried every solution on this board and spent 3 days trying to do this. Nothing has worked.
I begging someone to please find and post me a solution. I guarantee that I will pay to the first solution to make this possible.
Please help me out.
Click to expand...
Click to collapse
max_warheads said:
(additional CHOWN notes added below. If you are getting "chown: unknown user/group system:system" read them!
Ok, we do have a WHOLE other thread that was made a sticky already, but you need to read the WHOLE thing to get all the properly interesting parts. I'll make sure I keep this OP up to date.
The following methods enable side loading and installing of apps onto the captivate, without the need of a program on a computer attached via the SDK. There are multiple methods, and for the most part, these methods that have worked flawlessly for many users here on this forum. We're just collecting them all in one post for speed and clarity.
Methods that assist in loading applications, without modification to the settings (a.k.a still need a computer attached) can be found at the collective wiki, http://samsungcaptivate.wikia.com/wiki/How_to_Sideload
ALL METHODS REQUIRE ROOT & BUSYBOX:
Root your phone, see http://forum.xda-developers.com/showthread.php?t=725555
Busybox : http://www.appbrain.com/app/stericson.busybox
Please, save a clean, un-altered backup copy of this file. To be safe. Rarely does corruption occur, but if it does, it won't be good.
Method 1: From Win7x64, Samsung Drivers, Android SDK installed.
This method uses the tools you already have at hand, as part of the SDK. All instances in code blocks are run inside of the command prompt. You will need to know where you installed your SDK, and the tools directory therein.
Once rooted, go install BusyBox installer from the App Market/AppBrain etc and run it. It will download and install the latest version for you.
From my Win7x64, with USB Debugging ON. Ensure that you phone is UNLOCKED as it the SU app will ask for permission for 'UNKOWN' in the following command.
Connect to PC, and Eject/Safely Remove the SD card, and "Turn off USB Storage" on the phone.
open command prompt, follow along:
Code:
> c:
> cd \android\tools
> adb shell
$ su
# cp /dbdata/databases/com.android.providers.settings/settings.db /sdcard/settings.db
# exit
$ exit
mount the SD cards to the pc,
"USB Connected select to... ", Mount
mine mounted as H:
Code:
> copy H:\settings.db settings.db
> sqlite3 settings.db
~> update secure set value="1" where name="install_non_market_apps";
1 row updated
~> .quit
> copy settings.db H:\settings.db
Eject the drive, safely remove, etc.
"Turn off USB storage" etc, to mount it back to the phone
Code:
> adb shell
$ su
# cp /sdcard/settings.db /dbdata/databases/com.android.providers.settings/settings.db
# chmod 660 /dbdata/databases/com.android.providers.settings/settings.db
# chown system.system /dbdata/databases/com.android.providers.settings/settings.db
# exit
$ exit
> adb reboot
Bam. Done.
Method 2: with Root Explorer
(courtesy of kirbo20)
This is a pretty easy process. I went in to Root Explorer - dbdata - databases - com.android.providers.settings, copied settings.db to my sd card, edited it on my pc with a db editor changed 0 to a 1 next to non market apps. Copied it back to the original directory, rebooted and installed a non market app.
(added by gotfolk)
again using FF plug in..
Click Secure on the left pane
click on install_non_market_apps
click edit
number 3 states value click there and type in 1. hit ok
(/gotfolk)
Please use caution. If you want to make sure the db save properly open it on your sd card before you copy and replace the original. It should open up as a readable table. If it opens up in a txt editor its corrupt. This permanently enables non market apps. You can not toggle it on and off.
( This is a sqlite3 database file, you can find many GUI editors that will be able to handle the editing, including a FF plugin. Search "SQLite" )
Method 3: with Root Explorer & Sqlite Editor & Terminal Emulator
(courtesy of ice3186)
- Open Root Explorer
- Browse to /dbdata/databases/com.android.providers.settings/
- copy settings.db to the root of your sd card ( /sdcard/ )
- Click on the newly copied settings.db in /sdcard/, with SQLite Editor installed, you can open and edit it here.
- Select the "secure" table, and update the value of 'install_nonmarket_apps' from 0 to 1, and save.
- close out of SQLite editor
- copy the modified file ( /sdcard/settings.db ), and browse back to /dbdata/databases/com.android.providers.settings/ and paste
- confirm the overwrite if asked and then open again to confirm it's been changed.
- open Terminal Emulator
Code:
$ su
# chmod 660 /dbdata/databases/com.android.providers.settings/settings.db
# chown system.system /dbdata/databases/com.android.providers.settings/settings.db
# reboot
- reboot phone.
No PC, no Mac, no drivers, no SDK. Viola.
Method 4: Mac & Android SDK
You will see "[sdcard]" through this method...I don't own a Mac so I'm guessing a bit.
This method uses the tools you already have at hand, as part of the SDK. All instances in code blocks are run inside of the Terminal. You will need to know where you installed your SDK, and the tools directory therein.
Once rooted, go install BusyBox installer from the App Market/AppDroid etc and run it. It will download and install the latest version for you.
From a Max OS X, with USB Debugging ON. Ensure that you phone is UNLOCKED as it the SU app will ask for permission for 'UNKOWN' in the following command.
Connect to Mac, and Eject/Safely Remove the SD card, and "Turn off USB Storage" on the phone.
open Terminal, follow along:
Code:
> cd /android/tools
> ./adb shell
$ su
# cp /dbdata/databases/com.android.providers.settings/settings.db /sdcard/settings.db
# exit
$ exit
mount the SD cards to the Mac,
"USB Connected select to... ", Mount
mine mounted as [sdcard]
Code:
> cp [sdcard]/settings.db settings.db
> ./sqlite3 settings.db
~> update secure set value="1" where name="install_non_market_apps";
1 row updated
~> .quit
> cp settings.db [sdcard]/settings.db
Eject the drive, safely remove, etc.
"Turn off USB storage" etc, to mount it back to the phone
Code:
> ./adb shell
$ su
# cp /sdcard/settings.db /dbdata/databases/com.android.providers.settings/settings.db
# chmod 660 /dbdata/databases/com.android.providers.settings/settings.db
# chown system.system /dbdata/databases/com.android.providers.settings/settings.db
# exit
$ exit
> ./adb reboot
Method 5: Android SDK only
Of course, this also requires root and BusyBox.
From the android sdk tools folder in a command prompt:
note: all linux/mac should use './adb' in place of just 'adb', and place quotes on the echo statement between echo and |
Code:
adb shell
su
chmod 666 /dbdata/databases/com.android.providers.settings/settings.db
exit
exit
adb pull /dbdata/databases/com.android.providers.settings/settings.db settings.db
echo update secure set value = 1 where name = 'install_non_market_apps';|sqlite3 settings.db
adb push settings.db /dbdata/databases/com.android.providers.settings/settings.db
adb shell
su
chmod 660 /dbdata/databases/com.android.providers.settings/settings.db
chown system.system /dbdata/databases/com.android.providers.settings/settings.db
reboot
NOTICE
You must chown the settings.db file and reboot once it is back in its original location. If you do not, you will not be able to alter settings such as WiFi,GPS, default Ringtones, etc. It's also highly likely that you may wish to chmod to 660 (-rw-rw---), so I've tacked that in here and above.
Code:
> adb shell
$ su
# chmod 660 /dbdata/databases/com.android.providers.settings/settings.db
# chown system.system /dbdata/databases/com.android.providers.settings/settings.db
# exit
$ exit
> adb reboot
Chown Note
In the event that you are getting "chown: unknown user/group system:system" please try 1000.1000 as this has been reported to work on several of the samfirmware-released roms that fail with this message.
Absolutely do not use someone else's settings.db unless you specifially make it a point replace android_id with your android_id!
[
Sent from my AOSP Captivate
Click to expand...
Click to collapse

[RECOVERY/BOOTSTRAP]Tweaked Safestrap v2.00a (ICS Leak) 06-13-2012

************************************
************************************
Note: Please uninstall Hashcode's Safestrap before you try installing this one. To accomplish this properly, you have to do two things:
1. Open up the Safestrap app from your launcher, and choose "Uninstall Recovery". Let it finish. It'll tell you whether or not it worked.
2. Then, go to Settings - Apps and find Safestrap. Click "Uninstall".
************************************
************************************
Installation of this app requires root privileges. If the installation does
not work, it is likely because you either:
a) don't have busybox installed.
b) you do have busybox installed but it doesn't have the functions we
need.
No problem. Just do this through adb or a terminal on the phone:
Code:
$ su
# mount -o remount,rw /system
# cp /system/xbin/busybox /system/xbin/busybox.old
# cp /data/data/com.hashcode.droid4safestrap/files/busybox /system/xbin/
# chmod 755 /system/xbin/busybox
# exit
Now it should work without a hitch.
************************************
************************************
Those of you who came from the Droid 3 might remember my customized version of Hashcode's Safestrap, which included a console, improved user-interface, non-safe flashing, etc.
I've finally got it to the point where I think it would be okay to release out in the wild. That being said, I'm not responsible for anything dumb you do to your own device.
I wouldn't bother using the non-safe flashing capabilities yet, seeing as how there hasn't really been any official releases using the new ICS kernels that have been leaked as of late. This feature is handy if you're a developer testing out update.zips for /systemorig, but for the average person you'd best pay heed to the warnings and just use Safestrap as it was originally intended; that is, leaving your /systemorig partition intact and only mess around with your "safe" /system. (Or /preinstall, actually, but that's not really important.)
The console is beyond useful. Editing build.prop settings on the fly without having to boot up and do it in a terminal emulator or via adb on the phone is much easier. If you know what you're doing, you can even extract single files from your old backups, modify your old backups, etc. That's just a small fraction, but those of you who would care about this functionality don't need me to say how important it can be.
I've included statically compiled versions of "bash" and "vim" so that there aren't any dependencies on the libraries usually found in /system/lib. Thus, you can use all of these utilities without having either /system or /systemorig mounted. You're free to add your own binaries in your home folder, which is located at /cache/.safestrap/home, or just pop them onto your sdcard.
Also, I have a battery monitor running so it will tell you what level your battery is at, and have put a lot of work into the visual appearance of the user-interface. There are so many things I've modified that it would be impossible for me to list them all here.
Anyways, try it out and let me know what you guys think. I hope you like it!
For those of you who are interested, I always post my sources on Github. You can find my code repositories here:
https://github.com/buddyrich
The .APK can be downloaded from my DropBox via the link below:
http://db.tt/tZdmUHl1
=========================
RECOVERY MENU REFERENCE
=========================
Select Highlighted Item - Enter or Power
Scroll Up - Volume Up or Left Arrow
**Note: The Left/Right Arrow keys may sound weird but since the menu is displayed in portrait mode, it just feels like you are pushing Up/Down.**
Scroll Down - Volume Down or Right Arrow
Direct Menu Selection - Hit the corresponding number/letter at the beginning of each menu item.
**ie: from the main menu, hit "6" to jump to the advanced menu.**
Go Back / Cancel - Caps Lock
===================
CONSOLE REFERENCE
===================
Keys:
--------------------
Tab - Tab
** Note: The Tab key is your best friend when using bash. It will auto-complete file/directory names for you, or list out the possible choices if you double-tap it after entering a few letters.
SYM - Alt
Shift - Shift
OK - Control
Caps Lock - ESC
OK+Shift - Toggle Caps Lock
OK+SYM - Toggle Alt Lock
** Note: The LED beside the Caps Lock button will illuminate when either Caps Lock or Alt Lock is enabled.
OK+Backspace - Force exit
OK+A - Home
OK+E - End
OK+C - Stop current process, ie: if a program you are running chokes up.
=========================
bash Commands:
--------------------
Here are a few of the more useful bash commands that you will use:
===========
ls, ls -a, ls -l, ll
===========
Code:
/ {}$ ls
- "ls" lists the files and directories within the current directory.
- You can also add a path after it to look for certain files or directories.
Code:
/ {}$ ls -a
- "ls -a" will list all files and directories, including hidden ones starting with a ".", ie: .bashrc in /cache/.safestrap/home. (The bash startup script).
Code:
/ {}$ ls -l
- "ls -l" will do a long listing, showing permissions, file sizes, etc.
Now, instead of using those parameters, I've made aliases within the .bashrc script so you will probably just want to type:
Code:
/ {}$ ll
- "ll" is an alias for "ls -a -l", so it will list all files/directories, hidden or not and list their properties.
Code:
/ {}$ ll
- By putting a path after "ll", it will single out the file. Add a "*" in there to act as a wildcard to list multiple files with the same first few characters.
- ie: "ll /system/lib/libc*" would display all the files and directories starting with "libc" within /system/lib as well as their properties.
========
cd
========
Code:
/ {}$ cd (path)
- Change directory. Pretty self-explanatory. Try doing:
Code:
/ {}$ cd ~/
- This takes you to the home folder. Pretty useless here but this is usually pretty handy in other scenarios.
Code:
/ {}$ cd ../
- Using "../" as your target will cause you to drop down a single directory in the tree.
**** Don't forget to hit tab to auto-complete directory/file names for you whenever you've already entered the first few characters. More accurate and much less typing. ****
=======
mv
=======
Code:
/ {}$ mv (source) (destination)
- "mv" is short for move. The source is the path to the file/directory you want to move, and I don't think i need to tell you what the destination is.
=======
rm
=======
Code:
/ {}$ rm (-r -f) (target)
- "rm" is used to delete the targetted files.
- "-r" means to recurse, or go into every inner directory automatically, erasing as it goes.
- You'll use the -r flag a lot, because you can't delete directories without it unless you use "rmdir", which is just more typing.
"-f" means force in case of permission errors, as long as you are root.
========
cp
========
Code:
/ {}$ cp (-f -a) (source) (destination)
- Copy the source file or directory to the destination.
- Use "-f" to force the copying, in the event of a potential overwrite.
- Use "-a" to maintain permissions of the original, you'll want to use this whenever you are copying anything important. I just use it all the time, but sometimes it won't work, such as when copying from an /sdcard to either the /system or /data partition.
-This is because the file system of your /sdcard doesn't care about permissions.
=========================
============
[VIM REFERENCE]|
============
Vim deserves, and has, entire websites devoted to it's use. Here are some of the basics.
------------
Using Vim|
------------
From the console, simply type:
Code:
/ {}$ vim
Where is obviously replaced by the name of the file you are editing.
Multiple files can be opened at once by just adding them as parameters to vim:
Code:
/ {}$ vim file1 file2 file3 file4 filen
---------------
Insert Mode |
---------------
This is the mode you want to be in to make any visible changes to the file you are editing.
- Enter Insert Mode by pushing "i" when vim opens.
- Exit Insert Mode by pushing Capslock.
Keys:
------
Backspace - In insert mode, deletes the previous character.
Capslock - Exits insert mode
---------------
Visual mode |
---------------
By typing in "v" instead of "i", you will enter visual mode; this is Vim's fancy way of saying you will be selecting text.
Keys:
------
- Copy or Cut text by hitting "y" or "d" after you've made a selection
- Paste with "p" or "P" (that is, Shift+p). Shift-"p" puts the text before the cursor whereas plain lowercase "p" will paste it after.
- When you're done highlighting what you want to either cut or copy, just hit Capslock to go back to Command Mode.
-------------------
Command Mode |
-------------------
Vim starts out in Command mode. It seems confusing but once you get used to it, you can't help but hate Notepad.
Some of the more common commands are listed below.
Keys:
------
u - Undo
Shift+r (Usually denoted as R) - Enter Replace Mode, where you are replacing text instead of inserting it.
[#]yy - Yank (copy) the current line if you just entered "yy", or copy "#" lines if you enter #yy, ie: 5yy to copy 5 lines.
[#]dd - Delete (cut) the current line, or delete # lines if preceded by a #.
p - Pastes after the cursor
Shift+p (usually denoted as P) - Pastes before the cursor
:[#] - (Ignore the square brackets; a colon followed by a number goes to that particular line in the text file you are editing. eg: ":5" goes to line 5. (Obviously, don't type the quotation marks in.)
Note: - If you are in Insert mode, you will have to push Capslock to exit and be allowed to enter Command Mode by entering a ":"
- It's fairly common practice to just hit Capslock twice whenever you're done inserting so that you are sure to be able to hit ":" and proceed to enter another command.
:w - Write (save) the currently open file.
:q - Quit. If you haven't saved since making any changes, it will prompt you to either save your changes or append a "!" after "q" to quit without saving. (See below)
:q! - Force quit without saving.
:wq - Save and then quit.
:e [path to filename] Opens up another file; you can use bash command-line completion to scan the current directory, or otherwise just enter another path.
:next or rev - Aptly named, move to the next or previous file if you opened vim with two or more files as parameters, ie:
Code:
/ {}$ vim file1 file2
:/[text] - Search for "text". ie: ":/search" will find instances of the text "search" in the current file and highlight them.
Note: You need to make sure you are aware of regular expressions/escape characters before using this reliably; it's not broken if you can't seem to search for a quotation mark or other special characters, you need to precede them by a \. ie: to look for a double-quote symbol " you would enter :/\". The \ tells it that the next character is meant to be taken literally and not symbolically.
:/[text]/[moretext]/gc - Replace "text" with "moretext" everywhere in the file and ask confirmation for each change. If you forget to type in the "gc" at the end, it'll just replace everywhere without asking you for confirmation.
That's all I'm going to put here. There are tons of guide out there and I've already preloaded a pretty awesome configuration (.vimrc located at /cache/.safestrap/home) and runtime files. If you want to quickly access the configuration file, you can type ",,e" in Command Mode and it will automatically pop open.
================
COLOR CHANGING
================
1. If you want to change the color scheme, you need to figure out what the RGB code for the color you want is. Here's a website that provides a large table of colors and their corresponding RGB color code:
http://web.njit.edu/~kevin/rgb.txt.html
For example, let's say we like the "SlateGray4" color from the table linked above want to use it for the menus in both Safe and Non-Safe mode. As you can see, in the "R;G;B; Dec" column, the three codes we are interested in are 108, 123 and 139.
2. Now that you know the color codes, in our case 108, 123 and 139, we simply do the following:
a) Push 7 from the main menu, or scroll down and select "console menu".
b) Push 1, or scroll down and select "open console"
(Don't panic if it takes a few seconds to load the console; on the first initialization or after wiping the /cache partition, it will take a few seconds to reconfigure itself.)
c) At the prompt, enter the following:
Code:
/ {}$ ns_rgb 108 123 139
/ {}$ s_rgb 108 129 139
/ {}$ cc
/ {}$ exit
Now, it'll take another second or two and when the menu pops back up, you'll see that it is the color we chose from the table. The "ns_rgb" command takes three parameters, each of which correspond to the R, G and B values of the color code, and uses them for the "Non-Safe" (hence the "ns") menu color.
Similarly, the "s_rgb" command, (well technically, it's a bash function but anyways...) takes the same three parameters. It is applied to the "Safe" menu color.
The "cc" command actually sets the color, so don't forget to enter it. Otherwise, you won't notice a change when you exit out from the console.
Feel free to experiment with different colors! If you don't what you've done and just want to reset it back to the way it way, just wipe the cache partition:
a) Push 3, or scroll down to "wipe menu".
b) Push 1, or just hit Enter on "wipe cache".
c) Confirm your selection by pushing 8 or scrolling down and selecting "yes - wipe cache".
=================================================
More to come as I have more time.
Awesome, just a couple questions:
1) where is the dropbox download
2) if I already have the hashcode safestrap installed, how does one install yours? And what happens if I am already running a custom ROM?
Sent from my XT894 running ICS
Good call, I should make that clear.
Make sure you uninstall Hashcode's Safestrap, both inside the app and from the Android Settings menu before you install this .APK.
- download the pimped apk, uninstalled safestrap recovery, uninstalled old safestrap
- installed pimped safestrap, install new safestrap recovery, reboot
looks fine
anyone who restorerd a full backup of ics leak with safestrap 2.0?
friend got a problem, and system was unbootable and lost root....
Yeah, I've done it about four times today. No problems using either my modified version or Hashcode's original Safestrap v2.00.
It was no problem recovering from a busted /system partition either; just fastbooted the /system and /preinstall partitions only from the .219 leak, then rebooted the phone into the stock recovery and re-applied the .208 leaked update .zip file. Re-rooted with the technique I posted the other day without a hitch.
Didn't even lose any data...
Rick#2 said:
Yeah, I've done it about four times today. No problems using either my modified version or Hashcode's original Safestrap v2.00.
It was no problem recovering from a busted /system partition either; just fastbooted the /system and /preinstall partitions only from the .219 leak, then rebooted the phone into the stock recovery and re-applied the .208 leaked update .zip file. Re-rooted with the technique I posted the other day without a hitch.
Didn't even lose any data...
Click to expand...
Click to collapse
I mean full restore in safestrap, not advanced restore.
After restore from systemorig cames an "error while restoring systemorig!" And system damage.
...Tapatalk
Rennert said:
I mean full restore in safestrap, not advanced restore.
After restore from systemorig cames an "error while restoring systemorig!" And system damage.
...Tapatalk
Click to expand...
Click to collapse
I'm not following you here, this happened to you using my version?
I've done it countless times while testing this before I released it and have been working with this code for a long time; it's pretty foolproof.
Rick#2 said:
I'm not following you here, this happened to you using my version?
I've done it countless times while testing this before I released it and have been working with this code for a long time; it's pretty foolproof.
Click to expand...
Click to collapse
No, this was tested with hashcodes safestrap. Restore in your version doesn't tested, but not need at time;-)
...Tapatalk
Having some issues with getting safestrap installed in the 208 ICS leak. The app installs fine, click install and it says install complete, but I have no safestrap. Even after a reboot it still says "Not Installed" in the safestrap app. Anyone else experiencing this issue?
Sent from my DROID4 using Tapatalk
jgardner said:
Having some issues with getting safestrap installed in the 208 ICS leak. The app installs fine, click install and it says install complete, but I have no safestrap. Even after a reboot it still says "Not Installed" in the safestrap app. Anyone else experiencing this issue?
Sent from my DROID4 using Tapatalk
Click to expand...
Click to collapse
make sure u installed/updated busybox
That was exactly it. Realized shortly after posting it. Thanks!
Sent from my DROID4 using Tapatalk
So I have tried to restore 2 different backups using your safestrap and I keep on getting MD5 mismatch errors. I have tried deleting and regenerating the checksum file via ADB, disabled signature check, changed the folder name, pretty much everything I could think of. So whats going on?
An MD5 error would indicate that your backup files don't match the checksum that was generated at the time the backups were initially generated, which most likely means that your backup files may have become corrupted... unfortunately, this can happen with any files stored on an SD card.
Don't worry too much though, there still a really good chance that you can manually restore your data, although if your MD5's aren't matching there's a tiny possibility that your backup files are toast.
*** I'll assume you are trying to restore a "safe" system backup. If it's a "non-safe" backup, then just interchange "/systemorig" and "non-safe" for "/system" and "safe", respectively. ***
You have to manually wipe your /data and /cache partitions in the wipe menu, then format "/system" in the mounts menu. This way you have a clean slate to extract your backups to.
Try this from within the console in the recovery. (Depending on whether you backed up to the internal (/emmc) or external (/sdcard) card, just mount the required partition as follows:
*** Don't worry if you get a message saying the device can't mount because it is busy, that just means it's already mounted. ***
Internal card:
Code:
{}$: mount /emmc
External card:
Code:
{}$: mount /sdcard
(To be sure, it won't hurt if you just mount both of them.)
I'll assume you used the external sdcard which is mounted at /sdcard. Now:
Code:
{}$: cd /sdcard/safestrap/backup
If you list this directory (using "ll", or "ls -l"), you'll see a list of backup directories, prefixed by either "safe" or "nonsafe" and followed by the date and time of the backup. Remember, you can use the Tab key to autocomplete file/directory names so you don't have to type in the entire path. Here's an example:
Code:
/sdcard/safestrap/backup {}$ ll
total 192
d---rwxr-x 6 1000 1015 32768 Jun 24 04:42 ./
d---rwxr-x 3 1000 1015 32768 Jun 6 04:41 ../
d---rwxr-x 5 1000 1015 32768 Jun 6 04:41 nonsafe-2012-05-25.19.22.55/
d---rwxr-x 2 1000 1015 32768 Jun 8 20:42 nonsafe-2012-06-08.13.35.00/
d---rwxr-x 2 1000 1015 32768 Jun 20 03:13 safe-2012-06-19.20.10.44/
d---rwxr-x 3 1000 1015 32768 Jun 24 13:17 safe-2012-06-23.16.25.49/
/sdcard/safestrap/backup {}$
Let's use "safe-2012-06-19.20.10.44" for my example, substitute your own directory name as I'm sure it'll be different.
Go ahead and list the contents by entering the next two commands:
Code:
/sdcard/safestrap/backup {}$: cd safe-2012-06-19.20.10.44
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$: ll
You should see something like:
Code:
/sdcard/safestrap/backup {}$: cd safe-2012-06-19.20.10.44
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ ll
total 1117760
d---rwxr-x 2 1000 1015 32768 Jun 20 03:13 ./
d---rwxr-x 6 1000 1015 32768 Jun 24 04:42 ../
----rwxr-x 1 1000 1015 74135552 Jun 20 03:13 cache.ext3.tar*
----rwxr-x 1 1000 1015 225547776 Jun 20 03:12 data.ext3.tar*
----rwxr-x 1 1000 1015 201 Jun 20 03:13 nandroid.md5*
----rwxr-x 1 1000 1015 280272384 Jun 20 03:12 system.ext3.tar*
----rwxr-x 1 1000 1015 564430848 Jun 20 03:11 systemorig.ext3.tar*
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$
Now that you're at the proper path for the backup you want to restore, we can manually extract the files from the backups. (If you haven't already done so, remember to wipe /data, /cache and /system.)
We have to mount /system, /data and /cache:
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ mount /system
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ mount /data
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ mount /cache
*** Don't worry if you get a message saying the device can't mount because it is busy, that just means it's already mounted. ***
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ tar xvf system.ext3.tar -C /
Wait a minute or two for it to finish, then:
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ tar xvf data.ext3.tar -C /
Wait some more... then:
Code:
/sdcard/safestrap/backup/safe-2012-06-19.20.10.44 {}$ tar xvf cache.ext3.tar -C /
Done. If you want, you can restore your /systemorig partition now but you probably don't want to do that, not if your MD5's don't match up.
Assuming you just restored a "safe" system backup and you are in "safe" mode, you can cross your fingers and reboot. If you aren't in safe mode, switch over to it from the safe-boot menu before you reboot.
At this point, you should have restored that backup manually. Hope that helps, it's always a bummer to lose your data.
You sir need a medal. That was the best response I could have expected. I will try this later at work. I regenerated the checksum file but like you said, it has to be at the time of the backup.
Hey man, no prob. I figure I might as well do it step by step so that others can reference this in the event of a similar situation. Hope it works out for you.
To be honest, I got frustrated and gave up. I have discovered that on the 7-4 AOKP build, if I lose data all I have to do is wipe cache and dalvik cache and boom, I have have 4G. Now if only I can get a init.d tweak to clear both on startup then all I would have to do is reboot the phone to restore data. So long story short, I'm sticking with the non ICS-Leak AOKP, no need to risk going off the upgrade path and alot less of a hassle.
@Rick#2
new Safestrap 2.10 for Droid4 is out, can you pimp this one too?

Install ADB on Windows & ubuntu 12.04 or 12.10

If you need to flash ROM even using fastboot for Smartphone or Tablet in which they use Android OS! Then Ubuntu OS is needed!
This is a guide I made for ubuntu users and included a guide for windows users to setup Android SDK which contains ADB.
Android Debug Bridge (ADB) provides a terminal interface on your PC to interact with your device's file system. This can be useful for many things like installing & uninstalling apps, logcat, backup & restore, and hacking your device just to name a few.
ubuntu 12.04 & 12.10 Guide
1. Go here and download android-sdk (not the adt-bundle)....
https://hotfile.com/dl/241406263/5e6a306/android-sdk_r22.0.5-linux.tgz.html
2. Place the downloaded file in your home folder and then extract it and you should get a folder named android-sdk-linux (do not rename it).
3. If you’re on a 64bit machine run these commands in terminal to make sdk compatible with 64bit (if you’re on 32bit machine then skip this step)....
sudo apt-get update
sudo apt-get install ia32-libs-multiarch
4. Run this command in terminal to install jdk if you don’t have it already....
sudo apt-get install openjdk-6-jdk
5. Navigate to the home folder where you extracted android-sdk-linux and open the folder then open the folder named tools
6. Inside the tools folder there will be a file named android... double click it and select run then android sdk manager will open.
7. In the center pane deselect everything... Now only select the following....
Android SDK Tools
Android SDK Platform-tools
Android Support Library
8. Once selections have been made click on install packages and wait till finished.
9. Upon completion of step 8 in terminal run this command....
sudo gedit ~/.bashrc
When the file opens, go to the very bottom and copy/paste the following 3 lines (make sure they’re each on separate lines)....
# Android tools
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
10. Now reboot your computer.
11. Set your phone to usb debugging then plug it to your pc after pc is done booting
12. Open a terminal on your pc and enter....
adb devices
If all went well, you should see your phone’s serial number and you’ll be ready to go.
~~~~~Important~~~~~
You can use steps 5 & 6 to open Android SDK Manager & update your ADB/SDK installation. Only select your installed packages then update.
Also if you only need the fastboot/adbtools:
sudo add-apt-repository -y ppa: phablet-team/tools
Note: delete the space after"-y ppa:" -xda creates smileys like ppa
sudo apt-get update
sudo apt-get install -y phablet-tools
Sent from my Nexus 4 using xda app-developers app
Thank...
gazhead said:
Also if you only need the fastboot/adbtools:
sudo add-apt-repository -y ppa: phablet-team/tools
Note: delete the space after"-y ppa:" -xda creates smileys like ppa
sudo apt-get update
sudo apt-get install -y phablet-tools
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
Thanks man! It's also good way!
Followed this guide (thank you for posting) but couldn't connect. Scratched around and found I needed to create a new file in /etc/udev/rules.d with:
Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="<4-char_verndorID>", ATTR{idProduct}=="4-char_productID", MODE="0666", OWNER="username"
Followed by:
Code:
sudo restart udev
Then plugged device in and it worked!
qtoon said:
Followed this guide (thank you for posting) but couldn't connect. Scratched around and found I needed to create a new file in /etc/udev/rules.d with:
Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="<4-char_verndorID>", ATTR{idProduct}=="4-char_productID", MODE="0666", OWNER="username"
Followed by:
Code:
sudo restart udev
Then plugged device in and it worked!
Click to expand...
Click to collapse
What did you name the new file you created? Or did you add this string to another existing file from the rules.d directory? I'm not sure what I've done wrong, but I get
Code:
[email protected]:~$ adb devices
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'dab' from package 'bsdgames' (universe)
Command 'zdb' from package 'zfs-fuse' (universe)
Command 'kdb' from package 'elektra-bin' (universe)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'jdb' from package 'openjdk-7-jdk' (universe)
Command 'ab' from package 'apache2-utils' (main)
Command 'ad' from package 'netatalk' (universe)
adb: command not found
[email protected]:~$
This is after following each step, adding the three lines to the end of .bashrc and rebooting.
atmu5fear said:
What did you name the new file you created? Or did you add this string to another existing file from the rules.d directory? I'm not sure what I've done wrong, but I get
Code:
[email protected]:~$ adb devices
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'dab' from package 'bsdgames' (universe)
Command 'zdb' from package 'zfs-fuse' (universe)
Command 'kdb' from package 'elektra-bin' (universe)
Command 'tdb' from package 'tads2-dev' (multiverse)
Command 'pdb' from package 'python' (main)
Command 'jdb' from package 'openjdk-6-jdk' (main)
Command 'jdb' from package 'openjdk-7-jdk' (universe)
Command 'ab' from package 'apache2-utils' (main)
Command 'ad' from package 'netatalk' (universe)
adb: command not found
[email protected]:~$
This is after following each step, adding the three lines to the end of .bashrc and rebooting.
Click to expand...
Click to collapse
@atmu5fear, inferring that you're new to Linux (a common background for all), some notes:
Unlike wlth Win-d'oh-s, there is a worldwide development community that's always working toward improvement of every aspect of the system, including echoed messages and documentation. You may have to shake off the tendency to ignore Windudz messages, which are frequently unhelpful. Linux command echoes are much more on-target. Also, look for files such as README in rules.d and read it!
Now before creating a new config file (which may not be necessary on your system), see the top feedback line: "No command 'adb' found." First, see that the adb binary is present and that it has exec permission. (Since it's a small file and functions alone, I prefer to copy it to the folder I'm working from.)
If it then runs but won't connect, read on...
Directory (or "folder") names with a trailing '.d' are special: They configure, control, or provide executables for daemons (programs which run continuously, providing a service).
Within service-config.d folders, if the service steps through the files sequentially (as in this case), then it does so based on each filename. (True except for the special case of rc.d, iIRC, in which order is set by the special program rcorder).
So in this case, for example, since the existing files are named 70-whatever, your newly-created file could be 80-atmu5fears-phone to load after the others.
Should connect.
qtoon said:
@atmu5fear, inferring that you're new to Linux (a common background for all), some notes:
Unlike wlth Win-d'oh-s, there is a worldwide development community that's always working toward improvement of every aspect of the system, including echoed messages and documentation. You may have to shake off the tendency to ignore Windudz messages, which are frequently unhelpful. Linux command echoes are much more on-target. Also, look for files such as README in rules.d and read it!
Now before creating a new config file (which may not be necessary on your system), see the top feedback line: "No command 'adb' found." First, see that the adb binary is present and that it has exec permission. (Since it's a small file and functions alone, I prefer to copy it to the folder I'm working from.)
If it then runs but won't connect, read on...
Directory (or "folder") names with a trailing '.d' are special: They configure, control, or provide executables for daemons (programs which run continuously, providing a service).
Within service-config.d folders, if the service steps through the files sequentially (as in this case), then it does so based on each filename. (True except for the special case of rc.d, iIRC, in which order is set by the special program rcorder).
So in this case, for example, since the existing files are named 70-whatever, your newly-created file could be 80-atmu5fears-phone to load after the others.
Should connect.
Click to expand...
Click to collapse
Thanks @qtoon for the reply. I'm not really new to Ubuntu, albeit, it's been a while. First started using it just prior to the realease of Hardy Heron 8.04 LTS. That being said I am certainly no expert, but am somewhat familiar and comfortable with the command line. I did read the README file before posting, but since I'm not all that familiar with configuration files and the like, I figured maybe I should ask.
As per your suggestion i moved the ADB binary to my home folder, not necessarily my working folder, but to test to see if the adb command would be recognized in terminal.
Code:
mv ~/ADB/android-sdk-linux/platform-tools/adb ~/
Still got same result so I moved it back, then went on to make a new file and add the suggested string
Code:
sudo > /etc/udev/rules.d/80-atmu5fear-adb
sudo gedit /etc/udev/rules.d/80-atmu5fear-adb
After saving and restarting udev I still get the same "adb command not found" error.
I then changed the string to read OWNER"atmu5fear" instead of "username", still nothing
Any more suggestions?
Thanks
atmu5fear
Sorted it out
instead of:
adb devices
i needed to input:
./adb devices
It's listed, and in order to use the adb shell:
./adb shell
once in the shell all adb commands work
I get this error...
[email protected]:~$ sudo > /etc/udev/rules.d/80-sjy-phone
bash: /etc/udev/rules.d/80-sjy-phone: Permission denied
ok....... didn't need to add a file, changed phone usb mode to media device and all is ok.
thanks
atmu5fear said:
Sorted it out
instead of:
adb devices
i needed to input:
./adb devices
It's listed, and in order to use the adb shell:
./adb shell
once in the shell all adb commands work
Click to expand...
Click to collapse
Didn't think to mention that, apologies.
Quick 'why' on the ./ here.
Glad you got it running.
Just tried on 14.4 and worked like a charm.
Note: No need to reboot the computer, just reload the bash config with
Code:
source ~/.bashrc
Thanks
A good step by step guide
i will try it and see if it works
Thanks again
Hello, can someone help me ? - I m having problems connecting my device with adb (I ve connected several other devices before with no problems).
I ve got an Allwinner A20 tv box, it worked fine for a few months then one day, after being on (but idle) for a few hours, I noticed the screen was blank but the light on the front was blue (indicating it was on, red is standby). It would not respond to the remote control or to anything, so I unplugged it and since then it will not boot and the screen is blank, the red light will light up but that is it. I ve eliminated the remote controller not working, but I cant boot the device.
So I ve tried connecting via ADB (with Ubuntu) but I cant get the device to show up after typing "adb devices".
Using this guide:
http://androidonlinux.wordpress.com/2013/05/12/setting-up-adb-on-linux/
I can get the vendor id and device id and I ve added it and the manufacturer to udev/modeswitch devices, but when I type "sudo usb_modeswitch -v 0x1f3a -p 0xefe8 -S -R -W"
I get the following error:
~/Android/sdk/platform-tools$ sudo usb_modeswitch -v 0x1f3a -p 0xefe8 -S -R -W
Take all parameters from the command line
* usb_modeswitch: handle USB devices with multiple modes
* Version 2.1.1 (C) Josua Dietze 2014
* Based on libusb1/libusbx
! PLEASE REPORT NEW CONFIGURATIONS !
DefaultVendor= 0x1f3a
DefaultProduct= 0xefe8
SierraMode=1
NeedResponse=0
Look for default devices ...
found USB ID 048d:1336
found USB ID 1d6b:0002
found USB ID 19a8:2036
found USB ID 1f3a:efe8
vendor ID matched
product ID matched
found USB ID 1d6b:0001
found USB ID 062a:0102
found USB ID 1d6b:0001
Found devices in default mode (1)
Access device 004 on bus 003
Current configuration number is 1
Use interface number 0
USB description data (for identification)
-------------------------
Manufacturer: not provided
Product: not provided
Serial No.: not provided
-------------------------
Send Sierra control message
Error: Sierra control message failed (error -7). Abort
I ve searched Google for the error code but I cannot find anything.
The device was rooted and USB debugging was on.
Any help would really be appreciated.
Thanks

Getting rid of the emulated CD drive and unknown devices in MTP mode [Partial Fix]

When you connect your MIUI device to the computer through USB in File Transfer (MTP) mode (that is, not in Photo Transfer), it also emulates a CD-ROM drive. The ISO image for the fake CD contains a copy of Mi Assistant, a device management tool for the PC, which is in Chinese only and can be downloaded from the Internet anyway. Basically, it's all useless and mildly annoying.
View attachment 3137500
Here's what you need to do to get rid of it:
Step 1. Edit /system/build.prop and add the line:
Code:
persist.service.cdrom.enable=0
Step 2. Edit /init.qcom.usb.rc and where it says:
Code:
on property:sys.usb.config=mtp
(a) Change the first line to remove mention of mass_storage (this is for the CD only):
Code:
write /sys/class/android_usb/android0/functions mtp
(b) Remove these two lines:
Code:
write /sys/class/android_usb/android0/f_mass_storage/lun/ro 1
write /sys/class/android_usb/android0/f_mass_storage/lun/file /data/miui/cdrom_install.iso
Similarly, where it says:
Code:
on property:sys.usb.config=mtp,adb
(a) Change the first line after the above to:
Code:
write /sys/class/android_usb/android0/functions mtp,adb
(b) Remove these two lines:
Code:
write /sys/class/android_usb/android0/f_mass_storage/lun/ro 1
write /sys/class/android_usb/android0/f_mass_storage/lun/file /data/miui/cdrom_install.iso
Step 3. Delete the ISO image file to free up some space.
File location: /data/miui/cdrom_install.iso
And here's how to do it:
Using Android Debug Bridge from the command line:
Code:
adb root
adb shell "mount -o remount,rw /system"
adb shell "echo persist.service.cdrom.enable=0 >>/system/build.prop"
adb pull /init.qcom.usb.rc
Now use your favorite editor to make changes as described above in step 2.
Code:
adb push init.qcom.usb.rc /
adb shell "mount -o remount,ro /system"
adb shell "rm -f /data/miui/cdrom_install.iso"
adb reboot
Using ES File Explorer:
Download from Play Store or the developer's website. Install. Open. In context menu (hold leftmost button for 1 second), switch Root Explorer to On (this will fail). Go back to the home screen. Open Security, Permissions, Root Access. Put the switch next to ES File Explorer to On. Now you can switch back to ES File Explorer, and follow the steps 1-3 above. Use the built-in editor the make changes in the files.
Unknown USB devices when connected in MTP mode
When your device is connected in MTP mode (File Transfer) there are 3 unrecognized USB devices. To check if you have them too, go to Control Panel and choose Device Manager or run mmc devmgmt.msc from the command line (screenshot 1). The devices appear to have no hardware IDs (screenshot 2) and their class number seems to be {c897b31c-e8d2-59e9-a212-ccf0962fe102} (full registry dump provided as attachment).
View attachment 3137478 View attachment 3137479
This problem appears to be caused by the CD-ROM emulation as well: the number of devices will actually increase to 4 when it's switched off following the instructions above, which means there must be one extra step to get rid of it completely. This doesn't seem to cause any problems and the issue appears to be purely cosmetic. If I have time to investigate it further, I will report the conclusions back here. Meanwhile, if anyone has an idea what the cause is, please feel free to share it (might also be a driver issue).
Disclaimer: there might be some mistakes in what I wrote. Please use at your own discretion. This should work with a "developer" stock ROM out of the box, otherwise you'll need to set-up root access first.
Update for a total fix, and a more elegant approach
So the missing link to make the mysterious devices disappear is to edit /init.qcom.usb.rc and where it says:
Code:
case "$cdromenable" in
0)
Comment out (put the # sign) in front of:
Code:
#echo "" > /sys/class/android_usb/android0/f_mass_storage/lun0/file
The best way to make the whole change seems to be to unpack boot.img, for example with Android Image Kitchen, apply the patches (diffs attached), rebuild the image, and flash it. The persist.service.cdrom.enable=0 property can be set in /default.prop so that all the changes are contained within the boot image. In summary:
Code:
unpackimg boot.img
echo "persist.service.cdrom.enable=0" >>ramdisk/default.prop
patch ramdisk/init.qcom.usb.rc < init.qcom.usb.rc.diff
patch ramdisk/init.qcom.usb.sh < init.qcom.usb.sh.diff
repackimg
cleanup
adb reboot bootloader
fastboot erase boot
fastboot flash boot image-new.img
fastboot reboot
@ Aqq123 thanks for the write up, I have a Mi 4C and the iso file is not in /data/miui/ but it still shows up when connecting to pc

updown: remap hardware keys with root or adb wifi and Tasker

I really wanted to remap volume keys to page up and down in Chrome. I couldn't figure out how to do it well with existing tools (e.g., any tool using input keyevent will have an unavoidable lag), so I ended up writing an input remapper commandline tool which can be dropped to /data/local/tmp/ and activated either via a root shell or adb in Tasker for whatever apps you want it. And while I was at it, I made the tool more general, so you can use it to do whatever other remappings you want, or even to broadcast a Tasker intent (or run a shell script) on a hardware key.
The tool is only for people comfortable with commandline stuff.
My binaries are compiled for 64-bit arm. Get updown from: https://github.com/arpruss/updown
Installation:
Code:
adb push updown /data/local/tmp
adb shell chmod 755 /data/local/tmp/updown
Then to activate the volume to page up/down remap, do a root or adb wifi shell action that executes:
Code:
killall updown; /data/local/tmp/updown &
(Don't forget the ampersand to make updown run in the background.) Then when it's time to stop the remap:
Code:
killall updown
What I then did for my use was to run the activation command on entry into an app in Tasker and the killall on exit.
While the default remapping is for volume up/down, you can do various other remaps. For more information on the command-line parameters for updown, see: https://github.com/arpruss/updown/blob/main/README.md
(That said, I am not personally using updown with Tasker any more, since I have now made my xposed xupdown module work again with newer Androids.)
I recompiled it so it should work on both 32 and 64 bit devices.

Categories

Resources