วันอังคารที่ 28 กรกฎาคม พ.ศ. 2558

adb shell command svc recovery segment


Using adb, I believe it is possible:
am [start|instrument]
am start [-a <action>] [-d ] [-t <mime_type>]
[-c <category> [-c <category>] ...]
[-e <extra_key> <extra_value> [-e <extra_key> <extra_value> ...]
[-n <component>] [-D] [<uri>]
am instrument [-e <arg_name> <arg_value>] [-p <prof_file>]
[-w] <component>
for example we have android program with Manifest as under:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.app1.android.xtract">
  <application android:icon="@drawable/icon">
   <activity class=".Contact" android:label="@string/app_name">
    <intent-filter>
    <action android:value="android.intent.action.MAIN" />
    <category android:value="android.intent.category.LAUNCHER" />
   </intent-filter>
  </activity>
 </application>
.
.
</manifest>
To run the code issue command like this (in one line):
am start -a android.intent.action.MAIN -n com.app1.android.xtract/com.app1.android.xtract.Contac
================= Rootless CLI Utilities
Do I have to root my android device to install command line utilities? I would really like to run Vim, among other programs on my phone. I have no reason not to root my phone, I just want to know if this is possible.
The Android Scripting seems to possibly have done this. Do I have to write my own Terminal app to be able to do this?
shareimprove this question

2 Answers

You don't need root. You also don't need a terminal, for an app to use its own private utilities. But if you want vim, Terminal IDE provides that, a number of other utilities (git, ssh, tmux), the ability to use bash or Java as a 'scripting language' at the terminal, and the ability to create and install Android apps on-device. I use Terminal IDE and vim quite a bit, (but with Better Terminal Emulator Pro's terminal, actually.)
shareimprove this answer
   
What's the correct way to run Terminal IDE's bash from "adb shell"? Running it manually "su; /data/data/com.spartacusrex.spartacuside/files/system/bin/bash" leaves a slightly broken env. –  stsquadApr 30 '12 at 16:53
Rooting your phone gives you root access (duh!), but that doesn't mean accessing a shell requires you to root your phone. You can use ADB to connect to your device and gain shell access.
You can also use ConnectBot to access your device's shell on the device itself.
This will give you normal access to your device and you will not be able to run su to gain root access. You can, however, modify and play with files to which you have access.
vim is available without root access, so, so far you still have no reason to root your phone.
shareimprove this answer
====================
You should be able to call the messaging intent with
am start -a android.intent.action.VIEW "sms:numberhere" -e "sms_body" "hello"
Using the intent command as described here:
============================

service list
1|root@android:/ # service list
service list
Found 63 services:
0       phone: [com.android.internal.telephony.ITelephony]
1       iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo]
2       simphonebook: [com.android.internal.telephony.IIccPhoneBook]
3       isms: [com.android.internal.telephony.ISms]
4       samplingprofiler: []
5       diskstats: []
6       appwidget: [com.android.internal.appwidget.IAppWidgetService]
am start -n android/com.android.server.ShutdownActivity   ปิด
#!/bin/sh
am broadcast android.intent.action.ACTION_SHUTDOWN
sleep(5)
reboot      คำสั่ง reboot
เปิด usb ด้วย am และ ส่ง keyevent 66 2 คร้ง
F:\sdk\platform-tools>adb shell am start -n com.android.systemui/.usb.UsbStorag
Activity
Starting: Intent { cmp=com.android.systemui/.usb.UsbStorageActivity }

F:\sdk\platform-tools>input keyevent 66
'input' is not recognized as an internal or external command,
operable program or batch file.

F:\sdk\platform-tools>adb shell input keyevent 66

F:\sdk\platform-tools>adb shell input keyevent 66
http://android.stackexchange.com/tags/command-line/hot

adb shell setprop sys.usb.config mass_storage   **คำสั่งนี้ ดีกว่า เปิด usb storage ได้
=========

root@android:/ # svc wifi enable
svc wifi enable
root@android:/ # svc wifi disable

root@android:/ # svc
svc
Available commands:
    help     Show information about the subcomma
    power    Control the power manager
    data     Control mobile data connectivity
    wifi     Control the Wi-Fi manager
root@android:/ # svc help

Control the power manager

usage: svc power stayon [true|false|usb|ac]
         Set the 'keep awake while plugged in' setting.


root@android:/ # svc data
svc data
Control mobile data connectivity

usage: svc data [enable|disable]
         Turn mobile data on or off.

       svc data prefer
          Set mobile as the preferred data network

=======================
recovery Segmentation fault
you can try running
$ strace recovery
and see if that gives any information on what is going on.
you can also try
c:/> adb reboot recovery
and see if that allows you to reboot.
shareimprove this answer

วันพุธที่ 22 กรกฎาคม พ.ศ. 2558

flash recovery Build_a_custom_recovery


http://www.addictivetips.com/mobile/how-to-flash-a-recovery-to-an-android-device-without-sd-card/

http://android-dls.com/wiki/index.php?title=Build_a_custom_recovery_image


============
https://knarrnia.wordpress.com/2011/02/02/cant-use-clockwork-after-t-mobiles-2-2/

Can’t Use Clockwork After T-Mobile’s 2.2?

So my wifes phone is fragged and I really hate to say it but I think running voodoo once to convert it to EXT4 and then undoing voodoo to convert it back to RFS is going to be the only way to fix it. RFS has a known problem with crosslinking and it’s just straight up garbage. In traditional tech fashion, cleaning up someone elses mess is typically an excersize in circumventing security and then hitting it. Samsung Galaxy S has a kernel backup and flasher app which lets you backup your kernel and apply whatever you want, but it doesn’t do much for applying voodoo. Running a voodoo kernel does you no good without the EXT4 conversion process. Therefor, we must use the appropriate clockwork to do the voodoo update process and… Clockwork doesn’t work!
I’ve run into problems with clockwork before and Jeeves, I know you read this, feel free to chime in with an alternate method. If you’re stuck not being able to apply update.zips and you know it’s a correctly signed zip, you need to change out your /system/bin/recovery executable. This process is the manual version of this process, and you must visit that post to grab the first 3e_recovery_installer.zip so you have a recovery to put out there. Nothing against untermensch for his writeup but I feel like the whole adb thing is a crutch for a real shell on these phones.
REQUIREMENTS: Busybox, connectbot, root. Two braincells to rub together.
Grab the recovery binary out of the zip linked to in that post. Put it on the root of your internal storage (the ~12GB one). Fire up connectbot and connect to localhost so you have a command line. Cut and paste the following:
su
mount -o remount rw /system
mv /system/bin/recovery /system/bin/recovery.original
cat /mnt/sdcard/recovery > /system/bin/recovery
chmod 755 /system/bin/recovery
mount -o remount ro /system
exit
Now you have 3E recovery (the correct version) and it accepts update.zip files. You can proceed with clockwork as normal. Now to streamline the voodoo process.
==============

How To Flash A Recovery To An Android Device Without SD Card


ClockworkMod RecoveryWe recently featured a method to flash a ROM to your Android device without an SD card and now, we are bringing you a method for similarly flashing a recovery to your Android phone without an SD card, which can come handy if your SD card has somehow gotten corrupted or lost and you need to flash a recovery to your phone.
Disclaimer: Please follow this guide at your own risk. AddictiveTips will not be liable if your device gets damaged or bricked during the process.
We have previously featured several recovery installation methods in our guide on how to install a custom recovery to your Android device. This method was shared with us by XDA-Developers forum memberStuke00 and is based on the same procedure we used in our guide on how to install a ROM to an Android device without an SD card. It adds yet another way to install a custom recovery to your phone.

Before You Begin
To gain a better understanding of what you are about to do, you are advised to go through our custom recovery installation guide and specifically the section on installing recovery via flash_image before you proceed. It also guides you through the requirements of flashing a recovery that you will need to fulfill before you can proceed with the method.
The Method
  1. Connect your phone to your computer via USB and make sure USB debugging mode is enabled.
  2. Follow the first four steps of the ‘With flash_image’ section of our custom recovery installation guide.
  3. Launch a Command Prompt/Terminal window on your computer and enter the following commands:
    adb remount
    adb shell
    adb push c:\flash_image /system/bin/flash_image
    adb shell chmod 0755 /system/bin/flash_image
    adb push c:\recovery.img /system/bin/
    adb shell
    flash_image recovery /system/bin/Recovery.img
    rm /system/bin/recovery.img
    This should flash the recovery image to your phone. Do not close the Command Prompt/Terminal window yet.
  4. To verify that the recovery has been installed correctly, use this command to boot into it:
    reboot recovery
    This will boot your phone into the newly installed recovery!

วันจันทร์ที่ 20 กรกฎาคม พ.ศ. 2558

adb fastboot

http://code.tutsplus.com/tutorials/android-adb-quick-guide--mobile-12456
มี monkey


http://www.droidforums.net/threads/how-to-root-without-using-adb.62450/

ADB Commands 
Quote:
adb devices - list all connected devices
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections forward specs are one of: tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data)
('-s' means install on SD card instead of internal storage)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specified device
adb remount - remounts the /system partition on the device read-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
< tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
< localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be updated.
- If it is "system" or "data", only the corresponding partition is updated.

