From 07ada9811c8e2127d0fc359ddb102c447a1f22cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Wed, 17 Jun 2015 13:50:16 +0200 Subject: [PATCH 01/38] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6c6c09e..5d0e06e 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,23 @@ AndroidShell (Mac Os Commands) Summary:
-Maps
+
SHA1
ADB
Database

-
-### MAPS - + +### SHA1 +In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): __Debug KeyStore__ ``` keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android +// or +keytool -list -v -keystore {path_to_keystore}/debug.keystore -alias androiddebugkey -storepass android -keypass android +``` +__Release KeyStore__ +``` +keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_name} -storepass {store_pass} -keypass {keypass} ``` From 97520a0aa4bc5d586cf7a211bcd59c95e2a0a728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Wed, 17 Jun 2015 13:50:34 +0200 Subject: [PATCH 02/38] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d0e06e..1f36a8c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Summary: ### SHA1 -In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): +In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate):
__Debug KeyStore__ ``` keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android From 9cbec9c1f32e3c34989d9269c096fcf9ccbf425f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Wed, 17 Jun 2015 13:50:48 +0200 Subject: [PATCH 03/38] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f36a8c..7d37277 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ Summary: ### SHA1 -In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate):
+In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): + __Debug KeyStore__ ``` keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android From f65f551ebe053925c1fbdb7e4317adff03e2b464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 26 Jun 2015 10:29:02 +0200 Subject: [PATCH 04/38] Added Auto Backup Data section --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d37277..64393b6 100644 --- a/README.md +++ b/README.md @@ -118,10 +118,21 @@ cd apps/com.package.name > __allowBackup=false will break thos method__

Check Battery Stats

-``` +```sh $adb shell dumpsys batterystats -// Global and per-UID statistics -// options: --help +# Global and per-UID statistics +# options: --help +``` + +

Auto Backup Data (Only in Android M)

+``` +$adb shell bmgr + +$adb shell bmgr run +# do some work in the app +$adb shell bmgr fullbackup com.domain.android.app_name +# uninstall and reinstall the app +$adb shell bmgr restore com.domain.android.app_name ```

Use ADB over Wi-Fi without extra application or software

From e3188711129e45639ad11beab4671fa009e3c7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 26 Jun 2015 10:36:17 +0200 Subject: [PATCH 05/38] naming refactor due to sh style (markdown) --- README.md | 180 +++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 64393b6..e958ea6 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,13 @@ Summary: In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): __Debug KeyStore__ -``` +```sh keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -// or +# or keytool -list -v -keystore {path_to_keystore}/debug.keystore -alias androiddebugkey -storepass android -keypass android ``` __Release KeyStore__ -``` +```sh keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_name} -storepass {store_pass} -keypass {keypass} ``` @@ -27,89 +27,89 @@ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_ ### ADB

View connected devices

-``` -adb devices +```sh +$adb devices ``` If multiple devices are attached, use `adb -s DEVICE_ID` to target a specific device

Install an application

-``` -adb install -r file.apk -// Optional -r argument reinstalls and keeps any data if the application is already installed on the device +```sh +$adb install -r file.apk +# optional -r argument reinstalls and keeps any data if the application is already installed on the device ```

Uninstall an application

-``` -adb uninstall com.package.name +```sh +$adb uninstall com.package.name ``` To uninstall the application using uninstall dialog: -``` -adb shell am start -a android.intent.action.DELETE -d package:com.package.name +```sh +$adb shell am start -a android.intent.action.DELETE -d package:com.package.name ```

Start an activity

-``` -adb shell am start -n com.package.name/.ActivityName -adb shell am start -n com.package.name/com.package.name.ActivityName +```sh +$adb shell am start -n com.package.name/.ActivityName +$adb shell am start -n com.package.name/com.package.name.ActivityName ```

Take a screenshot

-``` -adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen_name.png +```sh +$adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen_name.png ``` Explanation of this command, [here](http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html)

Power button

-``` -adb shell input keyevent 26 -adb shell inout text "KEYCODE_POWER" +```sh +$adb shell input keyevent 26 +$adb shell inout text "KEYCODE_POWER" ``` This command sends the power button event to turn the device ON/OFF

Unlock screen

-``` -adb shell input keyevent 82 -adb shell inout text "KEYCODE_MENU" +```sh +$adb shell input keyevent 82 +$adb shell inout text "KEYCODE_MENU" ``` This command sends the event that unlocks the lockscreen on the device. It can be combined with the power button command above to turn on and unlock the device -``` -adb shell input keyevent 26 82 -adb shell inout text "KEYCODE_POWER" "KEYCODE_MENU" +```sh +$adb shell input keyevent 26 82 +$adb shell inout text "KEYCODE_POWER" "KEYCODE_MENU" ```

Print all installed packages

-``` -adb shell pm list packages -f +```sh +$adb shell pm list packages -f ```

Simulate application being killed

-``` -// 1 - Exit your app using home button -// 2 - After that -adb shell ps // Find the process id -adb shell ps | grep your.app.package // Then find the line with app name package -adb shell kill -9 21997 // Kill the app by PID -// 3 - Now return to the app using the task switcher +```sh +# exit your app using home button +# after that +$adb shell ps // Find the process id +$adb shell ps | grep your.app.package // Then find the line with app name package +$adb shell kill -9 21997 // Kill the app by PID +# now return to the app using the task switcher ```

Screen recording using Android 4.4

-``` -adb shell screenrecord --verbose /sdcard/nexus5.mp4 // Basic recording from shell -// Press Ctrl-C to stop -screenrecord --verbose --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds -screenrecord --verbose --bit-rate 8000000 --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds with 8Mbps bitrate -screenrecord --verbose --rotate /sdcard/nexus5.mp4 // Record in portrait view / horizontal +```sh +$adb shell screenrecord --verbose /sdcard/nexus5.mp4 // Basic recording from shell +# press Ctrl-C to stop +$screenrecord --verbose --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds +$screenrecord --verbose --bit-rate 8000000 --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds with 8Mbps bitrate +$screenrecord --verbose --rotate /sdcard/nexus5.mp4 // Record in portrait view / horizontal ```

Retrieve application's private data and databases for non debug application without root access

-``` -// Get a backup of your application data -adb backup --apk com.package.name -// Change the .ab in .tar -dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar -// Untar backup.tar +```sh +# get a backup of your application data +$adb backup --apk com.package.name +# Change the .ab in .tar +$dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar +# untar backup.tar tar xfv backup.tar -// Go in you app private dir -cd apps/com.package.name +# go in you app private dir +$cd apps/com.package.name ``` > You'll need : > - adb activated @@ -120,12 +120,12 @@ cd apps/com.package.name

Check Battery Stats

```sh $adb shell dumpsys batterystats -# Global and per-UID statistics +# global and per-UID statistics # options: --help ```

Auto Backup Data (Only in Android M)

-``` +```sh $adb shell bmgr $adb shell bmgr run @@ -140,71 +140,71 @@ __Prerequisites__ Android device and computer should be connected in same network. * Connect Android device with USB cable to computer * Use following command in terminal to make sure adb is running in USB mode. -``` +```sh $adb usb -// Restarting in USB mode -// Connect to the device over USB. +# restarting in USB mode +# connect to the device over USB. ``` * Execute following command in terminal to make sure adb identify/list gets connected with the device. -``` +```sh $adb devices ``` * Change adb mode from USB to tcpip using following command. -``` +```sh $adb tcpip 5555 -// Restarting in TCP mode port: 5555 +# restarting in TCP mode port: 5555 ``` * Now, adb is running over TCP/IP mode, Let’s find IP address of Android device. Go to Settings in Android device -> About -> Status -> IP address. note down the IP address of connected Android Device. * Use following command to connect ADB with IP address -``` +```sh $adb connect #.#.#.# -// Connected to #.#.#.#:5555 +# connected to #.#.#.#:5555 ``` * Now adb is working over Wi-fi, You can remove USB cable from Android device. * To confirm adb is working over Wi-fi and your device is still connect. you can use following command -``` +```sh $adb devices -#.#.#.#:5555 device +*.*.*.*:5555 device ``` You’re now ready to go!, Enjoy ADB over Wi-fi. Use following command to change ADB mode to USB -``` +```sh $adb usb ```

Filter by tagname in logcat

