summaryrefslogtreecommitdiffstats
path: root/apps/Development/src/com/android
diff options
context:
space:
mode:
authorPierre Vandwalle <vandwalle@google.com>2015-03-24 19:32:01 -0700
committerPierre Vandwalle <vandwalle@google.com>2015-03-24 19:40:32 -0700
commitc84e7b11e598d5a6c07c754755382279e194efcb (patch)
treea05c6370fbaaf0853a0af8f5c02188370c235807 /apps/Development/src/com/android
parentd8f9b78016ab99dd4edd3f74d89933c02ef8a3bf (diff)
downloadandroid_development-c84e7b11e598d5a6c07c754755382279e194efcb.tar.gz
android_development-c84e7b11e598d5a6c07c754755382279e194efcb.tar.bz2
android_development-c84e7b11e598d5a6c07c754755382279e194efcb.zip
add wifi power calculation
Change-Id: I3176d835454b1324403b844d075709ba277a7189
Diffstat (limited to 'apps/Development/src/com/android')
-rw-r--r--apps/Development/src/com/android/development/Connectivity.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/apps/Development/src/com/android/development/Connectivity.java b/apps/Development/src/com/android/development/Connectivity.java
index a576eb397..5ff72add9 100644
--- a/apps/Development/src/com/android/development/Connectivity.java
+++ b/apps/Development/src/com/android/development/Connectivity.java
@@ -33,6 +33,7 @@ import android.net.Network;
import android.net.NetworkUtils;
import android.net.RouteInfo;
import android.net.wifi.ScanResult;
+import android.net.wifi.WifiActivityEnergyInfo;
import android.net.wifi.WifiManager;
import android.os.RemoteException;
import android.os.Handler;
@@ -119,6 +120,8 @@ public class Connectivity extends Activity {
private long mTotalScanTime = 0;
private long mTotalScanCount = 0;
+ private TextView mLinkStatsResults;
+
private String mTdlsAddr = null;
private WifiManager mWm;
@@ -316,8 +319,12 @@ public class Connectivity extends Activity {
findViewById(R.id.routed_socket_request).setOnClickListener(mClickListener);
findViewById(R.id.default_request).setOnClickListener(mClickListener);
findViewById(R.id.default_socket).setOnClickListener(mClickListener);
+ findViewById(R.id.link_stats).setOnClickListener(mClickListener);
registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
+
+ mLinkStatsResults = (TextView)findViewById(R.id.stats);
+ mLinkStatsResults.setVisibility(View.VISIBLE);
}
@Override
@@ -408,6 +415,9 @@ public class Connectivity extends Activity {
mCm.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
Phone.FEATURE_ENABLE_HIPRI);
break;
+ case R.id.link_stats:
+ onLinkStats();
+ break;
}
}
};
@@ -544,6 +554,22 @@ public class Connectivity extends Activity {
}
}
+ private void onLinkStats() {
+ Log.e(TAG, "LINK STATS: ");
+ try {
+ WifiActivityEnergyInfo info =
+ mWm.getControllerActivityEnergyInfo(0);
+ if (info != null) {
+ mLinkStatsResults.setText(" power " + info.toString());
+ } else {
+ mLinkStatsResults.setText(" null! ");
+ }
+ } catch (Exception e) {
+ mLinkStatsResults.setText(" failed! " + e.toString());
+ }
+ }
+
+
private void onAddDefaultRoute() {
try {
int netId = Integer.valueOf(((TextView) findViewById(R.id.netid)).getText().toString());