Test using adb commands
Learn how to use adb
commands on Android devices when testing on BrowserStack App Live
Android Debug Bridge (adb) is a robust command-line tool that allows you to communicate with a connected Android device. Using adb
commands, you can perform a variety of device actions, such as installing apps, granting permissions, profiling for performance, etc.
You can now run adb
commands when testing your Android apps on BrowserStack App Live.
Follow these steps to access the adb
command interface and run your commands:
- Log in to the App Live dashboard.
- Select your app and the device to launch your test session.
The DevTools pane opens automatically. If you close it and want to open it again, click the DevTools option in the horizontal toolbar.
- In the DevTools pane, click the ADB Shell tab to open the command interface.
- Use this command interface to run supported
adb
commands. See the adb commands use cases section for supported commands.
adb commands use cases
This section provides details on how to run adb commands for the following use cases in an App Live session:
- Log and Debug Firebase Analytics events
- Log Google Analytics events
- Set system-level preferences using settings commands
- Get diagnostic output for system services using dumpsys commands
- Get system and device properties using getprop commands
Log and debug Firebase Analytics events
Log Events
You can set verbose logging to monitor the logs of Firebase events using the following setprop
commands:
setprop log.tag.FA VERBOSE
setprop log.tag.FA-SVC VERBOSE
When you run this command, logs for Firebase events will start appearing under device logs. You can capture the complete logs by using driver.manage().logs().get("logcat").filter(Level.ALL);
command and then filter out the firebase events for your app in your test.
Debug Events
You can enable the debug mode for Firebase Analytics on an Android device by using the following setprop
command:
setprop debug.firebase.analytics.app <PACKAGE_NAME>
When you run this command, your test session will begin on a device where debug mode has been enabled. You can then navigate to DebugView to view your app’s events being logged in the DebugView report.
Log Google Analytics events
You can enable the log feature of Google Analytics events by using the following setprop
command:
setprop log.tag.GAv4 DEBUG
When you run this command, logs for Google Analytics events will start appearing under device logs. You can capture the complete logs by using driver.manage().logs().get("logcat").filter(Level.ALL);
command and then filter out the Google Analytics events for your app in your test.
Set system-level preferences using settings commands
The settings put
commands can be used to set system-level device preferences such as disabling pop-up notifications, disabling location services, changing device orientation etc.
The following table lists all the settings put
commands that are supported in App Live:
Command | Description | Allowed Values |
---|---|---|
settings put secure location_mode 0 |
Enable/Disable location services on an android device | Disable: 0 Enable: 3 |
settings put global heads_up_notifications_enabled 0 |
Enable/Disable pop-up notifications on an android device | Disable: 0 Enable: 1 |
settings put global always_finish_activities 0 |
Enable/Disable aggressive finishing of activities and processes | Disable: 0 Enable: 1 |
settings put system accelerometer_rotation 0 |
Enable/Disable auto-rotation of the device | Disable: 0 Enable: 1 |
settings put system user_rotation 3 |
Rotate the device | 0° clockwise rotation: 0 90° clockwise rotation: 1 180° clockwise rotation: 2 270° clockwise rotation: 3 |
location_mode
setting can only be used on API level 19 (Android Version 4.4) to API level 28 (Android Version 9) devices.
Get diagnostic output for system services using dumpsys commands
dumpsys is a tool that runs on Android devices and offers information on system services. dumpsys
commands provide vital diagnostic output for system services operating on a connected device.
The following table lists all the dumpsys
commands that can be used in an App Live session:
Command | Description |
---|---|
dumpsys activity -p <package_name> |
Provides complete activity history for the given package |
dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp' |
Prints current app’s opened activity |
dumpsys activity -p <package_name> activities |
Provides activity manager activities that contain main stack, running activities and recent tasks |
dumpsys activity -p <package_name> activities | grep -E ‘mResumedActivity’ |
Prints current app’s resumed activity |
dumpsys activity -p <package_name> services |
Provides list of services running for the given package |
dumpsys activity -p <package_name> providers |
Provides list of current content providers for the given package |
dumpsys activity -p <package_name> recents |
Provides list of recent tasks for the given package |
dumpsys activity -p <package_name> broadcasts |
Provides list of broadcast states for the given package |
dumpsys activity -p <package_name> intents |
Provides list of pending intents for the given package |
dumpsys activity -p <package_name> permissions |
Provides list of permissions for the given package |
dumpsys activity -p <package_name> processes |
Provides list of running processes for the given package |
Command | Description |
---|---|
dumpsys gfxinfo <package_name> |
Gathers UI performance data for a specified package name |
dumpsys gfxinfo <package_name> framestats |
Provides even more detailed frame timing information from recent frames |
dumpsys gfxinfo <package_name> reset |
Resets the framemetrics data |
Command | Description |
---|---|
dumpsys input |
Dumps the state of the system’s input devices, such as keyboards and touchscreens, and the processing of input events |
Command | Description |
---|---|
dumpsys cpuinfo |
Provides info on CPU usage |
dumpsys display |
Provides info on display |
dumpsys power |
Provides info on power statistics |
dumpsys alarm |
Provides info on alarm |
dumpsys location |
Provides info on location |
dumpsys window displays |
Provides info like pixel resolution, FPS, and DPI of the device’s display |
dumpsys telephony.registry |
Gives information about wireless communication related parameters |
dumpsys bluetooth_manager |
Gives information about connected bluetooth devices, mac addresses etc. |
Command | Description |
---|---|
dumpsys netstats |
Displays network connections for the Transmission Control Protocol for both incoming and outgoing requests |
dumpsys netstats detail |
Outputs additional information, such as detailed unique user ID (UID) information |
dumpsys connectivity |
Provides the internet status and connectivity mode(cellular or Wi-Fi) |
dumpsys netpolicy |
Generates a report that includes the current global background network restriction setting, package UIDs that are currently allowed to bypass Data Saver, and the network permissions of other known packages |
dumpsys network_management |
Provides all information about device network management |
Command | Description |
---|---|
dumpsys batterystats options |
Generates interesting statistical data about battery usage on a device, organized by unique user ID (UID) |
dumpsys batterystats --charged <package_name> |
Outputs battery usage statistics for a specified app package since the device was last charged |
dumpsys batterystats --checkin |
Output in machine-readable CSV format |
Command | Description |
---|---|
dumpsys procstats --hours <hour> |
Provides info on how your app is behaving over time—including how long it runs in the background and how much memory it uses during that time |
dumpsys meminfo <package_name|pid> |
Record a snapshot of how your app’s memory is divided between different types of RAM allocation |
dumpsys meminfo <package_name|pid> [-d] |
The -d flag prints more info related to Dalvik and ART memory usage |
Command | Description |
---|---|
dumpsys package <package_name> |
Provides all the info about your app, ex: Version name/code, first install time, last update time, requested permissions, etc |
Get system and device properties using getprop commands
The getprop
commands can be used to get system and device properties such as Sim Operator, device model, Android version etc.
The following table lists all the getprop
commands that can be called in an App Live session:
Command | Description |
---|---|
getprop -T |
Provides a list of system property types |
getprop gsm.sim.operator.alpha |
Provides SIM Operator |
getprop ro.build.version.release |
Provides device android version |
getprop ro.boot.wifimacaddr |
Provides the WiFi Mac Address |
getprop ro.product.manufacturer |
Provides Android device manufacturer details |
getprop ro.vendor.product.model |
Provides Android device product number |
getprop ro.board.platform |
Provides Soc info |
getprop ro.oem_unlock_supported |
Provides OEM unlock status |
getprop ro.vendor.product.model |
Provides device model |
getprop ro.bootimage.build.fingerprint |
Provides Android device build fingerprint |
getprop ro.cdma.home.operator.alpha |
Provides SIM operator name |
getprop ro.system.build.version.sdk |
Provides API level |
getprop -T
command can only be used on Android devices with version 8.1 and above.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!