New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@wtto00/android-tools

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wtto00/android-tools

Node module for managing and controlling the Android Devices.

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
19
35.71%
Maintainers
1
Weekly downloads
 
Created
Source

android-tools

Test

Node module for managing and controlling the Android Devices.

English | 简体中文

Install

npm i @wtto00/android-tools

Usage

import Android from '@wtto00/android-tools';

const options = {
  // adb: "platform-tools/adb",
  // avdmanager: "cmdline-tools/bin/avdmanager",
  // sdkmanager: "cmdline-tools/bin/sdkmanager",
  // emulator: "emulator/emulator",
};
const android = new Android(options);

Andorid Options

fieldtyperequireddefaultnote
adbstringfalse${process.env.ANDROID_HOME}/platform-tools/adb or adb in PATHThe location of the adb executable file relative to ANDROID_HOME
avdmanagerstringfalse${process.env.ANDROID_HOME}/cmdline-tools/bin/avdmanager or avdmanager in PATHThe location of the avdmanager executable file relative to ANDROID_HOME
sdkmanagerstringfalse${process.env.ANDROID_HOME}/cmdline-tools/bin/sdkmanager or sdkmanager in PATHThe location of the sdkmanager executable file relative to ANDROID_HOME
emulatorstringfalse${process.env.ANDROID_HOME}/emulator/emulator or emulator in PATHThe location of the emulator executable file relative to ANDROID_HOME

start

Start the emulator using the AVD supplied through with avdName.

