Class AndroidDeviceUtil
java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.adb.AndroidDeviceUtil
Useful routines when debugging Android devices.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanexecuteCommandAsRoot(AdbWrapper adb, boolean rootVerification, String command) Attempt to execute a single ADB command as root.static booleanexecuteCommandAsRoot(AdbWrapper adb, String command) Attempt to execute a single ADB command as root, with a prior root verification.static booleanexecuteCommandsAsRoot(AdbWrapper adb, boolean rootVerification, String[] commands) Attempt to execute a sequence of ADB commands as root.static booleanexecuteCommandsAsRoot(AdbWrapper adb, String[] commands) Attempt to execute a sequence of ADB commands as root, with a prior root verification.static intRetrieve the numerical API level (eg, 29 on Android Q) of the target.static AndroidPlatformABIgetBestABIForApp(AdbWrapper adb, IApkUnit apk) Get the best ABI to run a given Android app on a given device.static AndroidPlatformABIGet the preferred ABI supported by a device.getProcessesByName(AdbWrapper adb, String processName) Get a list of PIDs by process namestatic List<AndroidPlatformABI>Get the ABIs supported by a device.static booleanisDebuggableApp(AdbWrapper adb, String pname) Determine whether an installed app is debuggable.static booleanisRootDevice(AdbWrapper adb) Heuristic to determine if the device appears to be rooted - and has a copy ofsuinstalled.static booleanpullFile(AdbWrapper adb, String remotePath, String localPath) Attempt to pull a file from a device using a variety of methods.static StringuploadFileToDeviceTemp(AdbWrapper adb, String name, AndroidPlatformABI platformAbi) Upload a JEB Android asset file to an Android device.static StringuploadFileToDeviceTemp(AdbWrapper adb, String name, AndroidPlatformABI platformAbi, String version, String extension) Upload a JEB Android asset file to an Android device.
-
Constructor Details
-
AndroidDeviceUtil
public AndroidDeviceUtil()
-
-
Method Details
-
uploadFileToDeviceTemp
public static String uploadFileToDeviceTemp(AdbWrapper adb, String name, AndroidPlatformABI platformAbi) throws IOException Upload a JEB Android asset file to an Android device.- Parameters:
adb-name-platformAbi-- Returns:
- Throws:
IOException
-
uploadFileToDeviceTemp
public static String uploadFileToDeviceTemp(AdbWrapper adb, String name, AndroidPlatformABI platformAbi, String version, String extension) throws IOException Upload a JEB Android asset file to an Android device.- Parameters:
adb- mandatoryname- mandatoryplatformAbi- optionalversion- optionalextension- optional- Returns:
- the path of the copied file on the target device, NOT containing
platform/version/extensioninformation - Throws:
IOException
-
isRootDevice
Heuristic to determine if the device appears to be rooted - and has a copy ofsuinstalled.- Parameters:
adb-- Returns:
-
executeCommandAsRoot
Attempt to execute a single ADB command as root, with a prior root verification.- Throws:
AdbException
-
executeCommandAsRoot
public static boolean executeCommandAsRoot(AdbWrapper adb, boolean rootVerification, String command) throws AdbException Attempt to execute a single ADB command as root.- Throws:
AdbException
-
executeCommandsAsRoot
Attempt to execute a sequence of ADB commands as root, with a prior root verification.- Throws:
AdbException
-
executeCommandsAsRoot
public static boolean executeCommandsAsRoot(AdbWrapper adb, boolean rootVerification, String[] commands) throws AdbException Attempt to execute a sequence of ADB commands as root.- Throws:
AdbException
-
pullFile
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.- Parameters:
adb-remotePath- file path on devicelocalPath- local destination path- Returns:
- true on success
-
getSupportedABIs
Get the ABIs supported by a device.- Parameters:
adb-- Returns:
- a list of ABIs, never null, but empty on error
-
getPreferredABI
Get the preferred ABI supported by a device.- Parameters:
adb-- Returns:
- an ABI, null on error
-
getBestABIForApp
Get the best ABI to run a given Android app on a given device. This method is a heuristic and may fail.- Parameters:
adb-apk-- Returns:
- the ABI that should be selected when running the app; null on error if if no compatible ABI was found
-
getProcessesByName
Get a list of PIDs by process name- Parameters:
adb-processName-- Returns:
-
getAndroidApiLevel
Retrieve the numerical API level (eg, 29 on Android Q) of the target.- Parameters:
adb-- Returns:
- 0 on error
-
isDebuggableApp
Determine whether an installed app is debuggable. An app is debuggable if its manifest has the 'debuggable' attribute explicitly set to true.- Parameters:
adb-pname- application package name- Returns:
-