Merge "Support periodic PSDS download"
This commit is contained in:
committed by
Android (Google) Code Review
commit
5ee2aa298d
@@ -71,7 +71,8 @@ public 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_ENABLE_PSDS_PERIODIC_DOWNLOAD =
|
||||
"ENABLE_PSDS_PERIODIC_DOWNLOAD";
|
||||
// Limit on NI emergency mode time extension after emergency sessions ends
|
||||
private static final int MAX_EMERGENCY_MODE_EXTENSION_SECONDS = 300; // 5 minute maximum
|
||||
|
||||
@@ -193,6 +194,13 @@ public class GnssConfiguration {
|
||||
return Arrays.asList(proxyAppsArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if PSDS periodic download is enabled, false otherwise.
|
||||
*/
|
||||
boolean isPsdsPeriodicDownloadEnabled() {
|
||||
return getBooleanConfig(CONFIG_ENABLE_PSDS_PERIODIC_DOWNLOAD, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the GNSS HAL satellite denylist.
|
||||
*/
|
||||
@@ -374,6 +382,14 @@ public class GnssConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getBooleanConfig(String configParameter, boolean defaultValue) {
|
||||
String valueString = mProperties.getProperty(configParameter);
|
||||
if (TextUtils.isEmpty(valueString)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.parseBoolean(valueString);
|
||||
}
|
||||
|
||||
private static boolean isConfigEsExtensionSecSupported(
|
||||
HalInterfaceVersion gnssConfiguartionIfaceVersion) {
|
||||
// ES_EXTENSION_SEC is introduced in @2.0::IGnssConfiguration.hal
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.location.gnss;
|
||||
|
||||
import static android.content.pm.PackageManager.FEATURE_WATCH;
|
||||
|
||||
import static android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP;
|
||||
import static android.location.provider.ProviderProperties.ACCURACY_FINE;
|
||||
import static android.location.provider.ProviderProperties.POWER_USAGE_HIGH;
|
||||
@@ -55,6 +57,7 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.ContentObserver;
|
||||
import android.location.GnssCapabilities;
|
||||
import android.location.GnssStatus;
|
||||
@@ -142,6 +145,9 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
|
||||
private static final int AGPS_SUPL_MODE_MSA = 0x02;
|
||||
private static final int AGPS_SUPL_MODE_MSB = 0x01;
|
||||
|
||||
// PSDS stands for Predicted Satellite Data Service
|
||||
private static final int DOWNLOAD_PSDS_DATA = 6;
|
||||
|
||||
// TCP/IP constants.
|
||||
// Valid TCP/UDP port range is (0, 65535].
|
||||
private static final int TCP_MIN_PORT = 0;
|
||||
@@ -651,6 +657,14 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
|
||||
mPsdsBackOff.reset();
|
||||
}
|
||||
});
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
if (pm != null && pm.hasSystemFeature(FEATURE_WATCH)
|
||||
&& mGnssConfiguration.isPsdsPeriodicDownloadEnabled()) {
|
||||
if (DEBUG) Log.d(TAG, "scheduling next Psds download");
|
||||
mHandler.removeMessages(DOWNLOAD_PSDS_DATA);
|
||||
mHandler.sendEmptyMessageDelayed(DOWNLOAD_PSDS_DATA,
|
||||
GnssPsdsDownloader.PSDS_INTERVAL);
|
||||
}
|
||||
} else {
|
||||
// Try download PSDS data again later according to backoff time.
|
||||
// Since this is delayed and not urgent, we do not hold a wake lock here.
|
||||
|
||||
@@ -38,6 +38,10 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
class GnssPsdsDownloader {
|
||||
|
||||
// how often to request PSDS download, in milliseconds
|
||||
// current setting 24 hours
|
||||
static final long PSDS_INTERVAL = 24 * 60 * 60 * 1000;
|
||||
|
||||
private static final String TAG = "GnssPsdsDownloader";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
private static final long MAXIMUM_CONTENT_LENGTH_BYTES = 1000000; // 1MB.
|
||||
|
||||
@@ -50,3 +50,12 @@
|
||||
# Set bit 0x2 if NI GPS functionalities are to be locked
|
||||
# default - non is locked for backward compatibility
|
||||
#GPS_LOCK = 0
|
||||
|
||||
################################
|
||||
##### PSDS download settings #####
|
||||
################################
|
||||
# For wear devices only.
|
||||
# Enable periodic PSDS download once a day.
|
||||
# true: Enable periodic PSDS download
|
||||
# false: Disable periodic PSDS download
|
||||
#ENABLE_PSDS_PERIODIC_DOWNLOAD=false
|
||||
|
||||
Reference in New Issue
Block a user