I am trying to make a way to telnet to an unrooted Droid. I have the INTERNET
permission active, I have my device connected on the same network as my Mac OS X
box via WiFi, and I am able to ping the port I opened.
In initial experiments, I got it to work on a rooted test device, but I had the socket handlers run on the UI Thread
rather than a separate thread. Now that I have the network modules on a separate thread, I can't get ServerSocket.accept ()
to return. It works on Google's version of android (vanilla), but not on Samsung's or Sony-Ericsson's.
When I telnet to it, my attempt would time out, and logcat
wouldn't print out any exceptions or errors.
Here is a link to a google-code repo of my code: Google-code Repository
I am running ServerScoket.accept ()
on a separate thread, and run the stream processors on another thread as well. Comments on my design (i.e. I should use Handler
s or AsyncTasks
) are extremely welcome. Right now, in order to Toast the messages received via telnet, I use a Handler with the looper being acquired via a Context
.
The following is what I get when I run netstat -n
on the adb shell on the non-working devices:
~$ adb shell netstat -n
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:7777 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7203 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:47609 127.0.0.1:7777 ESTABLISHED
tcp 0 0 127.0.0.1:7777 127.0.0.1:47609 ESTABLISHED
tcp 0 0 127.0.0.1:47610 127.0.0.1:7777 ESTABLISHED
tcp 0 0 127.0.0.1:7777 127.0.0.1:47610 ESTABLISHED
The difference is that in the working devices, they list an IP with my port open in the state, LISTEN.
UPDATE: Having the <uses-permission android:name="INTERNET"/>
set in my android_manifest
, I tried changing the port number to 689
. It didn't work; I got a BindException
, saying that I may be lacking the INTERNET permission. So, I changed it to 1989
, and I went back to everything working until accept ()
. I assume this is because I ran it on a non-root phone, and I don't have access to ports 1024
and below.
UPDATE: I ran a really similar program on my Mac, and it worked fine when I tried telnetting to my Mac using the IP address assigned to me. It didn't work when I tried telnetting from another Mac but it didn't seem to connect; the connection would timeout. It did work over an ad-hoc network, though. I still have yet to try it using the droid, but I will update this asap.
UPDATE: I managed to get the app working on 3 separate Droids running Vanilla (Android released by google). It worked on a Nexus, an Apanda A60 (my first device; adb has ceased to detect it for some reason.), and a custom-made, unbranded tablet. Still, because I already offered a pretty big bounty, I plan on seeing this through to the end.
As stated earlier, my app works with Vanilla versions of android, but not with modified versions. The three phones that failed to run it were all mid-range models; 2 Samsung GT-i5503
s, and a Sony-Ericcson E16i
.