android
  .start({
    avd: 'android-avd-name',
    verbose: true
    // ...
  })
  .then((res) => {
    console.log(`emulatorId: ${res.id}`);
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
avdstringtrue-use a specific android virtual device
verbosebooleantrue-enable specific debug messages
noWindowbooleanfalse-disable graphical window display
noSnapshotbooleanfalse-perform a full boot and do not auto-save, but qemu vmload and vmsave operate on snapstorage
noSnapstoragebooleanfalse-do not mount a snapshot storage file (this disables all snapshot functionality)
noSnapshotUpdateTimebooleanfalse-do not try to correct snapshot time on restore
noSnapshotSavebooleanfalse-do not auto-save to snapshot on exit: abandon changed state
noSnapshotLoadbooleanfalse-do not auto-start from snapshot: perform a full boot
cameraBack"emulated"
"virtualscene"
"videoplayback"
"none"
"webcam"
false-set emulation mode for a camera facing back
cameraFront'emulated'
'webcam'
'none'
false-set emulation mode for a camera facing front
gpu'auto'
'auto-no-window'
'host'
'swiftshader_indirect'
'angle_indirect'
'guest'
false'auto'set hardware OpenGLES emulation mode
nocachebooleanfalse-disable the cache partition
noaudiobooleanfalse-disable audio support
noBootAnimbooleanfalse-disable animation for faster boot
lowrambooleanfalse-device is a low ram device
restartWhenStalledbooleanfalse-Allows restarting guest when it is stalled.
waitForDebuggerbooleanfalse-Pause on launch and wait for a debugger process to attach before resuming
httpProxystringfalse-make TCP connections through a HTTP/HTTPS proxy
coresnumberfalse-Set number of CPU cores to emulator
wipeDatabooleanfalse-reset the user data image (copy it from initdata)
noPassiveGpsbooleanfalse-disable passive gps updates

waitForDevice

Waiting for the simulator device to become available.

android
  .waitForDevice('emulator-id')
  .then(() => {
    console.log('available');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device

ensureReady

Ensure device has been started and ready.

android
  .ensureReady('emulator-id')
  .then(() => {
    console.log('ready');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device

createAVD

Create a AVD based upon image.

android
  .createAVD({
    name: avdName,
    package: 'android-image-name',
    force: false
  })
  .then(() => {
    console.log('has been created');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
apiLevelnumberfalse-API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10.
target'default'
'google_apis'
'playstore'
'android-wear'
'android-wear-cn'
'android-tv'
'google-tv'
'aosp_atd '
'google_atd'
false'default'Target of the system image .
arch'x86_64'
'x86'
'arm64-v8a'
'armeabi-v7a'
falseCurrent system CPU architectureCPU architecture of the system image
packagestringfalse-Package path of the system image for this AVD (e.g. 'system-images;android-19;google_apis;x86').
namestringfalse-Name of the new AVD.
forcebooleanfalse-Forces creation (overwrites an existing AVD)
  • If you pass a package, the parameters apiLevel, target, and arch will be ignored. If you don't pass a package, the apiLevel parameter is required.

hasAVD

Check if a specific AVD has been created on this machine.

android
  .hasAVD('android-avd-name')
  .then((res) => {
    console.log(res ? 'has been created' : 'not exist');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-Name of AVD

stop

Stop a certain emulator.

android
  .stop('emulator-id')
  .then(() => {
    console.log('has sent stop command');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device

waitForStop

Wait until the device is stopped.

android
  .waitForStop('emulator-id')
  .then(() => {
    console.log('has been stopped');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device

isInstalled

Check the package specified with packageName is installed or not.

android
  .isInstalled('emulator-id', 'com.android.webview')
  .then((res) => {
    console.log(res ? 'installed' : 'not installed');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device
packageNamestringtrue-Package name of App

install

Install an APK located by absolute URI apkPath onto device with emulatorId.

android
  .install('emulator-id', '/path/to/apk', { r: true })
  .then(() => {
    console.log('installed');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device
apkPathstringtrue-Absolute path of apk file
optionsobjectfalse-The parameters for "adb install": -lrtsdg

inputKeyEvent

adb shell input keyevent.

android
  .inputKeyEvent('emulator-id', 82)
  .then(() => {
    console.log('has send key');
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device
keynumbertrue-key number,seeAndroid Document

devices

List connected devices

android
  .devices()
  .then((res) => {
    res.forEach((item) => {
      console.log(`name: ${item.name}, status: ${item.status}`);
    });
  })
  .catch((err) => {
    console.log(err);
  });

listPackages

List packages installed on the emulator with emulatorId.

android
  .listPackages('emulator-id')
  .then((res) => {
    res.forEach((item) => {
      console.log(item);
    });
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
emulatorIdstringtrue-ID of emulator device

listDevices

List the available device list for creating emulators in the current system.

android
  .listDevices()
  .then((res) => {
    res.forEach((item) => {
      console.log(`id: ${item.id}, Name: ${item.Name}, OEM: ${item.OEM}, Tag: ${item.Tag}`);
    });
  })
  .catch((err) => {
    console.log(err);
  });

listAVDs

List all AVDs created on this machine.

android
  .listAVDs()
  .then((res) => {
    res.forEach((item) => {
      console.log(`Name: ${item.Name}, Path: ${item.Path}, Target: ${item.Target}, Sdcard: ${item.Sdcard}`);
    });
  })
  .catch((err) => {
    console.log(err);
  });

listTargets

List available Android targets.

android
  .listTargets()
  .then((res) => {
    res.forEach((item) => {
      console.log(`id: ${item.id}, Name: ${item.Name}, Type: ${item.Type}, API level: ${item['API level']}`);
    });
  })
  .catch((err) => {
    console.log(err);
  });

listImages

List available android images on this machine.

android
  .listImages()
  .then((res) => {
    res.forEach((item) => {
      console.log(
        `name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
      );
    });
  })
  .catch((err) => {
    console.log(err);
  });

listInstalledImages

List installed android images on this machine.

android
  .listInstalledImages()
  .then((res) => {
    res.forEach((item) => {
      console.log(
        `name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
      );
    });
  })
  .catch((err) => {
    console.log(err);
  });

adb

Use adb to execute commands.

android
  .adb('emulator-id', 'shell pm list packages')
  .then((res) => {
    console.log(res.output);
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
cmdstringtrue-The command to be executed.

avdmanager

Use avdmanager to execute commands.

android
  .avdmanager('list avd')
  .then((res) => {
    console.log(res.output);
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
cmdstringtrue-The command to be executed.

sdkmanager

Use sdkmanager to execute commands.

android
  .sdkmanager('--list')
  .then((res) => {
    console.log(res.output);
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
cmdstringtrue-The command to be executed.

emulator

Use emulator to execute commands.

android
  .emulator('--help')
  .then((res) => {
    console.log(res.output);
  })
  .catch((err) => {
    console.log(err);
  });
fieldtyperequireddefaultnote
cmdstringtrue-The command to be executed.

Keywords

android

FAQs

Package last updated on 10 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts