New Location Manager APIs for Criteria based requests and single shot mode.

Use MS-Assisted mode for single shot GPS fixes if it is supported.

Add finer grained control over accuracy to the android.location.Criteria class
and location criteria logic from LocationManager to LocationManagerService

Change-Id: I156b1f6c6a45d255c87ff917cf3e9726a6d7a75b
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2010-04-01 08:10:09 -07:00
parent 4979601f88
commit 03ca216ac1
13 changed files with 970 additions and 347 deletions

View File

@@ -20,6 +20,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.location.Criteria;
import android.location.ILocationProvider;
import android.location.Location;
import android.net.NetworkInfo;
@@ -97,7 +98,7 @@ public class LocationProviderProxy implements LocationProviderInterface {
if (mCachedAttributes == null) {
try {
mCachedAttributes = new DummyLocationProvider(mName);
mCachedAttributes = new DummyLocationProvider(mName, null);
mCachedAttributes.setRequiresNetwork(provider.requiresNetwork());
mCachedAttributes.setRequiresSatellite(provider.requiresSatellite());
mCachedAttributes.setRequiresCell(provider.requiresCell());
@@ -199,6 +200,39 @@ public class LocationProviderProxy implements LocationProviderInterface {
}
}
public boolean meetsCriteria(Criteria criteria) {
ILocationProvider provider;
synchronized (mServiceConnection) {
provider = mProvider;
}
if (provider != null) {
try {
return provider.meetsCriteria(criteria);
} catch (RemoteException e) {
}
}
// default implementation if we lost connection to the provider
if ((criteria.getAccuracy() != Criteria.NO_REQUIREMENT) &&
(criteria.getAccuracy() < getAccuracy())) {
return false;
}
int criteriaPower = criteria.getPowerRequirement();
if ((criteriaPower != Criteria.NO_REQUIREMENT) &&
(criteriaPower < getPowerRequirement())) {
return false;
}
if (criteria.isAltitudeRequired() && !supportsAltitude()) {
return false;
}
if (criteria.isSpeedRequired() && !supportsSpeed()) {
return false;
}
if (criteria.isBearingRequired() && !supportsBearing()) {
return false;
}
return true;
}
public int getAccuracy() {
if (mCachedAttributes != null) {
return mCachedAttributes.getAccuracy();
@@ -297,6 +331,10 @@ public class LocationProviderProxy implements LocationProviderInterface {
}
}
public boolean requestSingleShotFix() {
return false;
}
public long getMinTime() {
return mMinTime;
}