am 348b92bd: Merge change Iee227ace into eclair

Merge commit '348b92bd513087369ac682e29620d7829fa1381b' into eclair-mr2

* commit '348b92bd513087369ac682e29620d7829fa1381b':
  GPS: Fix problem with SUPL when SUPL APN is already active.
This commit is contained in:
Mike Lockwood
2009-10-08 17:32:31 -07:00
committed by Android Git Automerger
7 changed files with 38 additions and 28 deletions

View File

@@ -48,6 +48,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
private ITelephony mPhoneService; private ITelephony mPhoneService;
private String mApnType; private String mApnType;
private String mApnName;
private boolean mEnabled; private boolean mEnabled;
private BroadcastReceiver mStateReceiver; private BroadcastReceiver mStateReceiver;
@@ -139,6 +140,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY); String reason = intent.getStringExtra(Phone.STATE_CHANGE_REASON_KEY);
String apnName = intent.getStringExtra(Phone.DATA_APN_KEY); String apnName = intent.getStringExtra(Phone.DATA_APN_KEY);
String apnTypeList = intent.getStringExtra(Phone.DATA_APN_TYPES_KEY); String apnTypeList = intent.getStringExtra(Phone.DATA_APN_TYPES_KEY);
mApnName = apnName;
boolean unavailable = intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY, boolean unavailable = intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
false); false);
@@ -339,6 +341,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
intent.putExtra(Phone.STATE_KEY, Phone.DataState.CONNECTED.toString()); intent.putExtra(Phone.STATE_KEY, Phone.DataState.CONNECTED.toString());
intent.putExtra(Phone.STATE_CHANGE_REASON_KEY, Phone.REASON_APN_CHANGED); intent.putExtra(Phone.STATE_CHANGE_REASON_KEY, Phone.REASON_APN_CHANGED);
intent.putExtra(Phone.DATA_APN_TYPES_KEY, mApnType); intent.putExtra(Phone.DATA_APN_TYPES_KEY, mApnType);
intent.putExtra(Phone.DATA_APN_KEY, mApnName);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY, mInterfaceName); intent.putExtra(Phone.DATA_IFACE_NAME_KEY, mInterfaceName);
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, false); intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, false);
if (mStateReceiver != null) mStateReceiver.onReceive(mContext, intent); if (mStateReceiver != null) mStateReceiver.onReceive(mContext, intent);

View File

