Title: Theory / Unimportant / CS / Development / Android / adb
On every note of this deck, unless a note says otherwise:
Page: https://developer.android.com/studio/command-line/adb

Instruction: adb
Page: https://developer.android.com/studio/command-line/adb
Effect: versatile command-line tool that lets you communicate with a device
Name: Android Debug Bridge

Name: Adb client
Definition: A program that run on the development machine and send commands to the android device
Page: https://developer.android.com/studio/command-line/adb

Name: Adbd
Definition: Runs adb commands on a device.
Page: https://developer.android.com/studio/command-line/adb
Extra: The daemon runs as a background process on each device.
Etymology: Adb daemon

Name: Adb server
Definition: manages communication between the client and the daemon
Page: https://developer.android.com/studio/command-line/adb
Context: Adb

Question: How to activate developer options in Android
Answer: Settings > About phone and tap Build number seven times
Page: https://developer.android.com/studio/command-line/adb
Context: Android

Fla: device
Effect: List all connected devices
Prefix: adb
Context: Android

Fla: -l
Effect: print more information from devices
Prefix: adb devices
Context: Android

Fla: kill-server
Effect: kill the adb server
Prefix: adb

Fla: start-server
Effect: start the adb server
Prefix: adb

Fla: -s serial
Effect: send the command to device with serial
Prefix: adb

Question: Which device adb connect
Answer: The one indicated by -d, -e or -s
Page: https://developer.android.com/studio/command-line/adb
Answer2: the one with serial $ANDROID_SERIAL otherwise
Answer3: the only one if there is a single one

Fla: -e
Effect: uses the only emulator
Prefix: adb

Fla: -d
Effect: uses the only connected device
Prefix: adb

Fla: forward port from to port to
Effect: forward from to
Prefix: adb

Fla: copy remote from device to local on the developer computer
Effect: pull remote local
Prefix: adb

Fla: copy local on the developer computer to remote on the android
Effect: push local remote
Prefix: adb

Fla: --help
Effect: show all supported command
Prefix: adb

Fla: shell
Effect: start a shell
Prefix: adb

Fla: shell command
Effect: execute command in the android device's shell
Prefix: adb

Instruction: am
Page: https://developer.android.com/studio/command-line/adb
Effect: perform various system actions, such as start an activity, force-stop a process, broadcast an intent, modify the device screen properties, and more
Context: adb
Name: Activity manager

Fla: intent
Effect: Start an activity specified by intent
Prefix: am
Context: adb

Fla: -D
Effect: enable debugging
Prefix: am intent
Context: adb

Fla: -W
Effect: Wait for launch to complete
Prefix: am intent
Context: adb

Fla: --start-profiler file
Effect: Start profiler and send results to file
Prefix: am intent
Context: adb

Fla: -P file
Effect: Start profiler, stop it when app goes idle, and send results to file
Prefix: am intent
Context: adb

Fla: -R count
Effect: Repeat the activity launch count times. Prior to each repeat, the top activity will be finished.
Prefix: am intent
Context: adb

Fla: -S
Effect: Force stop the target app before starting the activity.
Prefix: am intent
Context: adb

Fla: --opengl-trace
Effect: Enable tracing of OpenGL functions.
Prefix: am intent
Context: adb

Fla: --user user_id
Effect: Specify which user to run as
Prefix: am start|startservice|kill|broadcast|dumphead|list packages|disable-user|set-active-admin|set-profile-owner|set-device-owner|remove-active-admin intent
Context: adb
Default: current user

Fla: startservice intent
Effect: Start the Service specified by intent.
Prefix: am
Context: adb

Fla: force-stop package
Effect: Force stop everything associated with package
Prefix: am
Context: adb

Fla: kill package
Effect: Kill all processes associated with package
Prefix: am
Context: adb
Extra: This command kills only processes that are safe to kill and that will not impact the user experience.

Fla: kill-all
Effect: Kill all background processes
Prefix: am
Context: adb
Extra: This command kills only processes that are safe to kill and that will not impact the user experience.