environmental variables:
ADB_TRACE - Print debug information. A comma separated list of the following values
1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed
.

Fastboot Commands
Quote: Example (fastboot flash recovery TWRP-recovery.img) then hit enter this will flash a recovery image to the device.
usage: fastboot [ <option> ] <command>
commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
reboot reboot device normally
reboot-bootloader reboot device into bootloader
options:
-w erase userdata and cache
-s <serial number> specify device serial number
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default: 2048


http://techbeasts.com/2014/01/05/useful-adb-and-fastboot-commands-and-how-to-them/

Useful ADB and Fastboot Commands and How to Use them


ADB an official tool by Google – you must have heard of it if you have ever  come across Android development or flashing processes. Stands for Android Debug Bridge basically and helps you to establish a connection and communicate between your phone and your computer. ADB has a command line interface, which helps the developers / programmers / users to enter commands and do the stuff they want. ADB also plays an important role when you don’t have access to certain things on your phone, you can simply handle the problem through the command window.
Earlier we posted a guide on “How to Install and Use Android ADB & Fastboot” but missed the important ADB commands that may become handy in some cases, and found necessary to cover them now. In case you’re wondering about Fastboot, it’s a component of ADB that helps you to flash files or make tweaks by accessing Fastboot mode on your device. Well, let’s get back to the topic. In the following post I’ve listed the useful ADB commands, and also explained their use.?????????????
You may want to install Android ADB and Fastboot, and also learn how to use the program actually please go through this guide:

