Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61421099 authored by Soonil Nagarkar's avatar Soonil Nagarkar Committed by Android (Google) Code Review
Browse files

Merge "Add DPM API to request location provider enable"

parents b320cbcc 980ce6a7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6919,6 +6919,7 @@ package android.app.admin {
    method public boolean removeOverrideApn(@NonNull android.content.ComponentName, int);
    method public boolean removeUser(@NonNull android.content.ComponentName, @NonNull android.os.UserHandle);
    method public boolean requestBugreport(@NonNull android.content.ComponentName);
    method public void requestSetLocationProviderAllowed(@NonNull android.content.ComponentName, @NonNull String, boolean);
    method @Deprecated public boolean resetPassword(String, int);
    method public boolean resetPasswordWithToken(@NonNull android.content.ComponentName, String, byte[], int);
    method @Nullable public java.util.List<android.app.admin.NetworkEvent> retrieveNetworkLogs(@Nullable android.content.ComponentName, long);
+43 −0
Original line number Diff line number Diff line
@@ -8854,6 +8854,49 @@ public class DevicePolicyManager {
        }
    }
    /**
     * Called by device owners to request a location provider to change its allowed state. For a
     * provider to be enabled requires both that the master location setting is enabled, and that
     * the provider itself is allowed. Most location providers are always allowed. Some location
     * providers may have user consents or terms and conditions that must be accepted, or some other
     * type of blocker before they are allowed however. Every location provider is responsible for
     * its own allowed state.
     *
     * <p>This method requests that a location provider change its allowed state. For providers that
     * are always allowed and have no state to change, this will have no effect. If the provider
     * does require some consent, terms and conditions, or other blocking state, using this API
     * implies that the device owner is agreeing/disagreeing to any consents, terms and conditions,
     * etc, and the provider should make a best effort to adjust it's allowed state accordingly.
     *
     * <p>Location providers are generally only responsible for the current user, and callers must
     * assume that this method will only affect provider state for the current user. Callers are
     * responsible for tracking current user changes and re-updating provider state as necessary.
     *
     * <p>While providers are expected to make a best effort to honor this request, it is not a
     * given that all providers will support such a request. If a provider does change its state as
     * a result of this request, that may happen asynchronously after some delay. Test location
     * providers set through {@link android.location.LocationManager#addTestProvider} will respond
     * to this request to aide in testing.
     *
     * @param admin          Which {@link DeviceAdminReceiver} this request is associated with
     * @param provider       A location provider as listed by
     *                       {@link android.location.LocationManager#getAllProviders()}
     * @param providerAllowed Whether the location provider is being requested to enable or disable
     *                       itself
     * @throws SecurityException if {@code admin} is not a device owner.
     */
    public void requestSetLocationProviderAllowed(@NonNull ComponentName admin,
            @NonNull String provider, boolean providerAllowed) {
        throwIfParentInstance("requestSetLocationProviderAllowed");
        if (mService != null) {
            try {
                mService.requestSetLocationProviderAllowed(admin, provider, providerAllowed);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
    /**
     * Called by profile or device owners to update {@link android.provider.Settings.Secure}
     * settings. Validation that the value of the setting is in the correct form for the setting
+1 −0
Original line number Diff line number Diff line
@@ -270,6 +270,7 @@ interface IDevicePolicyManager {
    boolean isLockdownAdminConfiguredNetworks(in ComponentName who);

    void setLocationEnabled(in ComponentName who, boolean locationEnabled);
    void requestSetLocationProviderAllowed(in ComponentName who, in String provider, boolean providerAllowed);

    boolean setTime(in ComponentName who, long millis);
    boolean setTimeZone(in ComponentName who, String timeZone);
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+44 −0
Original line number Diff line number Diff line
/*
 * 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);
}
Loading