Fla: broadcast intent
Effect: issue a broadcast intent
Prefix: am
Context: adb

Fla: instrument component
Effect: Start monitoring component with an Instrumentation instance.
Prefix: am
Context: adb

Fla: -r
Effect: print raw result
Prefix: am instrument component
Context: adb
Extra: otherwise decode report_key_streamresult

Fla: -e name value
Effect: set argument name to value
Prefix: am instrument component
Context: adb
Extra: For test runners a common form is -e testrunner_flag value[,value...]

Fla: -p file
Effect: Write profiling data to file.
Prefix: am instrument component
Context: adb

Fla: -w
Effect: Wait for instrumentation to finish before returning.
Prefix: am instrument component
Context: adb
Extra: Required for test runners.

Fla: --no-window-animation
Effect: Turn off window animations while running.
Prefix: am instrument component
Context: adb

Fla: profile start process file
Effect: start profiler on process, write results to file
Prefix: am
Context: adb

Fla: profile stop process
Effect: spote profiler on process
Prefix: am
Context: adb

Fla: dumphead process file
Effect: dump the heap of process, write to file
Prefix: am
Context: adb

Fla: -n
Effect: Dump native heap instead of managed heap.
Prefix: am dumphead process file
Context: adb

Fla: set-debug-app package
Effect: set app package to debug
Prefix: am
Context: adb

Fla: -w
Effect: wait for debugger when app starts.
Prefix: am set-debug-app package
Context: adb

Fla: clear-debug-app
Effect: Clear the package previous set for debugging with set-debug-app.
Prefix: am
Context: adb

Fla: monitor
Effect: Start monitoring for crashes or ANRs.
Prefix: am
Context: adb

Fla: --gdb
Effect: Start gdbserv on the given port at crash/ANR.
Prefix: am monitor
Context: adb

Fla: screen-compat on|off package
Effect: control screen compatibility mode of package
Prefix: am
Context: adb

Fla: display-size reset
Effect: reset display size
Prefix: am
Context: adb

Fla: display-size WxH
Effect: set display size to width w and heigh h
Prefix: am
Context: adb

Fla: display-density dpi
Effect: set display density to dpi
Prefix: am
Context: adb

Fla: to-uri intent
Effect: Print the given intent specification as a URI.
Prefix: am
Context: adb

Fla: to-intent-uri intent
Effect: Print the given intent specification as an intent: URI.
Prefix: am
Context: adb

Fla: -a action
Effect: specify the intent action
Prefix: am command_with_intent
Context: adb
Assuming: declared at most once

Fla: -d data_uri
Effect: specify the intent data URI
Prefix: am command_with_intent
Context: adb
Assuming: declared at most once

Fla: -t mime_type
Effect: specify the MIME type
Prefix: am command_with_intent
Context: adb
Assuming: declared at most once

Fla: -c category
Effect: specify an intent actegory
Prefix: am command_with_intent
Context: adb

Fla: -n component
Effect: Specify the component name with package name prefix to create an explicit intent
Prefix: am command_with_intent
Context: adb

Fla: -f flags
Effect: add flags to the intent, as supported by setFlags()
Prefix: am command_with_intent
Context: adb

Fla: --esn extra_key
Effect: Add a null extra
Prefix: am command_with_intent
Context: adb
Assuming: not for URI intent

Fla: --e(s|z|i|b|l|f|u|cn) extra_key extra_value
Effect: Add a key with a (string|bool|int|long|float|uri|component_name) value
Prefix: am command_with_intent
Context: adb

Fla: --e(i|l|f)z extra_key extra_value_0,...,extra_value_n
Effect: Add a key with sequence of int|long|float values
Prefix: am command_with_intent
Context: adb

Fla: --flag_name
Effect: Include the flag FLAG_flag_name.
Prefix: am command_with_intent
Context: adb

Fla: --selector
Effect: Requires the use of -d and -t options to set the intent data and type.
Prefix: am command_with_intent

