Loading services/java/com/android/server/location/GpsLocationProvider.java +23 −5 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class GpsLocationProvider implements LocationProviderInterface { private static final int GPS_CAPABILITY_MSB = 0x0000002; private static final int GPS_CAPABILITY_MSA = 0x0000004; private static final int GPS_CAPABILITY_SINGLE_SHOT = 0x0000008; private static final int GPS_CAPABILITY_ON_DEMAND_TIME = 0x0000010; // these need to match AGpsType enum in gps.h private static final int AGPS_TYPE_SUPL = 1; Loading Loading @@ -200,6 +200,9 @@ public class GpsLocationProvider implements LocationProviderInterface { private boolean mInjectNtpTimePending = true; private boolean mDownloadXtraDataPending = true; // set to true if the GPS engine does not do on-demand NTP time requests private boolean mPeriodicTimeInjection; // true if GPS is navigating private boolean mNavigating; Loading Loading @@ -549,11 +552,13 @@ public class GpsLocationProvider implements LocationProviderInterface { delay = RETRY_INTERVAL; } if (mPeriodicTimeInjection) { // send delayed message for next NTP injection // since this is delayed and not urgent we do not hold a wake lock here mHandler.removeMessages(INJECT_NTP_TIME); mHandler.sendMessageDelayed(Message.obtain(mHandler, INJECT_NTP_TIME), delay); } } private void handleDownloadXtraData() { if (!mNetworkAvailable) { Loading Loading @@ -1305,6 +1310,11 @@ public class GpsLocationProvider implements LocationProviderInterface { */ private void setEngineCapabilities(int capabilities) { mEngineCapabilities = capabilities; if (!hasCapability(GPS_CAPABILITY_ON_DEMAND_TIME) && !mPeriodicTimeInjection) { mPeriodicTimeInjection = true; requestUtcTime(); } } /** Loading Loading @@ -1437,6 +1447,14 @@ public class GpsLocationProvider implements LocationProviderInterface { native_agps_set_id(type, data); } /** * Called from native code to request utc time info */ private void requestUtcTime() { sendMessage(INJECT_NTP_TIME, 0, null); } /** * Called from native code to request reference location info */ Loading services/jni/com_android_server_location_GpsLocationProvider.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ static jmethodID method_xtraDownloadRequest; static jmethodID method_reportNiNotification; static jmethodID method_requestRefLocation; static jmethodID method_requestSetID; static jmethodID method_requestUtcTime; static const GpsInterface* sGpsInterface = NULL; static const GpsXtraInterface* sGpsXtraInterface = NULL; Loading Loading @@ -122,6 +123,13 @@ static void release_wakelock_callback() release_wake_lock(WAKE_LOCK_NAME); } static void request_utc_time_callback() { JNIEnv* env = AndroidRuntime::getJNIEnv(); env->CallVoidMethod(mCallbacksObj, method_requestUtcTime); checkAndClearExceptionFromCallback(env, __FUNCTION__); } static pthread_t create_thread_callback(const char* name, void (*start)(void *), void* arg) { return (pthread_t)AndroidRuntime::createJavaThread(name, start, arg); Loading @@ -137,6 +145,7 @@ GpsCallbacks sGpsCallbacks = { acquire_wakelock_callback, release_wakelock_callback, create_thread_callback, request_utc_time_callback, }; static void xtra_download_request_callback() Loading Loading @@ -232,6 +241,7 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, "(IIIIILjava/lang/String;Ljava/lang/String;IILjava/lang/String;)V"); method_requestRefLocation = env->GetMethodID(clazz,"requestRefLocation","(I)V"); method_requestSetID = env->GetMethodID(clazz,"requestSetID","(I)V"); method_requestUtcTime = env->GetMethodID(clazz,"requestUtcTime","()V"); err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { Loading Loading
services/java/com/android/server/location/GpsLocationProvider.java +23 −5 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class GpsLocationProvider implements LocationProviderInterface { private static final int GPS_CAPABILITY_MSB = 0x0000002; private static final int GPS_CAPABILITY_MSA = 0x0000004; private static final int GPS_CAPABILITY_SINGLE_SHOT = 0x0000008; private static final int GPS_CAPABILITY_ON_DEMAND_TIME = 0x0000010; // these need to match AGpsType enum in gps.h private static final int AGPS_TYPE_SUPL = 1; Loading Loading @@ -200,6 +200,9 @@ public class GpsLocationProvider implements LocationProviderInterface { private boolean mInjectNtpTimePending = true; private boolean mDownloadXtraDataPending = true; // set to true if the GPS engine does not do on-demand NTP time requests private boolean mPeriodicTimeInjection; // true if GPS is navigating private boolean mNavigating; Loading Loading @@ -549,11 +552,13 @@ public class GpsLocationProvider implements LocationProviderInterface { delay = RETRY_INTERVAL; } if (mPeriodicTimeInjection) { // send delayed message for next NTP injection // since this is delayed and not urgent we do not hold a wake lock here mHandler.removeMessages(INJECT_NTP_TIME); mHandler.sendMessageDelayed(Message.obtain(mHandler, INJECT_NTP_TIME), delay); } } private void handleDownloadXtraData() { if (!mNetworkAvailable) { Loading Loading @@ -1305,6 +1310,11 @@ public class GpsLocationProvider implements LocationProviderInterface { */ private void setEngineCapabilities(int capabilities) { mEngineCapabilities = capabilities; if (!hasCapability(GPS_CAPABILITY_ON_DEMAND_TIME) && !mPeriodicTimeInjection) { mPeriodicTimeInjection = true; requestUtcTime(); } } /** Loading Loading @@ -1437,6 +1447,14 @@ public class GpsLocationProvider implements LocationProviderInterface { native_agps_set_id(type, data); } /** * Called from native code to request utc time info */ private void requestUtcTime() { sendMessage(INJECT_NTP_TIME, 0, null); } /** * Called from native code to request reference location info */ Loading
services/jni/com_android_server_location_GpsLocationProvider.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ static jmethodID method_xtraDownloadRequest; static jmethodID method_reportNiNotification; static jmethodID method_requestRefLocation; static jmethodID method_requestSetID; static jmethodID method_requestUtcTime; static const GpsInterface* sGpsInterface = NULL; static const GpsXtraInterface* sGpsXtraInterface = NULL; Loading Loading @@ -122,6 +123,13 @@ static void release_wakelock_callback() release_wake_lock(WAKE_LOCK_NAME); } static void request_utc_time_callback() { JNIEnv* env = AndroidRuntime::getJNIEnv(); env->CallVoidMethod(mCallbacksObj, method_requestUtcTime); checkAndClearExceptionFromCallback(env, __FUNCTION__); } static pthread_t create_thread_callback(const char* name, void (*start)(void *), void* arg) { return (pthread_t)AndroidRuntime::createJavaThread(name, start, arg); Loading @@ -137,6 +145,7 @@ GpsCallbacks sGpsCallbacks = { acquire_wakelock_callback, release_wakelock_callback, create_thread_callback, request_utc_time_callback, }; static void xtra_download_request_callback() Loading Loading @@ -232,6 +241,7 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, "(IIIIILjava/lang/String;Ljava/lang/String;IILjava/lang/String;)V"); method_requestRefLocation = env->GetMethodID(clazz,"requestRefLocation","(I)V"); method_requestSetID = env->GetMethodID(clazz,"requestSetID","(I)V"); method_requestUtcTime = env->GetMethodID(clazz,"requestUtcTime","()V"); err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { Loading