Mobile How To
How to pull APK for an installed app via ADB
Get the class for the app either via
adb shell pm list packages
or by simply looking at the play.google.com url id attribute
adb shell pm path com.example.someapp adb pull /data/app/com.example.someapp-2.apk .
How to connect two android devices
First, why:
I own two android tablets that act as a part-time car headrest entertainment system. Heck, they are so cheap, buying a dedicated car video just does not make sense. Tablets work great for that purpose, great resolution (for a car), games and music. There is only one piece that is missing, simultaneous video playback on both tablets.
Getting this working presents two challenges:
- A fast, stable, always ON connection between the tablets.
- A master/slave video playback software, either streaming or syncing
Tested on Froyo (Android 2.2). At least one device has to support the USB Host mode and provide root access.
Now, how:
The idea is simple - use the android debugging bridge to forward TCP ports between two systems over USB. If you do have USB tethering enabled on at least one device (I did not) you could use RNDIS to route all traffic, not just specific ports, over USB.
- Pick a tablet to be the slave. It must be rooted. Get the adb client compiled for android from here, upload it to the slave /system/xbin ("adb push ...") and make executable (adb shell chmod 755...). Get ConnectBot from the android market to access the console.
- Put the slave into the USB Host mode, disable USB debugging on it. Put the master into the USB device mode and enable USB debugging.
- Connect the master and the slave using a USB-female and USB-male combination, a USB hub (make sure it is a high-speed one) or a USBmale-to-USB male cord, if you can find one.
- Now the tedious part, typing shell commands on the tablet. You can make it a bit easier by using a USB hub and connecting a keyboard and a mouse together with the other tablet to the slave. On the slave start ConnectBot for the localhost and type the following:
less /proc/bus/usb/devices
Look for your master's devices BUS# and DEV#. Record both. Note, these numbers change when you re-plug USB.
Now, on the slave:
su mkdir -p /dev/bus/usb/001/ ln -sf /proc/bus/usb/[BUS#]/[Dev#] /dev/bus/usb/001/001[/CODE]
- Test. On the slave run 'adb devices'. It should show your master in the list.
- Forward slave ports to the master as needed. Run 'adb forward tcp:123 tcp:234'. Now you can use localhost:123 on the slave to reach out to the master port 234 over USB.
If your kernel is RNDIS enabled you could route all network connections over the usb0 interface, essentially creating a one-to-one network. Stock Kyros unfortunately does not support RNDIS so I've not tested it.
The ADB USB speed is not bad, averaging 2.5MB/sec after protocol overhead.
I did some research on the second issue, went several routes (mplayer, VLC and UPNP) and, sadly, found nothing that currently works. If you know of any working video source/sink pair or a sync peer for android, let me know.
How to forward tcp traffic over usb
adb forward tcp:portonhost tcp:portonremote
How to power on android when charger is connected
The battery charging graphic is displayed by /system/bin/playlpm file on Samsung devices.
If you are root, you can edit this file to
#!/system/bin/sh /system/bin/reboot
Be sure to add those permissions to the file
chmod 0755/system/bin/playlpm chown root.shell /system/bin/playlpm
the file might also be located at /system/bin/battery_charging
How to mount iPhone's file system
Make sure you have ifuse: sudo apt-get install ifuse fuse-utils Create a mount folder. I suggest creating a subfolder in the /media folder, otherwise a system indexer (updatedb/beagle/nepomuk) may get a little too friendly with it.
mkdir ~/mountfolder
Mount the phone’s filesystem: If you want to mount “mobile” user folder:
ifuse /mountfolder
If you want to mount iphone’s root /:
ifuse --root /mountfolder
You need a jailbroken phone for this to work. You might also need to install afc2add app from Cydia if you got your jailbreak through Blackra1n or Spirit, not PwnageTool To unmount run:
fusermount -u ~/mountfolder
How to sync iPhone music with Amarok
- Get it all hooked up:
sudo add-apt-repository ppa:pmcenery/ppa sudo apt-get update sudo apt-get install gvfs ipheth-dkms ipheth-utils
- Reboot if needed
- Start Amarok
- Connect your iPhone.
How to check iPhone UUID
sudo apt-get install libimobiledevice-utils
Now you can do
- ideviceinfo – various device data
- idevice_id get the device id – UUID
- idevicesyslog – view the syslog
- idevicebackup – to back it up
How to connect iPhone with Ubuntu
Please, note that the following information is outdated and is here for reference only. There's been great advances in iPhone+Ubuntu area since I wrote this up.
- First, get all the prerequisites:
apt-get install build-essential cmake libglib2.0-dev libxml2-dev python-dev swig automake autoconf libtool libgnutls-dev libusb-dev libfuse-dev libglib2.0-dev libxml2-dev libreadline5-dev
- Then, install libplist (needed for libiphone)
git clone git://github.com/JonathanBeck/libplist.git mkdir build cd build cmake .. make sudo make install sudo ln -s /usr/local/lib/libplist.so.0.0.11 /usr/lib sudo ln -s /usr/lib/libplist.so.0.0.11 /usr/lib/libplist.so.0 sudo ln -s /usr/lib/libplist.so.0 /usr/lib/libplist.so
- Now, install libiphone
git clone git://github.com/MattColyer/libiphone.git ln -s plist-folder/ swig/plist ./autogen.sh ./configure make sudo make install sudo ln -s /usr/local/lib/libiphone.so.0 /usr/lib/
- Get iTunnel and run it
./itunnel 7777
- Now go and change the iTunes DB version to an un-encrypted one
ssh -p 7777 root@localhost cp /System/Library/Lockdown/Checkpoint.xml /System/Library/Lockdown/Checkpoint.xml.bak nano /System/Library/Lockdown/Checkpoint.xml find (^W) and change DBVersion to 2.
- Terminate the tunnel and reboot the iPhone.
- Start the tunnel back up and mount the iPhone:
sshfs -p 7777 root@localhost:/var/mobile/Media /media/iphone/ -o workaround=rename
- Setup Amarok
- Click Settings → Configure Amarok.
- Choose Media Devices.Hit Add Device. Select Apple iPod Media Device for the plugin type.
- Point it at your mount point /media/iphone
- In Devices, click Connect. Once connected, click on the double arrows on the right hand side of the Connect, Disconnect, and Transfer buttons. A list of options opens up, one of which is iPod. Choose iPod → Set iPod Model → Mobile Phones → iPhone
- Enjoy
Tethering with SSH
- For tethering try this:
ssh -D 9800 -p 7777 mobile@127.0.0.1
-D sets a SOCKS proxy.
- Change the Opera to use the SOCKS proxy on localhost:9800. If you are using Firefox, also set its DNS in about:config set
network.proxy.socks_remote_dns=true.
Gotchas:
- Make sure you’ve got your FirewireGUID already setup (I.e. you’ve connected the iPhone to iTunes via USB after flushing its brain)
- Unmount gphoto2 gvfs iPhone share when it is automounted
- iTunnel does not support scp/sftp
- If iTunnel fails with -5 try running it again.
References: