Mobile_radio in battery history is not accurate

Invoke TelephonyManager#listen to connect mPhoneStateListener to receive
the notifications.

Bug: 15568103
Change-Id: I5a3fa6347704e96ceb34289f74ba6e3157bbb333
This commit is contained in:
Wink Saville
2014-06-18 16:43:14 -07:00
parent d09692de9c
commit 67e0789cd3
2 changed files with 11 additions and 2 deletions

View File

@@ -202,6 +202,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framew
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes/android/app/maintenance)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes/android/app/maintenance)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/app/maintenance)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/services_intermediates)
# ******************************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST ABOVE THIS BANNER

View File

@@ -63,6 +63,7 @@ import android.os.SystemProperties;
import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Slog;
import android.util.SparseBooleanArray;
@@ -240,15 +241,22 @@ public class NetworkManagementService extends INetworkManagementService.Stub
mThread = new Thread(mConnector, NETD_TAG);
mDaemonHandler = new Handler(FgThread.get().getLooper());
mPhoneStateListener = new PhoneStateListener(
SubscriptionManager.DEFAULT_SUB_ID, // FIXME: What Subscription should be used??
mPhoneStateListener = new PhoneStateListener(SubscriptionManager.DEFAULT_SUB_ID,
mDaemonHandler.getLooper()) {
@Override
public void onDataConnectionRealTimeInfoChanged(
DataConnectionRealTimeInfo dcRtInfo) {
if (DBG) Slog.d(TAG, "onDataConnectionRealTimeInfoChanged: " + dcRtInfo);
notifyInterfaceClassActivity(ConnectivityManager.TYPE_MOBILE,
dcRtInfo.getDcPowerState(), dcRtInfo.getTime(), true);
}
};
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null) {
tm.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO);
}
// Add ourself to the Watchdog monitors.
Watchdog.getInstance().addMonitor(this);