Adding SUPL NI Emergency Extension Time
Configurable by carrier config.xml resource Bug: 118839234 Bug: 115361555 Bug: 112159033 Test: On device, see b/115361555#comment14 Change-Id: I52e61656cca8b6fa6468d32d2e69bf60f4c83c61 Merged-In: I52e61656cca8b6fa6468d32d2e69bf60f4c83c61
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.internal.location;
|
package com.android.internal.location;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
@@ -27,6 +28,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.location.INetInitiatedListener;
|
import android.location.INetInitiatedListener;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
@@ -50,8 +52,7 @@ public class GpsNetInitiatedHandler {
|
|||||||
|
|
||||||
private static final String TAG = "GpsNetInitiatedHandler";
|
private static final String TAG = "GpsNetInitiatedHandler";
|
||||||
|
|
||||||
private static final boolean DEBUG = true;
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
private static final boolean VERBOSE = false;
|
|
||||||
|
|
||||||
// NI verify activity for bringing up UI (not used yet)
|
// NI verify activity for bringing up UI (not used yet)
|
||||||
public static final String ACTION_NI_VERIFY = "android.intent.action.NETWORK_INITIATED_VERIFY";
|
public static final String ACTION_NI_VERIFY = "android.intent.action.NETWORK_INITIATED_VERIFY";
|
||||||
@@ -94,6 +95,9 @@ public class GpsNetInitiatedHandler {
|
|||||||
public static final int GPS_ENC_SUPL_UCS2 = 3;
|
public static final int GPS_ENC_SUPL_UCS2 = 3;
|
||||||
public static final int GPS_ENC_UNKNOWN = -1;
|
public static final int GPS_ENC_UNKNOWN = -1;
|
||||||
|
|
||||||
|
// Limit on SUPL NI emergency mode time extension after emergency sessions ends
|
||||||
|
private static final int MAX_EMERGENCY_MODE_EXTENSION_SECONDS = 300; // 5 minute maximum
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final TelephonyManager mTelephonyManager;
|
private final TelephonyManager mTelephonyManager;
|
||||||
private final PhoneStateListener mPhoneStateListener;
|
private final PhoneStateListener mPhoneStateListener;
|
||||||
@@ -109,7 +113,7 @@ public class GpsNetInitiatedHandler {
|
|||||||
private volatile boolean mIsSuplEsEnabled;
|
private volatile boolean mIsSuplEsEnabled;
|
||||||
|
|
||||||
// Set to true if the phone is having emergency call.
|
// Set to true if the phone is having emergency call.
|
||||||
private volatile boolean mIsInEmergency;
|
private volatile boolean mIsInEmergencyCall;
|
||||||
|
|
||||||
// If Location function is enabled.
|
// If Location function is enabled.
|
||||||
private volatile boolean mIsLocationEnabled = false;
|
private volatile boolean mIsLocationEnabled = false;
|
||||||
@@ -119,6 +123,10 @@ public class GpsNetInitiatedHandler {
|
|||||||
// Set to true if string from HAL is encoded as Hex, e.g., "3F0039"
|
// Set to true if string from HAL is encoded as Hex, e.g., "3F0039"
|
||||||
static private boolean mIsHexInput = true;
|
static private boolean mIsHexInput = true;
|
||||||
|
|
||||||
|
// End time of emergency call, and extension, if set
|
||||||
|
private long mCallEndElapsedRealtimeMillis = 0;
|
||||||
|
private long mEmergencyExtensionMillis = 0;
|
||||||
|
|
||||||
public static class GpsNiNotification
|
public static class GpsNiNotification
|
||||||
{
|
{
|
||||||
public int notificationId;
|
public int notificationId;
|
||||||
@@ -146,16 +154,12 @@ public class GpsNetInitiatedHandler {
|
|||||||
if (action.equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
|
if (action.equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
|
||||||
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
|
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
|
||||||
/*
|
/*
|
||||||
Emergency Mode is when during emergency call or in emergency call back mode.
|
Tracks the emergency call:
|
||||||
For checking if it is during emergency call:
|
mIsInEmergencyCall records if the phone is in emergency call or not. It will
|
||||||
mIsInEmergency records if the phone is in emergency call or not. It will
|
|
||||||
be set to true when the phone is having emergency call, and then will
|
be set to true when the phone is having emergency call, and then will
|
||||||
be set to false by mPhoneStateListener when the emergency call ends.
|
be set to false by mPhoneStateListener when the emergency call ends.
|
||||||
For checking if it is in emergency call back mode:
|
|
||||||
Emergency call back mode will be checked by reading system properties
|
|
||||||
when necessary: SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)
|
|
||||||
*/
|
*/
|
||||||
setInEmergency(PhoneNumberUtils.isEmergencyNumber(phoneNumber));
|
mIsInEmergencyCall = PhoneNumberUtils.isEmergencyNumber(phoneNumber);
|
||||||
if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency());
|
if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency());
|
||||||
} else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) {
|
} else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) {
|
||||||
updateLocationMode();
|
updateLocationMode();
|
||||||
@@ -195,7 +199,10 @@ public class GpsNetInitiatedHandler {
|
|||||||
if (DEBUG) Log.d(TAG, "onCallStateChanged(): state is "+ state);
|
if (DEBUG) Log.d(TAG, "onCallStateChanged(): state is "+ state);
|
||||||
// listening for emergency call ends
|
// listening for emergency call ends
|
||||||
if (state == TelephonyManager.CALL_STATE_IDLE) {
|
if (state == TelephonyManager.CALL_STATE_IDLE) {
|
||||||
setInEmergency(false);
|
if (mIsInEmergencyCall) {
|
||||||
|
mCallEndElapsedRealtimeMillis = SystemClock.elapsedRealtime();
|
||||||
|
mIsInEmergencyCall = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -229,22 +236,35 @@ public class GpsNetInitiatedHandler {
|
|||||||
return mIsLocationEnabled;
|
return mIsLocationEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Currently, there are two mechanisms involved to determine if a
|
/**
|
||||||
// phone is in emergency mode:
|
* Determines whether device is in user-initiated emergency session based on the following
|
||||||
// 1. If the user is making an emergency call, this is provided by activly
|
* 1. If the user is making an emergency call, this is provided by actively
|
||||||
// monitoring the outgoing phone number;
|
* monitoring the outgoing phone number;
|
||||||
// 2. If the device is in a emergency callback state, this is provided by
|
* 2. If the user has recently ended an emergency call, and the device is in a configured time
|
||||||
// system properties.
|
* window after the end of that call.
|
||||||
// If either one of above exists, the phone is considered in an emergency
|
* 3. If the device is in a emergency callback state, this is provided by querying
|
||||||
// mode. Because of this complexity, we need to be careful about how to set
|
* TelephonyManager.
|
||||||
// and clear the emergency state.
|
* @return true if is considered in user initiated emergency mode for NI purposes
|
||||||
public void setInEmergency(boolean isInEmergency) {
|
*/
|
||||||
mIsInEmergency = isInEmergency;
|
public boolean getInEmergency() {
|
||||||
|
boolean isInEmergencyExtension =
|
||||||
|
(SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis) <
|
||||||
|
mEmergencyExtensionMillis;
|
||||||
|
boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode();
|
||||||
|
return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getInEmergency() {
|
public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) {
|
||||||
boolean isInEmergencyCallback = mTelephonyManager.getEmergencyCallbackMode();
|
if (emergencyExtensionSeconds > MAX_EMERGENCY_MODE_EXTENSION_SECONDS) {
|
||||||
return mIsInEmergency || isInEmergencyCallback;
|
Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds
|
||||||
|
+ " too high, reset to " + MAX_EMERGENCY_MODE_EXTENSION_SECONDS);
|
||||||
|
emergencyExtensionSeconds = MAX_EMERGENCY_MODE_EXTENSION_SECONDS;
|
||||||
|
} else if (emergencyExtensionSeconds < 0) {
|
||||||
|
Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds
|
||||||
|
+ " is negative, reset to zero.");
|
||||||
|
emergencyExtensionSeconds = 0;
|
||||||
|
}
|
||||||
|
mEmergencyExtensionMillis = TimeUnit.SECONDS.toMillis(emergencyExtensionSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -638,6 +638,17 @@ public class GnssLocationProvider implements LocationProviderInterface {
|
|||||||
Log.e(TAG, "unable to parse SUPL_ES: " + suplESProperty);
|
Log.e(TAG, "unable to parse SUPL_ES: " + suplESProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String emergencyExtensionSecondsString
|
||||||
|
= properties.getProperty("ES_EXTENSION_SEC", "0");
|
||||||
|
try {
|
||||||
|
int emergencyExtensionSeconds =
|
||||||
|
Integer.parseInt(emergencyExtensionSecondsString);
|
||||||
|
mNIHandler.setEmergencyExtensionSeconds(emergencyExtensionSeconds);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, "unable to parse ES_EXTENSION_SEC: "
|
||||||
|
+ emergencyExtensionSecondsString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPropertiesFromResource(Context context,
|
private void loadPropertiesFromResource(Context context,
|
||||||
|
|||||||
Reference in New Issue
Block a user