summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values-mcc310-mnc260/config.xml5
-rw-r--r--core/res/res/values-mcc310-mnc410/config.xml4
-rw-r--r--core/res/res/values/config.xml17
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--location/java/android/location/GpsMeasurement.java10
-rw-r--r--services/core/java/com/android/server/location/GpsLocationProvider.java140
-rw-r--r--services/core/jni/com_android_server_location_GpsLocationProvider.cpp110
7 files changed, 207 insertions, 80 deletions
diff --git a/core/res/res/values-mcc310-mnc260/config.xml b/core/res/res/values-mcc310-mnc260/config.xml
index d602c9f..00cdaeb 100644
--- a/core/res/res/values-mcc310-mnc260/config.xml
+++ b/core/res/res/values-mcc310-mnc260/config.xml
@@ -25,4 +25,9 @@
-->
<integer name="config_mobile_mtu">1440</integer>
+ <!-- Values for GPS configuration -->
+ <string-array translatable="false" name="config_gpsParameters">
+ <item>"SUPL_PORT=7279"</item>
+ <item>GPS_LOCK=1</item>
+ </string-array>
</resources>
diff --git a/core/res/res/values-mcc310-mnc410/config.xml b/core/res/res/values-mcc310-mnc410/config.xml
index c7ae8c8..9e63047 100644
--- a/core/res/res/values-mcc310-mnc410/config.xml
+++ b/core/res/res/values-mcc310-mnc410/config.xml
@@ -40,4 +40,8 @@
<item>315</item>
<item>316</item>
</string-array>
+ <!-- Values for GPS configuration -->
+ <string-array translatable="false" name="config_gpsParameters">
+ <item>"SUPL_HOST=supl.google.com"</item>
+ </string-array>
</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index af213ba..f5f079c 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1695,4 +1695,21 @@
<string-array translatable="false" name="no_ems_support_sim_operators" />
<bool name="config_auto_attach_data_on_creation">true</bool>
+
+ <!-- Values for GPS configuration -->
+ <string-array translatable="false" name="config_gpsParameters">
+ <item>SUPL_HOST=supl.google.com</item>
+ <item>SUPL_PORT=7275</item>
+ <item>XTRA_SERVER_1=http://xtrapath1.izatcloud.net/xtra2.bin</item>
+ <item>XTRA_SERVER_2=http://xtrapath2.izatcloud.net/xtra2.bin</item>
+ <item>XTRA_SERVER_3=http://xtrapath3.izatcloud.net/xtra2.bin</item>
+ <item>NTP_SERVER=north-america.pool.ntp.org</item>
+ <item>SUPL_VER=0x20000</item>
+ <item>CAPABILITIES=0x33</item>
+ <item>LPP_PROFILE=0</item>
+ <item>NMEA_PROVIDER=0</item>
+ <item>A_GLONASS_POS_PROTOCOL_SELECT=0</item>
+ <item>ERR_ESTIMATE=0</item>
+ <item>INTERMEDIATE_POS=0</item>
+ </string-array>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index d8c29b0..7748c26 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1036,6 +1036,7 @@
<java-symbol type="array" name="config_globalActionsList" />
<java-symbol type="array" name="config_telephonyHardware" />
<java-symbol type="array" name="config_keySystemUuidMapping" />
+ <java-symbol type="array" name="config_gpsParameters" />
<java-symbol type="drawable" name="default_wallpaper" />
<java-symbol type="drawable" name="indicator_input_error" />
diff --git a/location/java/android/location/GpsMeasurement.java b/location/java/android/location/GpsMeasurement.java
index 591a6ca..1550dc2 100644
--- a/location/java/android/location/GpsMeasurement.java
+++ b/location/java/android/location/GpsMeasurement.java
@@ -49,7 +49,7 @@ public class GpsMeasurement implements Parcelable {
private double mCarrierPhase;
private double mCarrierPhaseUncertainty;
private byte mLossOfLock;
- private short mBitNumber;
+ private int mBitNumber;
private short mTimeFromLastBitInMs;
private double mDopplerShiftInHz;
private double mDopplerShiftUncertaintyInHz;
@@ -784,14 +784,14 @@ public class GpsMeasurement implements Parcelable {
*
* The value is only available if {@link #hasBitNumber()} is true.
*/
- public short getBitNumber() {
+ public int getBitNumber() {
return mBitNumber;
}
/**
* Sets the bit number within the broadcast frame.
*/
- public void setBitNumber(short bitNumber) {
+ public void setBitNumber(int bitNumber) {
setFlag(HAS_BIT_NUMBER);
mBitNumber = bitNumber;
}
@@ -801,7 +801,7 @@ public class GpsMeasurement implements Parcelable {
*/
public void resetBitNumber() {
resetFlag(HAS_BIT_NUMBER);
- mBitNumber = Short.MIN_VALUE;
+ mBitNumber = Integer.MIN_VALUE;
}
/**
@@ -1161,7 +1161,7 @@ public class GpsMeasurement implements Parcelable {
gpsMeasurement.mCarrierPhase = parcel.readDouble();
gpsMeasurement.mCarrierPhaseUncertainty = parcel.readDouble();
gpsMeasurement.mLossOfLock = parcel.readByte();
- gpsMeasurement.mBitNumber = (short) parcel.readInt();
+ gpsMeasurement.mBitNumber = parcel.readInt();
gpsMeasurement.mTimeFromLastBitInMs = (short) parcel.readInt();
gpsMeasurement.mDopplerShiftInHz = parcel.readDouble();
gpsMeasurement.mDopplerShiftUncertaintyInHz = parcel.readDouble();
diff --git a/services/core/java/com/android/server/location/GpsLocationProvider.java b/services/core/java/com/android/server/location/GpsLocationProvider.java
index 753ae39..2ef9828 100644
--- a/services/core/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/core/java/com/android/server/location/GpsLocationProvider.java
@@ -22,6 +22,7 @@ import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
import com.android.internal.location.ProviderProperties;
import com.android.internal.location.ProviderRequest;
+import com.android.internal.R;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
@@ -76,6 +77,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.NtpTrustedTime;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -138,7 +140,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
private static final int LOCATION_HAS_BEARING = 8;
private static final int LOCATION_HAS_ACCURACY = 16;
-// IMPORTANT - the GPS_DELETE_* symbols here must match constants in gps.h
+ // IMPORTANT - the GPS_DELETE_* symbols here must match constants in gps.h
private static final int GPS_DELETE_EPHEMERIS = 0x0001;
private static final int GPS_DELETE_ALMANAC = 0x0002;
private static final int GPS_DELETE_POSITION = 0x0004;
@@ -367,6 +369,10 @@ public class GpsLocationProvider implements LocationProviderInterface {
// Alarms
private final static String ALARM_WAKEUP = "com.android.internal.location.ALARM_WAKEUP";
private final static String ALARM_TIMEOUT = "com.android.internal.location.ALARM_TIMEOUT";
+
+ // SIM/Carrier info.
+ private final static String SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
+
private final PowerManager mPowerManager;
private final AlarmManager mAlarmManager;
private final PendingIntent mWakeupIntent;
@@ -443,7 +449,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
return mGpsNavigationMessageProvider;
}
- private final BroadcastReceiver mBroadcastReciever = new BroadcastReceiver() {
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
@@ -477,6 +483,19 @@ public class GpsLocationProvider implements LocationProviderInterface {
|| Intent.ACTION_SCREEN_OFF.equals(action)
|| Intent.ACTION_SCREEN_ON.equals(action)) {
updateLowPowerMode();
+ } else if (action.equals(SIM_STATE_CHANGED)) {
+ TelephonyManager phone = (TelephonyManager)
+ mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ int simState = phone.getSimState();
+ Log.d(TAG, "SIM STATE CHANGED to " + simState);
+ String mccMnc = phone.getSimOperator();
+ if (simState == TelephonyManager.SIM_STATE_READY &&
+ !TextUtils.isEmpty(mccMnc)) {
+ Log.d(TAG, "SIM STATE is ready, SIM MCC/MNC is " + mccMnc);
+ synchronized (mLock) {
+ reloadGpsProperties(context, mProperties);
+ }
+ }
}
}
};
@@ -514,37 +533,73 @@ public class GpsLocationProvider implements LocationProviderInterface {
return native_is_supported();
}
- private boolean loadPropertiesFile(String filename) {
- mProperties = new Properties();
+ private void reloadGpsProperties(Context context, Properties properties) {
+ Log.d(TAG, "Reset GPS properties, previous size = " + properties.size());
+ loadPropertiesFromResource(context, properties);
+ boolean isPropertiesLoadedFromFile = false;
+ final String gpsHardware = SystemProperties.get("ro.hardware.gps");
+ if (!TextUtils.isEmpty(gpsHardware)) {
+ final String propFilename =
+ PROPERTIES_FILE_PREFIX + "." + gpsHardware + PROPERTIES_FILE_SUFFIX;
+ isPropertiesLoadedFromFile =
+ loadPropertiesFromFile(propFilename, properties);
+ }
+ if (!isPropertiesLoadedFromFile) {
+ loadPropertiesFromFile(DEFAULT_PROPERTIES_FILE, properties);
+ }
+ Log.d(TAG, "GPS properties reloaded, size = " + properties.size());
+
+ // TODO: we should get rid of C2K specific setting.
+ setSuplHostPort(properties.getProperty("SUPL_HOST"),
+ properties.getProperty("SUPL_PORT"));
+ mC2KServerHost = properties.getProperty("C2K_HOST");
+ String portString = properties.getProperty("C2K_PORT");
+ if (mC2KServerHost != null && portString != null) {
+ try {
+ mC2KServerPort = Integer.parseInt(portString);
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "unable to parse C2K_PORT: " + portString);
+ }
+ }
+
+ try {
+ // Convert properties to string contents and send it to HAL.
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
+ properties.store(baos, null);
+ native_configuration_update(baos.toString());
+ Log.d(TAG, "final config = " + baos.toString());
+ } catch (IOException ex) {
+ Log.w(TAG, "failed to dump properties contents");
+ }
+ }
+
+ private void loadPropertiesFromResource(Context context,
+ Properties properties) {
+ String[] configValues = context.getResources().getStringArray(
+ com.android.internal.R.array.config_gpsParameters);
+ for (String item : configValues) {
+ Log.d(TAG, "GpsParamsResource: " + item);
+ String[] split = item.split("=");
+ if (split.length == 2) {
+ properties.setProperty(split[0].trim().toUpperCase(), split[1]);
+ } else {
+ Log.w(TAG, "malformed contents: " + item);
+ }
+ }
+ }
+
+ private boolean loadPropertiesFromFile(String filename,
+ Properties properties) {
try {
File file = new File(filename);
FileInputStream stream = null;
try {
stream = new FileInputStream(file);
- mProperties.load(stream);
+ properties.load(stream);
} finally {
IoUtils.closeQuietly(stream);
}
- mSuplServerHost = mProperties.getProperty("SUPL_HOST");
- String portString = mProperties.getProperty("SUPL_PORT");
- if (mSuplServerHost != null && portString != null) {
- try {
- mSuplServerPort = Integer.parseInt(portString);
- } catch (NumberFormatException e) {
- Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
- }
- }
-
- mC2KServerHost = mProperties.getProperty("C2K_HOST");
- portString = mProperties.getProperty("C2K_PORT");
- if (mC2KServerHost != null && portString != null) {
- try {
- mC2KServerPort = Integer.parseInt(portString);
- } catch (NumberFormatException e) {
- Log.e(TAG, "unable to parse C2K_PORT: " + portString);
- }
- }
} catch (IOException e) {
Log.w(TAG, "Could not open GPS configuration file " + filename);
return false;
@@ -580,16 +635,9 @@ public class GpsLocationProvider implements LocationProviderInterface {
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(
BatteryStats.SERVICE_NAME));
- boolean propertiesLoaded = false;
- final String gpsHardware = SystemProperties.get("ro.hardware.gps");
- if (!TextUtils.isEmpty(gpsHardware)) {
- final String propFilename = PROPERTIES_FILE_PREFIX + "." + gpsHardware + PROPERTIES_FILE_SUFFIX;
- propertiesLoaded = loadPropertiesFile(propFilename);
- }
-
- if (!propertiesLoaded) {
- loadPropertiesFile(DEFAULT_PROPERTIES_FILE);
- }
+ // Load GPS configuration.
+ mProperties = new Properties();
+ reloadGpsProperties(mContext, mProperties);
// construct handler, listen for events
mHandler = new ProviderHandler(looper);
@@ -625,7 +673,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
intentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
intentFilter.addDataScheme("sms");
intentFilter.addDataAuthority("localhost","7275");
- mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
+ mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler);
intentFilter = new IntentFilter();
intentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
@@ -634,7 +682,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
} catch (IntentFilter.MalformedMimeTypeException e) {
Log.w(TAG, "Malformed SUPL init mime type");
}
- mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
+ mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler);
intentFilter = new IntentFilter();
intentFilter.addAction(ALARM_WAKEUP);
@@ -643,7 +691,9 @@ public class GpsLocationProvider implements LocationProviderInterface {
intentFilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
- mContext.registerReceiver(mBroadcastReciever, intentFilter, null, mHandler);
+ intentFilter = new IntentFilter();
+ intentFilter.addAction(SIM_STATE_CHANGED);
+ mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler);
}
/**
@@ -844,6 +894,19 @@ public class GpsLocationProvider implements LocationProviderInterface {
sendMessage(ENABLE, 1, null);
}
+ private void setSuplHostPort(String hostString, String portString) {
+ if (hostString != null) {
+ mSuplServerHost = hostString;
+ }
+ if (portString != null) {
+ try {
+ mSuplServerPort = Integer.parseInt(portString);
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
+ }
+ }
+ }
+
private void handleEnable() {
if (DEBUG) Log.d(TAG, "handleEnable");
@@ -2055,5 +2118,8 @@ public class GpsLocationProvider implements LocationProviderInterface {
private static native boolean native_is_navigation_message_supported();
private native boolean native_start_navigation_message_collection();
private native boolean native_stop_navigation_message_collection();
+
+ // GNSS Configuration
+ private static native void native_configuration_update(String configData);
}
diff --git a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp
index c398908..6958087 100644
--- a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp
@@ -65,6 +65,7 @@ static const AGpsRilInterface* sAGpsRilInterface = NULL;
static const GpsGeofencingInterface* sGpsGeofencingInterface = NULL;
static const GpsMeasurementInterface* sGpsMeasurementInterface = NULL;
static const GpsNavigationMessageInterface* sGpsNavigationMessageInterface = NULL;
+static const GnssConfigurationInterface* sGnssConfigurationInterface = NULL;
// temporary storage for GPS callbacks
static GpsSvStatus sGpsSvStatus;
@@ -502,6 +503,9 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env,
sGpsNavigationMessageInterface =
(const GpsNavigationMessageInterface*)sGpsInterface->get_extension(
GPS_NAVIGATION_MESSAGE_INTERFACE);
+ sGnssConfigurationInterface =
+ (const GnssConfigurationInterface*)sGpsInterface->get_extension(
+ GNSS_CONFIGURATION_INTERFACE);
}
}
@@ -901,55 +905,57 @@ static jobject translate_gps_clock(JNIEnv* env, GpsClock* clock) {
if (flags & GPS_CLOCK_HAS_LEAP_SECOND) {
jmethodID setterMethod = env->GetMethodID(gpsClockClass, "setLeapSecond", "(S)V");
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->leap_second);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->leap_second);
}
jmethodID typeSetterMethod = env->GetMethodID(gpsClockClass, "setType", "(B)V");
- env->CallObjectMethod(gpsClockObject, typeSetterMethod, clock->type);
+ env->CallVoidMethod(gpsClockObject, typeSetterMethod, clock->type);
jmethodID setterMethod = env->GetMethodID(gpsClockClass, "setTimeInNs", longSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->time_ns);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->time_ns);
if (flags & GPS_CLOCK_HAS_TIME_UNCERTAINTY) {
jmethodID setterMethod =
env->GetMethodID(gpsClockClass, "setTimeUncertaintyInNs", doubleSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->time_uncertainty_ns);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->time_uncertainty_ns);
}
if (flags & GPS_CLOCK_HAS_FULL_BIAS) {
jmethodID setterMethod = env->GetMethodID(gpsClockClass, "setFullBiasInNs", longSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->full_bias_ns);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->full_bias_ns);
}
if (flags & GPS_CLOCK_HAS_BIAS) {
jmethodID setterMethod = env->GetMethodID(gpsClockClass, "setBiasInNs", doubleSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->bias_ns);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->bias_ns);
}
if (flags & GPS_CLOCK_HAS_BIAS_UNCERTAINTY) {
jmethodID setterMethod =
env->GetMethodID(gpsClockClass, "setBiasUncertaintyInNs", doubleSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->bias_uncertainty_ns);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->bias_uncertainty_ns);
}
if (flags & GPS_CLOCK_HAS_DRIFT) {
jmethodID setterMethod =
env->GetMethodID(gpsClockClass, "setDriftInNsPerSec", doubleSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->drift_nsps);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->drift_nsps);
}
if (flags & GPS_CLOCK_HAS_DRIFT_UNCERTAINTY) {
jmethodID setterMethod =
env->GetMethodID(gpsClockClass, "setDriftUncertaintyInNsPerSec", doubleSignature);
- env->CallObjectMethod(gpsClockObject, setterMethod, clock->drift_uncertainty_nsps);
+ env->CallVoidMethod(gpsClockObject, setterMethod, clock->drift_uncertainty_nsps);
}
+ env->DeleteLocalRef(gpsClockClass);
return gpsClockObject;
}
static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measurement) {
const char* byteSignature = "(B)V";
const char* shortSignature = "(S)V";
+ const char* intSignature = "(I)V";
const char* longSignature = "(J)V";
const char* floatSignature = "(F)V";
const char* doubleSignature = "(D)V";
@@ -961,21 +967,21 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
GpsMeasurementFlags flags = measurement->flags;
jmethodID prnSetterMethod = env->GetMethodID(gpsMeasurementClass, "setPrn", byteSignature);
- env->CallObjectMethod(gpsMeasurementObject, prnSetterMethod, measurement->prn);
+ env->CallVoidMethod(gpsMeasurementObject, prnSetterMethod, measurement->prn);
jmethodID timeOffsetSetterMethod =
env->GetMethodID(gpsMeasurementClass, "setTimeOffsetInNs", doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
timeOffsetSetterMethod,
measurement->time_offset_ns);
jmethodID stateSetterMethod = env->GetMethodID(gpsMeasurementClass, "setState", shortSignature);
- env->CallObjectMethod(gpsMeasurementObject, stateSetterMethod, measurement->state);
+ env->CallVoidMethod(gpsMeasurementObject, stateSetterMethod, measurement->state);
jmethodID receivedGpsTowSetterMethod =
env->GetMethodID(gpsMeasurementClass, "setReceivedGpsTowInNs", longSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
receivedGpsTowSetterMethod,
measurement->received_gps_tow_ns);
@@ -991,13 +997,13 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
jmethodID cn0SetterMethod =
env->GetMethodID(gpsMeasurementClass, "setCn0InDbHz", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, cn0SetterMethod, measurement->c_n0_dbhz);
+ env->CallVoidMethod(gpsMeasurementObject, cn0SetterMethod, measurement->c_n0_dbhz);
jmethodID pseudorangeRateSetterMethod = env->GetMethodID(
gpsMeasurementClass,
"setPseudorangeRateInMetersPerSec",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
pseudorangeRateSetterMethod,
measurement->pseudorange_rate_mps);
@@ -1006,14 +1012,14 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
gpsMeasurementClass,
"setPseudorangeRateUncertaintyInMetersPerSec",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
pseudorangeRateUncertaintySetterMethod,
measurement->pseudorange_rate_uncertainty_mps);
jmethodID accumulatedDeltaRangeStateSetterMethod =
env->GetMethodID(gpsMeasurementClass, "setAccumulatedDeltaRangeState", shortSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
accumulatedDeltaRangeStateSetterMethod,
measurement->accumulated_delta_range_state);
@@ -1039,7 +1045,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_PSEUDORANGE) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setPseudorangeInMeters", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->pseudorange_m);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->pseudorange_m);
}
if (flags & GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY) {
@@ -1047,7 +1053,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
gpsMeasurementClass,
"setPseudorangeUncertaintyInMeters",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->pseudorange_uncertainty_m);
@@ -1056,7 +1062,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_CODE_PHASE) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setCodePhaseInChips", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->code_phase_chips);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->code_phase_chips);
}
if (flags & GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY) {
@@ -1064,7 +1070,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
gpsMeasurementClass,
"setCodePhaseUncertaintyInChips",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->code_phase_uncertainty_chips);
@@ -1073,7 +1079,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setCarrierFrequencyInHz", floatSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->carrier_frequency_hz);
@@ -1082,13 +1088,13 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_CARRIER_CYCLES) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setCarrierCycles", longSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->carrier_cycles);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->carrier_cycles);
}
if (flags & GPS_MEASUREMENT_HAS_CARRIER_PHASE) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setCarrierPhase", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->carrier_phase);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->carrier_phase);
}
if (flags & GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY) {
@@ -1096,7 +1102,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
gpsMeasurementClass,
"setCarrierPhaseUncertainty",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->carrier_phase_uncertainty);
@@ -1104,18 +1110,18 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
jmethodID lossOfLockSetterMethod =
env->GetMethodID(gpsMeasurementClass, "setLossOfLock", byteSignature);
- env->CallObjectMethod(gpsMeasurementObject, lossOfLockSetterMethod, measurement->loss_of_lock);
+ env->CallVoidMethod(gpsMeasurementObject, lossOfLockSetterMethod, measurement->loss_of_lock);
if (flags & GPS_MEASUREMENT_HAS_BIT_NUMBER) {
jmethodID setterMethod =
- env->GetMethodID(gpsMeasurementClass, "setBitNumber", shortSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->bit_number);
+ env->GetMethodID(gpsMeasurementClass, "setBitNumber", intSignature);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->bit_number);
}
if (flags & GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setTimeFromLastBitInMs", shortSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->time_from_last_bit_ms);
@@ -1124,7 +1130,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_DOPPLER_SHIFT) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setDopplerShiftInHz", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->doppler_shift_hz);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->doppler_shift_hz);
}
if (flags & GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY) {
@@ -1132,7 +1138,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
gpsMeasurementClass,
"setDopplerShiftUncertaintyInHz",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->doppler_shift_uncertainty_hz);
@@ -1140,7 +1146,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
jmethodID multipathIndicatorSetterMethod =
env->GetMethodID(gpsMeasurementClass, "setMultipathIndicator", byteSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
multipathIndicatorSetterMethod,
measurement->multipath_indicator);
@@ -1148,19 +1154,19 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_SNR) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setSnrInDb", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->snr_db);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->snr_db);
}
if (flags & GPS_MEASUREMENT_HAS_ELEVATION) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setElevationInDeg", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->elevation_deg);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->elevation_deg);
}
if (flags & GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setElevationUncertaintyInDeg", doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->elevation_uncertainty_deg);
@@ -1169,7 +1175,7 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
if (flags & GPS_MEASUREMENT_HAS_AZIMUTH) {
jmethodID setterMethod =
env->GetMethodID(gpsMeasurementClass, "setAzimuthInDeg", doubleSignature);
- env->CallObjectMethod(gpsMeasurementObject, setterMethod, measurement->azimuth_deg);
+ env->CallVoidMethod(gpsMeasurementObject, setterMethod, measurement->azimuth_deg);
}
if (flags & GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY) {
@@ -1177,14 +1183,14 @@ static jobject translate_gps_measurement(JNIEnv* env, GpsMeasurement* measuremen
gpsMeasurementClass,
"setAzimuthUncertaintyInDeg",
doubleSignature);
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
setterMethod,
measurement->azimuth_uncertainty_deg);
}
jmethodID usedInFixSetterMethod = env->GetMethodID(gpsMeasurementClass, "setUsedInFix", "(Z)V");
- env->CallObjectMethod(
+ env->CallVoidMethod(
gpsMeasurementObject,
usedInFixSetterMethod,
(flags & GPS_MEASUREMENT_HAS_USED_IN_FIX) && measurement->used_in_fix);
@@ -1240,6 +1246,11 @@ static void measurement_callback(GpsData* data) {
env->CallVoidMethod(mCallbacksObj, method_reportMeasurementData, gpsMeasurementsEvent);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
+
+ env->DeleteLocalRef(gpsClock);
+ env->DeleteLocalRef(measurementArray);
+ env->DeleteLocalRef(gpsMeasurementsEventClass);
+ env->DeleteLocalRef(gpsMeasurementsEvent);
} else {
ALOGE("Invalid GpsData size found in gps_measurement_callback, size=%d", data->size);
}
@@ -1318,6 +1329,8 @@ static jobject translate_gps_navigation_message(JNIEnv* env, GpsNavigationMessag
jmethodID setDataMethod = env->GetMethodID(navigationMessageClass, "setData", "([B)V");
env->CallVoidMethod(navigationMessageObject, setDataMethod, dataArray);
+ env->DeleteLocalRef(navigationMessageClass);
+ env->DeleteLocalRef(dataArray);
return navigationMessageObject;
}
@@ -1344,6 +1357,10 @@ static void navigation_message_callback(GpsNavigationMessage* message) {
env->CallVoidMethod(mCallbacksObj, method_reportNavigationMessages, navigationMessageEvent);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
+
+ env->DeleteLocalRef(navigationMessage);
+ env->DeleteLocalRef(navigationMessageEventClass);
+ env->DeleteLocalRef(navigationMessageEvent);
} else {
ALOGE("Invalid GpsNavigationMessage size found: %d", message->size);
}
@@ -1392,6 +1409,20 @@ static jboolean android_location_GpsLocationProvider_stop_navigation_message_col
return JNI_TRUE;
}
+static void android_location_GpsLocationProvider_configuration_update(JNIEnv* env, jobject obj,
+ jstring config_content)
+{
+ if (!sGnssConfigurationInterface) {
+ ALOGE("no GPS configuration interface in configuraiton_update");
+ return;
+ }
+ const char *data = env->GetStringUTFChars(config_content, NULL);
+ ALOGD("GPS configuration:\n %s", data);
+ sGnssConfigurationInterface->configuration_update(
+ data, env->GetStringUTFLength(config_content));
+ env->ReleaseStringUTFChars(config_content, data);
+}
+
static JNINativeMethod sMethods[] = {
/* name, signature, funcPtr */
{"class_init_native", "()V", (void *)android_location_GpsLocationProvider_class_init_native},
@@ -1479,6 +1510,9 @@ static JNINativeMethod sMethods[] = {
{"native_stop_navigation_message_collection",
"()Z",
(void*) android_location_GpsLocationProvider_stop_navigation_message_collection},
+ {"native_configuration_update",
+ "(Ljava/lang/String;)V",
+ (void*)android_location_GpsLocationProvider_configuration_update},
};
int register_android_server_location_GpsLocationProvider(JNIEnv* env)