Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r494 committed - Fill in client address.

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r494 committed - Fill in client address.


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r494 committed - Fill in client address.
  • Date: Mon, 15 Aug 2011 19:42:09 +0000

Revision: 494
Author:

Date: Mon Aug 15 12:41:56 2011
Log: Fill in client address.
http://code.google.com/p/ndt/source/detail?r=494

Modified:
/branches/android/Android/src/net/measurementlab/ndt/NdtService.java
/branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java

=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Mon Aug 15 10:13:26 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Mon Aug 15 12:41:56 2011
@@ -9,6 +9,8 @@
import android.util.Log;

public class NdtService extends Service {
+ static final String LOG_TAG = "ndt";
+
public static final int PREPARING = 0;
public static final int UPLOADING = 1;
public static final int DOWNLOADING = 2;
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Mon Aug 15 12:24:06 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Mon Aug 15 12:41:56 2011
@@ -2,6 +2,11 @@

package net.measurementlab.ndt;

+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -14,6 +19,8 @@
import android.util.Log;
import android.widget.TextView;

+import static net.measurementlab.ndt.NdtService.LOG_TAG;
+
/**
* Animated progress while selecting server location.
*/
@@ -27,7 +34,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tests);
- Log.i("ndt", "Loaded!");
+ Log.i(LOG_TAG, "Loaded!");
Typeface typeFace = Typeface.createFromAsset(getAssets(),
"fonts/League_Gothic.otf");
TextView textView = (TextView)
findViewById(R.id.NdtTestsHeader);
@@ -47,7 +54,7 @@
@Override
protected void onStart() {
super.onStart();
- Log.i("ndt", "Tests activity started.");
+ Log.i(LOG_TAG, "Tests activity started.");
}

@Override
@@ -64,7 +71,7 @@
intent.putExtra("networkType", getNetworkType());
startService(intent);

- Log.i("ndt", "Tests activity resumed.");
+ Log.i(LOG_TAG, "Tests activity resumed.");
}

@Override
@@ -83,25 +90,31 @@
}

private void preparing() {
- Log.i("ndt", "Preparing Your Tests...");
+ Log.i(LOG_TAG, "Preparing Your Tests...");
updateHeader(R.string.tests_preparing_header);
+
+ String localAddress = getLocalIpAddress();
+ if (null != localAddress) {
+ TextView textView = (TextView)
findViewById(R.id.TestClientValue);
+ textView.setText(localAddress);
+ }
// TODO show preparation animation
}

private void uploading() {
- Log.i("ndt", "Testing Upload...");
+ Log.i(LOG_TAG, "Testing Upload...");
updateHeader(R.string.tests_both_header,
R.string.tests_upload_info);
// TODO show upload animation
}

private void downloading() {
- Log.i("ndt", "Testing Download...");
+ Log.i(LOG_TAG, "Testing Download...");
updateHeader(R.string.tests_both_header,
R.string.tests_download_info);
// TODO show download animation
}

private void complete() {
- Log.i("ndt", "Testing Complete.");
+ Log.i(LOG_TAG, "Testing Complete.");
updateHeader(R.string.tests_complete_header);
// TODO send intent for summary activity
}
@@ -111,7 +124,7 @@

@Override
public void onReceive(Context context, Intent intent)
{
- Log.i("ndt", "Status change received.");
+ Log.i(LOG_TAG, "Status change received.");
int status = intent.getIntExtra("status",
NdtService.PREPARING);
switch (status) {
case NdtService.PREPARING:
@@ -127,12 +140,12 @@
complete();
break;
default:
- Log.i("ndt", "Test reporter not
initialized.");
+ Log.i(LOG_TAG, "Test reporter not
initialized.");
break;
}
}
};
- Log.i("ndt", "Status receiver created.");
+ Log.i(LOG_TAG, "Status receiver created.");
return receiver;

}
@@ -165,4 +178,21 @@
return NdtTests.NETWORK_UNKNOWN;
}
}
-}
+
+ public String getLocalIpAddress() {
+ try {
+ for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
+ NetworkInterface intf = en.nextElement();
+ for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
+ InetAddress inetAddress = enumIpAddr.nextElement();
+ if (!inetAddress.isLoopbackAddress()) {
+ return inetAddress.getHostAddress().toString();
+ }
+ }
+ }
+ } catch (SocketException ex) {
+ Log.e(LOG_TAG, ex.toString());
+ }
+ return null;
+ }
+}


  • [ndt-dev] [ndt] r494 committed - Fill in client address., ndt, 08/15/2011

Archive powered by MHonArc 2.6.16.

Top of Page