diff options
author | Soonil Nagarkar <sooniln@google.com> | 2020-01-23 18:06:31 -0800 |
---|---|---|
committer | Soonil Nagarkar <sooniln@google.com> | 2020-01-23 18:06:31 -0800 |
commit | 980ce6a7418dc4fea14dcbe076ad7970557e89c2 (patch) | |
tree | bf3bdf041e4b2d3cdbf1daaab42cd026d4b897a6 /location/java | |
parent | b20cfac061163449e1ba846f94f1164335ed1685 (diff) |
Add DPM API to request location provider enable
DPM can currently control the master location toggle, but cannot
influence the behavior of individual providers. This adds an API for
DPM (or other privileged entities) to request a provider to turn itself
on.
Practically, this is necessary to allow DPM to control network location,
which may be gated by additional consents. This change also renames some
internal location code to make clearer the distinction between provider
enabled and provider allowed: enabled = location on && allowed
Bug: 136219903
Test: CTS tests to be added
Change-Id: I05f03c976428f0f5a8a2cf627a84dc9e2baf3e67
Diffstat (limited to 'location/java')
4 files changed, 48 insertions, 2 deletions
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 687535c3304b..0c5fe787bbbc 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -74,7 +74,7 @@ import java.util.function.Consumer; * still return location results, but the exact location will be obfuscated to a coarse level of * accuracy. */ -@SuppressWarnings({"deprecation", "DeprecatedIsStillUsed"}) +@SuppressWarnings({"deprecation"}) @SystemService(Context.LOCATION_SERVICE) @RequiresFeature(PackageManager.FEATURE_LOCATION) public class LocationManager { diff --git a/location/java/android/location/LocationManagerInternal.java b/location/java/android/location/LocationManagerInternal.java new file mode 100644 index 000000000000..44d9d2372665 --- /dev/null +++ b/location/java/android/location/LocationManagerInternal.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2020 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 android.location; + + +import android.annotation.NonNull; + +/** + * Location manager local system service interface. + * + * @hide Only for use within the system server. + */ +public abstract class LocationManagerInternal { + + /** + * Requests that a provider change its allowed state. A provider may or may not honor this + * request, and if the provider does change its state as a result, that may happen + * asynchronously after some delay. + * + * <p>Setting a provider's state to allowed implies that any consents or terms and conditions + * that may be necessary to allow the provider are agreed to. Setting a providers state to + * disallowed implies that any consents or terms and conditions have their agreement revoked. + * + * @param provider A location provider as listed by {@link LocationManager#getAllProviders()} + * @param allowed Whether the location provider is being requested to allow or disallow + * itself + * @throws IllegalArgumentException if provider is null + */ + public abstract void requestSetProviderAllowed(@NonNull String provider, boolean allowed); +} diff --git a/location/java/com/android/internal/location/ILocationProvider.aidl b/location/java/com/android/internal/location/ILocationProvider.aidl index 4246c6cd1004..b7817ff1e1fc 100644 --- a/location/java/com/android/internal/location/ILocationProvider.aidl +++ b/location/java/com/android/internal/location/ILocationProvider.aidl @@ -37,4 +37,6 @@ interface ILocationProvider { @UnsupportedAppUsage oneway void sendExtraCommand(String command, in Bundle extras); + + oneway void requestSetAllowed(boolean allowed); } diff --git a/location/java/com/android/internal/location/ILocationProviderManager.aidl b/location/java/com/android/internal/location/ILocationProviderManager.aidl index 85e18ba5ec4b..439039148773 100644 --- a/location/java/com/android/internal/location/ILocationProviderManager.aidl +++ b/location/java/com/android/internal/location/ILocationProviderManager.aidl @@ -29,7 +29,7 @@ interface ILocationProviderManager { void onSetAdditionalProviderPackages(in List<String> packageNames); @UnsupportedAppUsage - void onSetEnabled(boolean enabled); + void onSetAllowed(boolean allowed); @UnsupportedAppUsage void onSetProperties(in ProviderProperties properties); |