copy system file without shell cp command - android
I need to read a 3rd party db file, so far i copyed the file to the sd card using shell su cp to copy the file to the sd card and read it from there using SQLiteDatabase
but on android 4.1.2 I get a message saying the cp command is missing, /system/bin dont have the file.
how can i read the 3rd patry application db?
I dont want to use busy box, it will drive many users away
I have those commands:
adb, am, app_process, applypatch, atrace, bcm4334.hcd, bcm4334_murata.hcd, bcm4334_semco.hcd, bcm_dut, bintvoutservice, bluetoothd, bmgr, bootanimation, brcm_patchram_plus, brcm_poke_helper, bu, bugreport, cat, chmod, chown, cmp, connfwexe, content, dalvikvm, date, dbus-daemon, dd, ddexe, ddexe_real, debuggerd, dexopt, df, dhcpcd, dmesg, dnsmasq, drmserver, dttexe, dumpstate, dumpsys, e2fsck, fsck.exfat, fsck_msdos, gbias, getevent, getprop, gps.cer, gpsd, gzip, hciattach, hd, hostapd, icd, id, ifconfig, iftop, ime, immvibed, input, insmod, installd, insthk, ioctl, ionice, ip, ip6tables, iptables, keystore, kiesexe, kill, linker, ln, log, logcat, logwrapper, lpmkey, ls, lsmod, lsof, macloader, make_ext4fs, mcDriverDaemon, md5, mdnsd, mediaserver, mfgloader, mkdir, mkfs.exfat, mksh, monkey, mount, mtpd, mv, nandread, ndc, netcfg, netd, netstat, newfs_msdos, notify, npsmobex, p2p_supplicant, pand, ping, playback, playlpm, pm, pppd, printenv, ps, racoon, reboot, renice, requestsync, rild, rm, rmdir, rmmod, route, run-as, samsungani, samsungpowersoundplay, schedtest, schedtop, scranton_RD, screencap, screenshot, sdcard, sdptool, sendevent, sensorservice, service, servicemanager, setconsole, setprop, setup_fs, sh, sleep, smd, smdexe, start, stop, surfaceflinger, svc, sync, system_server, tc, toolbox, top, touch, touchinput, uiautomator, umount, uptime, vdc, vmstat, vold, watchprops, wipe, wlandutservice, wpa_supplicant
Thank you
Try this
cat infile > outfile
Or
dd if=infile of=outfile
Related
How is SEAndroid process domain given
I've been looking on SEAndroid, and i've been trying to understand how is a process domain given. So far what i got is that in the init.rc file, under some of the services declaration, there is a token called seclabel: service adbd /sbin/adbd --root_seclabel=u:r:su:s0 class core socket adbd stream 660 system system disabled seclabel u:r:adbd:s0 Which later in init.c is being set by setexeccon to the context that was written: if (svc->seclabel) { if (is_selinux_enabled() > 0 && setexeccon(svc->seclabel) < 0) { ERROR("cannot setexeccon('%s'): %s\n", svc->seclabel, strerror(errno)); _exit(127); } } In the example above the domain will be adbd. But i didnt get to find what happens when there is no seclabel token in the service declaration. The thing that happens in init.c is that it will not call setexeccon, Meaning.. keep the parents domain? A call to: ps -Z in adb shell, which shows all the processes and their domains, shows otherwise. For example, the servicemanager in init.rc: class core user system group system critical onrestart restart healthd onrestart restart zygote onrestart restart media onrestart restart surfaceflinger onrestart restart drm but call to ps -Z shows: u:r:servicemanager:s0 system 53 1 /system/bin/servicemanager Whats going on?!
Ok, i looked at the code and finally got the answer! The file: /external/sepolicy/seapp_contexts found on the root file system in the android image includes the following content: isSystemServer=true domain=system_server user=system domain=system_app type=system_app_data_file user=bluetooth domain=bluetooth type=bluetooth_data_file user=nfc domain=nfc type=nfc_data_file user=radio domain=radio type=radio_data_file user=shared_relro domain=shared_relro user=shell domain=shell type=shell_data_file user=_isolated domain=isolated_app levelFrom=user user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user user=_app domain=untrusted_app type=app_data_file levelFrom=user This defines the security settings (outputs) for each process according to some inputs. We can see in this example in the first line: If its the system server, its domain will be system_server Or in the last line: The _app keyword stands for every app which doesn't have a rule associated to it. So by default, applications domain will be untrusted_app and the files belongs to it label will be app_data_file. More documentation on the syntax of the file is found inside the file.
Storing android adb shell screencap as variable
Making an app at the moment for my personal use (rooted) and it requires getting certain pixels colors from the screen. I was trying to accomplish this through the Runtime. Process p = Runtime.getRuntime().exec("screencap"); p.waitFor(); InputStream is = p.getInputStream() BitmapFactory.decodeStream(is); and I get factory returned null. but if I dump the process to my sd card through adb -d shell screencap /sdcard/ss.dump and access it from my app BitmapFactory.decodeFile("/sdcard/ss.dump"); all goes well. So it there anyway to dump the stream straight into BitmapFactory within my app? Thanks SO and please excuse the generally laziness/shortcuts of the example code.
This might help if not too far off your intended path. (I think you are using node / javascript). I spawned the ADB.EXE command producing a stream (and being 'jailed' on Windows the program must transform the stream to account for linefeed ending differences. So with that, I have working the following: exports.capture = function(filename) { // you'll need to map your requirement (decodeStream) instead // of streaming to a file var strm = fs.createWriteStream(path); var cv = new Convert(); cv.pipe(strm); var capture = spawn(cmd, args); capture.stdout.on('data', function(data) { cv.write(data); }); capture.stdout.on('exit', function(data) { cv.end(); }); } To explain the process, spawn is running the ADB command, on windows, CR-LF are inserted (being a PNG stream), and stream is chunked / piped through a fs-transformation. Others on the web have described the process as adb.exe shell screencap -p | sed 's/\r$//' > output.file. And it does work. To be clear the conversion is CR-CR-LF => LF for us window jailed birds. And if you don't want to implement a SED and not use javascript regular expressions converting binary->strings->binary, you may follow my path. There is probably a simpler way, I just don't know what it is... So, Convert() is an object with methods that converts the byte stream on the fly. See the codewind blog link is: http://codewinds.com/blog/2013-08-20-nodejs-transform-streams.html to build your convert.
When using screencap from inside an app you must use su, i.e. root. When you do this via adb it runs under a different user id, which has more permissions than a normal Android app. There are several examples how to use screencap, e.g. here.
Where does Android take default timezone from?
Where does Android device take default timezone from? Example - you boot a brand new Android device and there is Setup Wizard with "Date & time" activity where a default timezone is already selected (in my case http://en.wikipedia.org/wiki/Central_European_Time) - where it comes from?
It's a build flag that's baked into the ROM (it becomes a system property). It's in quite a few places so the easiest is to download the AOSP source and grep for: persist.sys.timezone A bit more info here: https://stackoverflow.com/search?q=persist.sys.timezone
Here is long post about the setting timezone. https://blog.csdn.net/victoryckl/article/details/7969433 It's in Chinese so use translate. Here is main points how to set locale and timezone The original android code, the system default language is English, generally need to be changed to the default Chinese, a lot of methods of modification: Modify the PRODUCT_LOCALES field, Put the language you want to choose first, such as: PRODUCT_LOCALES := en_US zh_CN The default language is English, copy it from build/target/product/sdk.mk and paste it into device/{hardware platform}/{product}. In mk, put zh_CN in the first place. Or paste directly into build/target/product/core.mk and all branches inherit this setting. Modify device/{hardware platform}/{product}/system.prop or default.prop and add: [persist.sys.language]: [zh] [persist.sys.country]: [CN] [persist.sys.localevar]: [] [persist.sys.timezone]: [Asia/Shanghai] [ro.product.locale.language]: [zh] [ro.product.locale.region]: [CN] Modify init.rc and add: Setprop persist.sys.language en Setprop persist.sys.country CN Setprop persist.sys.localevar Setprop persist.sys.timezone Asia/Shanghai Setprop ro.product.locale.language en Setprop ro.product.locale.region CN This method has a problem, because it will be executed every time you boot, so the language is the default language after each boot. Modify device/{hardware platform}/{product}/device.mk and add : PRODUCT_PROPERTY_OVERRIDES += \ Persist.sys.language=zh \ Persist.sys.country=CN \ Persist.sys.localevar= "" \ Persist.sys.timezone=Asia/Shanghai \ Ro.product.locale.language=zh \ Ro.product.locale.region=CN I am using the fourth. Note that the quotes above cannot be removed, otherwise the two lines will become one line in build.prop: Persist.sys.localevar= persist.sys.timezone=Asia/Shanghai This will result in the value of persist.sys.timezone not being obtained, and the time zone is still incorrect. Modify build/tools/buildinfo.sh: Echo "persist.sys.language=zh" Echo "persist.sys.country=CN" Echo " persist.sys.localevar= " Echo "persist.sys.timezone=Asia/Shanghai" Echo "ro.product.locale.language=zh" Echo "ro.product.locale.region=CN"
When you start a new phone with SIM card then based on the operator it automatically sets the locality in the phone. If it is using SIM data then based on the Telephony Manager API phone, automatically sets the current locality. Same way when your device is not having any SIM card but it is connected to any local WiFi then based on the Wifi Manager API it sets the Locality in the Phone automatically.
Finding right Android touchscreen driver file
My goal is to add a single printk command to one of the driver files for my phone's touchscreen. I would like to run this printk command everytime the screen recieves touch input. I found the list of touchscreen driver files shown below. I'm just hoping someone with some experience might be able to point me to the correct file to place this printk command. ad7877.c atmel_224e.c cy8ctmg110_ts.c gunze.c intel-mid-touch.c max11801_ts.c pcap_ts.c touchit213.c ucb1400_ts.c wm9712.c ad7879.c atmel_mxt_ts.c da9034-ts.c h3600_ts_input.c jornada720_ts.c mc13783_ts.c penmount.c touchright.c usbtouchscreen.c wm9713.c ad7879.h atmel_tsadcc.c dynapro.c hampshire.c Kconfig mcs5000_ts.c s3c2410_ts.c touchwin.c w90p910_ts.c wm97xx-core.c ad7879-i2c.c atmel-wm97xx.c eeti_ts.c hp680_ts_input.c lpc32xx_ts.c migor_ts.c st1232.c tps6507x-ts.c wacom_w8001.c zylonite-wm97xx.c ad7879-spi.c bu21013_ts.c elo.c htcpen.c mainstone-wm97xx.c mk712.c stmpe-ts.c tsc2005.c wm831x-ts.c
First Check the Driver file by using the following command on terminal: $logcat | grep EventHub You will find all the input devices (Including your touch driver) in the prints. Go to that file and add the print command in interrupt handler.
Try running the getevent command in a shell on the Android device. The touchscreen should be listed, and the name should be the driver being used. Here's what came up on my phone: add device 7: /dev/input/event1 name: "synaptics_dsx" This means my phone uses the synaptics_dsx touchscreen driver.
adb shell input unicode character
Knowing the basic key mappings described in ADB Shell Input Events I get the emulation of text input and special keys working quite well. But what about Unicode characters? For instance I want to use umlauts from the German QWERTZ keyboard layout. This gets me: $ adb shell input text ö Killed So it seems to crash and adb shell input text \xFC prints xFC on the input. I have tried to the the events with getevent but I haven't found a direct mapping, I've also looked into the keymapping file /system/usr/keylayout/Qwerty.kl I believe the only possibility is via the clipboard, but as pointed out in the question Pasting text into Android emulator clipboard using adb shell it seems to be unknown how to use it for Android Ice Cream Sandwich or later..
I wrote a virtual keyboard that accept broadcast intent, so you can send unicode characters to the editText view via adb. for e.g. adb shell am broadcast -a ADB_INPUT_TEXT --es msg "你好嗎! Hello!" Here is the github project: https://github.com/senzhk/ADBKeyBoard Hope this little project would help.
Actually ADBKeyBoard is very good! Thanks for Eric Tang ! Some useful extensions for comfortable usage: Switch to ADBKeyBoard from adb: adb shell ime set com.android.adbkeyboard/.AdbIME Check your available le virtual keyboards: ime list -a Use simple quote characters -not double as in example above- if your shell not accepts "!" (explanation sign) adb shell am broadcast -a ADB_INPUT_TEXT --es msg 'Accented characters here' Switch back to original virtual keyboard: (swype in my case...) adb shell ime set com.nuance.swype.dtc/com.nuance.swype.input.IME Use adb over wifi to simplify your life... :)
input won't work because it can only send single key event through the virtual keyboard (check the source code if you don't know what I mean). I think the only way left is using Instrumentation. I guess you can create a test for your Activity and then do something like this: final Instrumentation instrumentation = getInstrumentation(); final long downTime = SystemClock.uptimeMillis(); final long eventTime = SystemClock.uptimeMillis(); final KeyEvent altDown = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_GRAVE, 1, KeyEvent.META_ALT_LEFT_ON); final KeyEvent altUp = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_GRAVE, 1, KeyEvent.META_ALT_LEFT_ON); instrumentation.sendKeySync(altDown); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_A); instrumentation.sendKeySync(altUp); instrumentation.sendKeySync(altDown); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_E); instrumentation.sendKeySync(altUp); instrumentation.sendKeySync(altDown); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I); instrumentation.sendKeySync(altUp); instrumentation.sendKeySync(altDown); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_O); instrumentation.sendKeySync(altUp); instrumentation.sendKeySync(altDown); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_U); instrumentation.sendKeySync(altUp); This will send the modified keys: àèìòù update 2022 https://stackoverflow.com/a/71367206/236465 shows another solution using AndroidViewClient/culebra and CulebraTester2-public backend.