diff options
| author | 2014-09-23 18:54:02 +0000 | |
|---|---|---|
| committer | 2014-09-23 18:54:03 +0000 | |
| commit | 23e79fcef98618fc049af55673b43ea9e70ffa9b (patch) | |
| tree | 34674b1da4d2a15ffa734b1d257411002f64309e | |
| parent | 5e418a6692e4796a68eb83a759d5d61f2d1f5f77 (diff) | |
| parent | 678c13c02a7a9c48766d45166c9756fb3b404bb9 (diff) | |
Merge "Better detection for SIM information readyness. 1) listen to SUBINFO broadcast intent to better capture SIM info update. 2) notify HAL about SUPL server/host everytime they get set." into lmp-dev
| -rw-r--r-- | services/core/java/com/android/server/location/GpsLocationProvider.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/location/GpsLocationProvider.java b/services/core/java/com/android/server/location/GpsLocationProvider.java index f1c5a6c934e4..0198e46b786e 100644 --- a/services/core/java/com/android/server/location/GpsLocationProvider.java +++ b/services/core/java/com/android/server/location/GpsLocationProvider.java @@ -25,6 +25,7 @@ import com.android.internal.location.ProviderRequest; import com.android.internal.R; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; +import com.android.internal.telephony.TelephonyIntents; import android.app.AlarmManager; import android.app.AppOpsManager; @@ -227,6 +228,11 @@ public class GpsLocationProvider implements LocationProviderInterface { private static final int GPS_GEOFENCE_ERROR_INVALID_TRANSITION = -103; private static final int GPS_GEOFENCE_ERROR_GENERIC = -149; + // TCP/IP constants. + // Valid TCP/UDP port range is (0, 65535]. + private static final int TCP_MIN_PORT = 0; + private static final int TCP_MAX_PORT = 0xffff; + // Value of batterySaverGpsMode such that GPS isn't affected by battery saver mode. private static final int BATTERY_SAVER_MODE_NO_CHANGE = 0; // Value of batterySaverGpsMode such that GPS is disabled when battery saver mode @@ -332,7 +338,7 @@ public class GpsLocationProvider implements LocationProviderInterface { // properties loaded from PROPERTIES_FILE private Properties mProperties; private String mSuplServerHost; - private int mSuplServerPort; + private int mSuplServerPort = TCP_MIN_PORT; private String mC2KServerHost; private int mC2KServerPort; private boolean mSuplEsEnabled = false; @@ -487,7 +493,10 @@ 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)) { + } else if (action.equals(SIM_STATE_CHANGED) + || action.equals(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE) + || action.equals(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED)) { + Log.d(TAG, "received SIM realted action: " + action); TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); String mccMnc = phone.getSimOperator(); @@ -497,6 +506,8 @@ public class GpsLocationProvider implements LocationProviderInterface { reloadGpsProperties(context, mProperties); mNIHandler.setSuplEsEnabled(mSuplEsEnabled); } + } else { + Log.d(TAG, "SIM MCC/MNC is still not available"); } } } @@ -709,6 +720,10 @@ public class GpsLocationProvider implements LocationProviderInterface { intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(SIM_STATE_CHANGED); + // TODO: remove the use TelephonyIntents. We are using it because SIM_STATE_CHANGED + // is not reliable at the moment. + intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE); + intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED); mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler); } @@ -921,6 +936,11 @@ public class GpsLocationProvider implements LocationProviderInterface { Log.e(TAG, "unable to parse SUPL_PORT: " + portString); } } + if (mSuplServerHost != null + && mSuplServerPort > TCP_MIN_PORT + && mSuplServerPort <= TCP_MAX_PORT) { + native_set_agps_server(AGPS_TYPE_SUPL, mSuplServerHost, mSuplServerPort); + } } /** @@ -963,6 +983,8 @@ public class GpsLocationProvider implements LocationProviderInterface { if (enabled) { mSupportsXtra = native_supports_xtra(); + + // TODO: remove the following native calls if we can make sure they are redundant. if (mSuplServerHost != null) { native_set_agps_server(AGPS_TYPE_SUPL, mSuplServerHost, mSuplServerPort); } |