• 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évision79f540388df8207c31a3aed9333bd68b08e32db9 (tree)
l'heure2019-06-06 21:52:19
AuteurWyattRiley <wyattriley@goog...>
CommiterKevin F. Haggerty

Message de Log

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
(cherry picked from commit a725dd6650846090f70ed9811f1a94f036ab3f29)

Change Summary

Modification

--- a/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
+++ b/location/java/com/android/internal/location/GpsNetInitiatedHandler.java
@@ -16,6 +16,9 @@
1616
1717 package com.android.internal.location;
1818
19+import java.io.UnsupportedEncodingException;
20+import java.util.concurrent.TimeUnit;
21+
1922 import android.app.Notification;
2023 import android.app.NotificationManager;
2124 import android.app.PendingIntent;
@@ -23,20 +26,21 @@ import android.content.BroadcastReceiver;
2326 import android.content.Context;
2427 import android.content.Intent;
2528 import android.content.IntentFilter;
26-import android.location.INetInitiatedListener;
2729 import android.location.LocationManager;
30+import android.location.INetInitiatedListener;
31+import android.os.SystemClock;
32+import android.telephony.TelephonyManager;
33+import android.telephony.PhoneNumberUtils;
34+import android.telephony.PhoneStateListener;
2835 import android.os.Bundle;
2936 import android.os.RemoteException;
30-import android.os.SystemProperties;
3137 import android.os.UserHandle;
32-import android.telephony.PhoneNumberUtils;
33-import android.telephony.PhoneStateListener;
34-import android.telephony.TelephonyManager;
38+import android.os.SystemProperties;
3539 import android.util.Log;
40+
3641 import com.android.internal.R;
3742 import com.android.internal.telephony.GsmAlphabet;
3843 import com.android.internal.telephony.TelephonyProperties;
39-import java.io.UnsupportedEncodingException;
4044
4145 /**
4246 * A GPS Network-initiated Handler class used by LocationManager.
@@ -47,8 +51,7 @@ public class GpsNetInitiatedHandler {
4751
4852 private static final String TAG = "GpsNetInitiatedHandler";
4953
50- private static final boolean DEBUG = true;
51- private static final boolean VERBOSE = false;
54+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
5255
5356 // NI verify activity for bringing up UI (not used yet)
5457 public static final String ACTION_NI_VERIFY = "android.intent.action.NETWORK_INITIATED_VERIFY";
@@ -91,6 +94,9 @@ public class GpsNetInitiatedHandler {
9194 public static final int GPS_ENC_SUPL_UCS2 = 3;
9295 public static final int GPS_ENC_UNKNOWN = -1;
9396
97+ // Limit on SUPL NI emergency mode time extension after emergency sessions ends
98+ private static final int MAX_EMERGENCY_MODE_EXTENSION_SECONDS = 300; // 5 minute maximum
99+
94100 private final Context mContext;
95101 private final TelephonyManager mTelephonyManager;
96102 private final PhoneStateListener mPhoneStateListener;
@@ -106,7 +112,7 @@ public class GpsNetInitiatedHandler {
106112 private volatile boolean mIsSuplEsEnabled;
107113
108114 // Set to true if the phone is having emergency call.
109- private volatile boolean mIsInEmergency;
115+ private volatile boolean mIsInEmergencyCall;
110116
111117 // If Location function is enabled.
112118 private volatile boolean mIsLocationEnabled = false;
@@ -116,6 +122,10 @@ public class GpsNetInitiatedHandler {
116122 // Set to true if string from HAL is encoded as Hex, e.g., "3F0039"
117123 static private boolean mIsHexInput = true;
118124
125+ // End time of emergency call, and extension, if set
126+ private volatile long mCallEndElapsedRealtimeMillis = 0;
127+ private volatile long mEmergencyExtensionMillis = 0;
128+
119129 public static class GpsNiNotification
120130 {
121131 public int notificationId;
@@ -146,16 +156,12 @@ public class GpsNetInitiatedHandler {
146156 if (action.equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
147157 String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
148158 /*
149- Emergency Mode is when during emergency call or in emergency call back mode.
150- For checking if it is during emergency call:
151- mIsInEmergency records if the phone is in emergency call or not. It will
159+ Tracks the emergency call:
160+ mIsInEmergencyCall records if the phone is in emergency call or not. It will
152161 be set to true when the phone is having emergency call, and then will
153162 be set to false by mPhoneStateListener when the emergency call ends.
154- For checking if it is in emergency call back mode:
155- Emergency call back mode will be checked by reading system properties
156- when necessary: SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)
157163 */
158- setInEmergency(PhoneNumberUtils.isEmergencyNumber(phoneNumber));
164+ mIsInEmergencyCall = PhoneNumberUtils.isEmergencyNumber(phoneNumber);
159165 if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency());
160166 } else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) {
161167 updateLocationMode();
@@ -195,7 +201,10 @@ public class GpsNetInitiatedHandler {
195201 if (DEBUG) Log.d(TAG, "onCallStateChanged(): state is "+ state);
196202 // listening for emergency call ends
197203 if (state == TelephonyManager.CALL_STATE_IDLE) {
198- setInEmergency(false);
204+ if (mIsInEmergencyCall) {
205+ mCallEndElapsedRealtimeMillis = SystemClock.elapsedRealtime();
206+ mIsInEmergencyCall = false;
207+ }
199208 }
200209 }
201210 };
@@ -229,23 +238,37 @@ public class GpsNetInitiatedHandler {
229238 return mIsLocationEnabled;
230239 }
231240
232- // Note: Currently, there are two mechanisms involved to determine if a
233- // phone is in emergency mode:
234- // 1. If the user is making an emergency call, this is provided by activly
235- // monitoring the outgoing phone number;
236- // 2. If the device is in a emergency callback state, this is provided by
237- // system properties.
238- // If either one of above exists, the phone is considered in an emergency
239- // mode. Because of this complexity, we need to be careful about how to set
240- // and clear the emergency state.
241- public void setInEmergency(boolean isInEmergency) {
242- mIsInEmergency = isInEmergency;
243- }
244-
241+ /**
242+ * Determines whether device is in user-initiated emergency session based on the following
243+ * 1. If the user is making an emergency call, this is provided by actively
244+ * monitoring the outgoing phone number;
245+ * 2. If the user has recently ended an emergency call, and the device is in a configured time
246+ * window after the end of that call.
247+ * 3. If the device is in a emergency callback state, this is provided by querying
248+ * TelephonyManager.
249+ * @return true if is considered in user initiated emergency mode for NI purposes
250+ */
245251 public boolean getInEmergency() {
252+ boolean isInEmergencyExtension =
253+ (mCallEndElapsedRealtimeMillis > 0)
254+ && ((SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis)
255+ < mEmergencyExtensionMillis);
246256 boolean isInEmergencyCallback = Boolean.parseBoolean(
247257 SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE));
248- return mIsInEmergency || isInEmergencyCallback;
258+ return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension;
259+ }
260+
261+ public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) {
262+ if (emergencyExtensionSeconds > MAX_EMERGENCY_MODE_EXTENSION_SECONDS) {
263+ Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds
264+ + " too high, reset to " + MAX_EMERGENCY_MODE_EXTENSION_SECONDS);
265+ emergencyExtensionSeconds = MAX_EMERGENCY_MODE_EXTENSION_SECONDS;
266+ } else if (emergencyExtensionSeconds < 0) {
267+ Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds
268+ + " is negative, reset to zero.");
269+ emergencyExtensionSeconds = 0;
270+ }
271+ mEmergencyExtensionMillis = TimeUnit.SECONDS.toMillis(emergencyExtensionSeconds);
249272 }
250273
251274
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -675,6 +675,17 @@ public class GnssLocationProvider implements LocationProviderInterface {
675675 Log.e(TAG, "unable to parse SUPL_ES: " + suplESProperty);
676676 }
677677 }
678+
679+ String emergencyExtensionSecondsString
680+ = properties.getProperty("ES_EXTENSION_SEC", "0");
681+ try {
682+ int emergencyExtensionSeconds =
683+ Integer.parseInt(emergencyExtensionSecondsString);
684+ mNIHandler.setEmergencyExtensionSeconds(emergencyExtensionSeconds);
685+ } catch (NumberFormatException e) {
686+ Log.e(TAG, "unable to parse ES_EXTENSION_SEC: "
687+ + emergencyExtensionSecondsString);
688+ }
678689 }
679690
680691 private void loadPropertiesFromResource(Context context,