diff options
author | Eric Shienbrood <> | 2009-03-24 18:13:20 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 18:13:20 -0700 |
commit | d4c5f8919b0522bcaab41a5863c313fec52d3a79 (patch) | |
tree | f1465254ddd3ab57865aa5e77ff24ecfe3e47ba5 /wifi/java/android/net | |
parent | 4a5c1a7e84a250eafe0e3a12d859c45747520d55 (diff) | |
download | frameworks_base-d4c5f8919b0522bcaab41a5863c313fec52d3a79.zip frameworks_base-d4c5f8919b0522bcaab41a5863c313fec52d3a79.tar.gz frameworks_base-d4c5f8919b0522bcaab41a5863c313fec52d3a79.tar.bz2 |
Automated import from //branches/donutburger/...@140679,140679
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index 452a8fa..f7a9677 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -30,6 +30,8 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.SystemProperties; import android.os.Looper; +import android.os.RemoteException; +import android.os.ServiceManager; import android.provider.Settings; import android.text.TextUtils; import android.util.EventLog; @@ -43,6 +45,7 @@ import android.content.ContentResolver; import android.content.Intent; import android.content.Context; import android.database.ContentObserver; +import com.android.internal.app.IBatteryStats; import java.util.List; import java.util.ArrayList; @@ -244,12 +247,12 @@ public class WifiStateTracker extends NetworkStateTracker { private static final int RUN_STATE_STOPPED = 4; private int mRunState; + private final IBatteryStats mBatteryStats; + private boolean mIsScanOnly; private BluetoothA2dp mBluetoothA2dp; - private boolean mBluetoothScanMode; - private String mInterfaceName; private static String LS = System.getProperty("line.separator"); @@ -316,6 +319,8 @@ public class WifiStateTracker extends NetworkStateTracker { "dhcp." + mInterfaceName + ".dns1", "dhcp." + mInterfaceName + ".dns2" }; + mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo")); + } /** @@ -501,7 +506,7 @@ public class WifiStateTracker extends NetworkStateTracker { * Send the tracker a notification that the Wi-Fi driver has been stopped. */ void notifyDriverStopped() { - mRunState = RUN_STATE_STOPPED; + mRunState = RUN_STATE_STOPPED; // Send a driver stopped message to our handler Message.obtain(this, EVENT_DRIVER_STATE_CHANGED, 0, 0).sendToTarget(); @@ -530,6 +535,17 @@ public class WifiStateTracker extends NetworkStateTracker { return mRunState == RUN_STATE_STOPPED || mRunState == RUN_STATE_STOPPING; } + private void noteRunState() { + try { + if (mRunState == RUN_STATE_RUNNING) { + mBatteryStats.noteWifiRunning(); + } else if (mRunState == RUN_STATE_STOPPED) { + mBatteryStats.noteWifiStopped(); + } + } catch (RemoteException ignore) { + } + } + /** * Set the number of allowed radio frequency channels from the system * setting value, if any. @@ -654,6 +670,7 @@ public class WifiStateTracker extends NetworkStateTracker { switch (msg.what) { case EVENT_SUPPLICANT_CONNECTION: mRunState = RUN_STATE_RUNNING; + noteRunState(); checkUseStaticIp(); /* * DHCP requests are blocking, so run them in a separate thread. @@ -721,6 +738,8 @@ public class WifiStateTracker extends NetworkStateTracker { break; case EVENT_SUPPLICANT_DISCONNECT: + mRunState = RUN_STATE_STOPPED; + noteRunState(); int wifiState = mWM.getWifiState(); boolean died = wifiState != WifiManager.WIFI_STATE_DISABLED && wifiState != WifiManager.WIFI_STATE_DISABLING; @@ -1079,6 +1098,7 @@ public class WifiStateTracker extends NetworkStateTracker { } } } + noteRunState(); break; case EVENT_PASSWORD_KEY_MAY_BE_INCORRECT: |