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

Commit 5af368b6 authored by Vitor Carvalho's avatar Vitor Carvalho Committed by Android (Google) Code Review
Browse files

Merge "Enable the SupervisionManager#isSupervisionEnabled API behing a new flag." into main

parents 77f8ec25 183aee9b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2938,6 +2938,14 @@ package android.app.smartspace.uitemplatedata {
}
package android.app.supervision {
  @FlaggedApi("android.app.supervision.flags.supervision_manager_apis") public class SupervisionManager {
    method @FlaggedApi("android.app.supervision.flags.supervision_manager_apis") @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isSupervisionEnabled();
  }
}
package android.app.time {
  public final class Capabilities {
@@ -3801,6 +3809,7 @@ package android.content {
    field public static final String SHARED_CONNECTIVITY_SERVICE = "shared_connectivity";
    field public static final String SMARTSPACE_SERVICE = "smartspace";
    field public static final String STATS_MANAGER = "stats";
    field @FlaggedApi("android.app.supervision.flags.supervision_manager_apis") public static final String SUPERVISION_SERVICE = "supervision";
    field public static final String SYSTEM_CONFIG_SERVICE = "system_config";
    field public static final String SYSTEM_UPDATE_SERVICE = "system_update";
    field @FlaggedApi("com.android.net.thread.platform.flags.thread_enabled_platform") public static final String THREAD_NETWORK_SERVICE = "thread_network";
+8 −0
Original line number Diff line number Diff line
@@ -850,6 +850,14 @@ package android.app.prediction {

}

package android.app.supervision {

  @FlaggedApi("android.app.supervision.flags.supervision_manager_apis") public class SupervisionManager {
    method public void setSupervisionEnabled(boolean);
  }

}

package android.app.usage {

  public class StorageStatsManager {
+22 −16
Original line number Diff line number Diff line
@@ -16,11 +16,19 @@

package android.app.supervision;

import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.MANAGE_USERS;
import static android.Manifest.permission.QUERY_USERS;

import android.annotation.FlaggedApi;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserHandleAware;
import android.annotation.UserIdInt;
import android.app.supervision.flags.Flags;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.RemoteException;
@@ -31,6 +39,8 @@ import android.os.RemoteException;
 * @hide
 */
@SystemService(Context.SUPERVISION_SERVICE)
@SystemApi
@FlaggedApi(Flags.FLAG_SUPERVISION_MANAGER_APIS)
public class SupervisionManager {
    private final Context mContext;
    @Nullable private final ISupervisionManager mService;
@@ -47,7 +57,8 @@ public class SupervisionManager {
     *
     * @hide
     */
    public static final String ACTION_ENABLE_SUPERVISION = "android.app.action.ENABLE_SUPERVISION";
    public static final String ACTION_ENABLE_SUPERVISION =
            "android.app.supervision.action.ENABLE_SUPERVISION";

    /**
     * Activity action: ask the human user to disable supervision for this user. Only the app that
@@ -62,7 +73,7 @@ public class SupervisionManager {
     * @hide
     */
    public static final String ACTION_DISABLE_SUPERVISION =
            "android.app.action.DISABLE_SUPERVISION";
            "android.app.supervision.action.DISABLE_SUPERVISION";

    /** @hide */
    @UnsupportedAppUsage
@@ -76,7 +87,10 @@ public class SupervisionManager {
     *
     * @hide
     */
    @UserHandleAware
    @SystemApi
    @FlaggedApi(Flags.FLAG_SUPERVISION_MANAGER_APIS)
    @RequiresPermission(anyOf = {MANAGE_USERS, QUERY_USERS})
    @UserHandleAware(requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public boolean isSupervisionEnabled() {
        return isSupervisionEnabledForUser(mContext.getUserId());
    }
@@ -84,14 +98,10 @@ public class SupervisionManager {
    /**
     * Returns whether the device is supervised.
     *
     * <p>The caller must be from the same user as the target or hold the {@link
     * android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
     *
     * @hide
     */
    @RequiresPermission(
            value = android.Manifest.permission.INTERACT_ACROSS_USERS,
            conditional = true)
    @RequiresPermission(anyOf = {MANAGE_USERS, QUERY_USERS})
    @UserHandleAware(requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public boolean isSupervisionEnabledForUser(@UserIdInt int userId) {
        if (mService != null) {
            try {
@@ -108,7 +118,8 @@ public class SupervisionManager {
     *
     * @hide
     */
    @UserHandleAware
    @TestApi
    @UserHandleAware(requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public void setSupervisionEnabled(boolean enabled) {
        setSupervisionEnabledForUser(mContext.getUserId(), enabled);
    }
@@ -116,14 +127,9 @@ public class SupervisionManager {
    /**
     * Sets whether the device is supervised for a given user.
     *
     * <p>The caller must be from the same user as the target or hold the {@link
     * android.Manifest.permission#INTERACT_ACROSS_USERS} permission.
     *
     * @hide
     */
    @RequiresPermission(
            value = android.Manifest.permission.INTERACT_ACROSS_USERS,
            conditional = true)
    @UserHandleAware(requiresPermissionIfNotCaller = INTERACT_ACROSS_USERS)
    public void setSupervisionEnabledForUser(@UserIdInt int userId, boolean enabled) {
        if (mService != null) {
            try {
+8 −0
Original line number Diff line number Diff line
@@ -64,3 +64,11 @@ flag {
  description: "Flag that enables the Supervision pin recovery screen with Supervision settings entry point"
  bug: "390500290"
}

flag {
  name: "supervision_manager_apis"
  is_exported: true
  namespace: "supervision"
  description: "Flag that enables system APIs in Supervision Manager"
  bug: "382034839"
}
+3 −1
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
package android.content;

import static android.app.appfunctions.flags.Flags.FLAG_ENABLE_APP_FUNCTION_MANAGER;
import static android.content.flags.Flags.FLAG_ENABLE_BIND_PACKAGE_ISOLATED_PROCESS;
import static android.app.ondeviceintelligence.flags.Flags.FLAG_ENABLE_ON_DEVICE_INTELLIGENCE_MODULE;
import static android.content.flags.Flags.FLAG_ENABLE_BIND_PACKAGE_ISOLATED_PROCESS;
import static android.security.Flags.FLAG_SECURE_LOCKDOWN;

import android.annotation.AttrRes;
@@ -6858,6 +6858,8 @@ public abstract class Context {
     * @see android.app.supervision.SupervisionManager
     * @hide
     */
    @SystemApi
    @FlaggedApi(android.app.supervision.flags.Flags.FLAG_SUPERVISION_MANAGER_APIS)
    public static final String SUPERVISION_SERVICE = "supervision";

    /**
Loading