How to Install Android Adb & Fastboot Drivers on Your Windows PC [Guide]


Let’s move forward to the useful commands:
CommandsUse
Basic ADB Commands
adb devicesShows a list of devices attached to the computer.
adb rebootReboots a device connected to the PC.
adb reboot recoveryReboots a device into recovery mode.
adb reboot downloadReboots the connected device into download mode. E.G Download mode on Samsung Galaxy devices.
adb reboot bootloaderReboots a device into Bootloader. Once in Bootloader, you can make further selections here.
adb reboot fastbootReboots a connected device into Fastboot mode.
Installing / Uninstalling / Updating Apps with ADB. 
adb install <ApplicationpathPackagename>.apkADB install let’s you install APK files directly to your phone. To use this command type adb install application path, as shown in the commands part and hit enter key and it will start installing the app on your phone. e.g adb install C:/Users/UsamaM/Desktop/CandyCrushSaga.apk. If process succeeds it will show you “Success” in the command window.
adb install -r <AplicationpathPackagename>.apk
 If you have already installed an app, and you just want to update it then this command will let you do so. e.g adb install -r C:/Users/UsamaM/Desktop/CandyCrushSaga.apk
adb unistall package_namee.g
adb uninstall com.android.chrome
Uninstalls and application from your device. The easiest way to find a package name is, install Package Name Viewer from the play store and find the name of the package under the App Name. If process succeeds it will show you “Success” in the command window.
adb uninstall -K package_namee.g
adb uninstall -K com.android.chrome
Uninstall an app but keeps it’s data and cache directories. If process succeeds it will show you “Success” in the command window.
 Push and Pull files 
 adb rootadb push >e.gadb push c:\users\UsamaM\desktop\Song.mp3 \system\media
