Skip to content

A modern TypeScript library for Android Debug Bridge (ADB) with automatic detection, device management, and comprehensive API support.

Notifications You must be signed in to change notification settings

alisaitteke/adb-client

This branch is 45 commits behind master.

Folders and files

NameName
Last commit message
Last commit date
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024
Nov 23, 2024

Repository files navigation

๐Ÿค– ADB Client - Your Android's New Best Friend

A modern, powerful TypeScript library for Android Debug Bridge (ADB) operations. This library provides a robust interface to interact with Android devices, offering comprehensive device management, app control, and system monitoring capabilities.

TypeScript License Node

๐Ÿš€ What's This All About?

Imagine controlling your Android device with code that's actually readable. No more cryptic ADB commands or shell script nightmares. This library is like having a universal remote for your Android device, but cooler because... well, it's code!

โœจ The Cool Stuff You Get

  • ๐Ÿ” Sherlock-Level ADB Detection: Finds your ADB binary faster than you can say "where's my SDK?"
  • ๐ŸŽฏ TypeScript Superpowers: Because any's are scary and we like our types strict
  • ๐Ÿ›  Swiss Army Knife API: Everything you need, nothing you don't
  • ๐Ÿ“ฑ Device Whisperer: Talk to your device like never before
  • โšก Promise-based: Because callbacks are so 2010
  • ๐Ÿ”’ Type-Safe: Let the compiler catch your "oops" moments

๐ŸŽฏ Installation

npm install adb-client
# or if you're a yarn person
yarn add adb-client
# or if you're one of those cool pnpm folks
pnpm add adb-client

๐ŸŽฎ Quick Start

import { ADB } from 'adb-client';

// Let's do some magic! โœจ
async function main() {
  try {
    const adb = new ADB();
    
    // Find all your Android friends
    const devices = await adb.getDevices();
    
    if (devices.length === 0) {
      console.log('๐Ÿ˜ข No devices found. Did you forget to plug it in?');
      return;
    }

    // Pick your favorite device (or the only one you have ๐Ÿ˜…)
    const device = devices[0];
    console.log(`๐ŸŽฏ Found device: ${device.model || 'Mystery Phone'}`);
    
    // Let's take a selfie (screenshot)!
    await adb.takeScreenshot(device.serialNumber, './awesome-screenshot.png');
    console.log('๐Ÿ“ธ Say cheese!');
    
  } catch (error) {
    console.error('๐Ÿ’ฅ Oops!', error.message);
  }
}

๐ŸŽจ Cool Things You Can Do

๐Ÿ“ฑ Device Management

const adb = new ADB();

// Let's see what devices we've got
const devices = await adb.getDevices();
devices.forEach(device => {
  console.log(`๐Ÿ“ฑ Found: ${device.model || 'Mystery Device'} (${device.serialNumber})`);
});

// Get all the juicy details
const props = await adb.getDeviceProperties(devices[0].serialNumber);
console.log(`
  ๐Ÿค– Android Version: ${props.androidVersion}
  ๐Ÿ“ฆ SDK: ${props.sdkVersion}
  โญ Brand: ${props.brand}
`);

๐Ÿ“ฆ App Management

// Install that awesome app you built
await adb.installAPK('device123', './my-awesome-app.apk');

// Launch it to the moon! ๐Ÿš€
await adb.startApp('device123', 'com.your.awesome.app', '.MainActivity');

// Check how awesome your app is
const info = await adb.getPackageInfo('device123', 'com.your.awesome.app');
console.log(`๐Ÿ“Š App Version: ${info.versionName} (${info.versionCode})`);

// Marie Kondo your app data
await adb.clearAppData('device123', 'com.your.awesome.app');

๐Ÿ“ธ Screen Capture

// Take a screenshot (perfect for those "it works on my machine" moments)
await adb.takeScreenshot('device123', './proof-it-works.png');

// Record a video (great for catching those elusive bugs)
await adb.recordScreen('device123', './bug-in-action.mp4', 10, {
  size: '720x1280',  // For those who care about quality
  bitRate: '4M'      // For those who care about file size
});

๐Ÿ”‹ System Monitoring

// Check the battery (is it coffee break time?)
const battery = await adb.getBatteryInfo('device123');
console.log(`
  ๐Ÿ”‹ Battery: ${battery.level}%
  ๐ŸŒก๏ธ Temperature: ${battery.temperature}ยฐC
  โšก Charging: ${battery.isCharging ? 'Yep!' : 'Nope!'}
`);

// Network status (for when Wi-Fi is being sneaky)
const network = await adb.getNetworkInfo('device123');
console.log(`
  ๐ŸŒ IP: ${network.ipAddress}
  ๐Ÿ“ถ Wi-Fi: ${network.wifiEnabled ? 'Connected' : 'Looking for signal...'}
`);

๐ŸŽฎ Device Control

// Press buttons like a pro gamer
await adb.sendKeyEvent('device123', 'KEYCODE_HOME');  // Go home!
await adb.sendKeyEvent('device123', 'KEYCODE_BACK');  // Retreat!

// Toggle Wi-Fi (because why not?)
await adb.setWifiEnabled('device123', true);  // ๐Ÿ“ถ ON
await adb.setWifiEnabled('device123', false); // ๐Ÿ“ด OFF

๐ŸŽฏ Error Handling

import { ADB, ADBError, DeviceNotFoundError, CommandError } from 'adb-client';

try {
  const adb = new ADB();
  await adb.getDevices();
} catch (error) {
  if (error instanceof DeviceNotFoundError) {
    console.error('๐Ÿ˜ข Device went on vacation:', error.message);
  } else if (error instanceof CommandError) {
    console.error('๐Ÿค” ADB is being difficult:', error.message);
  } else {
    console.error('๐Ÿ’ฅ Something went boom:', error);
  }
}

โš™๏ธ Configuration

const adb = new ADB({
  customPath: '/path/to/your/special/adb',  // For the special snowflakes
  timeout: 5000  // For the impatient developers
});

๐Ÿ“š Requirements

  • Node.js โ‰ฅ 18 (Because we're modern like that)
  • ADB installed (You knew this was coming, right?)
  • An Android device (Or emulator, we don't judge)

๐Ÿค Contributing

  1. Fork it (Yes, that button up there โ˜๏ธ)
  2. Create your feature branch: git checkout -b feature/something-awesome
  3. Commit your changes: git commit -m 'Add something awesome'
  4. Push to the branch: git push origin feature/something-awesome
  5. Submit a PR (and make our day!)

๐Ÿ› ๏ธ Development

# Get the party started
npm install

# Build something amazing
npm run build

# Make sure it works
npm test

# Make it pretty
npm run format

๐Ÿ“ License

MIT License - Go wild! (Just don't blame us if something breaks ๐Ÿ˜‰)

๐Ÿ’ก Support

Found a bug? Got a cool idea? Need a virtual hug?

  • Open an issue
  • Submit a PR
  • Send a carrier pigeon

๐ŸŽ‰ Coming Soonโ„ข

  • Telepathic device control
  • Time travel debugging
  • Coffee maker integration
  • More realistic features we're actually working on...

Made with โ˜• and TypeScript. Happy coding! ๐Ÿš€

About

A modern TypeScript library for Android Debug Bridge (ADB) with automatic detection, device management, and comprehensive API support.

Resources

Stars

Watchers

Forks