-``` -adb logcat -s TAG_NAME -adb logcat -s TAG_NAME_1 TAG_NAME_2 +```sh +$adb logcat -s TAG_NAME +$adb logcat -s TAG_NAME_1 TAG_NAME_2 ```

Filter by priority in logcat

-``` -adb logcat "*:" +```sh +$adb logcat "*:" // Where can be V (Verbose), D (Debug), I (Info), W (Warning), E (Error), F (Fatal), S (Silent) ``` It can be combined with tagname command, to filter by tagname and priority -``` -adb logcat -s TEST: W +```sh +$adb logcat -s TEST: W ```

Filter using grep in logcat

-``` -adb logcat | grep "term" -adb logcat | grep "term1\|term2" +```sh +$adb logcat | grep "term" +$adb logcat | grep "term1\|term2" ````

See the executed SQL statements in plain text in logcat

-``` -adb shell setprop log.tag.SQLiteLog V -adb shell setprop log.tag.SQLiteStatements V -adb shell stop -adb shell start +```sh +$adb shell setprop log.tag.SQLiteLog V +$adb shell setprop log.tag.SQLiteStatements V +$adb shell stop +$adb shell start ``` That's it. Whenever any of the installed apps now accesses the database you should see the executed statement in the log output. @@ -212,19 +212,19 @@ That's it. Whenever any of the installed apps now accesses the database you shou The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner. -``` -adb shell monkey [options] -// Basic, make 500 random actions -adb shell monkey -p your.package.name -v 500 +```sh +$adb shell monkey [options] +# basic, make 500 random actions +$adb shell monkey -p your.package.name -v 500 ``` Complete information at http://developer.android.com/tools/help/monkey.html

Indentify Frame Rate Issues (Dumpsys)

-``` -cd platform-tools/ -// Before executing next command, go to Settings --> Developer Options --> Enable Profile GPU rendering option -// And make sure to kill your application first or at least to kill the window that you want to profile, and then you run the command: -adb shell dumpsys gfxinfo +```sh +$cd platform-tools/ +# before executing next command, go to Settings --> Developer Options --> Enable Profile GPU rendering option +# and make sure to kill your application first or at least to kill the window that you want to profile, and then you run the command: +$adb shell dumpsys gfxinfo ``` Purpose of Dumpsys is identifying frame rate issues and fix them. @@ -239,8 +239,8 @@ This is the data you can grab. You can create a stack graph, so every bar contai * The blue part is your code. When you write your Java code, your `onDraw()` method, and this is where you can do most of the optimizations There is a distinction between the GPU composition with frame buffers and overlays. So you can use a tool called __dumpsys surface flinger__ to see the state of overlays and frame buffers in the system. -``` -adb shell dumpsys SurfaceFlinger +```sh +$adb shell dumpsys SurfaceFlinger ``` You're going to get a list with all the windows currently visible on the screen. @@ -252,10 +252,10 @@ More info about this tool, [here](https://www.youtube.com/watch?v=Q8m9sHdyXnE#t= __DB Getter (Script)__ [by Ignasi](https://gist.github.com/ignasi) -``` +```sh #!/bin/bash -# Android 4.3+ changes app's internal directory permissions and you can not just pull your +# android 4.3+ changes app's internal directory permissions and you can not just pull your # databases to your computer, so this is a workaround to extract your databases. # I only use it for debug, use it under YOUR responsability. IT REQUIRES ROOT From 56f323220ff9ebea6b461d4ad4844edcd955decd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 26 Jun 2015 14:29:18 +0200 Subject: [PATCH 06/38] Update README.md added fingerprint simulation --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e958ea6..4d9af15 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ $adb shell dumpsys batterystats # options: --help ``` -

Auto Backup Data (Only in Android M)

+

Auto Backup Data (only in Android M)

```sh $adb shell bmgr @@ -135,6 +135,11 @@ $adb shell bmgr fullbackup com.domain.android.app_name $adb shell bmgr restore com.domain.android.app_name ``` +

Simulate fingerprint inputs (only in Android M)

+```sh +$ adb -e emu finger touch 1 +``` +

Use ADB over Wi-Fi without extra application or software

__Prerequisites__ Android device and computer should be connected in same network. From 5d4f71b936e37bda6d510a8dfe63453c2266cce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 26 Jun 2015 15:30:15 +0200 Subject: [PATCH 07/38] small refactor adding console spacings in instructions --- README.md | 113 +++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 4d9af15..6f58bfa 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,23 @@ AndroidShell (Mac Os Commands) Summary:
-SHA1
-
ADB
-
Database
+*
SHA1
+*
ADB
+*
Database

-
-### SHA1 +### SHA1 In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): __Debug KeyStore__ ```sh -keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android +$ keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android # or -keytool -list -v -keystore {path_to_keystore}/debug.keystore -alias androiddebugkey -storepass android -keypass android +$ keytool -list -v -keystore {path_to_keystore}/debug.keystore -alias androiddebugkey -storepass android -keypass android ``` __Release KeyStore__ ```sh -keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_name} -storepass {store_pass} -keypass {keypass} +$ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_name} -storepass {store_pass} -keypass {keypass} ``` @@ -28,88 +27,88 @@ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_

View connected devices

```sh -$adb devices +$ adb devices ``` If multiple devices are attached, use `adb -s DEVICE_ID` to target a specific device

Install an application

```sh -$adb install -r file.apk +$ adb install -r file.apk # optional -r argument reinstalls and keeps any data if the application is already installed on the device ```

Uninstall an application

```sh -$adb uninstall com.package.name +$ adb uninstall com.package.name ``` To uninstall the application using uninstall dialog: ```sh -$adb shell am start -a android.intent.action.DELETE -d package:com.package.name +$ adb shell am start -a android.intent.action.DELETE -d package:com.package.name ```

Start an activity

```sh -$adb shell am start -n com.package.name/.ActivityName +$ adb shell am start -n com.package.name/.ActivityName $adb shell am start -n com.package.name/com.package.name.ActivityName ```

Take a screenshot

```sh -$adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen_name.png +$ adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen_name.png ``` Explanation of this command, [here](http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html)

Power button

```sh -$adb shell input keyevent 26 -$adb shell inout text "KEYCODE_POWER" +$ adb shell input keyevent 26 +$ adb shell inout text "KEYCODE_POWER" ``` This command sends the power button event to turn the device ON/OFF

Unlock screen

```sh -$adb shell input keyevent 82 -$adb shell inout text "KEYCODE_MENU" +$ adb shell input keyevent 82 +$ adb shell inout text "KEYCODE_MENU" ``` This command sends the event that unlocks the lockscreen on the device. It can be combined with the power button command above to turn on and unlock the device ```sh -$adb shell input keyevent 26 82 -$adb shell inout text "KEYCODE_POWER" "KEYCODE_MENU" +$ adb shell input keyevent 26 82 +$ adb shell inout text "KEYCODE_POWER" "KEYCODE_MENU" ```

Print all installed packages

```sh -$adb shell pm list packages -f +$ adb shell pm list packages -f ```

Simulate application being killed

```sh # exit your app using home button # after that -$adb shell ps // Find the process id -$adb shell ps | grep your.app.package // Then find the line with app name package -$adb shell kill -9 21997 // Kill the app by PID +$ adb shell ps // Find the process id +$ adb shell ps | grep your.app.package // Then find the line with app name package +$ adb shell kill -9 21997 // Kill the app by PID # now return to the app using the task switcher ```

Screen recording using Android 4.4

```sh -$adb shell screenrecord --verbose /sdcard/nexus5.mp4 // Basic recording from shell +$ adb shell screenrecord --verbose /sdcard/nexus5.mp4 // Basic recording from shell # press Ctrl-C to stop -$screenrecord --verbose --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds -$screenrecord --verbose --bit-rate 8000000 --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds with 8Mbps bitrate -$screenrecord --verbose --rotate /sdcard/nexus5.mp4 // Record in portrait view / horizontal +$ screenrecord --verbose --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds +$ screenrecord --verbose --bit-rate 8000000 --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds with 8Mbps bitrate +$ screenrecord --verbose --rotate /sdcard/nexus5.mp4 // Record in portrait view / horizontal ```

Retrieve application's private data and databases for non debug application without root access

```sh # get a backup of your application data -$adb backup --apk com.package.name +$ adb backup --apk com.package.name # Change the .ab in .tar -$dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar +$ dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar # untar backup.tar tar xfv backup.tar # go in you app private dir -$cd apps/com.package.name +$ cd apps/com.package.name ``` > You'll need : > - adb activated @@ -119,20 +118,20 @@ $cd apps/com.package.name

Check Battery Stats

```sh -$adb shell dumpsys batterystats +$ adb shell dumpsys batterystats # global and per-UID statistics # options: --help ```

Auto Backup Data (only in Android M)

```sh -$adb shell bmgr +$ adb shell bmgr -$adb shell bmgr run +$ adb shell bmgr run # do some work in the app -$adb shell bmgr fullbackup com.domain.android.app_name +$ adb shell bmgr fullbackup com.domain.android.app_name # uninstall and reinstall the app -$adb shell bmgr restore com.domain.android.app_name +$ adb shell bmgr restore com.domain.android.app_name ```

Simulate fingerprint inputs (only in Android M)

@@ -146,70 +145,70 @@ Android device and computer should be connected in same network. * Connect Android device with USB cable to computer * Use following command in terminal to make sure adb is running in USB mode. ```sh -$adb usb +$ adb usb # restarting in USB mode # connect to the device over USB. ``` * Execute following command in terminal to make sure adb identify/list gets connected with the device. ```sh -$adb devices +$ adb devices ``` * Change adb mode from USB to tcpip using following command. ```sh -$adb tcpip 5555 +$ adb tcpip 5555 # restarting in TCP mode port: 5555 ``` * Now, adb is running over TCP/IP mode, Let’s find IP address of Android device. Go to Settings in Android device -> About -> Status -> IP address. note down the IP address of connected Android Device. * Use following command to connect ADB with IP address ```sh -$adb connect #.#.#.# +$ adb connect #.#.#.# # connected to #.#.#.#:5555 ``` * Now adb is working over Wi-fi, You can remove USB cable from Android device. * To confirm adb is working over Wi-fi and your device is still connect. you can use following command ```sh -$adb devices +$ adb devices *.*.*.*:5555 device ``` You’re now ready to go!, Enjoy ADB over Wi-fi. Use following command to change ADB mode to USB ```sh -$adb usb +$ adb usb ```

Filter by tagname in logcat

```sh -$adb logcat -s TAG_NAME -$adb logcat -s TAG_NAME_1 TAG_NAME_2 +$ adb logcat -s TAG_NAME +$ adb logcat -s TAG_NAME_1 TAG_NAME_2 ```

Filter by priority in logcat

```sh -$adb logcat "*:" +$ adb logcat "*:" // Where can be V (Verbose), D (Debug), I (Info), W (Warning), E (Error), F (Fatal), S (Silent) ``` It can be combined with tagname command, to filter by tagname and priority ```sh -$adb logcat -s TEST: W +$ adb logcat -s TEST: W ```

Filter using grep in logcat

```sh -$adb logcat | grep "term" -$adb logcat | grep "term1\|term2" +$ adb logcat | grep "term" +$ adb logcat | grep "term1\|term2" ````

See the executed SQL statements in plain text in logcat

```sh -$adb shell setprop log.tag.SQLiteLog V -$adb shell setprop log.tag.SQLiteStatements V -$adb shell stop -$adb shell start +$ adb shell setprop log.tag.SQLiteLog V +$ adb shell setprop log.tag.SQLiteStatements V +$ adb shell stop +$ adb shell start ``` That's it. Whenever any of the installed apps now accesses the database you should see the executed statement in the log output. @@ -218,18 +217,18 @@ That's it. Whenever any of the installed apps now accesses the database you shou The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner. ```sh -$adb shell monkey [options] +$ adb shell monkey [options] # basic, make 500 random actions -$adb shell monkey -p your.package.name -v 500 +$ adb shell monkey -p your.package.name -v 500 ``` Complete information at http://developer.android.com/tools/help/monkey.html

Indentify Frame Rate Issues (Dumpsys)

```sh -$cd platform-tools/ +$ cd platform-tools/ # before executing next command, go to Settings --> Developer Options --> Enable Profile GPU rendering option # and make sure to kill your application first or at least to kill the window that you want to profile, and then you run the command: -$adb shell dumpsys gfxinfo +$ adb shell dumpsys gfxinfo ``` Purpose of Dumpsys is identifying frame rate issues and fix them. @@ -245,7 +244,7 @@ This is the data you can grab. You can create a stack graph, so every bar contai There is a distinction between the GPU composition with frame buffers and overlays. So you can use a tool called __dumpsys surface flinger__ to see the state of overlays and frame buffers in the system. ```sh -$adb shell dumpsys SurfaceFlinger +$ adb shell dumpsys SurfaceFlinger ``` You're going to get a list with all the windows currently visible on the screen. From aed86d533ba27a53a541ddfd4c767da4f06c7cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Sun, 13 Sep 2015 13:35:15 +0200 Subject: [PATCH 08/38] added strictmode adb command --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 6f58bfa..bf772c2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,19 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia
### ADB +

Watching StrictMode

+ +If you’re using `penaltyLog()`, the default, just run +```sh +adb logcat +``` +and watch the terminal output. Any violations will be logged to your console, slightly rate-limited for duplicate elimination. + +If you want to get fancier, turn on `penaltyDropbox()` and they’ll be written to the DropBoxManager, where you can extract them later with +```sh +adb shell dumpsys dropbox data_app_strictmode --print +``` +

View connected devices

```sh $ adb devices From ca217926b1ab06f6b310bbf93a9333dee53b6a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Mon, 28 Sep 2015 11:29:22 +0200 Subject: [PATCH 09/38] added instruction to find out what processor does an android device have inside --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index bf772c2..5ff2bd7 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,11 @@ $ adb shell monkey -p your.package.name -v 500 ``` Complete information at http://developer.android.com/tools/help/monkey.html +

