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

Commit 92668918 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Expose MANAGED_PROVISIONING_DPC_DOWNLOADED via DevicePolicyManager"

parents dbad339f d603ad79
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1085,6 +1085,7 @@ package android.app.admin {
    method public boolean isDeviceManaged();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioningConfigApplied();
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public boolean isDpcDownloaded();
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public boolean isManagedKiosk();
    method public boolean isSecondaryLockscreenEnabled(@NonNull android.os.UserHandle);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public boolean isUnattendedManagedKiosk();
@@ -1097,6 +1098,7 @@ package android.app.admin {
    method @RequiresPermission(android.Manifest.permission.SEND_LOST_MODE_LOCATION_UPDATES) public void sendLostModeLocationUpdate(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
    method @Deprecated @RequiresPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS) public boolean setActiveProfileOwner(@NonNull android.content.ComponentName, String) throws java.lang.IllegalArgumentException;
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void setDeviceProvisioningConfigApplied();
    method @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS) public void setDpcDownloaded(boolean);
    method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_MANAGEMENT_RESOURCES) public void setDrawables(@NonNull java.util.Set<android.app.admin.DevicePolicyDrawableResource>);
    method @Deprecated @RequiresPermission(value=android.Manifest.permission.GRANT_PROFILE_OWNER_DEVICE_IDS_ACCESS, conditional=true) public void setProfileOwnerCanAccessDeviceIds(@NonNull android.content.ComponentName);
    method public void setSecondaryLockscreenEnabled(@NonNull android.content.ComponentName, boolean);
+41 −0
Original line number Diff line number Diff line
@@ -15367,4 +15367,45 @@ public class DevicePolicyManager {
        }
        return ParcelableResource.loadDefaultString(defaultStringLoader);
    }
    /**
     * Returns a boolean for whether the DPC has been downloaded during provisioning.
     *
     * <p>If true is returned, then any attempts to begin setup again should result in factory reset
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS)
    public boolean isDpcDownloaded() {
        throwIfParentInstance("isDpcDownloaded");
        if (mService != null) {
            try {
                return mService.isDpcDownloaded();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return false;
    }
    /**
     * Use to indicate that the DPC has or has not been downloaded during provisioning.
     *
     * @param downloaded {@code true} if the dpc has been downloaded during provisioning. false otherwise.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS)
    public void setDpcDownloaded(boolean downloaded) {
        throwIfParentInstance("setDpcDownloaded");
        if (mService != null) {
            try {
                mService.setDpcDownloaded(downloaded);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -555,6 +555,9 @@ interface IDevicePolicyManager {
    void resetDrawables(in String[] drawableIds);
    ParcelableResource getDrawable(String drawableId, String drawableStyle, String drawableSource);

    boolean isDpcDownloaded();
    void setDpcDownloaded(boolean downloaded);

    void setStrings(in List<DevicePolicyStringResource> strings);
    void resetStrings(in String[] stringIds);
    ParcelableResource getString(String stringId);
+24 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ import static android.net.ConnectivityManager.PROFILE_NETWORK_PREFERENCE_ENTERPR
import static android.net.NetworkCapabilities.NET_ENTERPRISE_ID_1;
import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
import static android.provider.Settings.Secure.MANAGED_PROVISIONING_DPC_DOWNLOADED;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static android.provider.Telephony.Carriers.DPC_URI;
import static android.provider.Telephony.Carriers.ENFORCE_KEY;
@@ -222,6 +223,7 @@ import android.compat.annotation.EnabledSince;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.IIntentReceiver;
@@ -18669,4 +18671,26 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            mContext.sendBroadcastAsUser(intent, user);
        }
    }
    public boolean isDpcDownloaded() {
        Preconditions.checkCallAuthorization(hasCallingOrSelfPermission(
                android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS));
        ContentResolver cr = mContext.getContentResolver();
        return mInjector.binderWithCleanCallingIdentity(() -> Settings.Secure.getIntForUser(
                cr, MANAGED_PROVISIONING_DPC_DOWNLOADED,
                /* def= */ 0, /* userHandle= */ cr.getUserId())
                == 1);
    }
    public void setDpcDownloaded(boolean downloaded) {
        Preconditions.checkCallAuthorization(hasCallingOrSelfPermission(
                android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS));
        int setTo = downloaded ? 1 : 0;
        mInjector.binderWithCleanCallingIdentity(() -> Settings.Secure.putInt(
                mContext.getContentResolver(), MANAGED_PROVISIONING_DPC_DOWNLOADED, setTo));
    }
}