add wifi power calculation
Change-Id: I3176d835454b1324403b844d075709ba277a7189
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user