• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Révision2a452f756905f5640154b12db0884b1b6bd78e87 (tree)
l'heure2010-11-22 16:07:16
AuteurStephane Lajeunesse <stephane.lajeunesse@gmai...>
CommiterChih-Wei Huang

Message de Log

BatteryService: update battery status periodically

Change Summary

Modification

--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -35,6 +35,7 @@ import android.os.UEventObserver;
3535 import android.provider.Settings;
3636 import android.util.EventLog;
3737 import android.util.Slog;
38+import android.os.Handler;
3839
3940 import java.io.File;
4041 import java.io.FileDescriptor;
@@ -42,6 +43,8 @@ import java.io.FileInputStream;
4243 import java.io.FileOutputStream;
4344 import java.io.IOException;
4445 import java.io.PrintWriter;
46+import java.util.Timer;
47+import java.util.TimerTask;
4548
4649
4750 /**
@@ -119,6 +122,8 @@ class BatteryService extends Binder {
119122
120123 private boolean mSentLowBatteryBroadcast = false;
121124
125+ private final Handler mHandler = new Handler();
126+
122127 public BatteryService(Context context) {
123128 mContext = context;
124129 mBatteryStats = BatteryStatsService.getService();
@@ -132,6 +137,25 @@ class BatteryService extends Binder {
132137
133138 // set initial status
134139 update();
140+
141+ // start auto refresh
142+ autoRefresh();
143+ }
144+
145+ private Runnable mUpdateResults = new Runnable() {
146+ public void run() {
147+ update();
148+ }
149+ };
150+
151+ private final void autoRefresh() {
152+ // Schedule every minute
153+ new Timer().scheduleAtFixedRate(new TimerTask() {
154+ @Override // Override!!
155+ public void run() {
156+ mHandler.post(mUpdateResults);
157+ }
158+ }, 60000, 60000);
135159 }
136160
137161 final boolean isPowered() {