diff --git a/README.md b/README.md index ad69024..72a8cd2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ - __Debug Keystore__ - __Release Keystore__ - __ADB__ - - __Show cold start Activity time__ + - [__Select a device when multiple devices are connected__](#select-a-device-when-multiple-devices-are-connected) + - __Server actions__ + - [__Show launcher activity cold start time__](#show-launcher-activity-cold-start-time) - __Database__ - __Watching StrictMode__ - __View connected devices__ @@ -33,21 +35,23 @@ - __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__ + - __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__
- ### 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): @@ -72,18 +76,66 @@ $ keytool -list -v -keystore {path_to_keystore}/my-release.keystore -alias {alia ### ADB - -#### Show cold start Activity time +#### 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 + +The following command kills the adb server: +```sh +adb kill-server +``` +This starts the adb server: ```sh +adb start-server +``` + +
+ +#### 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/.LaunchTime: +666ms +ActivityManager: Displayed com.example.launchtime/: +666ms ``` +If we also use want to show the content ready time, we should use the API method `reportFullyDrawn`: + +``` +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 @@ -139,8 +191,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 +208,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 @@ -169,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 @@ -525,6 +589,56 @@ 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 ``` +
+ +
+##### 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 +``` + +#### 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