summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStan Chesnutt <chesnutt@google.com>2013-04-16 02:49:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-04-16 02:49:45 +0000
commitb34b3211e01b0ae946f786b220f73d340159503b (patch)
tree0f04e62fa14fb1719caa12f042edc8e774045dbf
parent4b6d23d7b45f813bee52747b3243ce46ff9edbd0 (diff)
parent1d72d8c33d1ecba5b06a87aa06211477345fd4c5 (diff)
downloadframeworks_base-b34b3211e01b0ae946f786b220f73d340159503b.zip
frameworks_base-b34b3211e01b0ae946f786b220f73d340159503b.tar.gz
frameworks_base-b34b3211e01b0ae946f786b220f73d340159503b.tar.bz2
Merge "Re-introduce single-shot mode, set MS Assist Mode A when in single-shot mode." into jb-mr2-dev
-rw-r--r--services/java/com/android/server/location/GpsLocationProvider.java59
1 files changed, 52 insertions, 7 deletions
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index 1ebff67..8c88cab 100644
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -36,6 +36,7 @@ import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
+import android.location.LocationRequest;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
@@ -262,6 +263,9 @@ public class GpsLocationProvider implements LocationProviderInterface {
// true if we started navigation
private boolean mStarted;
+ // true if single shot request is in progress
+ private boolean mSingleShot;
+
// capabilities of the GPS engine
private int mEngineCapabilities;
@@ -382,7 +386,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
if (action.equals(ALARM_WAKEUP)) {
if (DEBUG) Log.d(TAG, "ALARM_WAKEUP");
- startNavigating();
+ startNavigating(false);
} else if (action.equals(ALARM_TIMEOUT)) {
if (DEBUG) Log.d(TAG, "ALARM_TIMEOUT");
hibernate();
@@ -803,10 +807,22 @@ public class GpsLocationProvider implements LocationProviderInterface {
}
private void handleSetRequest(ProviderRequest request, WorkSource source) {
- if (DEBUG) Log.d(TAG, "setRequest " + request);
+ boolean singleShot = false;
+ // see if the request is for a single update
+ if (request.locationRequests != null && request.locationRequests.size() > 0) {
+ // if any request has zero or more than one updates
+ // requested, then this is not single-shot mode
+ singleShot = true;
+ for (LocationRequest lr : request.locationRequests) {
+ if (lr.getNumUpdates() != 1) {
+ singleShot = false;
+ }
+ }
+ }
+ if (DEBUG) Log.d(TAG, "setRequest " + request);
if (request.reportLocation) {
// update client uids
updateClientUids(source);
@@ -828,7 +844,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
}
} else if (!mStarted) {
// start GPS
- startNavigating();
+ startNavigating(singleShot);
}
} else {
updateClientUids(new WorkSource());
@@ -982,21 +998,44 @@ public class GpsLocationProvider implements LocationProviderInterface {
return false;
}
- private void startNavigating() {
+ private void startNavigating(boolean singleShot) {
if (!mStarted) {
- if (DEBUG) Log.d(TAG, "startNavigating");
+ if (DEBUG) Log.d(TAG, "startNavigating, singleShot is " + singleShot);
mTimeToFirstFix = 0;
mLastFixTime = 0;
mStarted = true;
+ mSingleShot = singleShot;
mPositionMode = GPS_POSITION_MODE_STANDALONE;
if (Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ASSISTED_GPS_ENABLED, 1) != 0) {
- if (hasCapability(GPS_CAPABILITY_MSB)) {
+ if (singleShot && hasCapability(GPS_CAPABILITY_MSA)) {
+ mPositionMode = GPS_POSITION_MODE_MS_ASSISTED;
+ } else if (hasCapability(GPS_CAPABILITY_MSB)) {
mPositionMode = GPS_POSITION_MODE_MS_BASED;
}
}
+ if (DEBUG) {
+ String mode;
+
+ switch(mPositionMode) {
+ case GPS_POSITION_MODE_STANDALONE:
+ mode = "standalone";
+ break;
+ case GPS_POSITION_MODE_MS_ASSISTED:
+ mode = "MS_ASSISTED";
+ break;
+ case GPS_POSITION_MODE_MS_BASED:
+ mode = "MS_BASED";
+ break;
+ default:
+ mode = "unknown";
+ break;
+ }
+ Log.d(TAG, "setting position_mode to " + mode);
+ }
+
int interval = (hasCapability(GPS_CAPABILITY_SCHEDULING) ? mFixInterval : 1000);
if (!native_set_position_mode(mPositionMode, GPS_POSITION_RECURRENCE_PERIODIC,
interval, 0, 0)) {
@@ -1028,6 +1067,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
if (DEBUG) Log.d(TAG, "stopNavigating");
if (mStarted) {
mStarted = false;
+ mSingleShot = false;
native_stop();
mTimeToFirstFix = 0;
mLastFixTime = 0;
@@ -1122,6 +1162,10 @@ public class GpsLocationProvider implements LocationProviderInterface {
}
}
+ if (mSingleShot) {
+ stopNavigating();
+ }
+
if (mStarted && mStatus != LocationProvider.AVAILABLE) {
// we want to time out if we do not receive a fix
// within the time out and we are requesting infrequent fixes
@@ -1283,7 +1327,8 @@ public class GpsLocationProvider implements LocationProviderInterface {
if (DEBUG) Log.d(TAG, "PhoneConstants.APN_REQUEST_STARTED");
// Nothing to do here
} else {
- if (DEBUG) Log.d(TAG, "startUsingNetworkFeature failed");
+ if (DEBUG) Log.d(TAG, "startUsingNetworkFeature failed, value is " +
+ result);
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
native_agps_data_conn_failed();
}