adb push filepathonPC/filename.extension path.on.phone.toplace.the.file
 the adb push commands let’s you transfer any files to your phone from your PC. You simply need to provide the path of file on your PC and path where to place this file on your phone.
adb rootadb pull>e.gadb  pull \system\media\Song.mp C:\users\UsamaM\desktop
adb pull [Path of file on phone]  [Path on PC where to place the file]
 Similar to the adb push command. Using adb pull, you can simply pull any files from your phone.
Backing up system and installed apps. 
Before doing this, in your adb folder create a folder Backup and under the backup folder create two folders named SystemApps and InstalledApps.
These folders are necessary as you’ll be pushing the backed up apps to these folders.
adb pull /system/app backup/systemapps backs up all the system apps of your phone to the Systemapps folder that you created in the ADB folder.
 adb pull /system/app backup/installedapps backs up all the installed apps of your phone to the installedapps folder that you created in the ADB folder.
  Background Terminal
 adb shell starts the background terminal.
exitexits the background terminal.
adb shell <command you want>e.g adb shell suswitches to the root of your phone. Please make sure that you’re rooted in case you wish to use adb  shell su.
Fastboot commands
To flash files using fastboot, place the desired files in Fastboot folder or Platform-tools folder that you obtained after installation of Android SDK tools.
Fastboot Flash File.zip Flashes a .zip file to your phone, when your phone is connected in Fastboot mode.
Fastboot Flash recovery recoveryname.imgFlashes a recovery to your phone when it’s connected in Fastboot mode.
Fastboot flash boot bootname.imgFlashes a boot or kernel image when your phone is connected in Fastboot mode.
Fastboot getvar cidshows you the CID of your phone.
Fastboot oem writeCID xxxxxwrites the super CID.
fastboot erase system
fastboot erase data
fastboot erase cache
In case you want to restore a nandroid backup, you’ll have to delete the current system/data/cache of your phone first. Before doing this, it is always recommended to have backed up your system using a custom recovery>backup option and copy the backed up .img files to Fastboot or Platform-tools folder in Android SDK folder. Then performing these commands will erase everything.
fastboot flash system system.img
fastboot flash data data.img
fastboot flash cache cache.img
These commands will restore the backup that you made using a custom recovery on your phone and placed in the Fastboot folder under Android SDK tools.
fastboot oem get_identifier_token
fastboot oem flash Unlock_code.bin
fastboot oem lock
These commands help you to get the identifier token of your phone that can be used for unlocking the bootloader. The second command helps your to flash the bootloader unlock code, and the 3rd commands helps you to lock your phone’s bootloader once again if locking it is actually allowed.
Logcat
adb logcatShows you the real time logs of your phone, these logs represent the ongoing process on your device.It is recommended that you run this command while your device boots up to check what’s going on.
adb logcat > logcat.txtCreates a .txt file containing the logs in the Platform-tools folder or Fastboot folder in Android SDK tools directory.