Tips and Tricks for Android Users
Posts tagged osx
Samsung Captivate Tethering for OS X
Aug 17th
When I plugged my Samsung Captivate into my OS X machine I was surprised to see a network connection dialog pop up on my laptop and what looked like a tethering app pop up on the device. Given that AT&T tries to kill off tethering in every way possible with the iPhone, I figured it wouldn’t be on with my Captivate either. Or at least not easy to get working. No problem though. I just needed to figure out which set of settings to put in the network connection dialogs in OS X.
In the main network settings screen under System Preferences:
- leave telephone number blank
- use ‘WAP@CINGULARGPRS.COM’ for Account Name
- use ‘CINGULAR1′ for Password
Then click the advanced button and setup:
- Vendor generic
- Model GPRS (GSM/3G)
- APN is ‘wap.cingular’
- CID set to 1
After that starting up a network session with my Captivate attached over USB yielded a pretty quick network connection! Now if only they could fix these GPS issues….
Monitoring Network Traffic Using OS X
Jun 1st
Here’s a tip for monitoring network traffic from your Android phone using OS X. The same thing works for iPhone (or any other mobile device you can configure to use a wifi connection). I frequently use it to see how some bit of client/server interaction is done.
- Install Wireshark
- Follow the instructions in the readme to also install the ChmodBPF script
- Under Sharing area of the OS X settings app configure your system to use an ethernet connection and share it out to wifi clients
- Now configure your device to connect to the wifi network provided by your system, test to make sure it works
- Startup Wireshark and set it to capture traffic (wifi is en1 on MacBook Pro systems, what I normally use)
And that’s it, you should now get quite readable dumps of what applications are doing to communicate. Lots of interesting things you can learn digging into how folks structure their client/server interaction.
Compiling C Code for Android Using OS X
May 27th
I wanted to try out compiling some native C code for use on my device, but I wanted to do it using my OS X machine. I found this post about using the prebuilt toolchain over at Android Tricks, but figured I would write up some additional details for those who might also be looking.
- Follow the instructions to download and build Android from source. Follow the whole thing (I had to create a case-sensitive disk image and all), including the actual build step. Otherwise you won’t have the libraries necessary and agcc will error out when you try to run it.
- Add the prebuilt/darwin-x86/toolchain/arm-eabi-4.2.1/bin subdirectory of where ever you built the source to your PATH, add it to your .bash_profile if you want.
- Download the agcc wrapper script, put it somewhere in your path, and make it executable.
Now you should be ready to compile a program and download it to your phone. This was my test app:
#include <stdio.h>
int main( int argc, char **argv ) {
printf("Hello from Droid Hacks!\n");
return 0;
}
And you should be able to compile it with “agcc hello.c -o hello” and end up with a hello executable:
~ > agcc hello.c -o hello ~ > file hello hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped ~ >
And you can move the file across to the phone and run it. You’ll have to make a directory to push it into. The sdcard is marked as noexec, so you can’t run stuff from there. And the data directory has more restrictive permissions. So you’ll have to su and create a directory on the data partition, and relax the perms on that directory:
~ > adb shell $ su # mkdir /data/droidtest # chmod 777 /data/droidtest # exit $ exit ~ > adb push hello /data/droidtest 418 KB/s (6747 bytes in 0.015s) ~ > adb shell $ cd /data/droidtest $ ls -l -rwxrwxrwx shell shell 6747 2009-05-27 08:56 hello $ ./hello Hello from Droid Hacks! $
And of course you can run the same thing from the terminal on your device as well: