summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2016-04-26 14:28:29 -0700
committerStephen Bird <sbird@cyngn.com>2016-04-26 16:51:59 -0700
commitf6713d2a2f739d8c4e1ea538cd519d1fa6ea16e2 (patch)
tree63dcfabaea595ed4844b40ed3cc5a0fdefc9d6bb
parentbf43c1ffec4087c201b629fdfeafa0a8c32e1570 (diff)
downloadandroid_packages_apps_Dialer-f6713d2a2f739d8c4e1ea538cd519d1fa6ea16e2.tar.gz
android_packages_apps_Dialer-f6713d2a2f739d8c4e1ea538cd519d1fa6ea16e2.tar.bz2
android_packages_apps_Dialer-f6713d2a2f739d8c4e1ea538cd519d1fa6ea16e2.zip
WifiNudge: Use PreciseCallState to only show on outgoing calls
We don't want incoming calls to nudge Ticket: CD-583 Change-Id: Ic7f821c7d35f8dd95a1d945f62787ec89cf2d2c8
-rw-r--r--AndroidManifest_cm.xml1
-rw-r--r--src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java37
2 files changed, 24 insertions, 14 deletions
diff --git a/AndroidManifest_cm.xml b/AndroidManifest_cm.xml
index 737d6e046..9b9b0bd1e 100644
--- a/AndroidManifest_cm.xml
+++ b/AndroidManifest_cm.xml
@@ -26,6 +26,7 @@
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
+ <uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
<application>
diff --git a/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java b/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java
index 6508f4e67..696110114 100644
--- a/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java
+++ b/src/com/android/dialer/discovery/WifiCallStatusNudgeListener.java
@@ -11,6 +11,7 @@ import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Message;
import android.telephony.PhoneStateListener;
+import android.telephony.PreciseCallState;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.dialer.DialtactsActivity;
@@ -29,8 +30,8 @@ public class WifiCallStatusNudgeListener {
private final static AtomicBoolean mReceiverRegistered = new AtomicBoolean(false);
private final static int WIFI_STATE_DISABLED = 0;
- private final static int CALL_STATE_IDLE = 1;
- private final static int CALL_STATE_OFFHOOK = 2;
+ private final static int PRECISE_CALL_STATE_IDLE = 1;
+ private final static int PRECISE_CALL_STATE_DIALING = 2;
private static Context mContext;
@@ -52,7 +53,8 @@ public class WifiCallStatusNudgeListener {
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
- case CALL_STATE_OFFHOOK:
+ case PRECISE_CALL_STATE_DIALING:
+
ConnectivityManager connManager = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi
@@ -66,7 +68,7 @@ public class WifiCallStatusNudgeListener {
callOnWifiFailure();
}
break;
- case CALL_STATE_IDLE:
+ case PRECISE_CALL_STATE_IDLE:
synchronized (mReceiverRegistered) {
if (mReceiverRegistered.get()) {
// We lasted the whole call
@@ -87,15 +89,22 @@ public class WifiCallStatusNudgeListener {
private static PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
- public void onCallStateChanged(int state, String incomingNumber) {
- super.onCallStateChanged(state, incomingNumber);
- if (state == TelephonyManager.CALL_STATE_IDLE) {
- Message phoneStateMessage
- = mPhoneWifiStateHandler.obtainMessage(CALL_STATE_IDLE);
- phoneStateMessage.sendToTarget();
- } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
- Message phoneStateMessage
- = mPhoneWifiStateHandler.obtainMessage(CALL_STATE_OFFHOOK);
+ public void onPreciseCallStateChanged(PreciseCallState callState) {
+ int ringingState = callState.getForegroundCallState();
+ if (DEBUG) Log.v(TAG, "ringing state: " + ringingState);
+ Message phoneStateMessage = null;
+ switch (ringingState) {
+ case PreciseCallState.PRECISE_CALL_STATE_DIALING:
+ phoneStateMessage
+ = mPhoneWifiStateHandler.obtainMessage(PRECISE_CALL_STATE_DIALING);
+ break;
+ case PreciseCallState.PRECISE_CALL_STATE_IDLE:
+ case PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED:
+ phoneStateMessage
+ = mPhoneWifiStateHandler.obtainMessage(PRECISE_CALL_STATE_IDLE);
+ break;
+ }
+ if (phoneStateMessage != null) {
phoneStateMessage.sendToTarget();
}
}
@@ -107,7 +116,7 @@ public class WifiCallStatusNudgeListener {
TelephonyManager telephony
= (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
- telephony.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
+ telephony.listen(mPhoneStateListener, PhoneStateListener.LISTEN_PRECISE_CALL_STATE);
}
private static void startReceiver() {