# Class: com.pnfsoftware.jeb.core.units.code.android.adb.AndroidDeviceUtil

Useful routines when debugging Android devices.

## Static Method: executeCommandAsRoot
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `command`, type: `java.lang.String`
- return type: `boolean`

Description: Attempt to execute a single ADB command as root, with a prior root verification.
parameter: adb: ADB wrapper
parameter: command: shell command
return: true on success
throws: on root or execution error

## Static Method: executeCommandAsRoot
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `rootVerification`, type: `boolean`
- parameter: `command`, type: `java.lang.String`
- return type: `boolean`

Description: Attempt to execute a single ADB command as root.
parameter: adb: ADB wrapper
parameter: rootVerification: true to verify root availability before execution
parameter: command: shell command
return: true on success
throws: on root or execution error

## Static Method: executeCommandsAsRoot
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `commands`, type: `java.lang.String[]`
- return type: `boolean`

Description: Attempt to execute a sequence of ADB commands as root, with a prior root verification.
parameter: adb: ADB wrapper
parameter: commands: shell commands
return: true on success
throws: on root or execution error

## Static Method: executeCommandsAsRoot
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `rootVerification`, type: `boolean`
- parameter: `commands`, type: `java.lang.String[]`
- return type: `boolean`

Description: Attempt to execute a sequence of ADB commands as root.
parameter: adb: ADB wrapper
parameter: rootVerification: true to verify root availability before execution
parameter: commands: shell commands
return: true on success
throws: on root or execution error

## Static Method: getAndroidApiLevel
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- return type: `int`

Description: Retrieve the numerical API level \(eg, 29 on Android Q\) of the target.
parameter: adb: ADB wrapper
return: 0 on error

## Static Method: getBestABIForApp
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `apk`, type: `com.pnfsoftware.jeb.core.units.code.android.IApkUnit`
- return type: `com.pnfsoftware.jeb.core.units.code.android.adb.AndroidPlatformABI`

Description: Get the best ABI to run a given Android app on a given device. This method is a heuristic and may fail.
parameter: adb: ADB wrapper
parameter: apk: APK unit
return: the ABI that should be selected when running the app; null on error if if no         compatible ABI was found

## Static Method: getPreferredABI
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- return type: `com.pnfsoftware.jeb.core.units.code.android.adb.AndroidPlatformABI`

Description: Get the preferred ABI supported by a device.
parameter: adb: ADB wrapper
return: an ABI, null on error

## Static Method: getProcessesByName
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `processName`, type: `java.lang.String`
- return type: `java.util.List<java.lang.Integer>`

Description: Get a list of PIDs by process name
parameter: adb: ADB wrapper
parameter: processName: process name
return: matching process ids

## Static Method: getSupportedABIs
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.adb.AndroidPlatformABI>`

Description: Get the ABIs supported by a device.
parameter: adb: ADB wrapper
return: a list of ABIs, never null, but empty on error

## Static Method: isDebuggableApp
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `pname`, type: `java.lang.String`
- return type: `boolean`

Description: Determine whether an installed app is debuggable. An app is debuggable if its manifest has the 'debuggable' attribute explicitly set to true.
parameter: adb: ADB wrapper
parameter: pname: application package name
return: true if the app is debuggable

## Static Method: isRootDevice
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- return type: `boolean`

Description: Heuristic to determine if the device appears to be rooted \- and has a copy of `su` installed.
parameter: adb: ADB wrapper
return: true if the device appears to be rooted

## Static Method: pullFile
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `remotePath`, type: `java.lang.String`
- parameter: `localPath`, type: `java.lang.String`
- return type: `boolean`

Description: Attempt to pull a file from a device using a variety of methods. Ultimately, if the device is rooted, this method may resort to using super\-user capabilities to download the file.
parameter: adb: ADB wrapper
parameter: remotePath: file path on device
parameter: localPath: local destination path
return: true on success

## Static Method: uploadFileToDeviceTemp
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `name`, type: `java.lang.String`
- parameter: `platformAbi`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AndroidPlatformABI`
- return type: `java.lang.String`

Description: Upload a JEB Android asset file to an Android device.
parameter: adb: ADB wrapper
parameter: name: asset name
parameter: platformAbi: optional ABI
return: device path of the uploaded file
throws: on upload error

## Static Method: uploadFileToDeviceTemp
- parameter: `adb`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AdbWrapper`
- parameter: `name`, type: `java.lang.String`
- parameter: `platformAbi`, type: `com.pnfsoftware.jeb.core.units.code.android.adb.AndroidPlatformABI`
- parameter: `version`, type: `java.lang.String`
- parameter: `extension`, type: `java.lang.String`
- return type: `java.lang.String`

Description: Upload a JEB Android asset file to an Android device.
parameter: adb: mandatory ADB wrapper
parameter: name: mandatory asset name
parameter: platformAbi: optional
parameter: version: optional
parameter: extension: optional
return: the path of the copied file on the target device, NOT containing         `platform/version/extension` information
throws: on upload error

