frameworks/base
修訂 | f333b9570432d7b847364a145cb36225b7cd07d1 (tree) |
---|---|
時間 | 2019-02-26 06:54:48 |
作者 | JP Sugarbroad <jpsugar@goog...> |
Commiter | JP Sugarbroad |
Revert "Adding SUPL NI Emergency Extension Time"
This reverts commit 1f6d71f856ee770ecc24df446bd3693e0de0fbe0.
@@ -17,7 +17,6 @@ | ||
17 | 17 | package com.android.internal.location; |
18 | 18 | |
19 | 19 | import java.io.UnsupportedEncodingException; |
20 | -import java.util.concurrent.TimeUnit; | |
21 | 20 | |
22 | 21 | import android.app.Notification; |
23 | 22 | import android.app.NotificationManager; |
@@ -28,7 +27,6 @@ import android.content.Intent; | ||
28 | 27 | import android.content.IntentFilter; |
29 | 28 | import android.location.LocationManager; |
30 | 29 | import android.location.INetInitiatedListener; |
31 | -import android.os.SystemClock; | |
32 | 30 | import android.telephony.TelephonyManager; |
33 | 31 | import android.telephony.PhoneNumberUtils; |
34 | 32 | import android.telephony.PhoneStateListener; |
@@ -51,7 +49,8 @@ public class GpsNetInitiatedHandler { | ||
51 | 49 | |
52 | 50 | private static final String TAG = "GpsNetInitiatedHandler"; |
53 | 51 | |
54 | - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); | |
52 | + private static final boolean DEBUG = true; | |
53 | + private static final boolean VERBOSE = false; | |
55 | 54 | |
56 | 55 | // NI verify activity for bringing up UI (not used yet) |
57 | 56 | public static final String ACTION_NI_VERIFY = "android.intent.action.NETWORK_INITIATED_VERIFY"; |
@@ -94,9 +93,6 @@ public class GpsNetInitiatedHandler { | ||
94 | 93 | public static final int GPS_ENC_SUPL_UCS2 = 3; |
95 | 94 | public static final int GPS_ENC_UNKNOWN = -1; |
96 | 95 | |
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 | - | |
100 | 96 | private final Context mContext; |
101 | 97 | private final TelephonyManager mTelephonyManager; |
102 | 98 | private final PhoneStateListener mPhoneStateListener; |
@@ -112,7 +108,7 @@ public class GpsNetInitiatedHandler { | ||
112 | 108 | private volatile boolean mIsSuplEsEnabled; |
113 | 109 | |
114 | 110 | // Set to true if the phone is having emergency call. |
115 | - private volatile boolean mIsInEmergencyCall; | |
111 | + private volatile boolean mIsInEmergency; | |
116 | 112 | |
117 | 113 | // If Location function is enabled. |
118 | 114 | private volatile boolean mIsLocationEnabled = false; |
@@ -122,10 +118,6 @@ public class GpsNetInitiatedHandler { | ||
122 | 118 | // Set to true if string from HAL is encoded as Hex, e.g., "3F0039" |
123 | 119 | static private boolean mIsHexInput = true; |
124 | 120 | |
125 | - // End time of emergency call, and extension, if set | |
126 | - private long mCallEndElapsedRealtimeMillis = 0; | |
127 | - private long mEmergencyExtensionMillis = 0; | |
128 | - | |
129 | 121 | public static class GpsNiNotification |
130 | 122 | { |
131 | 123 | public int notificationId; |
@@ -156,12 +148,16 @@ public class GpsNetInitiatedHandler { | ||
156 | 148 | if (action.equals(Intent.ACTION_NEW_OUTGOING_CALL)) { |
157 | 149 | String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); |
158 | 150 | /* |
159 | - Tracks the emergency call: | |
160 | - mIsInEmergencyCall records if the phone is in emergency call or not. It will | |
151 | + Emergency Mode is when during emergency call or in emergency call back mode. | |
152 | + For checking if it is during emergency call: | |
153 | + mIsInEmergency records if the phone is in emergency call or not. It will | |
161 | 154 | be set to true when the phone is having emergency call, and then will |
162 | 155 | be set to false by mPhoneStateListener when the emergency call ends. |
156 | + For checking if it is in emergency call back mode: | |
157 | + Emergency call back mode will be checked by reading system properties | |
158 | + when necessary: SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE) | |
163 | 159 | */ |
164 | - mIsInEmergencyCall = PhoneNumberUtils.isEmergencyNumber(phoneNumber); | |
160 | + setInEmergency(PhoneNumberUtils.isEmergencyNumber(phoneNumber)); | |
165 | 161 | if (DEBUG) Log.v(TAG, "ACTION_NEW_OUTGOING_CALL - " + getInEmergency()); |
166 | 162 | } else if (action.equals(LocationManager.MODE_CHANGED_ACTION)) { |
167 | 163 | updateLocationMode(); |
@@ -201,10 +197,7 @@ public class GpsNetInitiatedHandler { | ||
201 | 197 | if (DEBUG) Log.d(TAG, "onCallStateChanged(): state is "+ state); |
202 | 198 | // listening for emergency call ends |
203 | 199 | if (state == TelephonyManager.CALL_STATE_IDLE) { |
204 | - if (mIsInEmergencyCall) { | |
205 | - mCallEndElapsedRealtimeMillis = SystemClock.elapsedRealtime(); | |
206 | - mIsInEmergencyCall = false; | |
207 | - } | |
200 | + setInEmergency(false); | |
208 | 201 | } |
209 | 202 | } |
210 | 203 | }; |
@@ -238,36 +231,23 @@ public class GpsNetInitiatedHandler { | ||
238 | 231 | return mIsLocationEnabled; |
239 | 232 | } |
240 | 233 | |
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 | - */ | |
234 | + // Note: Currently, there are two mechanisms involved to determine if a | |
235 | + // phone is in emergency mode: | |
236 | + // 1. If the user is making an emergency call, this is provided by activly | |
237 | + // monitoring the outgoing phone number; | |
238 | + // 2. If the device is in a emergency callback state, this is provided by | |
239 | + // system properties. | |
240 | + // If either one of above exists, the phone is considered in an emergency | |
241 | + // mode. Because of this complexity, we need to be careful about how to set | |
242 | + // and clear the emergency state. | |
243 | + public void setInEmergency(boolean isInEmergency) { | |
244 | + mIsInEmergency = isInEmergency; | |
245 | + } | |
246 | + | |
251 | 247 | public boolean getInEmergency() { |
252 | - boolean isInEmergencyExtension = | |
253 | - (SystemClock.elapsedRealtime() - mCallEndElapsedRealtimeMillis) < | |
254 | - mEmergencyExtensionMillis; | |
255 | 248 | boolean isInEmergencyCallback = Boolean.parseBoolean( |
256 | 249 | SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE)); |
257 | - return mIsInEmergencyCall || isInEmergencyCallback || isInEmergencyExtension; | |
258 | - } | |
259 | - | |
260 | - public void setEmergencyExtensionSeconds(int emergencyExtensionSeconds) { | |
261 | - if (emergencyExtensionSeconds > MAX_EMERGENCY_MODE_EXTENSION_SECONDS) { | |
262 | - Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds | |
263 | - + " too high, reset to " + MAX_EMERGENCY_MODE_EXTENSION_SECONDS); | |
264 | - emergencyExtensionSeconds = MAX_EMERGENCY_MODE_EXTENSION_SECONDS; | |
265 | - } else if (emergencyExtensionSeconds < 0) { | |
266 | - Log.w(TAG, "emergencyExtensionSeconds " + emergencyExtensionSeconds | |
267 | - + " is negative, reset to zero."); | |
268 | - emergencyExtensionSeconds = 0; | |
269 | - } | |
270 | - mEmergencyExtensionMillis = TimeUnit.SECONDS.toMillis(emergencyExtensionSeconds); | |
250 | + return mIsInEmergency || isInEmergencyCallback; | |
271 | 251 | } |
272 | 252 | |
273 | 253 |
@@ -675,17 +675,6 @@ public class GnssLocationProvider implements LocationProviderInterface { | ||
675 | 675 | Log.e(TAG, "unable to parse SUPL_ES: " + suplESProperty); |
676 | 676 | } |
677 | 677 | } |
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 | - } | |
689 | 678 | } |
690 | 679 | |
691 | 680 | private void loadPropertiesFromResource(Context context, |