summaryrefslogtreecommitdiffstats
path: root/location/java
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2009-10-08 15:45:03 -0400
committerMike Lockwood <lockwood@android.com>2009-10-08 17:24:21 -0400
commit03d246779ea65fc2bd10d0b4f32620f45211133a (patch)
treec0bba5558070d24e11c324af60f716f580229703 /location/java
parent9d5b58991ef90e91b3c942c80ae3502ed62d10aa (diff)
downloadframeworks_base-03d246779ea65fc2bd10d0b4f32620f45211133a.zip
frameworks_base-03d246779ea65fc2bd10d0b4f32620f45211133a.tar.gz
frameworks_base-03d246779ea65fc2bd10d0b4f32620f45211133a.tar.bz2
GPS: Fix problem with SUPL when SUPL APN is already active.
Use ConnectivityManager.CONNECTIVITY_ACTION broadcast in LocationManagerService to notify GPS when SUPL connection is ready instead of TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED, which is not sent in all cases. Expand LocationProvider.updateNetworkState() to include NetworkInfo object. Fixes bug b/2155661 Change-Id: Iee227ace7d536b36cf7973e3e6a8b7a621ce6565 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/ILocationProvider.aidl3
-rwxr-xr-xlocation/java/com/android/internal/location/GpsLocationProvider.java42
-rw-r--r--location/java/com/android/internal/location/LocationProviderProxy.java5
-rw-r--r--location/java/com/android/internal/location/MockProvider.java3
4 files changed, 28 insertions, 25 deletions
diff --git a/location/java/android/location/ILocationProvider.aidl b/location/java/android/location/ILocationProvider.aidl
index 4fe0494..7da16e4 100644
--- a/location/java/android/location/ILocationProvider.aidl
+++ b/location/java/android/location/ILocationProvider.aidl
@@ -17,6 +17,7 @@
package android.location;
import android.location.Location;
+import android.net.NetworkInfo;
import android.os.Bundle;
/**
@@ -41,7 +42,7 @@ interface ILocationProvider {
long getStatusUpdateTime();
void enableLocationTracking(boolean enable);
void setMinTime(long minTime);
- void updateNetworkState(int state);
+ void updateNetworkState(int state, in NetworkInfo info);
void updateLocation(in Location location);
boolean sendExtraCommand(String command, inout Bundle extras);
void addListener(int uid);
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index bfa0671..cd62ed1 100755
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -32,6 +32,7 @@ import android.location.Location;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.net.SntpClient;
import android.os.Bundle;
import android.os.IBinder;
@@ -46,7 +47,6 @@ import android.util.SparseIntArray;
import com.android.internal.app.IBatteryStats;
import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
@@ -303,22 +303,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
} else if (action.equals(ALARM_TIMEOUT)) {
if (DEBUG) Log.d(TAG, "ALARM_TIMEOUT");
hibernate();
- } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
- String state = intent.getStringExtra(Phone.STATE_KEY);
- String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
- String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY);
-
- if (Config.LOGD) {
- Log.d(TAG, "state: " + state + " apnName: " + apnName + " reason: " + reason);
- }
- // FIXME - might not have an APN on CDMA
- if ("CONNECTED".equals(state) && apnName != null && apnName.length() > 0) {
- mAGpsApn = apnName;
- if (mAGpsDataConnectionState == AGPS_DATA_CONNECTION_OPENING) {
- native_agps_data_conn_open(mAGpsApn);
- mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
- }
- }
}
}
};
@@ -343,7 +327,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ALARM_WAKEUP);
intentFilter.addAction(ALARM_TIMEOUT);
- intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
context.registerReceiver(mBroadcastReciever, intentFilter);
mConnMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -391,13 +374,30 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
return true;
}
- public void updateNetworkState(int state) {
+ public void updateNetworkState(int state, NetworkInfo info) {
mNetworkAvailable = (state == LocationProvider.AVAILABLE);
if (Config.LOGD) {
- Log.d(TAG, "updateNetworkState " + (mNetworkAvailable ? "available" : "unavailable"));
+ Log.d(TAG, "updateNetworkState " + (mNetworkAvailable ? "available" : "unavailable")
+ + " info: " + info);
}
-
+
+ if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE_SUPL
+ && mAGpsDataConnectionState == AGPS_DATA_CONNECTION_OPENING) {
+ String apnName = info.getExtraInfo();
+ if (mNetworkAvailable && apnName != null && apnName.length() > 0) {
+ mAGpsApn = apnName;
+ if (DEBUG) Log.d(TAG, "call native_agps_data_conn_open");
+ native_agps_data_conn_open(apnName);
+ mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
+ } else {
+ if (DEBUG) Log.d(TAG, "call native_agps_data_conn_failed");
+ mAGpsApn = null;
+ mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
+ native_agps_data_conn_failed();
+ }
+ }
+
if (mNetworkAvailable && mNetworkThread != null && mEnabled) {
// signal the network thread when the network becomes available
mNetworkThread.signal();
diff --git a/location/java/com/android/internal/location/LocationProviderProxy.java b/location/java/com/android/internal/location/LocationProviderProxy.java
index 4ae424a..89337b3 100644
--- a/location/java/com/android/internal/location/LocationProviderProxy.java
+++ b/location/java/com/android/internal/location/LocationProviderProxy.java
@@ -20,6 +20,7 @@ import android.location.Address;
import android.location.ILocationProvider;
import android.location.Location;
import android.location.LocationManager;
+import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
@@ -217,9 +218,9 @@ public class LocationProviderProxy implements IBinder.DeathRecipient {
}
}
- public void updateNetworkState(int state) {
+ public void updateNetworkState(int state, NetworkInfo info) {
try {
- mProvider.updateNetworkState(state);
+ mProvider.updateNetworkState(state, info);
} catch (RemoteException e) {
Log.e(TAG, "updateNetworkState failed", e);
}
diff --git a/location/java/com/android/internal/location/MockProvider.java b/location/java/com/android/internal/location/MockProvider.java
index e2e0562..2614f82 100644
--- a/location/java/com/android/internal/location/MockProvider.java
+++ b/location/java/com/android/internal/location/MockProvider.java
@@ -20,6 +20,7 @@ import android.location.ILocationManager;
import android.location.ILocationProvider;
import android.location.Location;
import android.location.LocationProvider;
+import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
@@ -169,7 +170,7 @@ public class MockProvider extends ILocationProvider.Stub {
public void setMinTime(long minTime) {
}
- public void updateNetworkState(int state) {
+ public void updateNetworkState(int state, NetworkInfo info) {
}
public void updateLocation(Location location) {