diff options
author | Nick Pelly <npelly@google.com> | 2012-08-10 15:47:53 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2012-08-10 17:17:32 -0700 |
commit | 08ca1046fe4f1890f91241f8d082a024ef6cfd93 (patch) | |
tree | da4e378d5fb57beac9ab8bca3f28e0f6da335456 | |
parent | 3914e4b7d12b014f73085cd6e34b6fd69ea26226 (diff) | |
download | frameworks_base-08ca1046fe4f1890f91241f8d082a024ef6cfd93.zip frameworks_base-08ca1046fe4f1890f91241f8d082a024ef6cfd93.tar.gz frameworks_base-08ca1046fe4f1890f91241f8d082a024ef6cfd93.tar.bz2 |
Fix a couple of bugs from the location overhaul.
Marshall LocationRequest array correctly.
Observe reportLocation from FusionEngine.
Actually deliver the setRequest message to fusion engine.
Change-Id: Iff64596fdd42f9fb06e563591dda9fbe0241533a
5 files changed, 13 insertions, 14 deletions
diff --git a/location/java/com/android/internal/location/ProviderRequest.java b/location/java/com/android/internal/location/ProviderRequest.java index 25c51f5..26243e7 100644 --- a/location/java/com/android/internal/location/ProviderRequest.java +++ b/location/java/com/android/internal/location/ProviderRequest.java @@ -39,10 +39,9 @@ public final class ProviderRequest implements Parcelable { * is a high power slow interval request and a * low power fast interval request. */ - public List<LocationRequest> locationRequests = null; + public List<LocationRequest> locationRequests = new ArrayList<LocationRequest>(); - public ProviderRequest() { - } + public ProviderRequest() { } public static final Parcelable.Creator<ProviderRequest> CREATOR = new Parcelable.Creator<ProviderRequest>() { @@ -52,7 +51,6 @@ public final class ProviderRequest implements Parcelable { request.reportLocation = in.readInt() == 1; request.interval = in.readLong(); int count = in.readInt(); - request.locationRequests = new ArrayList<LocationRequest>(count); for (int i = 0; i < count; i++) { request.locationRequests.add(LocationRequest.CREATOR.createFromParcel(in)); } @@ -73,8 +71,10 @@ public final class ProviderRequest implements Parcelable { public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(reportLocation ? 1 : 0); parcel.writeLong(interval); - parcel.writeParcelableArray(locationRequests.toArray( - new LocationRequest[locationRequests.size()]), 0); + parcel.writeInt(locationRequests.size()); + for (LocationRequest request : locationRequests) { + request.writeToParcel(parcel, flags); + } } @Override diff --git a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java index 7487a56..3ff19ca 100644 --- a/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java +++ b/location/lib/java/com/android/location/provider/ProviderRequestUnbundled.java @@ -42,6 +42,9 @@ public final class ProviderRequestUnbundled { return mRequest.interval; } + /** + * Never null. + */ public List<LocationRequest> getLocationRequests() { return mRequest.locationRequests; } diff --git a/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java b/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java index 45f05f3..7918882 100644 --- a/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java +++ b/packages/FusedLocation/src/com/android/location/fused/FusedLocationProvider.java @@ -78,7 +78,7 @@ public class FusedLocationProvider extends LocationProviderBase implements Fusio case MSG_SET_REQUEST: { RequestWrapper wrapper = (RequestWrapper) msg.obj; - mEngine.setRequirements(wrapper.request, wrapper.source); + mEngine.setRequest(wrapper.request, wrapper.source); break; } } @@ -97,7 +97,7 @@ public class FusedLocationProvider extends LocationProviderBase implements Fusio @Override public void onSetRequest(ProviderRequestUnbundled request, WorkSource source) { - mHandler.obtainMessage(MSG_SET_REQUEST, new RequestWrapper(request, source)); + mHandler.obtainMessage(MSG_SET_REQUEST, new RequestWrapper(request, source)).sendToTarget(); } @Override diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java index f4f87a8..38a6091 100644 --- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java +++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java @@ -120,9 +120,9 @@ public class FusionEngine implements LocationListener { } /** Called on mLooper thread */ - public void setRequirements(ProviderRequestUnbundled request, WorkSource source) { + public void setRequest(ProviderRequestUnbundled request, WorkSource source) { mRequest = request; - mEnabled = true; + mEnabled = request.getReportLocation(); updateRequirements(); } diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index a6c3860..e219e8d 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -787,10 +787,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Obs for (UpdateRecord record : records) { LocationRequest locationRequest = record.mRequest; - if (providerRequest.locationRequests == null) { - providerRequest.locationRequests = new ArrayList<LocationRequest>(); - } - providerRequest.locationRequests.add(locationRequest); if (locationRequest.getInterval() < providerRequest.interval) { providerRequest.reportLocation = true; |