Fla: URI component package
Effect: specify a URI package name and component name when not qualified by one of the above options
Prefix: am command_with_intent

Fla: pm
Effect: package manager command
Context: adb

Fla: list package
Effect: prints all packages
Prefix: pm
Context: adb

Fla: -f
Effect: see their associated file
Prefix: pm list package
Context: adb

Fla: -d
Effect: show only disabled  packages
Prefix: pm list package
Context: adb

Fla: -e
Effect: show only disabled  packages
Prefix: pm list package
Context: adb

Fla: -s
Effect: only show system packages
Prefix: pm list package
Context: adb

Fla: -3
Effect: only show third party packages
Prefix: pm list package
Context: adb

Fla: -i
Effect: see the installer for the packages
Prefix: pm list package
Context: adb

Fla: -u
Effect: also include uninstalled packages
Prefix: pm list package
Context: adb

Fla: list permission-groups
Effect: prints all known permission groups
Prefix: pm
Context: adb

Fla: permission
Effect: print all known permissions
Prefix: pm
Context: adb

Fla: -g
Effect: organize by group
Prefix: pm permission
Context: adb

Fla: -f
Effect: print all information
Prefix: pm permission
Context: adb

Fla: -s
Effect: short summary
Prefix: pm permission
Context: adb

Fla: -d
Effect: only list dangerous permission
Prefix: pm permission
Context: adb

Fla: -u
Effect: list only the permissions users will see
Prefix: pm permission
Context: adb

Fla: list instrumentation
Effect: list all test packages
Prefix: pm
Context: adb

Fla: -f
Effect: list the APK file for the test package
Prefix: pm instrumentation
Context: adb

Fla: target_package
Effect: list test packages only for this app
Prefix: pm instrumentation
Context: adb

Fla: list libraries
Effect: print all the libraries supported by the current device
Prefix: pm
Context: adb

Fla: list users
Effect: print all users on the system
Prefix: pm
Context: adb

Fla: path package
Effect: print the path to the apk of the given package
Prefix: pm
Context: adb

Fla: install path
Effect: install package at path
Prefix: pm
Context: adb

Fla: -r
Effect: reinstall an existing app, keeping its data
Prefix: pm install path
Context: adb

Fla: -i installer_package_name
Effect: Specify the installer package name.
Prefix: pm install path
Context: adb

Fla: --install-location 0
Effect: use the default install location
Prefix: pm install path
Context: adb

Fla: --install-location 1
Effect: install on internal device storage
Prefix: pm install path
Context: adb

Fla: --install-location 2
Effect: install on external media
Prefix: pm install path
Context: adb

Fla: -f
Effect: install package on the intenal system memory
Prefix: pm install path
Context: adb

Fla: -d
Effect: allow version code downgrade
Prefix: pm install path
Context: adb

Fla: -g
Effect: grant all permissions listed in the app manifest
Prefix: pm install path
Context: adb

Fla: --fastdeploy
Effect: quickly update an intsalled package by only updating the parts of the APK that changed
Prefix: pm install path
Context: adb

Fla: --incremental
Effect: Installs enough of the APK to launch the app while streaming the remaining data in the background.
Prefix: pm install path
Context: adb
Extra: This feature is only supported on certain devices. This option forces adb to use the feature or fail if it is not supported (with verbose information on why it failed). Append the --wait option to wait until the APK is fully installed before granting access to the APK.
Assuming: To use this feature, you must sign the APK, create an APK Signature Scheme v4 file, and place this file in the same directory as the APK.

Fla: --no-incremental
Effect: prevents adb from using the incremental feature
Prefix: pm install path
Context: adb

Fla: uninstall package
Effect: removes a package from the system
Prefix: pm
Context: adb

Fla: -k
Effect: Keep the data and cache directories around after package removal
Prefix: pm uninstall package
Context: adb

Fla: clear package
Effect: Deletes all data associated with a package
Prefix: pm
Context: adb

