summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-02-17 14:06:52 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-02-17 14:06:52 -0800
commit3ca6d6bbfe614312ad936bce9ab5805615103267 (patch)
tree1e3c9f1a2ea859ed4643d8979406ddea5cffe801 /packages
parent826fbd543d8b902e2934f793d5404252a493c47a (diff)
parent227bec49157bc496f7c9e8e8f63c12728a448922 (diff)
downloadframeworks_base-3ca6d6bbfe614312ad936bce9ab5805615103267.zip
frameworks_base-3ca6d6bbfe614312ad936bce9ab5805615103267.tar.gz
frameworks_base-3ca6d6bbfe614312ad936bce9ab5805615103267.tar.bz2
Merge "data activity reporting on wifi"
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 42868db..ef37b4e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -33,6 +33,11 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Binder;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Messenger;
import android.os.RemoteException;
import android.provider.Settings;
import android.provider.Telephony;
@@ -50,6 +55,7 @@ import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.EriInfo;
import com.android.server.am.BatteryStatsService;
+import com.android.internal.util.AsyncChannel;
import com.android.systemui.R;
@@ -82,6 +88,7 @@ public class NetworkController extends BroadcastReceiver {
// wifi
final WifiManager mWifiManager;
+ AsyncChannel mWifiChannel;
boolean mWifiEnabled, mWifiConnected;
int mWifiLevel;
String mWifiSsid;
@@ -140,6 +147,14 @@ public class NetworkController extends BroadcastReceiver {
// wifi
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ HandlerThread handlerThread = new HandlerThread("WifiServiceThread");
+ handlerThread.start();
+ Handler handler = new WifiHandler(handlerThread.getLooper());
+ mWifiChannel = new AsyncChannel();
+ Messenger wifiMessenger = mWifiManager.getMessenger();
+ if (wifiMessenger != null) {
+ mWifiChannel.connect(mContext, handler, wifiMessenger);
+ }
// broadcasts
IntentFilter filter = new IntentFilter();
@@ -584,6 +599,44 @@ public class NetworkController extends BroadcastReceiver {
// ===== Wifi ===================================================================
+ class WifiHandler extends Handler {
+
+ WifiHandler(Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED:
+ if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
+ mWifiChannel.sendMessage(Message.obtain(this,
+ AsyncChannel.CMD_CHANNEL_FULL_CONNECTION));
+ } else {
+ Slog.e(TAG, "Failed to connect to wifi");
+ }
+ break;
+ case WifiManager.DATA_ACTIVITY_NOTIFICATION:
+ int dataActivity = msg.arg1;
+ /* TODO: update icons based on data activity */
+ switch (dataActivity) {
+ case WifiManager.DATA_ACTIVITY_IN:
+ break;
+ case WifiManager.DATA_ACTIVITY_OUT:
+ break;
+ case WifiManager.DATA_ACTIVITY_INOUT:
+ break;
+ case WifiManager.DATA_ACTIVITY_NONE:
+ break;
+ }
+ break;
+ default:
+ //Ignore
+ break;
+ }
+ }
+ }
+
private void updateWifiState(Intent intent) {
final String action = intent.getAction();
if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {