Adb-Wrapper
An awesome ADB wrapper made in node js to use adb just with functions.
· Report Bug · Request Feature
Table of Contents
About The Project
The adb wrapper provides a flexibal API to execute adb commands.
A user can also pass the custom the adb path to it.
Getting Started
If you dont have ADB installed in your system, dont worry. It has inbuilt adb, you could also provide a path for adb explicity, which the module will use.
Prerequisites
Node js and an initialized npm folder
- npm
npm install adb-wrapper
See the open issues for a full list of proposed features (and known issues).
Usage
After installation of the module into your project, you can take this simple example.
import ADB from "adb-wrapper";
async function main() {
var getAdbInstalled = await ADB.isAdbInstalled();
if (!getAdbInstalled) return console.log("Adb is not installed");
var deviceList = await ADB.deviceList();
console.log(`Connected Devices ${JSON.stringify(deviceList)}`);
}
main();
There will be more functions in upcoming days as we are actively developing it. Watch it to get notified whenever we add something new to it.
Methods
Here are the list of methods you can use.
-
deviceList()
Returns: { type: string, udid: string, port: string} Returns Object of all detected devices by adb. -
setCurrentActiveDevice()
Prams: device (device udid)
set the current active device -
isAdbInstalled()
Returns: boolean
detect if adb is installed or not -
setAdbExplicitPath()
Params: path (folder path of the adb)
if the adb is not installed, you can manually download it and provide the path of the folder where adb.exe exsists -
killServer()
kill the adb server -
startServer()
start the adb server -
tcpip()
Prams: port (port on which to start the adb server listening to)
adb listen to a port -
connectRemote()
Params: {ip( of the remote host), port (of remort host)} (folder path of the adb)
connect to a device on a remote host -
disconnectRemote()
Params: {ip( of the remote host), port (of remort host)} (folder path of the adb)
disconnect to a device on a remote host
Please set the current active device to which the command will executed, some function wont work. Do it by calling setCurrentActiveDevice() and providing the udid of the device.
You can get the devices udid by calling the function deviceList() -
installApp()
Params: apkPath (path of the apk)
Install the app to the current active android device -
uninstallApp()
Params: packageId (the package id of the app to uninstall)
uninstall the app given by the package id -
execShellCmd()
Params: shellCmd (shell command) note: dont includeshell
in it
its equivalent to adb shell. you can execute the shell commands using it -
getCurrentOpendedActivity()
Returns: packageInfo (of the current Activity Openned)
it will return the info of the current openned activity, including the package id of the app.
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Contact
Author Name - @amir-alam-44378416b - [email protected]
Project Link: https://github.com/MrSharpp/adb-wrapper-node-js