Find out processor version on Android Device (check if it's an ARM, for example)

+```sh +$ adb shell cat /proc/cpuinfo +``` +

Indentify Frame Rate Issues (Dumpsys)

```sh $ cd platform-tools/ From cccc9985a5c18f87cfd99925b82eeb301e4502a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Wed, 4 Nov 2015 02:54:10 +0100 Subject: [PATCH 10/38] Update README.md refactored file --- README.md | 338 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 209 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 5ff2bd7..b0811b1 100644 --- a/README.md +++ b/README.md @@ -1,251 +1,311 @@ -AndroidShell (Mac Os Commands) -============================= - -Summary: -
-* SHA1
-*
ADB
-*
Database
+# AndroidShell (Mac Os Commands) + +#### Table of Contents + +-
__SHA-1__ + - __Debug Keystore__ + - __Release Keystore__ +- __ADB__ + - __Database__ + - __Watching StrictMode__ + - __View connected devices__ + - __Install an application__ + - __Uninstall an application__ + - __Start an Activity__ + - __Take an screenshot__ + - __Power button__ + - __Unlock screen__ + - __Print all installed packages__ + - __Simulate application being killed__ + - __Screen recording using Android 4.4__ + - __Check battery stats__ + - __Auto Backup Data (only in Android M)__ + - __Simulate fingerprint inputs (only in Android M)__ + - __Filter by tagname in Logcat__ + - __Filter by priority in Logcat__ + - __Filter using grep in Logcat__ + - __See the executed SQL statements in plain text in Logcat__ + - __Testing - Execute Monkey to test user interaction__ + - __Find out processor version on Android Device (check if it's an ARM, for example)__ + - __Retrieve application's private data and databases for non debug application without root access__ + - __Indentify Frame Rate Issues (Dumpsys)__ + - __Use ADB over Wi-Fi without extra application or software__ +
-### SHA1 + +### SHA-1 In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): -__Debug KeyStore__ + +#### Debug KeyStore ```sh $ keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -# or +``` +or + +```sh $ keytool -list -v -keystore {path_to_keystore}/debug.keystore -alias androiddebugkey -storepass android -keypass android ``` -__Release KeyStore__ + +#### Release KeyStore ```sh $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_name} -storepass {store_pass} -keypass {keypass} ``` +
+
-### ADB +### ADB -

Watching StrictMode

+ +#### Database + +[__This__](https://gist.github.com/ignasi is a Database getter script, developed by [__Ignasi__](https://github.com/ignasi) +```sh +#!/bin/bash + +# android 4.3+ changes app's internal directory permissions and you can not just pull your +# databases to your computer, so this is a workaround to extract your databases. +# I only use it for debug, use it under YOUR responsability. IT REQUIRES ROOT + +package=$1 +db_name=$2 +path="/data/data/$package/" + +rm $db_name +adb shell "su -c 'cd $path; chmod -R 777 databases; exit'; exit" +adb pull $path/databases/$db_name +open $db_name +``` + + +#### Watching StrictMode If you’re using `penaltyLog()`, the default, just run ```sh -adb logcat +$ adb logcat ``` and watch the terminal output. Any violations will be logged to your console, slightly rate-limited for duplicate elimination. If you want to get fancier, turn on `penaltyDropbox()` and they’ll be written to the DropBoxManager, where you can extract them later with ```sh -adb shell dumpsys dropbox data_app_strictmode --print +$ adb shell dumpsys dropbox data_app_strictmode --print ``` -

View connected devices

+
+#### View connected device + ```sh $ adb devices ``` If multiple devices are attached, use `adb -s DEVICE_ID` to target a specific device -

Install an application

+
+#### Install an application + ```sh $ adb install -r file.apk -# optional -r argument reinstalls and keeps any data if the application is already installed on the device +# Optional -r argument reinstalls and keeps any data if the application is already installed on the device. ``` -

Uninstall an application

+
+#### Uninstall an application + ```sh $ adb uninstall com.package.name ``` + To uninstall the application using uninstall dialog: ```sh $ adb shell am start -a android.intent.action.DELETE -d package:com.package.name ``` -

Start an activity

+
+#### Start an Activity + ```sh $ adb shell am start -n com.package.name/.ActivityName -$adb shell am start -n com.package.name/com.package.name.ActivityName +$ adb shell am start -n com.package.name/com.package.name.ActivityName ``` -

Take a screenshot

+ +
+#### Take an screenshot + ```sh $ adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen_name.png ``` -Explanation of this command, [here](http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html) -

Power button

+Explanation of this command, [__here__](http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html) + +
+#### Power button + +This command sends the power button event to turn the device ON/OFF. ```sh $ adb shell input keyevent 26 $ adb shell inout text "KEYCODE_POWER" ``` -This command sends the power button event to turn the device ON/OFF -

Unlock screen

+
+#### Unlock screen + +This command sends the event that unlocks the lockscreen on the device. It can be combined with the power button command above to turn on and unlock the device + ```sh $ adb shell input keyevent 82 $ adb shell inout text "KEYCODE_MENU" -``` -This command sends the event that unlocks the lockscreen on the device. It can be combined with the power button command above to turn on and unlock the device -```sh + $ adb shell input keyevent 26 82 $ adb shell inout text "KEYCODE_POWER" "KEYCODE_MENU" ``` -

Print all installed packages

+
+#### Print all installed packages + ```sh $ adb shell pm list packages -f ``` -

Simulate application being killed

+
+#### Simulate application being killed + ```sh # exit your app using home button -# after that +# After that. $ adb shell ps // Find the process id $ adb shell ps | grep your.app.package // Then find the line with app name package $ adb shell kill -9 21997 // Kill the app by PID -# now return to the app using the task switcher +# Now return to the app using the task switcher. ``` -

Screen recording using Android 4.4

+
+#### Screen recording using Android 4.4 + ```sh $ adb shell screenrecord --verbose /sdcard/nexus5.mp4 // Basic recording from shell -# press Ctrl-C to stop +# Press Ctrl-C to stop. $ screenrecord --verbose --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds $ screenrecord --verbose --bit-rate 8000000 --time-limit 30 /sdcard/nexus5.mp4 // Recording for 30 seconds with 8Mbps bitrate $ screenrecord --verbose --rotate /sdcard/nexus5.mp4 // Record in portrait view / horizontal ``` -

Retrieve application's private data and databases for non debug application without root access

-```sh -# get a backup of your application data -$ adb backup --apk com.package.name -# Change the .ab in .tar -$ dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar -# untar backup.tar -tar xfv backup.tar -# go in you app private dir -$ cd apps/com.package.name -``` -> You'll need : -> - adb activated -> - physical access to unlocked device -> - works on Nexus 5 at least, might not work with other devices. -> __allowBackup=false will break thos method__ +
+#### Check battery stats -

Check Battery Stats

```sh $ adb shell dumpsys batterystats -# global and per-UID statistics -# options: --help +# Global and per-UID statistics. +# Options: --help. ``` -

Auto Backup Data (only in Android M)

+
+#### Auto Backup Data (only in Android M) + ```sh $ adb shell bmgr $ adb shell bmgr run -# do some work in the app +# Do some work in the app. $ adb shell bmgr fullbackup com.domain.android.app_name -# uninstall and reinstall the app +# Uninstall and reinstall the app. $ adb shell bmgr restore com.domain.android.app_name ``` -

Simulate fingerprint inputs (only in Android M)

-```sh -$ adb -e emu finger touch 1 -``` - -

Use ADB over Wi-Fi without extra application or software

-__Prerequisites__ -Android device and computer should be connected in same network. -* Connect Android device with USB cable to computer -* Use following command in terminal to make sure adb is running in USB mode. -```sh -$ adb usb -# restarting in USB mode -# connect to the device over USB. -``` - -* Execute following command in terminal to make sure adb identify/list gets connected with the device. -```sh -$ adb devices -``` - -* Change adb mode from USB to tcpip using following command. -```sh -$ adb tcpip 5555 -# restarting in TCP mode port: 5555 -``` +
+#### Simulate fingerprint inputs (only in Android M) -* Now, adb is running over TCP/IP mode, Let’s find IP address of Android device. Go to Settings in Android device -> About -> Status -> IP address. note down the IP address of connected Android Device. -* Use following command to connect ADB with IP address ```sh -$ adb connect #.#.#.# -# connected to #.#.#.#:5555 -``` - -* Now adb is working over Wi-fi, You can remove USB cable from Android device. -* To confirm adb is working over Wi-fi and your device is still connect. you can use following command -```sh -$ adb devices -*.*.*.*:5555 device +$ adb -e emu finger touch 1 ``` -You’re now ready to go!, Enjoy ADB over Wi-fi. -Use following command to change ADB mode to USB -```sh -$ adb usb -``` + +#### Filter by tagname in Logcat -

Filter by tagname in logcat

```sh $ adb logcat -s TAG_NAME $ adb logcat -s TAG_NAME_1 TAG_NAME_2 ``` -

Filter by priority in logcat

+
+#### Filter by priority in Logcat + ```sh $ adb logcat "*:" -// Where can be V (Verbose), D (Debug), I (Info), W (Warning), E (Error), F (Fatal), S (Silent) +# Where can be V (Verbose), D (Debug), I (Info), W (Warning), E (Error), F (Fatal), S (Silent). ``` + It can be combined with tagname command, to filter by tagname and priority ```sh $ adb logcat -s TEST: W ``` -

Filter using grep in logcat

+
+#### Filter using grep in Logcat + ```sh $ adb logcat | grep "term" $ adb logcat | grep "term1\|term2" ```` -

See the executed SQL statements in plain text in logcat

+
+#### See the executed SQL statements in plain text in Logcat + ```sh $ adb shell setprop log.tag.SQLiteLog V $ adb shell setprop log.tag.SQLiteStatements V $ adb shell stop $ adb shell start ``` + That's it. Whenever any of the installed apps now accesses the database you should see the executed statement in the log output. -

Testing - Execute Monkey to test user interaction

+
+#### Testing - Execute Monkey to test user interaction The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner. ```sh $ adb shell monkey [options] -# basic, make 500 random actions +# Basic, make 500 random actions. $ adb shell monkey -p your.package.name -v 500 ``` + Complete information at http://developer.android.com/tools/help/monkey.html -

Find out processor version on Android Device (check if it's an ARM, for example)

+
+#### Find out processor version on Android Device (check if it's an ARM, for example) + ```sh $ adb shell cat /proc/cpuinfo ``` -

Indentify Frame Rate Issues (Dumpsys)

+
+#### Retrieve application's private data and databases for non debug application without root access + +```sh +# Get a backup of your application data. +$ adb backup --apk com.package.name +# Change the .ab in .tar. +$ dd if=backup.ab bs=24 skip=1 | openssl zlib -d > backup.tar +# Untar backup.tar. +tar xfv backup.tar +# Go in you app private dir. +$ cd apps/com.package.name +``` +> You'll need : +> - adb activated +> - physical access to unlocked device +> - works on Nexus 5 at least, might not work with other devices. +> __allowBackup=false will break thos method__ + + +#### Indentify Frame Rate Issues (Dumpsys) + ```sh $ cd platform-tools/ -# before executing next command, go to Settings --> Developer Options --> Enable Profile GPU rendering option -# and make sure to kill your application first or at least to kill the window that you want to profile, and then you run the command: +# Before executing next command, go to Settings --> Developer Options --> Enable Profile GPU rendering option. +# And make sure to kill your application first or at least to kill the window that you want to profile, and then you run the command: $ adb shell dumpsys gfxinfo ``` Purpose of Dumpsys is identifying frame rate issues and fix them. @@ -267,28 +327,48 @@ $ adb shell dumpsys SurfaceFlinger You're going to get a list with all the windows currently visible on the screen. -More info about this tool, [here](https://www.youtube.com/watch?v=Q8m9sHdyXnE#t=2469) +More info about this tool, [__here__](https://www.youtube.com/watch?v=Q8m9sHdyXnE#t=2469) + + +#### Use ADB over Wi-Fi without extra application or software + +__Prerequisites__ +Android device and computer should be connected in same network. +* Connect Android device with USB cable to computer +* Use following command in terminal to make sure adb is running in USB mode. +```sh +$ adb usb +# Restarting in USB mode. +# Connect to the device over USB. +``` - -### Database +* Execute following command in terminal to make sure adb identify/list gets connected with the device. +```sh +$ adb devices +``` -__DB Getter (Script)__ [by Ignasi](https://gist.github.com/ignasi) +* Change adb mode from USB to tcpip using following command. +```sh +$ adb tcpip 5555 +# Restarting in TCP mode port: 5555. +``` +* Now, adb is running over TCP/IP mode, Let’s find IP address of Android device. Go to Settings in Android device -> About -> Status -> IP address. note down the IP address of connected Android Device. +* Use following command to connect ADB with IP address ```sh -#!/bin/bash - -# android 4.3+ changes app's internal directory permissions and you can not just pull your -# databases to your computer, so this is a workaround to extract your databases. -# I only use it for debug, use it under YOUR responsability. IT REQUIRES ROOT - -package=$1 -db_name=$2 -path="/data/data/$package/" - -rm $db_name -adb shell "su -c 'cd $path; chmod -R 777 databases; exit'; exit" -adb pull $path/databases/$db_name -open $db_name +$ adb connect #.#.#.# +# Connected to #.#.#.#:5555. ``` +* Now adb is working over Wi-fi, You can remove USB cable from Android device. +* To confirm adb is working over Wi-fi and your device is still connect. you can use following command +```sh +$ adb devices +*.*.*.*:5555 device +``` +You’re now ready to go!, Enjoy ADB over Wi-fi. +Use following command to change ADB mode to USB +```sh +$ adb usb +``` From 80a493d6905b62f3b76ddb4638da99fb843d5c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Wed, 4 Nov 2015 02:57:21 +0100 Subject: [PATCH 11/38] Update README.md fixed bugs --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b0811b1..9fc9588 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ or $ keytool -list -v -keystore {path_to_keystore}/debug.keystore -alias androiddebugkey -storepass android -keypass android ``` + #### Release KeyStore ```sh $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alias_name} -storepass {store_pass} -keypass {keypass} @@ -61,7 +62,7 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia #### Database -[__This__](https://gist.github.com/ignasi is a Database getter script, developed by [__Ignasi__](https://github.com/ignasi) +[__This__](https://gist.github.com/ignasi) is a Database getter script, developed by [__Ignasi__](https://github.com/ignasi) ```sh #!/bin/bash From a6eefc639c028b3169ef6bbf1ff3b6c0661c68ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Wed, 4 Nov 2015 17:57:54 +0100 Subject: [PATCH 12/38] Update README.md added aapt tooling and an example of use case --- README.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fc9588..d40c1fe 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,9 @@ - __Retrieve application's private data and databases for non debug application without root access__ - __Indentify Frame Rate Issues (Dumpsys)__ - __Use ADB over Wi-Fi without extra application or software__ - +- __AAPT__ + - __Check Permissions in order to avoid Play Store app filtering__ +
@@ -373,3 +375,69 @@ Use following command to change ADB mode to USB ```sh $ adb usb ``` + +
+ +
+### AAPT + + +#### Check Permissions in order to avoid Play Store app filtering + +[__Source__](https://goo.gl/jpxeLO) + +Certain permissions also imply certain features. Google Play uses these to filter out apps just as it would with explicit requirements. Developers should __NOT__ rely on this implicit behavior, they should always declare explicitly every feature their app needs. + +__aapt__ allows us, among other things, to see the contents of an app’s manifest. This is not as easy as simply unpacking the apk and reading the manifest as you’ll find it’s in a binary format. Here is the result of running the SDK-provided aapt tool in its apk: +```sh +$ aapt dump badging com.your-app.apk +``` +Output +``` +package: name='com.germanwings.android' versionCode='3' versionName='1.0.2' sdkVersion:'10' targetSdkVersion:'17' +uses-permission:'android.permission.WRITE_EXTERNAL_STORAGE' +uses-permission:'android.permission.INTERNET' +uses-permission:'android.permission.ACCESS_FINE_LOCATION' +uses-permission:'android.permission.ACCESS_COARSE_LOCATION' +uses-permission:'com.germanwings.android.permission.C2D_MESSAGE' +uses-permission:'android.permission.ACCESS_LOCATION_EXTRA_COMMANDS' +uses-permission:'android.permission.INTERNET' +uses-permission:'android.permission.GET_ACCOUNTS' +uses-permission:'android.permission.WAKE_LOCK' +uses-permission:'android.permission.READ_PHONE_STATE' +uses-permission:'com.google.android.c2dm.permission.RECEIVE' +uses-permission:'android.permission.ACCESS_LOCATION_EXTRA_COMMANDS' +uses-permission:'android.permission.ACCESS_MOCK_LOCATION' +uses-permission:'android.permission.ACCESS_NETWORK_STATE' +uses-permission:'android.permission.ACCESS_GPS' +uses-permission:'android.permission.ACCESS_LOCATION' +uses-permission:'android.permission.READ_EXTERNAL_STORAGE' +application-label:'Germanwings' +application-icon-120:'res/drawable-ldpi/ic_launcher.png' +application-icon-160:'res/drawable-mdpi/ic_launcher.png' +application-icon-240:'res/drawable-hdpi/ic_launcher.png' +application-icon-320:'res/drawable-xhdpi/ic_launcher.png' +application: label='Germanwings' icon='res/drawable-mdpi/ic_launcher.png' +launchable-activity: name='com.germanwings.android.presentation.activity.DashboardActivity' label='Germanwings' icon='' +uses-feature:'android.hardware.location' +uses-implied-feature:'android.hardware.location','requested a location access permission' +uses-feature:'android.hardware.location.gps' +uses-implied-feature:'android.hardware.location.gps','requested android.permission.ACCESS_FINE_LOCATION permission' +uses-feature:'android.hardware.location.network' +uses-implied-feature:'android.hardware.location.network','requested android.permission.ACCESS_COURSE_LOCATION permission' +uses-feature:'android.hardware.touchscreen' +uses-implied-feature:'android.hardware.touchscreen','assumed you require a touch screen unless explicitly made optional' +uses-feature:'android.hardware.screen.portrait' +uses-implied-feature:'android.hardware.screen.portrait','one or more activities have specified a portrait orientation' +main +other-activities +other-receivers +other-services +supports-screens: 'small' 'normal' 'large' 'xlarge' +supports-any-density: 'true' +locales: '--_--' +densities: '120' '160' '240' '320' +``` + + + From dd953e097a9693c0b0e5aacc0bb5e960b4cfb8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Thu, 12 Nov 2015 10:14:19 +0100 Subject: [PATCH 13/38] Update README.md add new permissions section --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index d40c1fe..f15c181 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ - __Retrieve application's private data and databases for non debug application without root access__ - __Indentify Frame Rate Issues (Dumpsys)__ - __Use ADB over Wi-Fi without extra application or software__ + - __Test new Marshmallow permissions__ - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ @@ -376,6 +377,18 @@ Use following command to change ADB mode to USB $ adb usb ``` + +#### Test new Marshmallow permissions + +In order to test permissions targeting API 23+, we could use following commands to programatically grant and revoke permissions on the device: +```sh +$adb pm grant +``` +or +```sh +$adb pm revoke +``` +
From 9852abf379aa3e4e89989e69ff7ab0e28b7b3613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 29 Jan 2016 16:44:50 +0000 Subject: [PATCH 14/38] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index f15c181..4354f90 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ - __See the executed SQL statements in plain text in Logcat__ - __Testing - Execute Monkey to test user interaction__ - __Find out processor version on Android Device (check if it's an ARM, for example)__ + - __Find out Application Binary Interface (ABI) in different devices__ - __Retrieve application's private data and databases for non debug application without root access__ - __Indentify Frame Rate Issues (Dumpsys)__ - __Use ADB over Wi-Fi without extra application or software__ @@ -284,6 +285,14 @@ Complete information at http://developer.android.com/tools/help/monkey.html $ adb shell cat /proc/cpuinfo ``` + +#### Find out Application Binary Interface (ABI) in different devices + +__ABI__ (Application Binary Interface) is gonna tell us if an Android device support 64-bit. So using the next command the developer know if the device is __32-bit__ or __64-bit__ based. +```sh +$ adb shell getprop ro.product.cpu.abi\ +``` + #### Retrieve application's private data and databases for non debug application without root access From 20998745a995cf0f0e5ad8f5a992348de5a822b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Sun, 3 Apr 2016 22:04:28 +0100 Subject: [PATCH 15/38] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 4354f90..0eca918 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ - __Power button__ - __Unlock screen__ - __Print all installed packages__ + - __Get the path of an installed application__ - __Simulate application being killed__ - __Screen recording using Android 4.4__ - __Check battery stats__ @@ -172,6 +173,13 @@ $ adb shell inout text "KEYCODE_POWER" "KEYCODE_MENU" $ adb shell pm list packages -f ``` + +#### Get the path of an installed application + +```sh +$ adb shell pm path app.package.application-name +``` + #### Simulate application being killed From 0cefd700c3825b5ebe759e1b01e89a4b76eca8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Sun, 3 Apr 2016 22:07:29 +0100 Subject: [PATCH 16/38] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 0eca918..20f1a5a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ - __Install an application__ - __Uninstall an application__ - __Start an Activity__ + - __Open a deep linking intent__ - __Take an screenshot__ - __Power button__ - __Unlock screen__ @@ -135,6 +136,13 @@ $ adb shell am start -n com.package.name/.ActivityName $ adb shell am start -n com.package.name/com.package.name.ActivityName ``` + +#### Open a deep linking intent + +```sh +$ adb shell am start -n android.intent.action.VIEW -d "scheme://app/deep/linking" +``` + #### Take an screenshot From 1eae92f956dc156ea2f966263dab86afa45c20b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Sun, 3 Apr 2016 22:10:52 +0100 Subject: [PATCH 17/38] Update README.md --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20f1a5a..f2906f5 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,11 @@ - __SHA-1__ - __Debug Keystore__ - __Release Keystore__ -- __ADB__ + - __ADB__ - __Database__ - __Watching StrictMode__ - __View connected devices__ + - __List of running services__ - __Install an application__ - __Uninstall an application__ - __Start an Activity__ @@ -106,8 +107,16 @@ $ adb shell dumpsys dropbox data_app_strictmode --print ```sh $ adb devices ``` + If multiple devices are attached, use `adb -s DEVICE_ID` to target a specific device + +#### List of running services + +```sh +$ adb shell dumpsys activity services +``` + #### Install an application From 8573d555401c4147342364db280a7f86b6f198dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 22 Apr 2016 22:53:45 +0100 Subject: [PATCH 18/38] Updated readme with Testing your app with App Standby --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f2906f5..1e9fc3e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ - __SHA-1__ - __Debug Keystore__ - __Release Keystore__ - - __ADB__ +- __ADB__ - __Database__ - __Watching StrictMode__ - __View connected devices__ @@ -32,6 +32,7 @@ - __Find out processor version on Android Device (check if it's an ARM, for example)__ - __Find out Application Binary Interface (ABI) in different devices__ - __Retrieve application's private data and databases for non debug application without root access__ + - __Testing your app with App Standby__ - __Indentify Frame Rate Issues (Dumpsys)__ - __Use ADB over Wi-Fi without extra application or software__ - __Test new Marshmallow permissions__ @@ -425,6 +426,30 @@ $adb pm revoke
+ +#### Testing your app with App Standby + +[__Source__](http://developer.android.com/intl/ru/training/monitoring-device-state/doze-standby.html?utm_campaign=android_series_appstandby_012116&utm_source=medium&utm_medium=blog#testing_your_app_with_app_standby) + +To test the App Standby mode with your app: + +1- Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. +2- Connect the device to your development machine and install your app. +3- Run your app and leave it active. +4- Force the app into App Standby mode by running the following commands: +```sh +$ adb shell dumpsys battery unplug +$ adb shell am set-inactive true +``` +5- Simulate waking your app using the following commands: +```sh +$ adb shell am set-inactive false +$ adb shell am get-inactive +``` +6- Observe the behavior of your app after waking it. Make sure the app recovers gracefully from standby mode. In particular, you should check if your app's Notifications and background jobs continue to function as expected. + +
+
### AAPT From 7cfc673bccd68db604eb80b6cc307e9a1e65b0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 22 Apr 2016 22:54:25 +0100 Subject: [PATCH 19/38] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e9fc3e..91224ce 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ - __Find out processor version on Android Device (check if it's an ARM, for example)__ - __Find out Application Binary Interface (ABI) in different devices__ - __Retrieve application's private data and databases for non debug application without root access__ - - __Testing your app with App Standby__ - __Indentify Frame Rate Issues (Dumpsys)__ - __Use ADB over Wi-Fi without extra application or software__ - __Test new Marshmallow permissions__ + - __Testing your app with App Standby__ - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ From acae923ea710f79a24d0cb9eb008bec4fc30ad10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 22 Apr 2016 23:51:03 +0100 Subject: [PATCH 20/38] Updated readme with Testing your app with Doze --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 91224ce..9efeefa 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ - __Use ADB over Wi-Fi without extra application or software__ - __Test new Marshmallow permissions__ - __Testing your app with App Standby__ + - __Testing your app with Doze__ - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ @@ -450,6 +451,27 @@ $ adb shell am get-inactive
+ +#### Testing your app with Doze + +[__Source__](http://developer.android.com/intl/ru/training/monitoring-device-state/doze-standby.html?utm_campaign=android_series_appstandby_012116&utm_source=medium&utm_medium=blog#testing_your_app_with_app_standby) + +You can test Doze mode by following these steps: + +1- Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. +2- Connect the device to your development machine and install your app. +3- Run your app and leave it active. +4- Shut off the device screen. (The app remains active.) +5- Force the system to cycle through Doze modes by running the following commands: +```java +$ adb shell dumpsys battery unplug +$ adb shell dumpsys deviceidle step +``` +You may need to run the second command more than once. Repeat it until the device state changes to idle. +6- Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze. + +
+
### AAPT From 720be51c534f925498604674e6a1338982b86639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 22 Apr 2016 23:52:45 +0100 Subject: [PATCH 21/38] Fixed broken linebreaks --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9efeefa..34f902d 100644 --- a/README.md +++ b/README.md @@ -434,20 +434,20 @@ $adb pm revoke To test the App Standby mode with your app: -1- Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. -2- Connect the device to your development machine and install your app. -3- Run your app and leave it active. -4- Force the app into App Standby mode by running the following commands: +1. Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. +2. Connect the device to your development machine and install your app. +3. Run your app and leave it active. +4. Force the app into App Standby mode by running the following commands: ```sh $ adb shell dumpsys battery unplug $ adb shell am set-inactive true ``` -5- Simulate waking your app using the following commands: +5. Simulate waking your app using the following commands: ```sh $ adb shell am set-inactive false $ adb shell am get-inactive ``` -6- Observe the behavior of your app after waking it. Make sure the app recovers gracefully from standby mode. In particular, you should check if your app's Notifications and background jobs continue to function as expected. +6. Observe the behavior of your app after waking it. Make sure the app recovers gracefully from standby mode. In particular, you should check if your app's Notifications and background jobs continue to function as expected.
@@ -458,17 +458,17 @@ $ adb shell am get-inactive You can test Doze mode by following these steps: -1- Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. -2- Connect the device to your development machine and install your app. -3- Run your app and leave it active. -4- Shut off the device screen. (The app remains active.) -5- Force the system to cycle through Doze modes by running the following commands: +1. Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. +2. Connect the device to your development machine and install your app. +3. Run your app and leave it active. +4. Shut off the device screen. (The app remains active.) +5. Force the system to cycle through Doze modes by running the following commands: ```java $ adb shell dumpsys battery unplug $ adb shell dumpsys deviceidle step ``` You may need to run the second command more than once. Repeat it until the device state changes to idle. -6- Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze. +6. Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze.
From 35d6efa1797048246646e88fc20da0bc9930986a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 22 Apr 2016 23:54:43 +0100 Subject: [PATCH 22/38] Fixed broken linebreaks and section, again. --- README.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 34f902d..6879184 100644 --- a/README.md +++ b/README.md @@ -434,20 +434,22 @@ $adb pm revoke To test the App Standby mode with your app: -1. Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. -2. Connect the device to your development machine and install your app. -3. Run your app and leave it active. -4. Force the app into App Standby mode by running the following commands: +- Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. +- Connect the device to your development machine and install your app. +- Run your app and leave it active. +- Force the app into App Standby mode by running the following commands: ```sh $ adb shell dumpsys battery unplug $ adb shell am set-inactive true ``` -5. Simulate waking your app using the following commands: + +- Simulate waking your app using the following commands: ```sh $ adb shell am set-inactive false $ adb shell am get-inactive ``` -6. Observe the behavior of your app after waking it. Make sure the app recovers gracefully from standby mode. In particular, you should check if your app's Notifications and background jobs continue to function as expected. + +- Observe the behavior of your app after waking it. Make sure the app recovers gracefully from standby mode. In particular, you should check if your app's Notifications and background jobs continue to function as expected.
@@ -458,17 +460,19 @@ $ adb shell am get-inactive You can test Doze mode by following these steps: -1. Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. -2. Connect the device to your development machine and install your app. -3. Run your app and leave it active. -4. Shut off the device screen. (The app remains active.) -5. Force the system to cycle through Doze modes by running the following commands: +- Configure a hardware device or virtual device with an Android 6.0 (API level 23) or higher system image. +- Connect the device to your development machine and install your app. +- Run your app and leave it active. +- Shut off the device screen. (The app remains active.) +- Force the system to cycle through Doze modes by running the following commands: ```java $ adb shell dumpsys battery unplug $ adb shell dumpsys deviceidle step ``` + You may need to run the second command more than once. Repeat it until the device state changes to idle. -6. Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze. + +- Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze.
From a024a5a6ac1b7f8cdc7e41771cd308a0da674f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez?= Date: Fri, 8 Jul 2016 22:28:39 +0100 Subject: [PATCH 23/38] added launchtime adb watcher --- README.md | 90 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 6879184..84d82f7 100644 --- a/README.md +++ b/README.md @@ -3,33 +3,34 @@ #### Table of Contents -
__SHA-1__ - - __Debug Keystore__ - - __Release Keystore__ + - __Debug Keystore__ + - __Release Keystore__ - __ADB__ - - __Database__ - - __Watching StrictMode__ - - __View connected devices__ - - __List of running services__ - - __Install an application__ - - __Uninstall an application__ - - __Start an Activity__ - - __Open a deep linking intent__ - - __Take an screenshot__ - - __Power button__ - - __Unlock screen__ - - __Print all installed packages__ - - __Get the path of an installed application__ - - __Simulate application being killed__ - - __Screen recording using Android 4.4__ - - __Check battery stats__ - - __Auto Backup Data (only in Android M)__ - - __Simulate fingerprint inputs (only in Android M)__ - - __Filter by tagname in Logcat__ - - __Filter by priority in Logcat__ - - __Filter using grep in Logcat__ - - __See the executed SQL statements in plain text in Logcat__ - - __Testing - Execute Monkey to test user interaction__ - - __Find out processor version on Android Device (check if it's an ARM, for example)__ + - __Show cold start Activity time__ + - __Database__ + - __Watching StrictMode__ + - __View connected devices__ + - __List of running services__ + - __Install an application__ + - __Uninstall an application__ + - __Start an Activity__ + - __Open a deep linking intent__ + - __Take an screenshot__ + - __Power button__ + - __Unlock screen__ + - __Print all installed packages__ + - __Get the path of an installed application__ + - __Simulate application being killed__ + - __Screen recording using Android 4.4__ + - __Check battery stats__ + - __Auto Backup Data (only in Android M)__ + - __Simulate fingerprint inputs (only in Android M)__ + - __Filter by tagname in Logcat__ + - __Filter by priority in Logcat__ + - __Filter using grep in Logcat__ + - __See the executed SQL statements in plain text in Logcat__ + - __Testing - Execute Monkey to test user interaction__ + - __Find out processor version on Android Device (check if it's an ARM, for example)__ - __Find out Application Binary Interface (ABI) in different devices__ - __Retrieve application's private data and databases for non debug application without root access__ - __Indentify Frame Rate Issues (Dumpsys)__ @@ -68,21 +69,33 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia ### ADB + +#### Show cold start Activity time + +```sh +$ adb logcat | grep "ActivityManager" +``` + +The output would be something similar to: +``` +ActivityManager: Displayed com.example.launchtime/.LaunchTime: +666ms +``` + #### Database [__This__](https://gist.github.com/ignasi) is a Database getter script, developed by [__Ignasi__](https://github.com/ignasi) ```sh #!/bin/bash - -# android 4.3+ changes app's internal directory permissions and you can not just pull your + +# android 4.3+ changes app's internal directory permissions and you can not just pull your # databases to your computer, so this is a workaround to extract your databases. # I only use it for debug, use it under YOUR responsability. IT REQUIRES ROOT - + package=$1 db_name=$2 path="/data/data/$package/" - + rm $db_name adb shell "su -c 'cd $path; chmod -R 777 databases; exit'; exit" adb pull $path/databases/$db_name @@ -92,9 +105,9 @@ open $db_name #### Watching StrictMode -If you’re using `penaltyLog()`, the default, just run +If you’re using `penaltyLog()`, the default, just run ```sh -$ adb logcat +$ adb logcat ``` and watch the terminal output. Any violations will be logged to your console, slightly rate-limited for duplicate elimination. @@ -300,7 +313,7 @@ The Monkey is a program that runs on your emulator or device and generates pseud ```sh $ adb shell monkey [options] # Basic, make 500 random actions. -$ adb shell monkey -p your.package.name -v 500 +$ adb shell monkey -p your.package.name -v 500 ``` Complete information at http://developer.android.com/tools/help/monkey.html @@ -354,7 +367,7 @@ What matter is the three columns shown. Copy paste results in a spreadsheet. And ![Image](./images/dumpsys_sample.png) -This is the data you can grab. You can create a stack graph, so every bar contains the sum of the three columns on the left in the data we output. Is the time it takes to update the display list on every frame. +This is the data you can grab. You can create a stack graph, so every bar contains the sum of the three columns on the left in the data we output. Is the time it takes to update the display list on every frame. * The middle column is called process display list. It's the time we take to draw the actual display list * The last column is the time we take to swap the buffers, so to give the buffer back to surface flinger. Scrolling or doing any kind of actions should be below 16 millisecond limit. So this app is running at 60FPS, we're vsync'd, everything is going great. You can see that most of the time, you should spend most of the time in process display list, so drawing, executing the display list should be where you spend the bulk of the time. @@ -387,7 +400,7 @@ $ adb usb $ adb devices ``` -* Change adb mode from USB to tcpip using following command. +* Change adb mode from USB to tcpip using following command. ```sh $ adb tcpip 5555 # Restarting in TCP mode port: 5555. @@ -396,7 +409,7 @@ $ adb tcpip 5555 * Now, adb is running over TCP/IP mode, Let’s find IP address of Android device. Go to Settings in Android device -> About -> Status -> IP address. note down the IP address of connected Android Device. * Use following command to connect ADB with IP address ```sh -$ adb connect #.#.#.# +$ adb connect #.#.#.# # Connected to #.#.#.#:5555. ``` @@ -420,7 +433,7 @@ In order to test permissions targeting API 23+, we could use following commands ```sh $adb pm grant ``` -or +or ```sh $adb pm revoke ``` @@ -536,6 +549,3 @@ supports-any-density: 'true' locales: '--_--' densities: '120' '160' '240' '320' ``` - - - From 4198bde58a5a43a2005615907badb8b62e2e6785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar?= Date: Tue, 16 Aug 2016 10:43:04 +0200 Subject: [PATCH 24/38] Added test alarms section/ --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 84d82f7..2798efa 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ - __See the executed SQL statements in plain text in Logcat__ - __Testing - Execute Monkey to test user interaction__ - __Find out processor version on Android Device (check if it's an ARM, for example)__ + - [__Test Alarms__](#test-alarms) - __Find out Application Binary Interface (ABI) in different devices__ - __Retrieve application's private data and databases for non debug application without root access__ - __Indentify Frame Rate Issues (Dumpsys)__ @@ -325,6 +326,25 @@ Complete information at http://developer.android.com/tools/help/monkey.html $ adb shell cat /proc/cpuinfo ``` +#### Test Alarms + +[__Source__](http://vitovalov.com/2016/07/18/adb-date-changer.html) + +To check the alarms that are set on the connected device and to know more about them: + +```shell +$ adb shell dumpsys alarm +``` + +To see the alarms from you app you can grep with your package keywords: +```shell +$ adb shell dumpsys alarm | grep -A 3 google +``` + +So now you can see if you have correctly implemented your alarms functionality using AlarmManager API. + +[__More info here__](http://vitovalov.com/2016/07/18/adb-date-changer.html) + #### Find out Application Binary Interface (ABI) in different devices From eab5658be3badd685c92ed09d434a7e003299d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Tue, 30 Aug 2016 07:49:52 +0100 Subject: [PATCH 25/38] Android Nightmode enabler section (adb) --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2798efa..a30e92c 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,9 @@ - __Test new Marshmallow permissions__ - __Testing your app with App Standby__ - __Testing your app with Doze__ -- __AAPT__ - - __Check Permissions in order to avoid Play Store app filtering__ + - __Enabling Night Mode on Android Nougat__ + - __AAPT__ + - __Check Permissions in order to avoid Play Store app filtering__
@@ -507,6 +508,17 @@ You may need to run the second command more than once. Repeat it until the devic - Observe the behavior of your app after you reactivate the device. Make sure the app recovers gracefully when the device exits Doze. +
+ + +#### Enabling Night Mode on Android Nougat + +[__Source__](http://michaelevans.org/blog/2016/08/23/enabling-night-mode-on-android-nougat/) +``` +$ adb -d shell am start --ez show_night_mode true com.android.systemui/.tuner.TunerActivity +``` + +
From f558206f213c5a1a0acd674acee56e2db05be987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Tue, 30 Aug 2016 07:50:37 +0100 Subject: [PATCH 26/38] Wrong format fixed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a30e92c..c500283 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ - __Testing your app with App Standby__ - __Testing your app with Doze__ - __Enabling Night Mode on Android Nougat__ - - __AAPT__ +- __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__
From b0cac5ba6401ef0bd13f6485a06dbbd753810559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar?= Date: Mon, 5 Sep 2016 19:38:24 +0100 Subject: [PATCH 27/38] Added Content Provider Query section --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index c500283..ad69024 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ - __Testing - Execute Monkey to test user interaction__ - __Find out processor version on Android Device (check if it's an ARM, for example)__ - [__Test Alarms__](#test-alarms) + - [__Query a Content Provider__](#query-a-content-provider) - __Find out Application Binary Interface (ABI) in different devices__ - __Retrieve application's private data and databases for non debug application without root access__ - __Indentify Frame Rate Issues (Dumpsys)__ @@ -346,6 +347,12 @@ So now you can see if you have correctly implemented your alarms functionality u [__More info here__](http://vitovalov.com/2016/07/18/adb-date-changer.html) +#### Query a Content Provider + +```shell +$ adb shell content query --uri content://your.package.name --projection name +``` + #### Find out Application Binary Interface (ABI) in different devices From 0609374372d5df67a50ceaef5c956b5064e776fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Thu, 10 Nov 2016 15:58:31 +0100 Subject: [PATCH 28/38] Update README.md added more adb actions. --- README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ad69024..c5346e0 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - __Debug Keystore__ - __Release Keystore__ - __ADB__ + - __Server actions__ - __Show cold start Activity time__ - __Database__ - __Watching StrictMode__ @@ -72,6 +73,19 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia ### ADB + +### Server actions + +The following command kills the adb server: +```sh +adb kill-server +``` + +This starts the adb server: +```sh +adb start-server +``` + #### Show cold start Activity time @@ -139,8 +153,9 @@ $ adb shell dumpsys activity services #### Install an application ```sh -$ adb install -r file.apk -# Optional -r argument reinstalls and keeps any data if the application is already installed on the device. +$ adb install -r file.apk // (or com.package.name) +# optional -r argument reinstalls and keeps any data if the application is already installed on the device. +# optional -s argument installs the app on the SD card instead of the internal storage. ``` @@ -155,6 +170,12 @@ To uninstall the application using uninstall dialog: $ adb shell am start -a android.intent.action.DELETE -d package:com.package.name ``` +To keep the data in the cache directory, add `-k` + +```sh +$ adb uninstall -k com.package.name +``` + #### Start an Activity @@ -525,7 +546,6 @@ You may need to run the second command more than once. Repeat it until the devic $ adb -d shell am start --ez show_night_mode true com.android.systemui/.tuner.TunerActivity ``` -
From 5e1932dac251e1a5ec13fe5b7a67479f14f99c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Thu, 10 Nov 2016 16:31:19 +0100 Subject: [PATCH 29/38] Update README.md push and pull local files to device/emulator. --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5346e0..88fb188 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ - __Testing your app with App Standby__ - __Testing your app with Doze__ - __Enabling Night Mode on Android Nougat__ + - [__Copy files from/to a device/emulator__](#copy-files-emulator) - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ @@ -74,7 +75,7 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia ### ADB -### Server actions +#### Server actions The following command kills the adb server: ```sh @@ -548,6 +549,35 @@ $ adb -d shell am start --ez show_night_mode true com.android.systemui/.tuner.Tu
+
+##### Copy files from/to a device/emulator + +[__Source__](http://crushingcode.co/do-you-like-to-adb/) + +To push a file/dir to device: +```sh +$ adb push +``` +where `` is file in your local system i.e my_image.png and `` is file location in device/emulator i.e `/sdcard/Downloads/my_image.png` + +Sample: +```sh +$ adb push ~/Downloads/my_image.png /sdcard/Downloads/my_image.png +``` +To pull a file/dir from device + +```sh +$ adb pull [] +``` +where `` is file in your local system i.e my_image.png and `` is file location in device/emulator i.e `/sdcard/Downloads/my_image.png`. + +Sample: +```sh +adb pull /sdcard/Downloads/my_image.png my_image.png +``` + +
+
### AAPT From a09406ce7d7c613e61c299119a36ac580b07b1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 9 Dec 2016 11:42:43 +0000 Subject: [PATCH 30/38] Update README.md Added device selection instructions. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 88fb188..1bffd31 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - __Debug Keystore__ - __Release Keystore__ - __ADB__ + - [__Select a device when multiple devices are connected__](#select-a-device-when-multiple-devices-are-connected) - __Server actions__ - __Show cold start Activity time__ - __Database__ @@ -74,6 +75,14 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia ### ADB +#### Select a device when multiple devices are connected + +You can use `adb devices -l` to check information related to them, in order to select the one you want. Then: +``` +adb -s +``` +where is the number listed when you use `adb devices` and are the instructions you want to execute over the device. + #### Server actions From 2784dcdf53fd65da4d503c4b49fde3f193d6188c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 9 Dec 2016 11:43:28 +0000 Subject: [PATCH 31/38] Update README.md fixed error related to instructions. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bffd31..250f1c4 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ You can use `adb devices -l` to check information related to them, in order to s ``` adb -s ``` -where is the number listed when you use `adb devices` and are the instructions you want to execute over the device. +where `` is the number listed when you use `adb devices` and `` are the instructions you want to execute over the device. #### Server actions From 2ec208919c77ca81a8db896e8b02caac0c3a76fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Sun, 16 Apr 2017 08:43:03 +0100 Subject: [PATCH 32/38] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 250f1c4..d1a0d3d 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@
-
### SHA-1 + In order to get SHA1 to use it in many services, like Google+ Sign In, Maps, In app purchases, we should generate keys for every keystore (certificate): From 27527c65a39fd33cb257b2f371886ae0500cbcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Mon, 17 Apr 2017 17:52:10 +0100 Subject: [PATCH 33/38] Update README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index d1a0d3d..5fc0b90 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ - __Testing your app with Doze__ - __Enabling Night Mode on Android Nougat__ - [__Copy files from/to a device/emulator__](#copy-files-emulator) + - [Trigger a notification without GCM](trigger-a-notification-without-gcm) - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ @@ -585,6 +586,28 @@ Sample: adb pull /sdcard/Downloads/my_image.png my_image.png ``` +#### Trigger a notification without GCM + +[Source](https://plus.google.com/108612553581259107752/posts/ERVnjUAjsbZ) + +**IMPORTANT**: Remember to remove **temporally** the following attribute from the declaration of the Broadcast Receiver you want to test, in the Manifest: +``` +android:permission="com.google.android.c2dm.permission.SEND" +``` + +It's based on enabling broadcast receivers. +``` +am broadcast -a -n / +``` + +Some examples could be: +``` +adb shell am broadcast -a com.whereismywifeserver.intent.TEST --es sms_body "test from adb" +adb shell am broadcast -a com.google.android.c2dm.intent.REGISTRATION -n de.example/.GCMBroadcastReceiver +--es "registration_id" "1234" +``` +where `--es` define extra as string +
From c176abc29b445790bdb07177c0cfbebbc4077cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Mon, 17 Apr 2017 17:53:59 +0100 Subject: [PATCH 34/38] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fc0b90..dd193f1 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ - __Testing your app with Doze__ - __Enabling Night Mode on Android Nougat__ - [__Copy files from/to a device/emulator__](#copy-files-emulator) - - [Trigger a notification without GCM](trigger-a-notification-without-gcm) + - [__Trigger a notification without GCM__](trigger-a-notification-without-gcm) - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ From 6712a83734f930209fdf23a7fb7108e136146f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Mon, 17 Apr 2017 17:54:32 +0100 Subject: [PATCH 35/38] Updated bold title in the table of content From 72e40cf5bc987ddd04860a45640613118aed8adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Mon, 17 Apr 2017 17:56:02 +0100 Subject: [PATCH 36/38] Update README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dd193f1..1d44a16 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,16 @@ - __Find out processor version on Android Device (check if it's an ARM, for example)__ - [__Test Alarms__](#test-alarms) - [__Query a Content Provider__](#query-a-content-provider) - - __Find out Application Binary Interface (ABI) in different devices__ - - __Retrieve application's private data and databases for non debug application without root access__ - - __Indentify Frame Rate Issues (Dumpsys)__ - - __Use ADB over Wi-Fi without extra application or software__ - - __Test new Marshmallow permissions__ - - __Testing your app with App Standby__ - - __Testing your app with Doze__ - - __Enabling Night Mode on Android Nougat__ - - [__Copy files from/to a device/emulator__](#copy-files-emulator) - - [__Trigger a notification without GCM__](trigger-a-notification-without-gcm) + - __Find out Application Binary Interface (ABI) in different devices__ + - __Retrieve application's private data and databases for non debug application without root access__ + - __Indentify Frame Rate Issues (Dumpsys)__ + - __Use ADB over Wi-Fi without extra application or software__ + - __Test new Marshmallow permissions__ + - __Testing your app with App Standby__ + - __Testing your app with Doze__ + - __Enabling Night Mode on Android Nougat__ + - [__Copy files from/to a device/emulator__](#copy-files-emulator) + - [__Trigger a notification without GCM__](#trigger-a-notification-without-gcm) - __AAPT__ - __Check Permissions in order to avoid Play Store app filtering__ From a204fdf1380bfc2890fd6578f6b4dec6e92cc14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Sat, 29 Apr 2017 11:03:03 -0400 Subject: [PATCH 37/38] Update README.md --- README.md | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1d44a16..1e2db2d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ - __ADB__ - [__Select a device when multiple devices are connected__](#select-a-device-when-multiple-devices-are-connected) - __Server actions__ - - __Show cold start Activity time__ + - [__Show launcher activity cold start time__](#show-launcher-activity-cold-start-time) - __Database__ - __Watching StrictMode__ - __View connected devices__ @@ -97,17 +97,44 @@ This starts the adb server: adb start-server ``` - -#### Show cold start Activity time +
-```sh +#### Show launcher activity cold start time + +[__Source__](https://www.youtube.com/watch?v=oJAS7T-qurk) + +``` $ adb logcat | grep "ActivityManager" ``` The output would be something similar to: + +``` +ActivityManager: Displayed com.example.launchtime/: +666ms +``` + +If we also use want to show the content ready time, we should use the API method `reportFullyDrawn`: + ``` -ActivityManager: Displayed com.example.launchtime/.LaunchTime: +666ms +ActivityCompatAdditions.reportFullyDrawn(this); ``` +Then the time output will be the actual time that takes to Activity to be ready: +``` +ActivityManager: Displayed com.example.launchtime/.LaunchTimeActivity: +666ms +ActivityManager: Fully drawn com.example.launchtime/.LaunchTimeActivity: +1s440ms +``` + +Amount of time that takes to draw the first frame + the content. + +We can also use the `Activity` start command from ADB, with the `W` flag: + +``` +adb shell am start -W com.package.name/.LauncherScreenActivity +``` + +We will see 3 times related to starting times. + +
#### Database From 85cbd6c60a4d1dbf8ee40c8ffb63536ceb4ac73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20D=C3=ADez=20S=C3=A1nchez?= Date: Fri, 8 Jun 2018 11:24:27 -0400 Subject: [PATCH 38/38] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 1e2db2d..72a8cd2 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,11 @@ $ adb shell am start -n com.package.name/com.package.name.ActivityName ```sh $ adb shell am start -n android.intent.action.VIEW -d "scheme://app/deep/linking" ``` +or +```sh +$ adb shell am start -n android.intent.action.VIEW -d "https://name.app/user-settings/324" com.packaging.app +``` + #### Take an screenshot