Node module for managing and controlling Android devices and emulators.
npm install --save androidctrl
Start the emulator using the AVD supplied through with avdName
. Returns a
promise that is resolved with an object that has the following properties.
{
id: String, // The ID of the emulator
process: Object // The child_process object
}
Return a promise that will be resolved when the device specified with deviceId
is ready (adb daemon is running).
Resolves a promise when the device with the id deviceId
has completed its
boot process.
Run an adb command on the device with the id deviceId
, and resolve to an
object containing the following:
{
code: Number, // the exit code of the process,
stdout: String, // The captured stdout
stderr: String // The captured stderr
}
Create an AVD based upon targetId
(from listTargets
). Returns a promise
that will be resolved when the AVD has finished being created.
Resolves to an array of Android target objects that can be used with createAVD.
The array looks like:
[
{
id: '1 or "android-22"',
Name: 'Android 5.1.1',
Type: 'Platform',
level: '22',
Revision: '2',
Skins: 'HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in'
},
{
id: '2 or "android-23"',
Name: 'Android 6.0.0',
Type: 'Platform',
level: '23',
Revision: '2',
Skins: 'HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in'
}
]
Resolves to true if the AVD exists, or false if it does not.
Resolves to an array of Android AVD objects that can be used in conjunction
with start(avd.Name)
.
The array looks like:
[
{
Name: 'Android511',
Device: 'Nexus 5 (Google)',
Path: '/Users/michael/.android/avd/Android511.avd',
Target: 'Android 5.1.1 (API level 22)',
'Tag/ABI': 'default/x86',
Skin: '1080x1920',
Sdcard: '500M'
},
{
Name: 'Android600',
Device: 'Nexus 5 (Google)',
Path: '/Users/michael/.android/avd/Android600.avd',
Target: 'Android 6.0.0 (API level 23)',
'Tag/ABI': 'default/x86',
Skin: '1080x1920',
Sdcard: '500M'
}
]
Resolves to an array of device objects.
The array looks like:
[
{ name: 'emulator-5554', status: 'device' },
{ name: 'emulator-5555', status: 'device' },
{ name: 'emulator-5556', status: 'offline' }
]
Returns a promise that resolves to an array containing packages installed on
the device with deviceId
.
The array looks like:
[
'com.android.smoketest',
'com.example.android.livecubes',
'com.android.providers.telephony',
'com.android.providers.calendar',
'com.android.providers.media',
'com.android.protips',
'com.android.launcher',
'com.android.documentsui',
'com.android.gallery',
'com.android.externalstorage'
]
Returns a promise that resolves with a boolean value that is true if the package
specified with packageName
is installed.
Install an APK located by absolute URI apkPath
onto device with deviceId
.
Returns a Promise that resolves to undefined
on success, and throws
'Already installed'
if it's already installed.
If reinstall
is true, than the package will be reinstalled and all related
data will be kept.
Stop the device specified with deviceId
. (This should only be used with
emulators. It will kill the process.)
Presses the power on button on the phone.
Presses the unlock button on the phone.
Sends a key event with keyCode
to device specified with deviceId
.