Merge "Make non-framework emergency location notification configurable" into qt-dev

This commit is contained in:
Anil Admal
2019-05-10 21:21:36 +00:00
committed by Android (Google) Code Review
4 changed files with 45 additions and 7 deletions

View File

@@ -70,6 +70,7 @@ class GnssConfiguration {
private static final String CONFIG_GPS_LOCK = "GPS_LOCK";
private static final String CONFIG_ES_EXTENSION_SEC = "ES_EXTENSION_SEC";
public static final String CONFIG_NFW_PROXY_APPS = "NFW_PROXY_APPS";
public static final String CONFIG_ES_NOTIFY_INT = "ES_NOTIFY_INT";
// Limit on NI emergency mode time extension after emergency sessions ends
private static final int MAX_EMERGENCY_MODE_EXTENSION_SECONDS = 300; // 5 minute maximum
@@ -198,6 +199,14 @@ class GnssConfiguration {
return proxyApps;
}
/**
* Returns the value of config parameter ES_NOTIFY_INT or {@code defaulEsNotify} if no
* value is provided or if there is an error parsing the configured value.
*/
int getEsNotify(int defaulEsNotify) {
return getIntConfig(CONFIG_ES_NOTIFY_INT, defaulEsNotify);
}
/**
* Updates the GNSS HAL satellite blacklist.
*/
@@ -320,10 +329,12 @@ class GnssConfiguration {
.substring(CarrierConfigManager.Gps.KEY_PREFIX.length())
.toUpperCase();
Object value = configs.get(configKey);
if (DEBUG) Log.d(TAG, "Gps config: " + key + " = " + value);
if (value instanceof String) {
// All GPS properties are of String type; convert so.
if (DEBUG) Log.d(TAG, "Gps config: " + key + " = " + value);
// Most GPS properties are of String type; convert so.
mProperties.setProperty(key, (String) value);
} else if (value != null) {
mProperties.setProperty(key, value.toString());
}
}
}

View File

@@ -579,6 +579,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
mSuplEsEnabled = mGnssConfiguration.getSuplEs(0) == 1;
if (mGnssVisibilityControl != null) {
mGnssVisibilityControl.updateProxyApps(mGnssConfiguration.getProxyApps());
mGnssVisibilityControl.setEsNotify(mGnssConfiguration.getEsNotify(0));
}
}

View File

@@ -58,6 +58,11 @@ class GnssVisibilityControl {
// Max wait time for synchronous method onGpsEnabledChanged() to run.
private static final long ON_GPS_ENABLED_CHANGED_TIMEOUT_MILLIS = 3 * 1000;
// Valid values for config parameter es_notify_int for posting notification in the status
// bar for non-framework location requests in user-initiated emergency use cases.
private static final int ES_NOTIFY_NONE = 0;
private static final int ES_NOTIFY_ALL = 1;
// Wakelocks
private static final String WAKELOCK_KEY = TAG;
private static final long WAKELOCK_TIMEOUT_MILLIS = 60 * 1000;
@@ -71,6 +76,7 @@ class GnssVisibilityControl {
private final GpsNetInitiatedHandler mNiHandler;
private boolean mIsGpsEnabled;
private volatile boolean mEsNotify;
// Number of non-framework location access proxy apps is expected to be small (< 5).
private static final int ARRAY_MAP_INITIAL_CAPACITY_PROXY_APP_TO_LOCATION_PERMISSIONS = 7;
@@ -130,6 +136,17 @@ class GnssVisibilityControl {
requestor, requestorId, responseType, inEmergencyMode, isCachedLocation)));
}
void setEsNotify(int esNotifyConfig) {
if (esNotifyConfig != ES_NOTIFY_NONE && esNotifyConfig != ES_NOTIFY_ALL) {
Log.e(TAG, "Config parameter " + GnssConfiguration.CONFIG_ES_NOTIFY_INT
+ " is set to invalid value: " + esNotifyConfig
+ ". Using default value: " + ES_NOTIFY_NONE);
esNotifyConfig = ES_NOTIFY_NONE;
}
mEsNotify = (esNotifyConfig == ES_NOTIFY_ALL);
}
private void handleInitialize() {
disableNfwLocationAccess(); // Disable until config properties are loaded.
listenForProxyAppsPackageUpdates();
@@ -494,7 +511,7 @@ class GnssVisibilityControl {
logEvent(nfwNotification, isPermissionMismatched);
if (nfwNotification.isLocationProvided()) {
if (mEsNotify && nfwNotification.isLocationProvided()) {
// Emulate deprecated IGnssNi.hal user notification of emergency NI requests.
GpsNetInitiatedHandler.GpsNiNotification notification =
new GpsNetInitiatedHandler.GpsNiNotification();

View File

@@ -2791,7 +2791,7 @@ public class CarrierConfigManager {
/**
* Control Plane / SUPL NI emergency extension time in seconds. Default to "0".
*/
public static final String KEY_ES_EXTENSION_SEC = KEY_PREFIX + "es_extension_sec";
public static final String KEY_ES_EXTENSION_SEC_STRING = KEY_PREFIX + "es_extension_sec";
/**
* Space separated list of Android package names of proxy applications representing
@@ -2799,7 +2799,15 @@ public class CarrierConfigManager {
* the framework, as managed by IGnssVisibilityControl.hal. For example,
* "com.example.mdt com.example.ims".
*/
public static final String KEY_NFW_PROXY_APPS = KEY_PREFIX + "nfw_proxy_apps";
public static final String KEY_NFW_PROXY_APPS_STRING = KEY_PREFIX + "nfw_proxy_apps";
/**
* Specify whether to post a notification on the status bar whenever device location is
* provided for non-framework location requests in user-initiated emergency use cases.
* 0 - Do not post notification. This is default.
* 1 - Post notification for all request types.
*/
public static final String KEY_ES_NOTIFY_INT = KEY_PREFIX + "es_notify_int";
private static PersistableBundle getDefaults() {
PersistableBundle defaults = new PersistableBundle();
@@ -2813,8 +2821,9 @@ public class CarrierConfigManager {
defaults.putString(KEY_USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_STRING, "1");
defaults.putString(KEY_A_GLONASS_POS_PROTOCOL_SELECT_STRING, "0");
defaults.putString(KEY_GPS_LOCK_STRING, "3");
defaults.putString(KEY_ES_EXTENSION_SEC, "0");
defaults.putString(KEY_NFW_PROXY_APPS, "");
defaults.putString(KEY_ES_EXTENSION_SEC_STRING, "0");
defaults.putString(KEY_NFW_PROXY_APPS_STRING, "");
defaults.putInt(KEY_ES_NOTIFY_INT, 0);
return defaults;
}
}