Merge change 4786 into donut
* changes: gps: Set SUPL server via hostname rather than IP address.
This commit is contained in:
8
core/jni/android_location_GpsLocationProvider.cpp
Normal file → Executable file
8
core/jni/android_location_GpsLocationProvider.cpp
Normal file → Executable file
@@ -336,13 +336,15 @@ static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* e
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
|
static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
|
||||||
jint type, jint addr, jint port)
|
jint type, jstring hostname, jint port)
|
||||||
{
|
{
|
||||||
if (!sAGpsInterface) {
|
if (!sAGpsInterface) {
|
||||||
sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
|
sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
|
||||||
}
|
}
|
||||||
if (sAGpsInterface) {
|
if (sAGpsInterface) {
|
||||||
sAGpsInterface->set_server(type, addr, port);
|
const char *c_hostname = env->GetStringUTFChars(hostname, NULL);
|
||||||
|
sAGpsInterface->set_server(type, c_hostname, port);
|
||||||
|
env->ReleaseStringUTFChars(hostname, c_hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +367,7 @@ static JNINativeMethod sMethods[] = {
|
|||||||
{"native_agps_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_agps_data_conn_open},
|
{"native_agps_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_agps_data_conn_open},
|
||||||
{"native_agps_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_closed},
|
{"native_agps_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_closed},
|
||||||
{"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
|
{"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
|
||||||
{"native_set_agps_server", "(III)V", (void*)android_location_GpsLocationProvider_set_agps_server},
|
{"native_set_agps_server", "(ILjava/lang/String;I)V", (void*)android_location_GpsLocationProvider_set_agps_server},
|
||||||
};
|
};
|
||||||
|
|
||||||
int register_android_location_GpsLocationProvider(JNIEnv* env)
|
int register_android_location_GpsLocationProvider(JNIEnv* env)
|
||||||
|
|||||||
70
location/java/com/android/internal/location/GpsLocationProvider.java
Normal file → Executable file
70
location/java/com/android/internal/location/GpsLocationProvider.java
Normal file → Executable file
@@ -208,12 +208,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
private GpsNetworkThread mNetworkThread;
|
private GpsNetworkThread mNetworkThread;
|
||||||
private Object mNetworkThreadLock = new Object();
|
private Object mNetworkThreadLock = new Object();
|
||||||
|
|
||||||
private String mSuplHost;
|
|
||||||
private int mSuplPort;
|
|
||||||
private String mC2KHost;
|
|
||||||
private int mC2KPort;
|
|
||||||
private boolean mSetSuplServer;
|
|
||||||
private boolean mSetC2KServer;
|
|
||||||
private String mAGpsApn;
|
private String mAGpsApn;
|
||||||
private int mAGpsDataConnectionState;
|
private int mAGpsDataConnectionState;
|
||||||
private final ConnectivityManager mConnMgr;
|
private final ConnectivityManager mConnMgr;
|
||||||
@@ -355,23 +349,27 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
stream.close();
|
stream.close();
|
||||||
mNtpServer = mProperties.getProperty("NTP_SERVER", null);
|
mNtpServer = mProperties.getProperty("NTP_SERVER", null);
|
||||||
|
|
||||||
mSuplHost = mProperties.getProperty("SUPL_HOST");
|
String host = mProperties.getProperty("SUPL_HOST");
|
||||||
String portString = mProperties.getProperty("SUPL_PORT");
|
String portString = mProperties.getProperty("SUPL_PORT");
|
||||||
if (mSuplHost != null && portString != null) {
|
if (host != null && portString != null) {
|
||||||
try {
|
try {
|
||||||
mSuplPort = Integer.parseInt(portString);
|
int port = Integer.parseInt(portString);
|
||||||
mSetSuplServer = true;
|
native_set_agps_server(AGPS_TYPE_SUPL, host, port);
|
||||||
|
// use MS-Based position mode if SUPL support is enabled
|
||||||
|
mPositionMode = GPS_POSITION_MODE_MS_BASED;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
|
Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mC2KHost = mProperties.getProperty("C2K_HOST");
|
host = mProperties.getProperty("C2K_HOST");
|
||||||
portString = mProperties.getProperty("C2K_PORT");
|
portString = mProperties.getProperty("C2K_PORT");
|
||||||
if (mC2KHost != null && portString != null) {
|
if (host != null && portString != null) {
|
||||||
try {
|
try {
|
||||||
mC2KPort = Integer.parseInt(portString);
|
int port = Integer.parseInt(portString);
|
||||||
mSetC2KServer = true;
|
native_set_agps_server(AGPS_TYPE_C2K, host, port);
|
||||||
|
// use MS-Based position mode if SUPL support is enabled
|
||||||
|
mPositionMode = GPS_POSITION_MODE_MS_BASED;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "unable to parse C2K_PORT: " + portString);
|
Log.e(TAG, "unable to parse C2K_PORT: " + portString);
|
||||||
}
|
}
|
||||||
@@ -386,10 +384,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
* data network (e.g., the Internet), false otherwise.
|
* data network (e.g., the Internet), false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean requiresNetwork() {
|
public boolean requiresNetwork() {
|
||||||
// We want updateNetworkState() to get called when the network state changes
|
return true;
|
||||||
// for XTRA and NTP time injection support.
|
|
||||||
return (mNtpServer != null || native_supports_xtra() ||
|
|
||||||
mSuplHost != null || mC2KHost != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNetworkState(int state) {
|
public void updateNetworkState(int state) {
|
||||||
@@ -989,29 +984,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setAGpsServer(int type, String host, int port) {
|
|
||||||
try {
|
|
||||||
InetAddress inetAddress = InetAddress.getByName(host);
|
|
||||||
if (inetAddress != null) {
|
|
||||||
byte[] addrBytes = inetAddress.getAddress();
|
|
||||||
long addr = 0;
|
|
||||||
for (int i = 0; i < addrBytes.length; i++) {
|
|
||||||
int temp = addrBytes[i];
|
|
||||||
// signed -> unsigned
|
|
||||||
if (temp < 0) temp = 256 + temp;
|
|
||||||
addr = addr * 256 + temp;
|
|
||||||
}
|
|
||||||
// use MS-Based position mode if SUPL support is enabled
|
|
||||||
mPositionMode = GPS_POSITION_MODE_MS_BASED;
|
|
||||||
native_set_agps_server(type, (int)addr, port);
|
|
||||||
}
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
Log.e(TAG, "unknown host for server " + host);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class GpsEventThread extends Thread {
|
private class GpsEventThread extends Thread {
|
||||||
|
|
||||||
public GpsEventThread() {
|
public GpsEventThread() {
|
||||||
@@ -1085,7 +1057,7 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
}
|
}
|
||||||
waitTime = getWaitTime();
|
waitTime = getWaitTime();
|
||||||
} while (!mDone && ((!mXtraDownloadRequested &&
|
} while (!mDone && ((!mXtraDownloadRequested &&
|
||||||
!mTimeInjectRequested && !mSetSuplServer && !mSetC2KServer && waitTime > 0)
|
!mTimeInjectRequested && waitTime > 0)
|
||||||
|| !mNetworkAvailable));
|
|| !mNetworkAvailable));
|
||||||
if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
|
if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
|
||||||
|
|
||||||
@@ -1113,18 +1085,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the AGPS server addresses if we have not yet
|
|
||||||
if (mSetSuplServer) {
|
|
||||||
if (setAGpsServer(AGPS_TYPE_SUPL, mSuplHost, mSuplPort)) {
|
|
||||||
mSetSuplServer = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mSetC2KServer) {
|
|
||||||
if (setAGpsServer(AGPS_TYPE_C2K, mC2KHost, mC2KPort)) {
|
|
||||||
mSetC2KServer = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mXtraDownloadRequested ||
|
if ((mXtraDownloadRequested ||
|
||||||
(mNextXtraTime > 0 && mNextXtraTime <= System.currentTimeMillis()))
|
(mNextXtraTime > 0 && mNextXtraTime <= System.currentTimeMillis()))
|
||||||
&& xtraDownloader != null) {
|
&& xtraDownloader != null) {
|
||||||
@@ -1225,5 +1185,5 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
|
|||||||
private native void native_agps_data_conn_open(String apn);
|
private native void native_agps_data_conn_open(String apn);
|
||||||
private native void native_agps_data_conn_closed();
|
private native void native_agps_data_conn_closed();
|
||||||
private native void native_agps_data_conn_failed();
|
private native void native_agps_data_conn_failed();
|
||||||
private native void native_set_agps_server(int type, int addr, int port);
|
private native void native_set_agps_server(int type, String hostname, int port);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user