Fla: enable package_or_component
Effect: Enable the given package or component (written as "package/class").
Prefix: pm
Context: adb

Fla: disable package_or_component
Effect: Disable the given package or component (written as "package/class").
Prefix: pm
Context: adb

Fla: disable-user package_or_component
Effect: ?
Prefix: pm
Context: adb

Fla: grant package_name permission
Effect: grant permission to packagename
Prefix: pm
Context: adb
Assuming: On devices running Android 6.0 (API level 23) and higher, the permission can be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.

Fla: revoke package_name permission
Effect: Revoke a permission from an app.
Prefix: pm
Context: adb
Assuming: On devices running Android 6.0 (API level 23) and higher, the permission can be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.

Fla: set-install-location 0
Effect: let sytsem decide the best location
Prefix: pm
Context: adb

Fla: set-install-location 1
Effect: install on internal device storage
Prefix: pm
Context: adb
Intuition: This is only intended for debugging; using this can cause apps to break and other undesireable behavior.

Fla: set-install-location 2
Effect: install on external device storage
Prefix: pm
Context: adb
Intuition: This is only intended for debugging; using this can cause apps to break and other undesireable behavior.

Fla: get-install-location 2
Effect: returns the current install location as set by set-install-location
Prefix: pm
Context: adb

Fla: set_permission_enforced permission true|false
Effect: set whether permission is enforced
Prefix: pm
Context: adb

Fla: trim_caches desired_free_space
Effect: Trim cache files to reach the given free space.
Prefix: pm
Context: adb

Fla: create-user user_name
Effect: Create a new user with the given user_name, printing the new user identifier of the user.
Prefix: pm
Context: adb

Fla: remove-user user_id
Effect: Remove the user with the given user_id, deleting all data associated with that user
Prefix: pm
Context: adb

Fla: get-max-users
Effect: Prints the maximum number of users supported by the device.
Prefix: pm
Context: adb

Fla: dpm
Effect: call device policy manager
Context: adb

Fla: set-active-admin component
Effect: Sets component as active admin.
Prefix: dpm
Context: adb

Fla: set-profile-owner component
Effect: Sets component as active admin and its package as profile owner for an existing user.
Prefix: dpm
Context: adb

Fla: set-device-owner component
Effect: Sets component as active admin and its package as device owner.
Prefix: dpm
Context: adb

Fla: remove-active-admin component
Effect: Disables an active admin. This command also removes device and profile owners.
Prefix: dpm
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Fla: clear-freeze-period-record
Effect: Clears the device's record of previously-set freeze periods for system OTA updates. This is useful to avoid the device's scheduling restrictions when developing apps that manage freeze-periods. See Manage system updates.
Prefix: dpm
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Fla: force-network-logs
Effect: Forces the system to make any existing network logs ready for retrieval by a DPC. If there are connection or DNS logs available, the DPC receives the onNetworkLogsAvailable() callback.
Prefix: dpm
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Fla: force-security-logs
Effect: Forces the system to make any existing security logs available to the DPC. If there are logs available, the DPC receives the onSecurityLogsAvailable() callback.
Prefix: dpm
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Fla: screencap filename
Effect: a shell utility for taking a screenshot of a device display
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Instruction: screenrecord filename
Page: https://developer.android.com/studio/command-line/adb
Effect: record screen video and put it in filename
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Instruction: screencap filename
Page: https://developer.android.com/studio/command-line/adb
Effect: take a screenshot in filename
Context: adb
Assuming: The app must declare android:testOnly in the manifest.

Name: android runtime
Definition: collects execution profiles for installed apps, which are used to optimize app performance.
Page: https://developer.android.com/studio/command-line/adb
Context: adb
Abbreviation: ART
Assuming: The app must declare android:testOnly in the manifest.

Fla: package dump-profiles package
Effect: output ART stats for package in /data/misc/profman/package.txt
Prefix: cmd
Context: adb

Fla: testharness enable
Effect: reset all user data to ensure to reset the test environment
Prefix: cmd
Context: adb