Loading services/core/java/com/android/server/location/GnssLocationProvider.java +17 −7 Original line number Diff line number Diff line Loading @@ -687,7 +687,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements } } private void handleRequestLocation(boolean independentFromGnss) { private void handleRequestLocation(boolean independentFromGnss, boolean isUserEmergency) { if (isRequestLocationRateLimited()) { if (DEBUG) { Log.d(TAG, "RequestLocation is denied due to too frequent requests."); Loading Loading @@ -723,9 +723,17 @@ public class GnssLocationProvider extends AbstractLocationProvider implements String.format( "GNSS HAL Requesting location updates from %s provider for %d millis.", provider, durationMillis)); try { locationManager.requestLocationUpdates(provider, LocationRequest locationRequest = LocationRequest.createFromDeprecatedProvider(provider, LOCATION_UPDATE_MIN_TIME_INTERVAL_MILLIS, /* minDistance= */ 0, /* singleShot= */ false); // Ignore location settings if in emergency mode. if (isUserEmergency && mNIHandler.getInEmergency()) { locationRequest.setLocationSettingsIgnored(true); } try { locationManager.requestLocationUpdates(locationRequest, locationListener, mHandler.getLooper()); locationListener.mNumLocationUpdateRequest++; mHandler.postDelayed(() -> { Loading Loading @@ -1828,11 +1836,13 @@ public class GnssLocationProvider extends AbstractLocationProvider implements } @NativeEntryPoint private void requestLocation(boolean independentFromGnss) { private void requestLocation(boolean independentFromGnss, boolean isUserEmergency) { if (DEBUG) { Log.d(TAG, "requestLocation. independentFromGnss: " + independentFromGnss); Log.d(TAG, "requestLocation. independentFromGnss: " + independentFromGnss + ", isUserEmergency: " + isUserEmergency); } sendMessage(REQUEST_LOCATION, 0, independentFromGnss); sendMessage(REQUEST_LOCATION, independentFromGnss ? 1 : 0, isUserEmergency); } @NativeEntryPoint Loading Loading @@ -1923,7 +1933,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements mNtpTimeHelper.retrieveAndInjectNtpTime(); break; case REQUEST_LOCATION: handleRequestLocation((boolean) msg.obj); handleRequestLocation(msg.arg1 == 1, (boolean) msg.obj); break; case DOWNLOAD_XTRA_DATA: handleDownloadXtraData(); Loading services/core/jni/com_android_server_location_GnssLocationProvider.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -548,12 +548,15 @@ struct GnssCallback : public IGnssCallback { Return<void> gnssReleaseWakelockCb() override; Return<void> gnssRequestTimeCb() override; Return<void> gnssRequestLocationCb(const bool independentFromGnss) override; Return<void> gnssSetSystemInfoCb(const IGnssCallback::GnssSystemInfo& info) override; // New in 1.1 Return<void> gnssNameCb(const android::hardware::hidl_string& name) override; // New in 2.0 Return<void> gnssRequestLocationCb_2_0(const bool independentFromGnss, const bool isUserEmergency) override; Return<void> gnssSetCapabilitiesCb_2_0(uint32_t capabilities) override; Return<void> gnssLocationCb_2_0(const GnssLocation_V2_0& location) override; Loading Loading @@ -713,8 +716,15 @@ Return<void> GnssCallback::gnssRequestTimeCb() { } Return<void> GnssCallback::gnssRequestLocationCb(const bool independentFromGnss) { return GnssCallback::gnssRequestLocationCb_2_0(independentFromGnss, /* isUserEmergency= */ false); } Return<void> GnssCallback::gnssRequestLocationCb_2_0(const bool independentFromGnss, const bool isUserEmergency) { JNIEnv* env = getJniEnv(); env->CallVoidMethod(mCallbacksObj, method_requestLocation, boolToJbool(independentFromGnss)); env->CallVoidMethod(mCallbacksObj, method_requestLocation, boolToJbool(independentFromGnss), boolToJbool(isUserEmergency)); checkAndClearExceptionFromCallback(env, __FUNCTION__); return Void(); } Loading Loading @@ -1422,7 +1432,7 @@ static void android_location_GnssLocationProvider_init_once(JNIEnv* env, jclass method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V"); method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification", "(IIIIILjava/lang/String;Ljava/lang/String;II)V"); method_requestLocation = env->GetMethodID(clazz, "requestLocation", "(Z)V"); method_requestLocation = env->GetMethodID(clazz, "requestLocation", "(ZZ)V"); method_requestRefLocation = env->GetMethodID(clazz, "requestRefLocation", "()V"); method_requestSetID = env->GetMethodID(clazz, "requestSetID", "(I)V"); method_requestUtcTime = env->GetMethodID(clazz, "requestUtcTime", "()V"); Loading Loading
services/core/java/com/android/server/location/GnssLocationProvider.java +17 −7 Original line number Diff line number Diff line Loading @@ -687,7 +687,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements } } private void handleRequestLocation(boolean independentFromGnss) { private void handleRequestLocation(boolean independentFromGnss, boolean isUserEmergency) { if (isRequestLocationRateLimited()) { if (DEBUG) { Log.d(TAG, "RequestLocation is denied due to too frequent requests."); Loading Loading @@ -723,9 +723,17 @@ public class GnssLocationProvider extends AbstractLocationProvider implements String.format( "GNSS HAL Requesting location updates from %s provider for %d millis.", provider, durationMillis)); try { locationManager.requestLocationUpdates(provider, LocationRequest locationRequest = LocationRequest.createFromDeprecatedProvider(provider, LOCATION_UPDATE_MIN_TIME_INTERVAL_MILLIS, /* minDistance= */ 0, /* singleShot= */ false); // Ignore location settings if in emergency mode. if (isUserEmergency && mNIHandler.getInEmergency()) { locationRequest.setLocationSettingsIgnored(true); } try { locationManager.requestLocationUpdates(locationRequest, locationListener, mHandler.getLooper()); locationListener.mNumLocationUpdateRequest++; mHandler.postDelayed(() -> { Loading Loading @@ -1828,11 +1836,13 @@ public class GnssLocationProvider extends AbstractLocationProvider implements } @NativeEntryPoint private void requestLocation(boolean independentFromGnss) { private void requestLocation(boolean independentFromGnss, boolean isUserEmergency) { if (DEBUG) { Log.d(TAG, "requestLocation. independentFromGnss: " + independentFromGnss); Log.d(TAG, "requestLocation. independentFromGnss: " + independentFromGnss + ", isUserEmergency: " + isUserEmergency); } sendMessage(REQUEST_LOCATION, 0, independentFromGnss); sendMessage(REQUEST_LOCATION, independentFromGnss ? 1 : 0, isUserEmergency); } @NativeEntryPoint Loading Loading @@ -1923,7 +1933,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements mNtpTimeHelper.retrieveAndInjectNtpTime(); break; case REQUEST_LOCATION: handleRequestLocation((boolean) msg.obj); handleRequestLocation(msg.arg1 == 1, (boolean) msg.obj); break; case DOWNLOAD_XTRA_DATA: handleDownloadXtraData(); Loading
services/core/jni/com_android_server_location_GnssLocationProvider.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -548,12 +548,15 @@ struct GnssCallback : public IGnssCallback { Return<void> gnssReleaseWakelockCb() override; Return<void> gnssRequestTimeCb() override; Return<void> gnssRequestLocationCb(const bool independentFromGnss) override; Return<void> gnssSetSystemInfoCb(const IGnssCallback::GnssSystemInfo& info) override; // New in 1.1 Return<void> gnssNameCb(const android::hardware::hidl_string& name) override; // New in 2.0 Return<void> gnssRequestLocationCb_2_0(const bool independentFromGnss, const bool isUserEmergency) override; Return<void> gnssSetCapabilitiesCb_2_0(uint32_t capabilities) override; Return<void> gnssLocationCb_2_0(const GnssLocation_V2_0& location) override; Loading Loading @@ -713,8 +716,15 @@ Return<void> GnssCallback::gnssRequestTimeCb() { } Return<void> GnssCallback::gnssRequestLocationCb(const bool independentFromGnss) { return GnssCallback::gnssRequestLocationCb_2_0(independentFromGnss, /* isUserEmergency= */ false); } Return<void> GnssCallback::gnssRequestLocationCb_2_0(const bool independentFromGnss, const bool isUserEmergency) { JNIEnv* env = getJniEnv(); env->CallVoidMethod(mCallbacksObj, method_requestLocation, boolToJbool(independentFromGnss)); env->CallVoidMethod(mCallbacksObj, method_requestLocation, boolToJbool(independentFromGnss), boolToJbool(isUserEmergency)); checkAndClearExceptionFromCallback(env, __FUNCTION__); return Void(); } Loading Loading @@ -1422,7 +1432,7 @@ static void android_location_GnssLocationProvider_init_once(JNIEnv* env, jclass method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V"); method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification", "(IIIIILjava/lang/String;Ljava/lang/String;II)V"); method_requestLocation = env->GetMethodID(clazz, "requestLocation", "(Z)V"); method_requestLocation = env->GetMethodID(clazz, "requestLocation", "(ZZ)V"); method_requestRefLocation = env->GetMethodID(clazz, "requestRefLocation", "()V"); method_requestSetID = env->GetMethodID(clazz, "requestSetID", "(I)V"); method_requestUtcTime = env->GetMethodID(clazz, "requestUtcTime", "()V"); Loading