@@ -17,6 +17,7 @@
package android.location; package android.location;
import android.location.Location; import android.location.Location;
import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
/** /**
@@ -41,7 +42,7 @@ interface ILocationProvider {
long getStatusUpdateTime(); long getStatusUpdateTime();
void enableLocationTracking(boolean enable); void enableLocationTracking(boolean enable);
void setMinTime(long minTime); void setMinTime(long minTime);
void updateNetworkState(int state); void updateNetworkState(int state, in NetworkInfo info);
void updateLocation(in Location location); void updateLocation(in Location location);
boolean sendExtraCommand(String command, inout Bundle extras); boolean sendExtraCommand(String command, inout Bundle extras);
void addListener(int uid); void addListener(int uid);

View File

@@ -32,6 +32,7 @@ import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
import android.location.LocationProvider; import android.location.LocationProvider;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.SntpClient; import android.net.SntpClient;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
@@ -46,7 +47,6 @@ import android.util.SparseIntArray;
import com.android.internal.app.IBatteryStats; import com.android.internal.app.IBatteryStats;
import com.android.internal.telephony.Phone; import com.android.internal.telephony.Phone;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.location.GpsNetInitiatedHandler; import com.android.internal.location.GpsNetInitiatedHandler;
import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification; import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
@@ -303,22 +303,6 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
} else if (action.equals(ALARM_TIMEOUT)) { } else if (action.equals(ALARM_TIMEOUT)) {
if (DEBUG) Log.d(TAG, "ALARM_TIMEOUT"); if (DEBUG) Log.d(TAG, "ALARM_TIMEOUT");
hibernate(); 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 intentFilter = new IntentFilter();
intentFilter.addAction(ALARM_WAKEUP); intentFilter.addAction(ALARM_WAKEUP);
intentFilter.addAction(ALARM_TIMEOUT); intentFilter.addAction(ALARM_TIMEOUT);
intentFilter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
context.registerReceiver(mBroadcastReciever, intentFilter); context.registerReceiver(mBroadcastReciever, intentFilter);
mConnMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); mConnMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -391,13 +374,30 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
return true; return true;
} }
public void updateNetworkState(int state) { public void updateNetworkState(int state, NetworkInfo info) {
mNetworkAvailable = (state == LocationProvider.AVAILABLE); mNetworkAvailable = (state == LocationProvider.AVAILABLE);
if (Config.LOGD) { 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) { if (mNetworkAvailable && mNetworkThread != null && mEnabled) {
// signal the network thread when the network becomes available // signal the network thread when the network becomes available
mNetworkThread.signal(); mNetworkThread.signal();

View File

@@ -20,6 +20,7 @@ import android.location.Address;
import android.location.ILocationProvider; import android.location.ILocationProvider;
import android.location.Location; import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; 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 { try {
mProvider.updateNetworkState(state); mProvider.updateNetworkState(state, info);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "updateNetworkState failed", e); Log.e(TAG, "updateNetworkState failed", e);
} }

View File

@@ -20,6 +20,7 @@ import android.location.ILocationManager;
import android.location.ILocationProvider; import android.location.ILocationProvider;
import android.location.Location; import android.location.Location;
import android.location.LocationProvider; import android.location.LocationProvider;
import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
@@ -169,7 +170,7 @@ public class MockProvider extends ILocationProvider.Stub {
public void setMinTime(long minTime) { public void setMinTime(long minTime) {
} }
public void updateNetworkState(int state) { public void updateNetworkState(int state, NetworkInfo info) {
} }
public void updateLocation(Location location) { public void updateLocation(Location location) {

View File

@@ -48,6 +48,7 @@ import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
import android.location.LocationProvider; import android.location.LocationProvider;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Binder; import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
@@ -529,7 +530,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
} }
// notify provider of current network state // notify provider of current network state
proxy.updateNetworkState(mNetworkState); proxy.updateNetworkState(mNetworkState, null);
} }
} }
@@ -1600,13 +1601,15 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
} else { } else {
mNetworkState = LocationProvider.TEMPORARILY_UNAVAILABLE; mNetworkState = LocationProvider.TEMPORARILY_UNAVAILABLE;
} }
NetworkInfo info =
(NetworkInfo)intent.getExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
// Notify location providers of current network state // Notify location providers of current network state
synchronized (mLock) { synchronized (mLock) {
for (int i = mProviders.size() - 1; i >= 0; i--) { for (int i = mProviders.size() - 1; i >= 0; i--) {
LocationProviderProxy provider = mProviders.get(i); LocationProviderProxy provider = mProviders.get(i);
if (provider.requiresNetwork()) { if (provider.requiresNetwork()) {
provider.updateNetworkState(mNetworkState); provider.updateNetworkState(mNetworkState, info);
} }
} }
} }

View File

@@ -22,6 +22,7 @@ import android.location.ILocationManager;
import android.location.ILocationProvider; import android.location.ILocationProvider;
import android.location.Location; import android.location.Location;
import android.location.LocationProvider; import android.location.LocationProvider;
import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemClock; import android.os.SystemClock;
@@ -156,7 +157,7 @@ public class TestLocationProvider extends ILocationProvider.Stub {
public void setMinTime(long minTime) { public void setMinTime(long minTime) {
} }
public void updateNetworkState(int state) { public void updateNetworkState(int state, NetworkInfo info) {
} }
public void updateLocation(Location location) { public void updateLocation(Location location) {