From 1575a04e7bc830a8fc15de34dea6362b10c563eb Mon Sep 17 00:00:00 2001 From: Soonil Nagarkar Date: Wed, 24 Oct 2018 17:54:54 -0700 Subject: Refactor how location providers are managed Put enabled/disabled state under location provider control, and use it to represent whether a location provider may be used, not whether the user has enabled or disabled a location provider. Bug: 118885128 Test: manually Change-Id: I1209c49c13ca8995b223f383ad332322fffc7a96 --- .../internal/location/ILocationProvider.aidl | 21 ++++++------- .../location/ILocationProviderManager.aidl | 34 ++++++++++++++++++++++ .../android/internal/location/ProviderRequest.java | 13 +++++++-- 3 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 location/java/com/android/internal/location/ILocationProviderManager.aidl (limited to 'location/java/com') diff --git a/location/java/com/android/internal/location/ILocationProvider.aidl b/location/java/com/android/internal/location/ILocationProvider.aidl index 39c2d92bf278..71b54fb65ae5 100644 --- a/location/java/com/android/internal/location/ILocationProvider.aidl +++ b/location/java/com/android/internal/location/ILocationProvider.aidl @@ -16,29 +16,26 @@ package com.android.internal.location; -import android.location.Location; -import android.net.NetworkInfo; import android.os.Bundle; import android.os.WorkSource; -import com.android.internal.location.ProviderProperties; +import com.android.internal.location.ILocationProviderManager; import com.android.internal.location.ProviderRequest; /** - * Binder interface for services that implement location providers. - *

Use {@link LocationProviderBase} as a helper to implement this - * interface. + * Binder interface for services that implement location providers. Do not implement this directly, + * extend {@link LocationProviderBase} instead. * @hide */ interface ILocationProvider { - void enable(); - void disable(); - void setRequest(in ProviderRequest request, in WorkSource ws); + oneway void setLocationProviderManager(in ILocationProviderManager manager); - // --- deprecated (but still supported) --- - ProviderProperties getProperties(); + oneway void setRequest(in ProviderRequest request, in WorkSource ws); + + oneway void sendExtraCommand(String command, in Bundle extras); + + // --- deprecated and will be removed the future --- int getStatus(out Bundle extras); long getStatusUpdateTime(); - boolean sendExtraCommand(String command, inout Bundle extras); } diff --git a/location/java/com/android/internal/location/ILocationProviderManager.aidl b/location/java/com/android/internal/location/ILocationProviderManager.aidl new file mode 100644 index 000000000000..b1b8f0c7c3f7 --- /dev/null +++ b/location/java/com/android/internal/location/ILocationProviderManager.aidl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.location; + +import android.location.Location; + +import com.android.internal.location.ProviderProperties; + +/** + * Binder interface for manager of all location providers. + * @hide + */ +interface ILocationProviderManager { + + void onSetEnabled(boolean enabled); + + void onSetProperties(in ProviderProperties properties); + + void onReportLocation(in Location location); +} diff --git a/location/java/com/android/internal/location/ProviderRequest.java b/location/java/com/android/internal/location/ProviderRequest.java index 88919f628638..a45c20d9d09d 100644 --- a/location/java/com/android/internal/location/ProviderRequest.java +++ b/location/java/com/android/internal/location/ProviderRequest.java @@ -16,15 +16,15 @@ package com.android.internal.location; -import java.util.ArrayList; -import java.util.List; - import android.annotation.UnsupportedAppUsage; import android.location.LocationRequest; import android.os.Parcel; import android.os.Parcelable; import android.util.TimeUtils; +import java.util.ArrayList; +import java.util.List; + /** @hide */ public final class ProviderRequest implements Parcelable { /** Location reporting is requested (true) */ @@ -35,6 +35,13 @@ public final class ProviderRequest implements Parcelable { @UnsupportedAppUsage public long interval = Long.MAX_VALUE; + /** + * When this flag is true, providers should ignore all location settings, user consents, power + * restrictions or any other restricting factors and always satisfy this request to the best of + * their ability. This flag should only be used in event of an emergency. + */ + public boolean forceLocation = false; + /** * Whether provider shall make stronger than normal tradeoffs to substantially restrict power * use. -- cgit v1.2.3-59-g8ed1b