summaryrefslogtreecommitdiffstats
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
parentd8f9b78016ab99dd4edd3f74d89933c02ef8a3bf (diff)
downloadandroid_development-c84e7b11e598d5a6c07c754755382279e194efcb.tar.gz
android_development-c84e7b11e598d5a6c07c754755382279e194efcb.tar.bz2
android_development-c84e7b11e598d5a6c07c754755382279e194efcb.zip
add wifi power calculation
Change-Id: I3176d835454b1324403b844d075709ba277a7189
-rw-r--r--apps/Development/res/layout/connectivity.xml27
-rw-r--r--apps/Development/res/values/strings.xml2
-rw-r--r--apps/Development/src/com/android/development/Connectivity.java26
3 files changed, 55 insertions, 0 deletions
diff --git a/apps/Development/res/layout/connectivity.xml b/apps/Development/res/layout/connectivity.xml
index d23a6b1b9..00ba508bb 100644
--- a/apps/Development/res/layout/connectivity.xml
+++ b/apps/Development/res/layout/connectivity.xml
@@ -350,6 +350,33 @@
android:layout_height="wrap_content"
android:text="@string/routed_socket_request" />
</LinearLayout>
+
+ <!-- divider line -->
+ <View android:background="#FFFFFFFF"
+ android:layout_width="match_parent"
+ android:layout_height="3dip" />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:paddingTop="4dip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <Button android:id="@+id/link_stats"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/link_stats" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:id="@+id/stats"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/stats_results" />
+ </LinearLayout>
+
</LinearLayout>
</ScrollView>
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index d670cf4c4..3ef88458e 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -33,6 +33,8 @@
<string name="start_scan">Start Scan</string>
<string name="scan_cycles">Scan Cycles: </string>
<string name="disconnect">Disconnect</string>
+ <string name="link_stats">Link Stats</string>
+ <string name="stats_results"> results </string>
<string name="start_tdls">Start TDLS</string>
<string name="stop_tdls">Stop TDLS</string>
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());