Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mishguru/muppet

Package Overview
Dependencies
Maintainers
6
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mishguru/muppet

ADB utils

  • 6.0.0-beta.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
6
Weekly downloads
 
Created
Source

@mishguru/muppet

Utils for remote controlling android phone

device

import { device } from '@mishguru/muppet'

const deviceId = await device.firstDeviceIdAvailable()

await device.enableRoot(deviceId)

await device.runCommand(deviceId, 'echo hello world')

const buffer = await device.runCommandAndAll(deviceId, 'ls')

const string = await device.runCommandAndReadAllAsString('deviceId, ls')

await device.pullFile(deviceId, '/etc/passwd', './local/passwd.txt')

await device.pushFile(deviceId, './local/cache.tgz', '/data/cache.tgz')

await device.reboot(deviceId, )

android

import { android } from '@mishguru/muppet'

await android.setSELinuxToEnforce(deviceId)

await android.writeId(deviceId, android.generateRandomId())

const androidId = await android.readId(deviceId)

await android.pressPowerButton(deviceId)

const isSleeping = await android.isSleeping(deviceId)

await android.toggleScreenAwake(deviceId, !isSleeping)

await android.whileAwake(deviceId, async () => {
  // phone is guranteed to be awake
  // and will be reset to it's existing state
  // when this function finishes
})

const batteryLevel = await android.batteryLevel(deviceId)

const screenshotPath = await android.screenshot(deviceId)

automator

import { automator } from '@mishguru/muppet'

const window = automator.dumpWindow(deviceId)
const node = window.findNodeById('android:id/button1')

const { x, y } = node.center()
await automator.tap(deviceId, x, y)

await automator.tapNode(deviceId, node)

await automator.longTouch(deviceId, x, y)

await automator.longTouchNode(deviceId, node)

await automator.type(deviceId, 'hello world')

await automator.pressKey(deviceId, 66)

await automator.pressEnter(deviceId)

await automator.pressBack(deviceId)

await automator.pressDelete(deviceId)

await automator.moveToEndOfInput(deviceId)

const textInput = window.findNodeById('android:id/textinput')
await automator.clearTextInput(deviceId, textInput)

// window
window.findNodeById()
window.mustFindNodeById()
window.findNodeByRegex()
window.mustFindNodeByRegex()
window.findNodeByText()
window.mustFindNodeByText()
window.toString

// node
node.id()
node.class()
node.text()
node.coords()
node.size()
node.center()
node.findChild()
node.toString()

wifiSettings

import { wifiSettings } from '@mishguru/muppet'

await wifiSettings.start(deviceId)

await wifiSettings.quit(deviceId)

await wifiSettings.getProxy(deviceId)

await wifiSettings.setProxy(deviceId, { host: '192.168.1.100', port: 8080 })

await wifiSettings.removeProxy()

await wifiSettings.restartWifi()

Logger

import { logger } from '@mishguru/muppet'

logger.debug(message)
logger.verbose(message)
logger.info({ success: true })
logger.error(message)

poll

import { poll } from '@mishguru/muppet'

// repeatedly loop a function
// until it either returns true
// or 2 seconds have passed

const timedOut = await poll(2000, async () => {
  const result = await device.runCommandAndReadAllAsString(deviceId, 'cat /data/status')
  return /ready/.test(result)
})

if (timedOut) {
  // ...
}

Keywords

FAQs

Package last updated on 18 Feb 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc