Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Regroup application and filesystem commands #788

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
338 changes: 171 additions & 167 deletions lib/adb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ import type { LogcatOpts, StringRecord } from './tools/types';
import type { LRUCache } from 'lru-cache';
import type { ExecError } from 'teen_process';

import * as generalMethods from './tools/adb-commands';
import * as manifestMethods from './tools/android-manifest';
import * as systemCallMethods from './tools/system-calls';
import * as apkSigningMethods from './tools/apk-signing';
import * as apkUtilsMethods from './tools/apk-utils';
import * as apksUtilsMethods from './tools/apks-utils';
import * as aabUtilsMethods from './tools/aab-utils';
import * as emuMethods from './tools/adb-emu-commands';
import * as generalCommands from './tools/adb-commands';
import * as manifestCommands from './tools/android-manifest';
import * as systemCommands from './tools/system-calls';
import * as signingCommands from './tools/apk-signing';
import * as apkUtilCommands from './tools/apk-utils';
import * as apksUtilCommands from './tools/apks-utils';
import * as aabUtilCommands from './tools/aab-utils';
import * as emuCommands from './tools/adb-emu-commands';
import * as emuConstants from './tools/emu-constants';
import * as lockManagementCommands from './tools/lockmgmt';
import * as keyboardCommands from './tools/keyboard-commands';
import * as emuConstants from './tools/emu-constants';
import * as deviceSettingsCommands from './tools/device-settings';
import * as fsCommands from './tools/fs-commands';
import * as appCommands from './tools/app-commands';


export const DEFAULT_ADB_PORT = 5037;
Expand Down Expand Up @@ -138,95 +140,92 @@ export class ADB implements ADBOptions {
}

// TODO: Group methods from general to corresponding modules
shellChunks = generalMethods.shellChunks;
getAdbWithCorrectAdbPath = generalMethods.getAdbWithCorrectAdbPath;
initAapt = generalMethods.initAapt;
initAapt2 = generalMethods.initAapt2;
initZipAlign = generalMethods.initZipAlign;
initBundletool = generalMethods.initBundletool;
getApiLevel = generalMethods.getApiLevel;
isDeviceConnected = generalMethods.isDeviceConnected;
mkdir = generalMethods.mkdir;
isValidClass = generalMethods.isValidClass;
resolveLaunchableActivity = generalMethods.resolveLaunchableActivity;
forceStop = generalMethods.forceStop;
killPackage = generalMethods.killPackage;
clear = generalMethods.clear;
grantAllPermissions = generalMethods.grantAllPermissions;
grantPermissions = generalMethods.grantPermissions;
grantPermission = generalMethods.grantPermission;
revokePermission = generalMethods.revokePermission;
getGrantedPermissions = generalMethods.getGrantedPermissions;
getDeniedPermissions = generalMethods.getDeniedPermissions;
getReqPermissions = generalMethods.getReqPermissions;
stopAndClear = generalMethods.stopAndClear;
clearTextField = generalMethods.clearTextField;
lock = generalMethods.lock;
back = generalMethods.back;
goToHome = generalMethods.goToHome;
getAdbPath = generalMethods.getAdbPath;
sendTelnetCommand = generalMethods.sendTelnetCommand;
rimraf = generalMethods.rimraf;
push = generalMethods.push;
pull = generalMethods.pull;
processExists = generalMethods.processExists;
getForwardList = generalMethods.getForwardList;
forwardPort = generalMethods.forwardPort;
removePortForward = generalMethods.removePortForward;
getReverseList = generalMethods.getReverseList;
reversePort = generalMethods.reversePort;
removePortReverse = generalMethods.removePortReverse;
forwardAbstractPort = generalMethods.forwardAbstractPort;
ping = generalMethods.ping;
restart = generalMethods.restart;
startLogcat = generalMethods.startLogcat;
stopLogcat = generalMethods.stopLogcat;
getLogcatLogs = generalMethods.getLogcatLogs;
setLogcatListener = generalMethods.setLogcatListener;
removeLogcatListener = generalMethods.removeLogcatListener;
listProcessStatus = generalMethods.listProcessStatus;
getNameByPid = generalMethods.getNameByPid;
getPIDsByName = generalMethods.getPIDsByName;
killProcessesByName = generalMethods.killProcessesByName;
killProcessByPID = generalMethods.killProcessByPID;
broadcastProcessEnd = generalMethods.broadcastProcessEnd;
broadcast = generalMethods.broadcast;
bugreport = generalMethods.bugreport;
screenrecord = generalMethods.screenrecord;
listFeatures = generalMethods.listFeatures;
isStreamedInstallSupported = generalMethods.isStreamedInstallSupported;
isIncrementalInstallSupported = generalMethods.isIncrementalInstallSupported;
takeScreenshot = generalMethods.takeScreenshot;
listPorts = generalMethods.listPorts;
shellChunks = generalCommands.shellChunks;
getAdbWithCorrectAdbPath = generalCommands.getAdbWithCorrectAdbPath;
initAapt = generalCommands.initAapt;
initAapt2 = generalCommands.initAapt2;
initZipAlign = generalCommands.initZipAlign;
initBundletool = generalCommands.initBundletool;
getApiLevel = generalCommands.getApiLevel;
isDeviceConnected = generalCommands.isDeviceConnected;
clearTextField = generalCommands.clearTextField;
lock = generalCommands.lock;
back = generalCommands.back;
goToHome = generalCommands.goToHome;
getAdbPath = generalCommands.getAdbPath;
sendTelnetCommand = generalCommands.sendTelnetCommand;
getForwardList = generalCommands.getForwardList;
forwardPort = generalCommands.forwardPort;
removePortForward = generalCommands.removePortForward;
getReverseList = generalCommands.getReverseList;
reversePort = generalCommands.reversePort;
removePortReverse = generalCommands.removePortReverse;
forwardAbstractPort = generalCommands.forwardAbstractPort;
ping = generalCommands.ping;
restart = generalCommands.restart;
startLogcat = generalCommands.startLogcat;
stopLogcat = generalCommands.stopLogcat;
getLogcatLogs = generalCommands.getLogcatLogs;
setLogcatListener = generalCommands.setLogcatListener;
removeLogcatListener = generalCommands.removeLogcatListener;
bugreport = generalCommands.bugreport;
screenrecord = generalCommands.screenrecord;
listFeatures = generalCommands.listFeatures;
isStreamedInstallSupported = generalCommands.isStreamedInstallSupported;
isIncrementalInstallSupported = generalCommands.isIncrementalInstallSupported;
takeScreenshot = generalCommands.takeScreenshot;
listPorts = generalCommands.listPorts;

executeApksigner = apkSigningMethods.executeApksigner;
signWithDefaultCert = apkSigningMethods.signWithDefaultCert;
signWithCustomCert = apkSigningMethods.signWithCustomCert;
sign = apkSigningMethods.sign;
zipAlignApk = apkSigningMethods.zipAlignApk;
checkApkCert = apkSigningMethods.checkApkCert;
getKeystoreHash = apkSigningMethods.getKeystoreHash;
executeApksigner = signingCommands.executeApksigner;
signWithDefaultCert = signingCommands.signWithDefaultCert;
signWithCustomCert = signingCommands.signWithCustomCert;
sign = signingCommands.sign;
zipAlignApk = signingCommands.zipAlignApk;
checkApkCert = signingCommands.checkApkCert;
getKeystoreHash = signingCommands.getKeystoreHash;

APP_INSTALL_STATE = apkUtilsMethods.APP_INSTALL_STATE;
isAppInstalled = apkUtilsMethods.isAppInstalled;
startUri = apkUtilsMethods.startUri;
startApp = apkUtilsMethods.startApp;
dumpWindows = apkUtilsMethods.dumpWindows;
getFocusedPackageAndActivity = apkUtilsMethods.getFocusedPackageAndActivity;
waitForActivityOrNot = apkUtilsMethods.waitForActivityOrNot;
waitForActivity = apkUtilsMethods.waitForActivity;
waitForNotActivity = apkUtilsMethods.waitForNotActivity;
uninstallApk = apkUtilsMethods.uninstallApk;
installFromDevicePath = apkUtilsMethods.installFromDevicePath;
cacheApk = apkUtilsMethods.cacheApk;
install = apkUtilsMethods.install;
getApplicationInstallState = apkUtilsMethods.getApplicationInstallState;
installOrUpgrade = apkUtilsMethods.installOrUpgrade;
extractStringsFromApk = apkUtilsMethods.extractStringsFromApk;
getApkInfo = apkUtilsMethods.getApkInfo;
getPackageInfo = apkUtilsMethods.getPackageInfo;
pullApk = apkUtilsMethods.pullApk;
activateApp = apkUtilsMethods.activateApp;
grantAllPermissions = appCommands.grantAllPermissions;
grantPermissions = appCommands.grantPermissions;
grantPermission = appCommands.grantPermission;
revokePermission = appCommands.revokePermission;
getGrantedPermissions = appCommands.getGrantedPermissions;
getDeniedPermissions = appCommands.getDeniedPermissions;
getReqPermissions = appCommands.getReqPermissions;
stopAndClear = appCommands.stopAndClear;
isValidClass = appCommands.isValidClass;
resolveLaunchableActivity = appCommands.resolveLaunchableActivity;
forceStop = appCommands.forceStop;
killPackage = appCommands.killPackage;
clear = appCommands.clear;
listProcessStatus = appCommands.listProcessStatus;
getNameByPid = appCommands.getNameByPid;
getPIDsByName = appCommands.getPIDsByName;
killProcessesByName = appCommands.killProcessesByName;
killProcessByPID = appCommands.killProcessByPID;
broadcastProcessEnd = appCommands.broadcastProcessEnd;
broadcast = appCommands.broadcast;
processExists = appCommands.processExists;
readonly APP_INSTALL_STATE = appCommands.APP_INSTALL_STATE;
isAppInstalled = appCommands.isAppInstalled;
startUri = appCommands.startUri;
startApp = appCommands.startApp;
dumpWindows = appCommands.dumpWindows;
getFocusedPackageAndActivity = appCommands.getFocusedPackageAndActivity;
waitForActivityOrNot = appCommands.waitForActivityOrNot;
waitForActivity = appCommands.waitForActivity;
waitForNotActivity = appCommands.waitForNotActivity;
getPackageInfo = appCommands.getPackageInfo;
pullApk = appCommands.pullApk;
activateApp = appCommands.activateApp;

