summaryrefslogtreecommitdiffstats
path: root/telephony/java/android/telephony/PhoneStateListener.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-04-21 15:56:18 -0700
committerDianne Hackborn <hackbod@google.com>2014-04-24 11:21:30 -0700
commit2ffa11e4b71c545e34533ef827bdc1a07fbe8246 (patch)
treeaf0aa233d8c90bc6ab18c79a0724132f71f9b40b /telephony/java/android/telephony/PhoneStateListener.java
parent79cb5505a97a0465fb849dc20dcaf3dd2f608c9f (diff)
downloadframeworks_base-2ffa11e4b71c545e34533ef827bdc1a07fbe8246.zip
frameworks_base-2ffa11e4b71c545e34533ef827bdc1a07fbe8246.tar.gz
frameworks_base-2ffa11e4b71c545e34533ef827bdc1a07fbe8246.tar.bz2
Start collecting mobile radio activity from the radio.
Hook in to the new radio API to find out when the radio is active and use that to track its state in batter stats. We also still have the data being tracked from the kernel's emulation, and continue to use that if we don't get data from the radio. Currently this monitoring is turned off until some issues in the radio can be fixed that are providing bad data. Also add a new API to get estimated drain and charge times. Change-Id: Ifc4900fabb8f848f9cda361dce698664ea75f175
Diffstat (limited to 'telephony/java/android/telephony/PhoneStateListener.java')
-rw-r--r--telephony/java/android/telephony/PhoneStateListener.java113
1 files changed, 61 insertions, 52 deletions
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index 7c5c648..59ec6f5 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -18,6 +18,7 @@ package android.telephony;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -199,7 +200,67 @@ public class PhoneStateListener {
*/
public static final int LISTEN_DATA_CONNECTION_REAL_TIME_INFO = 0x00002000;
+ private final Handler mHandler;
+
public PhoneStateListener() {
+ this(Looper.myLooper());
+ }
+
+ /** @hide */
+ public PhoneStateListener(Looper looper) {
+ mHandler = new Handler(looper) {
+ public void handleMessage(Message msg) {
+ //Rlog.d("TelephonyRegistry", "what=0x" + Integer.toHexString(msg.what)
+ // + " msg=" + msg);
+ switch (msg.what) {
+ case LISTEN_SERVICE_STATE:
+ PhoneStateListener.this.onServiceStateChanged((ServiceState)msg.obj);
+ break;
+ case LISTEN_SIGNAL_STRENGTH:
+ PhoneStateListener.this.onSignalStrengthChanged(msg.arg1);
+ break;
+ case LISTEN_MESSAGE_WAITING_INDICATOR:
+ PhoneStateListener.this.onMessageWaitingIndicatorChanged(msg.arg1 != 0);
+ break;
+ case LISTEN_CALL_FORWARDING_INDICATOR:
+ PhoneStateListener.this.onCallForwardingIndicatorChanged(msg.arg1 != 0);
+ break;
+ case LISTEN_CELL_LOCATION:
+ PhoneStateListener.this.onCellLocationChanged((CellLocation)msg.obj);
+ break;
+ case LISTEN_CALL_STATE:
+ PhoneStateListener.this.onCallStateChanged(msg.arg1, (String)msg.obj);
+ break;
+ case LISTEN_DATA_CONNECTION_STATE:
+ PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1, msg.arg2);
+ PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1);
+ break;
+ case LISTEN_DATA_ACTIVITY:
+ PhoneStateListener.this.onDataActivity(msg.arg1);
+ break;
+ case LISTEN_SIGNAL_STRENGTHS:
+ PhoneStateListener.this.onSignalStrengthsChanged((SignalStrength)msg.obj);
+ break;
+ case LISTEN_OTASP_CHANGED:
+ PhoneStateListener.this.onOtaspChanged(msg.arg1);
+ break;
+ case LISTEN_CELL_INFO:
+ PhoneStateListener.this.onCellInfoChanged((List<CellInfo>)msg.obj);
+ break;
+ case LISTEN_PRECISE_CALL_STATE:
+ PhoneStateListener.this.onPreciseCallStateChanged((PreciseCallState)msg.obj);
+ break;
+ case LISTEN_PRECISE_DATA_CONNECTION_STATE:
+ PhoneStateListener.this.onPreciseDataConnectionStateChanged(
+ (PreciseDataConnectionState)msg.obj);
+ break;
+ case LISTEN_DATA_CONNECTION_REAL_TIME_INFO:
+ PhoneStateListener.this.onDataConnectionRealTimeInfoChanged(
+ (DataConnectionRealTimeInfo)msg.obj);
+ break;
+ }
+ }
+ };
}
/**
@@ -424,56 +485,4 @@ public class PhoneStateListener {
dcRtInfo).sendToTarget();
}
};
-
- Handler mHandler = new Handler() {
- public void handleMessage(Message msg) {
- //Rlog.d("TelephonyRegistry", "what=0x" + Integer.toHexString(msg.what) + " msg=" + msg);
- switch (msg.what) {
- case LISTEN_SERVICE_STATE:
- PhoneStateListener.this.onServiceStateChanged((ServiceState)msg.obj);
- break;
- case LISTEN_SIGNAL_STRENGTH:
- PhoneStateListener.this.onSignalStrengthChanged(msg.arg1);
- break;
- case LISTEN_MESSAGE_WAITING_INDICATOR:
- PhoneStateListener.this.onMessageWaitingIndicatorChanged(msg.arg1 != 0);
- break;
- case LISTEN_CALL_FORWARDING_INDICATOR:
- PhoneStateListener.this.onCallForwardingIndicatorChanged(msg.arg1 != 0);
- break;
- case LISTEN_CELL_LOCATION:
- PhoneStateListener.this.onCellLocationChanged((CellLocation)msg.obj);
- break;
- case LISTEN_CALL_STATE:
- PhoneStateListener.this.onCallStateChanged(msg.arg1, (String)msg.obj);
- break;
- case LISTEN_DATA_CONNECTION_STATE:
- PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1, msg.arg2);
- PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1);
- break;
- case LISTEN_DATA_ACTIVITY:
- PhoneStateListener.this.onDataActivity(msg.arg1);
- break;
- case LISTEN_SIGNAL_STRENGTHS:
- PhoneStateListener.this.onSignalStrengthsChanged((SignalStrength)msg.obj);
- break;
- case LISTEN_OTASP_CHANGED:
- PhoneStateListener.this.onOtaspChanged(msg.arg1);
- break;
- case LISTEN_CELL_INFO:
- PhoneStateListener.this.onCellInfoChanged((List<CellInfo>)msg.obj);
- break;
- case LISTEN_PRECISE_CALL_STATE:
- PhoneStateListener.this.onPreciseCallStateChanged((PreciseCallState)msg.obj);
- break;
- case LISTEN_PRECISE_DATA_CONNECTION_STATE:
- PhoneStateListener.this.onPreciseDataConnectionStateChanged((PreciseDataConnectionState)msg.obj);
- break;
- case LISTEN_DATA_CONNECTION_REAL_TIME_INFO:
- PhoneStateListener.this.onDataConnectionRealTimeInfoChanged(
- (DataConnectionRealTimeInfo)msg.obj);
- break;
- }
- }
- };
}