George Smart - M1GEO

An online scrapbook full of half-baked projects and silly ideas.

Ads

Android ADB udev

This page gives the main steps in setting up a udev rule to bridge ports to/from your android phone using ADB.

The Script

The script is called by udev and actually makes the bridge. You will need to adjust your path for adb on the bottom line. Name it /opt/google/phone_forward.sh

#!/bin/bash
# Script to link ADB with my phone, to be called from udev.
# George Smart, M1GEO. 03/Oct/2011.

/opt/google/android-sdk/platform-tools/adb forward tcp:8080 tcp:8080

# Notifications requre “libnotify-bin” from repos. Not Working Yet.
notify-send “HTC Desire Connected” “ADB was launched via UDEV” –icon “/usr/share/pixmaps/pidgin/emotes/default/phone.png”

You will need to make it executable; sudo chmod a+x /opt/google/phone_forward.sh

The udev Rule

We then made udev call this script whenever the phone is plugged in. This link shows you how to run external programs from udev rules. This link shows the vendor IDs, etc, for various phones.

The udev rule is as follows. Name it /etc/udev/rules.d/android_phone_adb.rules

SUBSYSTEM==”usb”, ATTR{idVendor}==”0bb4″, MODE=”0666″, GROUP=”plugdev” RUN+=”/opt/google/phone_forward.sh”

Ads

Dr. George Smart, M1GEO. © 2003–2017 Frontier Theme