uninstallApk = apkUtilCommands.uninstallApk;
installFromDevicePath = apkUtilCommands.installFromDevicePath;
cacheApk = apkUtilCommands.cacheApk;
install = apkUtilCommands.install;
installOrUpgrade = apkUtilCommands.installOrUpgrade;
extractStringsFromApk = apkUtilCommands.extractStringsFromApk;
getApkInfo = apkUtilCommands.getApkInfo;
getApplicationInstallState = apkUtilCommands.getApplicationInstallState;

hideKeyboard = keyboardCommands.hideKeyboard;
isSoftKeyboardPresent = keyboardCommands.isSoftKeyboardPresent;
Expand All @@ -249,88 +248,93 @@ export class ADB implements ADBOptions {
dismissKeyguard = lockManagementCommands.dismissKeyguard;
cycleWakeUp = lockManagementCommands.cycleWakeUp;

getSdkBinaryPath = systemCallMethods.getSdkBinaryPath;
getBinaryNameForOS = systemCallMethods.getBinaryNameForOS;
getBinaryFromSdkRoot = systemCallMethods.getBinaryFromSdkRoot;
getBinaryFromPath = systemCallMethods.getBinaryFromPath;
getConnectedDevices = systemCallMethods.getConnectedDevices;
getDevicesWithRetry = systemCallMethods.getDevicesWithRetry;
reconnect = systemCallMethods.reconnect;
restartAdb = systemCallMethods.restartAdb;
killServer = systemCallMethods.killServer;
resetTelnetAuthToken = systemCallMethods.resetTelnetAuthToken;
adbExecEmu = systemCallMethods.adbExecEmu;
EXEC_OUTPUT_FORMAT = systemCallMethods.EXEC_OUTPUT_FORMAT;
adbExec = systemCallMethods.adbExec;
shell = systemCallMethods.shell;
createSubProcess = systemCallMethods.createSubProcess;
getAdbServerPort = systemCallMethods.getAdbServerPort;
getEmulatorPort = systemCallMethods.getEmulatorPort;
getPortFromEmulatorString = systemCallMethods.getPortFromEmulatorString;
getConnectedEmulators = systemCallMethods.getConnectedEmulators;
setEmulatorPort = systemCallMethods.setEmulatorPort;
setDeviceId = systemCallMethods.setDeviceId;
setDevice = systemCallMethods.setDevice;
getRunningAVD = systemCallMethods.getRunningAVD;
getRunningAVDWithRetry = systemCallMethods.getRunningAVDWithRetry;
killAllEmulators = systemCallMethods.killAllEmulators;
killEmulator = systemCallMethods.killEmulator;
launchAVD = systemCallMethods.launchAVD;
getVersion = systemCallMethods.getVersion;
waitForEmulatorReady = systemCallMethods.waitForEmulatorReady;
waitForDevice = systemCallMethods.waitForDevice;
reboot = systemCallMethods.reboot;
changeUserPrivileges = systemCallMethods.changeUserPrivileges;
root = systemCallMethods.root;
unroot = systemCallMethods.unroot;
isRoot = systemCallMethods.isRoot;
fileExists = systemCallMethods.fileExists;
ls = systemCallMethods.ls;
fileSize = systemCallMethods.fileSize;
installMitmCertificate = systemCallMethods.installMitmCertificate;
isMitmCertificateInstalled = systemCallMethods.isMitmCertificateInstalled;
getSdkBinaryPath = systemCommands.getSdkBinaryPath;
getBinaryNameForOS = systemCommands.getBinaryNameForOS;
getBinaryFromSdkRoot = systemCommands.getBinaryFromSdkRoot;
getBinaryFromPath = systemCommands.getBinaryFromPath;
getConnectedDevices = systemCommands.getConnectedDevices;
getDevicesWithRetry = systemCommands.getDevicesWithRetry;
reconnect = systemCommands.reconnect;
restartAdb = systemCommands.restartAdb;
killServer = systemCommands.killServer;
resetTelnetAuthToken = systemCommands.resetTelnetAuthToken;
adbExecEmu = systemCommands.adbExecEmu;
EXEC_OUTPUT_FORMAT = systemCommands.EXEC_OUTPUT_FORMAT;
adbExec = systemCommands.adbExec;
shell = systemCommands.shell;
createSubProcess = systemCommands.createSubProcess;
getAdbServerPort = systemCommands.getAdbServerPort;
getEmulatorPort = systemCommands.getEmulatorPort;
getPortFromEmulatorString = systemCommands.getPortFromEmulatorString;
getConnectedEmulators = systemCommands.getConnectedEmulators;
setEmulatorPort = systemCommands.setEmulatorPort;
setDeviceId = systemCommands.setDeviceId;
setDevice = systemCommands.setDevice;
getRunningAVD = systemCommands.getRunningAVD;
getRunningAVDWithRetry = systemCommands.getRunningAVDWithRetry;
killAllEmulators = systemCommands.killAllEmulators;
killEmulator = systemCommands.killEmulator;
launchAVD = systemCommands.launchAVD;
getVersion = systemCommands.getVersion;
waitForEmulatorReady = systemCommands.waitForEmulatorReady;
waitForDevice = systemCommands.waitForDevice;
reboot = systemCommands.reboot;
changeUserPrivileges = systemCommands.changeUserPrivileges;
root = systemCommands.root;
unroot = systemCommands.unroot;
isRoot = systemCommands.isRoot;
installMitmCertificate = systemCommands.installMitmCertificate;
isMitmCertificateInstalled = systemCommands.isMitmCertificateInstalled;

execBundletool = apksUtilsMethods.execBundletool;
getDeviceSpec = apksUtilsMethods.getDeviceSpec;
installMultipleApks = apksUtilsMethods.installMultipleApks;
installApks = apksUtilsMethods.installApks;
extractBaseApk = apksUtilsMethods.extractBaseApk;
extractLanguageApk = apksUtilsMethods.extractLanguageApk;
isTestPackageOnlyError = apksUtilsMethods.isTestPackageOnlyError;
execBundletool = apksUtilCommands.execBundletool;
getDeviceSpec = apksUtilCommands.getDeviceSpec;
installMultipleApks = apksUtilCommands.installMultipleApks;
installApks = apksUtilCommands.installApks;
extractBaseApk = apksUtilCommands.extractBaseApk;
extractLanguageApk = apksUtilCommands.extractLanguageApk;
isTestPackageOnlyError = apksUtilCommands.isTestPackageOnlyError;

packageAndLaunchActivityFromManifest = manifestMethods.packageAndLaunchActivityFromManifest;
targetSdkVersionFromManifest = manifestMethods.targetSdkVersionFromManifest;
targetSdkVersionUsingPKG = manifestMethods.targetSdkVersionUsingPKG;
compileManifest = manifestMethods.compileManifest;
insertManifest = manifestMethods.insertManifest;
hasInternetPermissionFromManifest = manifestMethods.hasInternetPermissionFromManifest;
packageAndLaunchActivityFromManifest = manifestCommands.packageAndLaunchActivityFromManifest;
targetSdkVersionFromManifest = manifestCommands.targetSdkVersionFromManifest;
targetSdkVersionUsingPKG = manifestCommands.targetSdkVersionUsingPKG;
compileManifest = manifestCommands.compileManifest;
insertManifest = manifestCommands.insertManifest;
hasInternetPermissionFromManifest = manifestCommands.hasInternetPermissionFromManifest;

extractUniversalApk = aabUtilsMethods.extractUniversalApk;
extractUniversalApk = aabUtilCommands.extractUniversalApk;

isEmulatorConnected = emuMethods.isEmulatorConnected;
verifyEmulatorConnected = emuMethods.verifyEmulatorConnected;
fingerprint = emuMethods.fingerprint;
rotate = emuMethods.rotate;
powerAC = emuMethods.powerAC;
sensorSet = emuMethods.sensorSet;
powerCapacity = emuMethods.powerCapacity;
powerOFF = emuMethods.powerOFF;
sendSMS = emuMethods.sendSMS;
gsmCall = emuMethods.gsmCall;
gsmSignal = emuMethods.gsmSignal;
gsmVoice = emuMethods.gsmVoice;
networkSpeed = emuMethods.networkSpeed;
execEmuConsoleCommand = emuMethods.execEmuConsoleCommand;
getEmuVersionInfo = emuMethods.getEmuVersionInfo;
getEmuImageProperties = emuMethods.getEmuImageProperties;
checkAvdExist = emuMethods.checkAvdExist;
isEmulatorConnected = emuCommands.isEmulatorConnected;
verifyEmulatorConnected = emuCommands.verifyEmulatorConnected;
fingerprint = emuCommands.fingerprint;
rotate = emuCommands.rotate;
powerAC = emuCommands.powerAC;
sensorSet = emuCommands.sensorSet;
powerCapacity = emuCommands.powerCapacity;
powerOFF = emuCommands.powerOFF;
sendSMS = emuCommands.sendSMS;
gsmCall = emuCommands.gsmCall;
gsmSignal = emuCommands.gsmSignal;
gsmVoice = emuCommands.gsmVoice;
networkSpeed = emuCommands.networkSpeed;
execEmuConsoleCommand = emuCommands.execEmuConsoleCommand;
getEmuVersionInfo = emuCommands.getEmuVersionInfo;
getEmuImageProperties = emuCommands.getEmuImageProperties;
checkAvdExist = emuCommands.checkAvdExist;
readonly POWER_AC_STATES = emuConstants.POWER_AC_STATES;
readonly GSM_CALL_ACTIONS = emuConstants.GSM_CALL_ACTIONS;
readonly GSM_VOICE_STATES = emuConstants.GSM_VOICE_STATES;
readonly GSM_SIGNAL_STRENGTHS = emuConstants.GSM_SIGNAL_STRENGTHS;
readonly NETWORK_SPEED = emuConstants.NETWORK_SPEED;
readonly SENSORS = emuConstants.SENSORS;

fileExists = fsCommands.fileExists;
ls = fsCommands.ls;
fileSize = fsCommands.fileSize;
rimraf = fsCommands.rimraf;
push = fsCommands.push;
pull = fsCommands.pull;
mkdir = fsCommands.mkdir;

getDeviceProperty = deviceSettingsCommands.getDeviceProperty;
setDeviceProperty = deviceSettingsCommands.setDeviceProperty;
getDeviceSysLanguage = deviceSettingsCommands.getDeviceSysLanguage;
Expand Down
Loading
Loading