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

Commit 7e34b391 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add an API in SupervisionManager to create intent for launching the PIN...

Merge "Add an API in SupervisionManager to create intent for launching the PIN verification activity" into main
parents 4520c230 3a86bd81
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -16,11 +16,14 @@

package android.app.supervision;

import android.content.Intent;

/**
 * Internal IPC interface to the supervision service.
 * {@hide}
 */
interface ISupervisionManager {
    Intent createConfirmSupervisionCredentialsIntent();
    boolean isSupervisionEnabledForUser(int userId);
    void setSupervisionEnabledForUser(int userId, boolean enabled);
    String getActiveSupervisionAppPackage(int userId);
+33 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.annotation.UserIdInt;
import android.app.supervision.flags.Flags;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
import android.os.RemoteException;

/**
@@ -82,6 +83,38 @@ public class SupervisionManager {
        mService = service;
    }

    /**
     * Creates an {@link Intent} that can be used with {@link Context#startActivity(Intent)} to
     * launch the activity to verify supervision credentials.
     *
     * <p>A valid {@link Intent} is always returned if supervision is enabled at the time this API
     * is called, the launched activity still need to perform validity checks as the supervision
     * state can change when the activity is launched. A null intent is returned if supervision is
     * disabled at the time of this API call.
     *
     * <p>A result code of {@link android.app.Activity#RESULT_OK} indicates successful verification
     * of the supervision credentials.
     *
     * @hide
     */
    @RequiresPermission(value = android.Manifest.permission.QUERY_USERS)
    @Nullable
    public Intent createConfirmSupervisionCredentialsIntent() {
        if (mService != null) {
            try {
                Intent result = mService.createConfirmSupervisionCredentialsIntent();
                if (result != null) {
                    result.prepareToEnterProcess(
                            Intent.LOCAL_FLAG_FROM_SYSTEM, mContext.getAttributionSource());
                }
                return result;
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return null;
    }

    /**
     * Returns whether the device is supervised.
     *
+19 −0
Original line number Diff line number Diff line
@@ -80,6 +80,25 @@ public class SupervisionService extends ISupervisionManager.Stub {
        mInjector.getUserManagerInternal().addUserLifecycleListener(new UserLifecycleListener());
    }

    /**
     * Creates an {@link Intent} that can be used with {@link Context#startActivity(Intent)} to
     * launch the activity to verify supervision credentials.
     *
     * <p>A valid {@link Intent} is always returned if supervision is enabled at the time this
     * method is called, the launched activity still need to perform validity checks as the
     * supervision state can change when it's launched. A null intent is returned if supervision is
     * disabled at the time of this method call.
     *
     * <p>A result code of {@link android.app.Activity#RESULT_OK} indicates successful verification
     * of the supervision credentials.
     */
    @Override
    @Nullable
    public Intent createConfirmSupervisionCredentialsIntent() {
        // TODO(b/392961554): Implement createAuthenticationIntent API
        throw new UnsupportedOperationException();
    }

    /**
     * Returns whether supervision is enabled for the given user.
     *