adb-helper
v1.0.13
Published
A library for interacting with Android devices via ADB(Android Debug Bridge).
Downloads
32
Maintainers
Readme
Table of Contents
- [ADB][1]
- [execCommand][2]
- [Parameters][3]
- [execCommand][2]
- [ADBHelper][4]
- [Properties][5]
- [Examples][6]
- [AppManagement][7]
- [Parameters][8]
- [Examples][9]
- [getCurrentScreenActivity][10]
- [Examples][11]
- [openApp][12]
- [Parameters][13]
- [Examples][14]
- [openActivity][15]
- [Parameters][16]
- [Examples][17]
- [getInstalledApps][18]
- [Parameters][19]
- [Examples][20]
- [clearAppData][21]
- [Parameters][22]
- [Examples][23]
- [installApp][24]
- [Parameters][25]
- [Examples][26]
- [uninstallApp][27]
- [Parameters][28]
- [Examples][29]
- [disableApp][30]
- [Parameters][31]
- [Examples][32]
- [enableApp][33]
- [Parameters][34]
- [Examples][35]
- [getGrantedPermissions][36]
- [Parameters][37]
- [Examples][38]
- [getAppPermissions][39]
- [Parameters][40]
- [Examples][41]
- [grantPermission][42]
- [Parameters][43]
- [Examples][44]
- [revokePermission][45]
- [Parameters][46]
- [Examples][47]
- [isAppInstalled][48]
- [Parameters][49]
- [Examples][50]
- [forceStopApp][51]
- [Parameters][52]
- [Examples][53]
- [launchURL][54]
- [Parameters][55]
- [Examples][56]
- [launchActivityWithExtras][57]
- [Parameters][58]
- [Examples][59]
- [disableAppNotifications][60]
- [Parameters][61]
- [Examples][62]
- [enableAppNotifications][63]
- [Parameters][64]
- [Examples][65]
- [modifySharedPreferences][66]
- [Parameters][67]
- [sendIntentToApp][68]
- [Parameters][69]
- [listAppActivities][70]
- [Parameters][71]
- [listProcesses][72]
- [getCachedScreenHierarchyValue][73]
- [setCachedScreenHierarchyValue][74]
- [Parameters][75]
- [getCachedElementValue][76]
- [setCachedElementValue][77]
- [Parameters][78]
- [getCurrentActivityValue][79]
- [setCurrentActivityValue][80]
- [Parameters][81]
- [getCachedScreenResolutionValue][82]
- [setCachedScreenResolutionValue][83]
- [Parameters][84]
- [DeviceControl][85]
- [Parameters][86]
- [Examples][87]
- [pressBack][88]
- [pressHome][89]
- [pressRecentApps][90]
- [checkDevice][91]
- [Examples][92]
- [rebootDevice][93]
- [Examples][94]
- [setBrightness][95]
- [Parameters][96]
- [Examples][97]
- [setAutoRotation][98]
- [Parameters][99]
- [Examples][100]
- [enableUSBDebugging][101]
- [Examples][102]
- [disableDeveloperMode][103]
- [Examples][104]
- [checkAndroidVersion][105]
- [Examples][106]
- [getBatteryStatus][107]
- [Examples][108]
- [toggleMobileData][109]
- [Parameters][110]
- [Examples][111]
- [toggleSync][112]
- [Parameters][113]
- [Examples][114]
- [toggleGPS][115]
- [Parameters][116]
- [Examples][117]
- [toggleWiFi][118]
- [Parameters][119]
- [Examples][120]
- [toggleBluetooth][121]
- [Parameters][122]
- [Examples][123]
- [toggleAirplaneMode][124]
- [Parameters][125]
- [Examples][126]
- [factoryReset][127]
- [Examples][128]
- [wipeUserData][129]
- [Examples][130]
- [rebootIntoRecovery][131]
- [Examples][132]
- [changeLanguage][133]
- [Parameters][134]
- [Examples][135]
- [captureSystemLog][136]
- [Examples][137]
- [setMediaVolume][138]
- [Parameters][139]
- [Examples][140]
- [setRingtoneVolume][141]
- [Parameters][142]
- [Examples][143]
- [setNotificationVolume][144]
- [Parameters][145]
- [Examples][146]
- [enableSilentMode][147]
- [Examples][148]
- [disableSilentMode][149]
- [Examples][150]
- [enableDoNotDisturb][151]
- [Examples][152]
- [disableDoNotDisturb][153]
- [Examples][154]
- [setSystemTime][155]
- [Parameters][156]
- [Examples][157]
- [setTimeZone][158]
- [Parameters][159]
- [Examples][160]
- [enableAutoTimeSync][161]
- [Examples][162]
- [checkDevelopmentSettings][163]
- [Examples][164]
- [checkAdbSettings][165]
- [Examples][166]
- [][167]
- [Parameters][168]
- [FileManager][169]
- [Parameters][170]
- [Examples][171]
- [listFiles][172]
- [Parameters][173]
- [Examples][174]
- [findFile][175]
- [Parameters][176]
- [Examples][177]
- [pushFile][178]
- [Parameters][179]
- [Examples][180]
- [pullFile][181]
- [Parameters][182]
- [Examples][183]
- [deleteFile][184]
- [Parameters][185]
- [Examples][186]
- [makeDirectory][187]
- [Parameters][188]
- [Examples][189]
- [getDiskUsage][190]
- [Parameters][191]
- [Examples][192]
- [exists][193]
- [Parameters][194]
- [Examples][195]
- [renameFile][196]
- [Parameters][197]
- [Examples][198]
- [createFile][199]
- [Parameters][200]
- [Examples][201]
- [deleteDirectory][202]
- [Parameters][203]
- [Examples][204]
- [readFile][205]
- [Parameters][206]
- [Examples][207]
- [writeFile][208]
- [Parameters][209]
- [Examples][210]
- [copyFile][211]
- [Parameters][212]
- [Examples][213]
- [pasteFile][214]
- [Parameters][215]
- [Examples][216]
- [moveFile][217]
- [Parameters][218]
- [Examples][219]
- [Screen][220]
- [Parameters][221]
- [Examples][222]
- [getScreenHierarchy][223]
- [Parameters][224]
- [Examples][225]
- [findElement][226]
- [Parameters][227]
- [Examples][228]
- [getScreenResolution][229]
- [Examples][230]
- [startScreenRecording][231]
- [Parameters][232]
- [Examples][233]
- [stopScreenRecording][234]
- [Parameters][235]
- [Examples][236]
- [enableDarkMode][237]
- [Examples][238]
- [disableDarkMode][239]
- [Examples][240]
- [setSystemDefaultDisplayMode][241]
- [Examples][242]
- [setLandscapeMode][243]
- [Examples][244]
- [setPortraitMode][245]
- [Examples][246]
- [checkScreenStatus][247]
- [Examples][248]
- [getScreenDensity][249]
- [Examples][250]
- [setScreenDensity][251]
- [Parameters][252]
- [Examples][253]
- [ScreenInteractions][254]
- [Parameters][255]
- [Examples][256]
- [clickElement][257]
- [Parameters][258]
- [Examples][259]
- [clickAtCoordinates][260]
- [Parameters][261]
- [Examples][262]
- [longClickOnElement][263]
- [Parameters][264]
- [Examples][265]
- [longClickAtCoordinates][266]
- [Parameters][267]
- [Examples][268]
- [doubleTapAtCoordinates][269]
- [Parameters][270]
- [Examples][271]
- [takeScreenshot][272]
- [Parameters][273]
- [Examples][274]
- [swipe][275]
- [Parameters][276]
- [Examples][277]
- [typeText][278]
- [Parameters][279]
- [Examples][280]
- [pressKey][281]
- [Parameters][282]
- [Examples][283]
- [zoom][284]
- [Parameters][285]
- [Examples][286]
- [UIAttributes][287]
- [Parameters][288]
- [Examples][289]
- [isCheckable][290]
- [Parameters][291]
- [Examples][292]
- [checkChecked][293]
- [Parameters][294]
- [Examples][295]
- [isClickable][296]
- [Parameters][297]
- [Examples][298]
- [isEnabled][299]
- [Parameters][300]
- [Examples][301]
- [isFocusable][302]
- [Parameters][303]
- [Examples][304]
- [isFocused][305]
- [Parameters][306]
- [Examples][307]
- [isScrollable][308]
- [Parameters][309]
- [Examples][310]
- [isLongClickable][311]
- [Parameters][312]
- [Examples][313]
- [isPassword][314]
- [Parameters][315]
- [Examples][316]
- [isSelected][317]
- [Parameters][318]
- [Examples][319]
ADB
ADB class to execute ADB shell commands.
execCommand
Executes an ADB shell command.
Parameters
command[string][320] The command to execute.
Returns [Promise][321]<void> A promise that resolves when the command execution is complete.
ADBHelper
Extends ADB
ADBHelper class provides an abstraction layer to interact with an Android device via ADB (Android Debug Bridge). It includes various helpers to manage apps, control devices, interact with screens, and access UI elements.
Properties
deviceControl[DeviceControl][85] Instance of the DeviceControl class, used to control the device.appManagement[AppManagement][7] Instance of the AppManagement class, used for app-related operations.screenInteractions[ScreenInteractions][254] Instance of the ScreenInteractions class, used for screen actions.screen[Screen][220] Instance of the Screen class, used for managing screen operations.uiAttributes[UIAttributes][287] Instance of the UIAttributes class, used to interact with UI elements.
Examples
const adbHelper = new ADBHelper("device123");
adbHelper.deviceControl.checkDevice(); // Control the device
adbHelper.appManagement.getCurrentScreenActivity(); // List app activities
adbHelper.screenInteractions.swipe(0, 0, 100, 100, 500); // Perform screen swipeAppManagement
Extends ADB
Class to manage various application-related functionalities, such as interacting with apps via ADB, managing UI elements, and checking UI element attributes.
This class provides methods to get current screen opened activity, open an application, list installed app on android, clear application data, install or uninstall an application and others. It uses ADB commands to communicate with Android devices and also caches UI element data for quick reference.
Parameters
deviceId[string][320] The unique identifier for the Android device.
Examples
// Using AppManagement independently:
let deviceId = "XXXXXXXXXXXXX";
const appManager = new AppManagement(deviceId);
await appManager.openApp('com.example.app');
const currentScreenActivity = await appManager.getCurrentScreenActivity('');// Using AppManagement within ADBHelper:
const adbHelper = new ADBHelper("device123");
await adbHelper.appManagement.openApp('com.example.app');
const activities = await adbHelper.appManagement.getCurrentScreenActivity('');getCurrentScreenActivity
Gets the currently displayed activity on the device.
This method executes an ADB command to retrieve information about the current activities on the device. It extracts the name of the activity currently in the foreground and returns it.
Examples
// Example of getting the current screen activity
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const currentActivity = await adbHelper.appManagement.getCurrentScreenActivity();
console.log(currentActivity); // Logs the current activity in the foreground- Throws [Error][322] If there is an issue retrieving the current activity or if no activity is found.
Returns [Promise][321]<[string][320]> A promise that resolves to the name of the activity currently in the foreground.
openApp
Opens an application using the package name.
This method executes an ADB command to open the specified application on the device using its package name.
Parameters
packageName[string][320] The package name of the application to be opened.
Examples
// Example of opening an app by its package name
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.openApp('com.example.app');
console.log('App opened successfully.');- Throws [Error][322] If there is an issue opening the application.
Returns [Promise][321]<void> A promise that resolves when the application is successfully opened.
openActivity
Opens a specific activity of an application using its package name and activity name.
This method executes an ADB command to open a specified activity within an application on the device using its package name and the activity name.
Parameters
packageName[string][320] The package name of the application.activityName[string][320] The fully qualified name of the activity to be opened.
Examples
// Example of opening a specific activity within an app
const { ADBHelper } = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.openActivity('com.example.app', 'com.example.app.MainActivity');
console.log('Activity opened successfully.');- Throws [Error][322] If there is an issue opening the activity.
Returns [Promise][321]<void> A promise that resolves when the activity is successfully opened.
getInstalledApps
Lists installed applications on the device with optional filters.
This method executes an ADB command to list installed applications based on the specified filter.
Parameters
filterType("enabled"|"disabled"|"system"|"user"| [string][320])? The type of filter to apply: 'enabled' : enabled apps, 'disabled' : disabled apps, 'system' : system apps, 'user' : user-installed apps, or a specific package name to filter by.
Examples
// Example of listing user-installed apps
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const apps = await adbHelper.appManagement.getInstalledApps('user');
console.log('User-installed apps:', apps);- Throws [Error][322] If there is an issue retrieving the list of installed apps.
Returns [Promise][321]<[Array][323]<[string][320]>> A promise that resolves to an array containing the package names of installed apps matching the filter.
clearAppData
Clears data of a specified app.
This method executes an ADB command to clear the data of a specified app, which will reset the app's settings, cache, and files.
Parameters
packageName[string][320] The package name of the app whose data is to be cleared.
Examples
// Example of clearing app data
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.clearAppData('com.example.app');
console.log('App data cleared.');- Throws [Error][322] If there is an issue clearing the app data.
Returns [Promise][321]<void> A promise that resolves when the app data is cleared.
installApp
Installs an APK file on the device with optional configurations.
This method executes an ADB command to install an APK file on the device with customizable options.
Parameters
apkPath[string][320] The path to the APK file to be installed.options[Object][324] Optional configuration for the installation.options.replace[boolean][325]? Whether to replace an existing app (default is false).options.allowDowngrade[boolean][325]? Whether to allow downgrading the app version (default is false).options.grantPermissions[boolean][325]? Whether to automatically grant app permissions (default is false).options.installToSD[boolean][325]? Whether to install the app to the SD card (default is false).
Examples
// Example of installing an APK with options
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.installApp('/path/to/app.apk', { replace: true, grantPermissions: true });
console.log('App installed successfully.');- Throws [Error][322] If there is an issue installing the app.
Returns [Promise][321]<void> A promise that resolves when the app is installed successfully.
uninstallApp
Uninstalls a specified app from the device with optional data retention.
This method executes an ADB command to uninstall an app, and optionally keep its data.
Parameters
packageName[string][320] The package name of the app to uninstall.options[Object][324] Optional configuration for the uninstallation.options.keepData[boolean][325]? Whether to retain app data after uninstallation (default is false).
Examples
// Example of uninstalling an app with data retention
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.uninstallApp('com.example.app', { keepData: true });
console.log('App uninstalled successfully.');- Throws [Error][322] If there is an issue uninstalling the app.
Returns [Promise][321]<void> A promise that resolves when the app is uninstalled successfully.
disableApp
Disables a specified app on the device.
This method executes an ADB command to disable an app, making it inactive but not uninstalling it.
Parameters
packageName[string][320] The package name of the app to disable.
Examples
// Example of disabling an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.disableApp('com.example.app');
console.log('App disabled successfully.');- Throws [Error][322] If there is an issue disabling the app.
Returns [Promise][321]<void> A promise that resolves when the app is disabled successfully.
enableApp
Enables a previously disabled app on the device.
This method executes an ADB command to enable an app that was previously disabled.
Parameters
packageName[string][320] The package name of the app to enable.
Examples
// Example of enabling a disabled app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.enableApp('com.example.app');
console.log('App enabled successfully.');- Throws [Error][322] If there is an issue enabling the app.
Returns [Promise][321]<void> A promise that resolves when the app is enabled successfully.
getGrantedPermissions
Retrieves the granted permissions of a specified app.
This method executes an ADB command to retrieve the list of permissions granted to a specified app.
Parameters
packageName[string][320] The package name of the app whose granted permissions are to be retrieved.
Examples
// Example of retrieving granted permissions for an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const grantedPermissions = await adbHelper.appManagement.getGrantedPermissions('com.example.app');
console.log('Granted permissions:', grantedPermissions);- Throws [Error][322] If there is an issue retrieving the granted permissions.
Returns [Promise][321]<[Array][323]<[string][320]>> A promise that resolves to an array containing granted permissions.
getAppPermissions
Retrieves permissions of a specified app based on the specified status.
This method executes an ADB command to retrieve all, granted, or denied permissions for a specified app.
Parameters
packageName[string][320] The package name of the app whose permissions are to be retrieved.status("all"|"granted"|"denied") The status of permissions to retrieve: 'all' : All permissions, 'granted' : Granted permissions, 'denied' : Denied permissions. (optional, default'all')
Examples
// Example of retrieving all permissions for an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const allPermissions = await adbHelper.appManagement.getAppPermissions('com.example.app', 'all');
console.log('All permissions:', allPermissions);- Throws [Error][322] If there is an issue retrieving the permissions.
Returns [Promise][321]<[Array][323]<[string][320]>> A promise that resolves to an array containing the permissions matching the specified status.
grantPermission
Grants a specified permission to an app.
This method executes an ADB command to grant a specified permission to an app.
Parameters
packageName[string][320] The package name of the app to which the permission is to be granted.permission[string][320] The permission to grant.
Examples
// Example of granting a permission to an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.grantPermission('com.example.app', 'android.permission.CAMERA');
console.log('Permission granted.');- Throws [Error][322] If there is an issue granting the permission.
Returns [Promise][321]<void> A promise that resolves when the permission is granted.
revokePermission
Revokes a specified permission from an app.
This method executes an ADB command to revoke a specified permission from an app.
Parameters
packageName[string][320] The package name of the app from which the permission is to be revoked.permission[string][320] The permission to revoke.
Examples
// Example of revoking a permission from an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.revokePermission('com.example.app', 'android.permission.CAMERA');
console.log('Permission revoked.');- Throws [Error][322] If there is an issue revoking the permission.
Returns [Promise][321]<void> A promise that resolves when the permission is revoked.
isAppInstalled
Checks if a specified app is installed on the device.
This method executes an ADB command to list installed packages and checks if the specified app's package name is present.
Parameters
packageName[string][320] The package name of the app to check for installation.
Examples
// Example of checking if an app is installed
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const isInstalled = await adbHelper.appManagement.isAppInstalled('com.example.app');
console.log('App installed:', isInstalled);- Throws [Error][322] If there is an issue checking the installation status.
Returns [Promise][321]<[boolean][325]> A promise that resolves to a boolean indicating if the app is installed.
forceStopApp
Force stops a specified app.
This method executes an ADB command to force stop an app using its package name.
Parameters
packageName[string][320] The package name of the app to force stop.
Examples
// Example of force stopping an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.forceStopApp('com.example.app');
console.log('App force stopped.');- Throws [Error][322] If there is an issue stopping the app.
Returns [Promise][321]<void> A promise that resolves when the app is successfully stopped.
launchURL
Launches a URL in the default browser or a specific app on the device.
This method executes an ADB command to open a specified URL on the device. It also allows specifying an app package to open the URL in that app.
Parameters
url[string][320] The URL to open.packageName[string][320]? The package name of the app to handle the URL (optional).
Examples
// Example of launching a URL in the default browser
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.launchURL('https://example.com');
console.log('URL launched.');
// Example of launching a URL in WhatsApp
await adbHelper.appManagement.launchURL('https://web.whatsapp.com/send/?phone=221771370101&text=Hello', 'com.whatsapp');- Throws [Error][322] If there is an issue opening the URL.
Returns [Promise][321]<void> A promise that resolves when the URL is successfully opened.
launchActivityWithExtras
Launches an app's activity with specified extras.
This method executes an ADB command to launch a specified activity within an app, passing additional key-value data.
Parameters
packageName[string][320] The package name of the app.activityName[string][320] The name of the activity to launch within the app.extras{: any}
Examples
// Example of launching an activity with extras
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.launchActivityWithExtras('com.example.app', '.MainActivity', { key1: 'value1', key2: 'value2' });
console.log('Activity launched with extras.');- Throws [Error][322] If there is an issue launching the activity with extras.
Returns [Promise][321]<void> A promise that resolves when the activity is launched.
disableAppNotifications
Disables notifications for a specified app.
This method executes an ADB command to disable notifications for an app.
Parameters
packageName[string][320] The package name of the app for which to disable notifications.
Examples
// Example of disabling notifications for an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.disableAppNotifications('com.example.app');
console.log('Notifications disabled.');- Throws [Error][322] If there is an issue disabling notifications.
Returns [Promise][321]<void> A promise that resolves when notifications are disabled.
enableAppNotifications
Enables notifications for a specified app.
This method executes an ADB command to enable notifications for an app.
Parameters
packageName[string][320] The package name of the app for which to enable notifications.
Examples
// Example of enabling notifications for an app
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.appManagement.enableAppNotifications('com.example.app');
console.log('Notifications enabled.');- Throws [Error][322] If there is an issue enabling notifications.
Returns [Promise][321]<void> A promise that resolves when notifications are enabled.
modifySharedPreferences
Modify a parameter in the SharedPreferences of an application
Parameters
packageName[string][320] The package name of the applicationkey[string][320] The key of the parameter to modifyvalue[string][320] The value to set for the parameter
Returns [Promise][321]<void>
sendIntentToApp
Send an Intent to activate a feature in the app
Parameters
intentAction[string][320] The action of the Intent to send
Returns [Promise][321]<void>
listAppActivities
List the activities of a given application via ADB
Parameters
packageName[string][320] The package name of the application
Returns [Promise][321]<[Array][323]<[string][320]>>
listProcesses
List the processes running on the Android device.
Returns [Promise][321]<([string][320] | null)>
getCachedScreenHierarchyValue
Getter for the screen hierarchy cache.
This method returns the cached screen hierarchy, which is a list of UIHierarchy objects.
Type: ([Array][323]<UIHierarchy> | null)
Returns ([Array][323]<UIHierarchy> | null) The cached screen hierarchy, or null if no data is cached.
setCachedScreenHierarchyValue
Setter for the screen hierarchy cache.
This method sets the cached screen hierarchy with a list of UIHierarchy objects.
Type: ([Array][323]<UIHierarchy> | null)
Parameters
value([Array][323]<UIHierarchy> | null) The new value to set for the cached screen hierarchy, or null to clear it.
getCachedElementValue
Getter for the cached element.
This method returns the cached element, which is a single UIHierarchy object.
Type: (UIHierarchy | null)
Returns (UIHierarchy | null) The cached UIHierarchy element, or null if no element is cached.
setCachedElementValue
Setter for the cached element.
This method sets the cached element with a UIHierarchy object.
Type: (UIHierarchy | null)
Parameters
value(UIHierarchy | null) The new value to set for the cached element, or null to clear it.
getCurrentActivityValue
Getter for the current activity.
This method returns the current activity as a string.
Type: ([string][320] | null)
Returns ([string][320] | null) The current activity, or null if no activity is set.
setCurrentActivityValue
Setter for the current activity.
This method sets the current activity with a string value.
Type: [string][320]
Parameters
value([string][320] | null) The new value to set for the current activity, or null to clear it.
getCachedScreenResolutionValue
Getter for the current activity.
This method returns the current activity as a string.
Type: ({width: [number][326], height: [number][326]} | null)
Returns ([string][320] | null) The current activity, or null if no activity is set.
setCachedScreenResolutionValue
Setter for the current activity.
This method sets the current activity with a string value.
Type: {width: [number][326], height: [number][326]}
Parameters
value([string][320] | null) The new value to set for the current activity, or null to clear it.
DeviceControl
Extends ADB
Class to manage various device operations via ADB commands.
This class provides methods for controlling and interacting with Android devices, such as enabling/disabling airplane mode, performing factory resets, capturing system logs, managing device volumes, and checking system settings like developer options and USB debugging and others.
Parameters
deviceId[string][320] The unique identifier for the Android device.
Examples
// Using DeviceControl independently:
let deviceId = "XXXXXXXXXXXX";
const deviceControl = new DeviceControl(deviceId);
const isDevelopmentEnabled = await deviceControl.checkDevelopmentSettings();
console.log(isDevelopmentEnabled); // Logs true if development options are enabled// Using DeviceControl within ADBHelper:
const {ADBHelper} = require('adb-helper');
const adbHelper = new ADBHelper("device123");
const isDevelopmentEnabled = await adbHelper.deviceControl.checkDevelopmentSettings();
console.log(isDevelopmentEnabled); // Logs true if development options are enabledpressBack
Simulates pressing the "Back" button on the device.
This method sends a command to the device to simulate the action of pressing the physical or virtual "Back" button, typically used for navigating backward in the app or closing the current activity or screen.
- Throws [Error][322] If an error occurs while executing the command or interacting with the device.const {ADBHelper} = require('adb-helper'); const adbHelper = new ADBHelper("device123"); adbHelper.deviceControl.pressBack()
Returns [Promise][321]<void> A promise that resolves when the "Back" button has been successfully pressed or rejects if an error occurs during execution.
pressHome
Simulates pressing the "Home" button on the device.
This method sends a command to the device to simulate the action of pressing the physical or virtual "Home" button, typically used to navigate to the home screen or return to the device's main launcher.
- Throws [Error][322] If an error occurs while executing the command or interacting with the device. const {ADBHelper} = require('adb-helper'); const adbHelper = new ADBHelper("device123"); adbHelper.deviceControl.pressHome()
Returns [Promise][321]<void> A promise that resolves when the "Home" button has been successfully pressed or rejects if an error occurs during execution.
pressRecentApps
Simulates pressing the "Recent Apps" button on the device.
This method sends a command to the device to simulate the action of pressing the "Recent Apps" button, which typically shows the list of recently used applications or opens the multitasking view on the device.
- Throws [Error][322] If an error occurs while executing the command or interacting with the device. const {ADBHelper} = require('adb-helper'); const adbHelper = new ADBHelper("device123"); adbHelper.deviceControl.pressRecentApps()
Returns [Promise][321]<void> A promise that resolves when the "Recent Apps" button has been successfully pressed or rejects if an error occurs during execution.
checkDevice
Checks the status of the connected device.
This method checks whether the device identified by the deviceId is properly connected
and recognized by the adb tool. It sends a command to list the connected devices and verifies
if the current device is present in the list.
Examples
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('deviceIdOrAnyValue');
adbHelper.deviceControl.checkDevice()- Throws [Error][322] If there is an issue executing the command or if the device is not detected.
Returns [Promise][321]<[string][320]> A promise that resolves with a string message indicating the device status (e.g., "Device detected") or throws an error if the device is not detected.
rebootDevice
Restarts the connected device.
This method sends a reboot command to the connected device identified by the deviceId.
It uses the adb reboot command to restart the device.
Examples
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('deviceId');
adbHelper.deviceControl.rebootDevice()- Throws [Error][322] If there is an issue executing the command or if the device cannot be rebooted.
Returns [Promise][321]<void> A promise that resolves when the reboot command is successfully executed.
setBrightness
Changes the device's screen brightness.
This method allows you to set the screen brightness of the connected device. The brightness value must be between 0 and 255 (0 to turn off the screen, 255 for maximum brightness).
Parameters
brightness[number][326] The brightness value to set, between 0 and 255.
Examples
// Set the brightness to 255 (maximum brightness)
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setBrightness(255);- Throws [Error][322] If the brightness value is outside the valid range (0 to 255) or if the command fails.
Returns [Promise][321]<void> A promise that resolves when the command is executed successfully.
setAutoRotation
Enables or disables the device's auto-rotation.
This method allows you to enable or disable the auto-rotation feature of the connected device. When enabled, the screen orientation will automatically adjust based on the device's position.
Parameters
enable[boolean][325]trueto enable auto-rotation,falseto disable it.
Examples
// Enable auto-rotation
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setAutoRotation(true);// Disable auto-rotation
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setAutoRotation(false);- Throws [Error][322] If the command fails or the device cannot process the command.
Returns [Promise][321]<void> A promise that resolves when the command is successfully executed.
enableUSBDebugging
Enables USB debugging via ADB (part of the Developer Mode).
This method enables the USB debugging feature on the connected device. It is required for establishing a connection between the device and ADB for debugging purposes.
Examples
// Example of enabling USB debugging
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.enableUSBDebugging();- Throws [Error][322] If the command fails or the device cannot process the command.
Returns [Promise][321]<void> A promise that resolves when USB debugging is successfully enabled.
disableDeveloperMode
Disables Developer Mode options such as USB debugging.
This method disables USB debugging and other developer options on the connected device. It is used to turn off the developer settings once they are no longer needed.
Examples
// Example of disabling developer mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.disableDeveloperMode();- Throws [Error][322] If the command fails or the device cannot process the command.
Returns [Promise][321]<void> A promise that resolves when USB debugging is successfully disabled.
checkAndroidVersion
Checks the currently running Android version on the device.
This method retrieves the Android version of the connected device using ADB. It returns the version string which can be used to determine the device's OS version.
Examples
// Example of checking Android version
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const androidVersion = await adbHelper.deviceControl.checkAndroidVersion();
console.log(`Android Version: ${androidVersion}`);- Throws [Error][322] If the command fails or the device cannot provide the version.
Returns [Promise][321]<[string][320]> A promise that resolves with the Android version string.
getBatteryStatus
Checks the battery status (battery level and charging status) of the device.
This method retrieves the battery level, charging status, and the power source (USB, AC, or Wireless) of the connected Android device. It parses the data returned by the ADB command and returns an object containing the battery level, status, and charging source.
Examples
// Example of checking battery status
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const batteryStatus = await adbHelper.deviceControl.getBatteryStatus();
console.log(`Battery Level: ${batteryStatus.level}%`);
console.log(`Battery Status: ${batteryStatus.status}`);
console.log(`Charging via: ${batteryStatus.plugged}`);- Throws [Error][322] If the ADB command fails or the battery status cannot be retrieved.
Returns [Promise][321]<{level: [number][326], status: [string][320], plugged: [string][320]}> A promise that resolves with an object containing the battery level, status, and charging source.
toggleMobileData
Enables or disables mobile data on the device.
This method toggles the mobile data connection on an Android device by using ADB commands. It accepts a boolean value to either enable or disable mobile data.
Parameters
enable[boolean][325] A boolean value to indicate whether to enable (true) or disable (false) mobile data.
Examples
// Example of toggling mobile data
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.toggleMobileData(true); // Enable mobile data
await adbHelper.deviceControl.toggleMobileData(false); // Disable mobile data- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the mobile data status is toggled.
toggleSync
Enables or disables automatic synchronization on the device.
This method toggles the automatic synchronization setting on an Android device using ADB commands. It accepts a boolean value to either enable or disable the synchronization.
Parameters
enable[boolean][325] A boolean value indicating whether to enable (true) or disable (false) automatic synchronization.
Examples
// Example of toggling automatic synchronization
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.toggleSync(true); // Enable automatic synchronization
await adbHelper.deviceControl.toggleSync(false); // Disable automatic synchronization- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the synchronization setting is toggled.
toggleGPS
Enables or disables GPS location on the device.
This method toggles the GPS (location services) on an Android device using ADB commands. It accepts a boolean value to either enable or disable the GPS functionality.
Parameters
enable[boolean][325] A boolean value indicating whether to enable (true) or disable (false) GPS.
Examples
// Example of toggling GPS (Location Services)
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.toggleGPS(true); // Enable GPS
await adbHelper.deviceControl.toggleGPS(false); // Disable GPS- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the GPS setting is toggled.
toggleWiFi
Enables or disables Wi-Fi on the device.
This method toggles the Wi-Fi on an Android device using ADB commands. It accepts a boolean value to either enable or disable the Wi-Fi functionality.
Parameters
enable[boolean][325] A boolean value indicating whether to enable (true) or disable (false) Wi-Fi.
Examples
// Example of toggling Wi-Fi
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.toggleWiFi(true); // Enable Wi-Fi
await adbHelper.deviceControl.toggleWiFi(false); // Disable Wi-Fi- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the Wi-Fi setting is toggled.
toggleBluetooth
Enables or disables Bluetooth on the device.
This method toggles the Bluetooth functionality on an Android device using ADB commands. It accepts a boolean value to either enable or disable Bluetooth.
Parameters
enable[boolean][325] A boolean value indicating whether to enable (true) or disable (false) Bluetooth.
Examples
// Example of toggling Bluetooth
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.toggleBluetooth(true); // Enable Bluetooth
await adbHelper.deviceControl.toggleBluetooth(false); // Disable Bluetooth- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the Bluetooth setting is toggled.
toggleAirplaneMode
Enables or disables airplane mode on the device.
This method toggles the airplane mode on an Android device using ADB commands. It accepts a boolean value to either enable or disable airplane mode.
Parameters
enable[boolean][325] A boolean value indicating whether to enable (true) or disable (false) airplane mode.
Examples
// Example of toggling airplane mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.toggleAirplaneMode(true); // Enable airplane mode
await adbHelper.deviceControl.toggleAirplaneMode(false); // Disable airplane mode- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the airplane mode setting is toggled.
factoryReset
Performs a factory reset on the device, erasing all data.
This method resets the device to its factory settings, effectively wiping all data.
It uses the ADB MASTER_CLEAR intent to trigger the factory reset process.
Examples
// Example of performing a factory reset
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.factoryReset(); // Perform factory reset- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the device is reset to factory settings.
wipeUserData
Wipes the user data on the device.
This method erases the user data on the device using the ADB recovery command. It only clears the user data without affecting system settings or installed apps.
Examples
// Example of wiping user data
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.wipeUserData(); // Wipe user data- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the user data is wiped.
rebootIntoRecovery
Reboots the device into recovery mode.
This method reboots the device into recovery mode, which is typically used for maintenance tasks like updating the device or performing factory resets.
It uses the ADB reboot recovery command to restart the device in recovery mode.
Examples
// Example of rebooting into recovery mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.rebootIntoRecovery(); // Reboot into recovery mode- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the device has successfully rebooted into recovery mode.
changeLanguage
Changes the system language and region on the device.
This method sets the system language and region (locale) using the ADB setprop command for language and country.
After the properties are set, it broadcasts the LOCALE_CHANGED intent to apply the changes.
Parameters
language[string][320] The language code (e.g., "en", "fr") to set on the device.region[string][320] The region code (e.g., "US", "FR") to set on the device.
Examples
// Example of changing language and region
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.changeLanguage('fr', 'FR'); // Change language to French and region to France- Throws [Error][322] If any of the ADB commands fail to execute.
Returns [Promise][321]<void> A promise that resolves when the language and region are successfully changed.
captureSystemLog
Captures the system logs from the device and saves them to a file.
This method collects the system logs using the ADB logcat -d command, which dumps the logs from the device.
The logs are printed to the console and saved to a file named system_log.txt.
Examples
// Example of capturing the system log
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.captureSystemLog(); // Capture the system log- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the system log is successfully captured.
setMediaVolume
Sets the media volume on the device.
This method adjusts the media volume on the device by executing an ADB command to set the volume level. The volume level must be an integer between 0 (mute) and 15 (maximum volume).
Parameters
volumeLevel[number][326] The desired media volume level (0-15).
Examples
// Example of setting media volume to level 5
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setMediaVolume(5); // Set media volume to level 5- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the volume is successfully set.
setRingtoneVolume
Sets the ringtone volume on the device.
This method adjusts the ringtone volume on the device by executing an ADB command. The volume level must be an integer between 0 (mute) and 15 (maximum volume).
Parameters
volumeLevel[number][326] The desired ringtone volume level (0-15).
Examples
// Example of setting ringtone volume to level 8
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setRingtoneVolume(8); // Set ringtone volume to level 8- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the volume is successfully set.
setNotificationVolume
Sets the notification volume on the device.
This method adjusts the notification volume on the device by executing an ADB command. The volume level must be an integer between 0 (mute) and 15 (maximum volume).
Parameters
volumeLevel[number][326] The desired notification volume level (0-15).
Examples
// Example of setting notification volume to level 7
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setNotificationVolume(7); // Set notification volume to level 7- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the volume is successfully set.
enableSilentMode
Enables silent mode on the device.
This method activates silent mode on the device using the ADB command. It broadcasts the intent to mute audio.
Examples
// Example of enabling silent mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.enableSilentMode(); // Enable silent mode- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when silent mode is successfully activated.
disableSilentMode
Disables silent mode on the device.
This method deactivates silent mode on the device using the ADB command. It broadcasts the intent to unmute audio.
Examples
// Example of disabling silent mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.disableSilentMode(); // Disable silent mode- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when silent mode is successfully deactivated.
enableDoNotDisturb
Enables the "Do Not Disturb" mode on the device.
This method activates the "Do Not Disturb" mode by setting the global zen_mode to 1 using the ADB command.
Examples
// Example of enabling Do Not Disturb mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.enableDoNotDisturb(); // Enable Do Not Disturb mode- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when "Do Not Disturb" mode is successfully enabled.
disableDoNotDisturb
Disables the "Do Not Disturb" mode on the device.
This method deactivates the "Do Not Disturb" mode by setting the global zen_mode to 0 using the ADB command.
Examples
// Example of disabling Do Not Disturb mode
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.disableDoNotDisturb(); // Disable Do Not Disturb mode- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when "Do Not Disturb" mode is successfully disabled.
setSystemTime
Sets the system time on the device.
This method sets the system time on the device using the ADB date -s command. The date should be provided in the format "YYYY-MM-DD HH:MM:SS".
Parameters
date[string][320] The date and time to set on the device, in the format "YYYY-MM-DD HH:MM:SS".
Examples
// Example of setting the system time to "2024-11-16 15:30:00"
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setSystemTime("2024-11-16 15:30:00"); // Set system time- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the system time is successfully set.
setTimeZone
Sets the system time zone on the device.
This method sets the time zone on the device using the ADB setprop command. Time zone should be provided as a string like "GMT+0".
Parameters
timeZone[string][320] The time zone to set on the device (e.g., "GMT+0", "Asia/Kolkata").
Examples
// Example of setting the system time zone to "Asia/Kolkata"
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.setTimeZone("Asia/Kolkata"); // Set system time zone- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when the time zone is successfully set.
enableAutoTimeSync
Enables automatic time synchronization on the device.
This method enables the automatic synchronization of time from an NTP server.
Examples
// Example of enabling auto time sync
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
await adbHelper.deviceControl.enableAutoTimeSync(); // Enable automatic time sync- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<void> A promise that resolves when auto time sync is successfully enabled.
checkDevelopmentSettings
Checks if developer options are enabled on the device.
This method executes an ADB command to retrieve the value of the development_settings_enabled global setting.
It returns true if developer options are enabled, otherwise it returns false.
Examples
// Example of checking if developer options are enabled
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const isDevelopmentEnabled = await adbHelper.deviceControl.checkDevelopmentSettings();
console.log(isDevelopmentEnabled); // Logs true if developer options are enabled- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<[boolean][325]> A promise that resolves to true if developer options are enabled, otherwise false.
checkAdbSettings
Checks if USB debugging is enabled on the device.
This method executes an ADB command to retrieve the value of the adb_enabled global setting.
It returns true if USB debugging is enabled, otherwise it returns false.
Examples
// Example of checking if USB debugging is enabled
const {ADBHelper} = require('adb-helper');
let adbHelper = new ADBHelper('XXXXXXXXX');
const isAdbEnabled = await adbHelper.deviceControl.checkAdbSettings();
console.log(isAdbEnabled); // Logs true if USB debugging is enabled- Throws [Error][322] If the ADB command fails to execute.
Returns [Promise][321]<[boolean][325]> A promise that resolves to true if USB debugging is enabled, otherwise false.
Executes an ADB shell command.
This method sends the given command to the ADB shell and returns the response.
Parameters
command[string][320] The ADB shell command to execute.
Returns [Promise][321]<ADBResponse> A promise that resolves with the response from the ADB shell.
FileManager
Extends ADB
FileManager class provides high-level ADB-based file system operations on an Android device.
This class allows you to interact with the device's file system, including reading, writing, copying, deleting, moving files and directories. It communicates via ADB shell commands and is designed to work with any Android device connected either via USB or wirelessly (if paired).
Unlike generic ADB shell execution, this class abstracts common file-related operations into reusable and strongly-typed methods, making it easier to integrate Android file management in your app or toolchain.
Parameters
deviceId[string][320]
Examples
// Standalone usage:
const manager = new FileManager("deviceId123");
await manager.writeFile("/sdcard/test.txt", "Hello from ADB");// Inside an ADBHelper wrapper:
const { ADBHelper } = require("adb-helper");
const adbHelper = new ADBHelper("deviceId123");
await adbHelper.fileManager.deleteDirectory("/sdcard/Temp");// Copy-paste simulation:
await manager.copyFile("/sdcard/file.txt");
await manager.pasteFile("/sdcard/backup/file.txt");listFiles
Lists files and directories at a specified path on the Android device.
Parameters
remotePath[string][320] The absolute path on the device (e.g. "/sdcard/Download").
Examples
```ts
const files = await fileManager.listFiles('/sdcard/Download');
console.log(files); // ['file1.jpg', 'file2.pdf', 'subfolder']
```Returns [Promise][321]<[Array][323]<[string][320]>> Promise<string[]> - An array of file and directory names.
findFile
Searches for a file by name recursively starting from a specified directory.
Parameters
remotePath[string][320] Root directory on the device to start the search (e.g. "/sdcard").fileName[string][320] The exact file name to search for (e.g. "photo.jpg").
Examples
```ts
const results = await fileManager.findFile('/sdcard', 'photo.jpg');
console.log(results); // ['/sdcard/Download/photo.jpg', '/sdcard/Pictures/photo.jpg']
```Returns [Promise][321]<[Array][323]<[string][320]>> Promise<string[]> - Array of full file paths matching the file name.
pushFile
Pushes (uploads) a file from the local PC to the Android device.
Parameters
localPath[string][320] The full local file path (e.g. "./photo.jpg").remotePath[string][320] The destination absolute path on the device (e.g. "/sdcard/Download/photo.jpg").
Examples
```ts
await fileManager.pushFile('./photo.jpg', '/sdcard/Download/photo.jpg');
console.log('File uploaded successfully');
```Returns [Promise][321]<void> Promise
pullFile
Pulls (downloads) a file from the Android device to the local PC.
Parameters
remotePath[string][320] The full file path on the device (e.g. "/sdcard/Download/photo.jpg").localPath[string][320] The destination local file path (e.g. "./photo.jpg").
Examples
```ts
await fileManager.pullFile('/sdcard/Download/photo.jpg', './photo.jpg');
console.log('File downloaded successfully');
```Returns [Promise][321]<void> Promise
deleteFile
Deletes a file or directory on the Android device.
Parameters
remotePath[string][320] Absolute path to the file or directory to delete.
Examples
```ts
await fileManager.deleteFile('/sdcard/Download/oldfile.jpg');
console.log('File deleted');
```Returns [Promise][321]<void> Promise
makeDirectory
Creates a directory (and parents if necessary) on the Android device.
Parameters
remotePath[string][320] Absolute path of the directory to create.
Examples
```ts
await fileManager.makeDirectory('/sdcard/NewFolder/SubFolder');
console.log('Directory created');
```Returns [Promise][321]<void> Promise
getDiskUsage
Retrieves disk usage information for a given path on the Android device.
Parameters
remotePath[string][320] The path to check disk usage (e.g. "/sdcard").
Examples
```ts
const usage = await fileManager.getDiskUsage('/sdcard');
console.log(usage);
// Example output:
// Filesystem 1K-blocks Used Available Use% Mounted on
// /dev/block/... 12345678 1234567 11111111 10% /sdcard
```Returns [Promise][321]<[string][320]> Promise - The raw output of the 'df' command on the device.
exists
Checks if a file or directory exists on the Android device.
Parameters
remotePath[string][320] Absolute path to the file or directory.
Examples
```ts
const doesExist = await fileManager.exists('/sdcard/Download/photo.jpg');
console.log(doesExist); // true or false
```Returns [Promise][321]<[boolean][325]> Promise - True if it exists, false otherwise.
renameFile
Renames or moves a file or directory on the Android device.
Parameters
oldPath[string][320] The current absolute path of the file or directory.newPath[string][320] The new absolute path (new name or location).
Examples
```ts
await fileManager.renameFile('/sdcard/Download/oldname.txt', '/sdcard/Download/newname.txt');
console.log('File renamed successfully');
```Returns [Promise][321]<void> Promise
createFile
Creates an empty file at the specified path on the Android device.
Parameters
remotePath[string][320] The absolute path where the empty file will be created.
Examples
```ts
await fileManager.createFile('/sdcard/Download/newfile.txt');
console.log('File created successfully');
```Returns [Promise][321]<void> Promise
deleteDirectory
Deletes a directory on the Android device, including all its contents.
Parameters
path[string][320] The absolute path to the directory you want to delete.
Examples
```ts
await fileManager.deleteDirectory('/sdcard/TestFolder');
console.log('Directory deleted successfully');
```- Throws any Will throw an error if the directory cannot be deleted.
Returns [Promise][321]<void> Promise
readFile
Reads and returns the content of a text file from the Android device.
Parameters
filePath[string][320] The absolute path to the file to be read.
Examples
```ts
const content = await fileManager.readFile('/sdcard/Download/myfile.txt');
console.log('File content:', content);
```- Throws any Will throw an error if the file cannot be read.
Returns [Promise][321]<[string][320]> Promise - The contents of the file as a string.
writeFile
Writes string content to a file on the Android device.
If the file already exists, it will be overwritten. If it doesn't exist, it will be created. This method supports writing small text content directly via ADB.
Parameters
remotePath[string][320] The absolute path to the target file on the device.content[string][320] The text content to be written into the file.
Examples
```ts
await fileManager.writeFile('/sdcard/Download/note.txt', 'Hello from ADB!');
console.log('File written successfully');
```- Throws any Will throw an error if the write operation fails.
Returns [Promise][321]<void> Promise
