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

Commit 84844597 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Tweaks to user creation intent text and error codes"

parents 7cb25581 37ed8d1c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -29221,6 +29221,8 @@ package android.os {
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
    field public static final int USER_CREATION_FAILED_NO_MORE_USERS = 2; // 0x2
  }
  public abstract class Vibrator {
+2 −0
Original line number Diff line number Diff line
@@ -31122,6 +31122,8 @@ package android.os {
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
    field public static final int USER_CREATION_FAILED_NO_MORE_USERS = 2; // 0x2
  }
  public abstract class Vibrator {
+2 −0
Original line number Diff line number Diff line
@@ -29231,6 +29231,8 @@ package android.os {
    field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
    field public static final java.lang.String ENSURE_VERIFY_APPS = "ensure_verify_apps";
    field public static final java.lang.String KEY_RESTRICTIONS_PENDING = "restrictions_pending";
    field public static final int USER_CREATION_FAILED_NOT_PERMITTED = 1; // 0x1
    field public static final int USER_CREATION_FAILED_NO_MORE_USERS = 2; // 0x2
  }
  public abstract class Vibrator {
+21 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.admin.DevicePolicyManager;
@@ -621,6 +622,20 @@ public class UserManager {
    /** @hide */
    public static final int PIN_VERIFICATION_SUCCESS = -1;

    /**
     * Error result indicating that this user is not allowed to add other users on this device.
     * This is a result code returned from the activity created by the intent
     * {@link #createUserCreationIntent(String, String, String, PersistableBundle)}.
     */
    public static final int USER_CREATION_FAILED_NOT_PERMITTED = Activity.RESULT_FIRST_USER;

    /**
     * Error result indicating that no more users can be created on this device.
     * This is a result code returned from the activity created by the intent
     * {@link #createUserCreationIntent(String, String, String, PersistableBundle)}.
     */
    public static final int USER_CREATION_FAILED_NO_MORE_USERS = Activity.RESULT_FIRST_USER + 1;

    /** @hide */
    public static UserManager get(Context context) {
        return (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -1194,7 +1209,10 @@ public class UserManager {
     * If this device does not support multiple users, null is returned.
     * <p/>
     * The intent should be launched using startActivityForResult and the return result will
     * indicate if the user consented to adding a new user and if the operation succeeded.
     * indicate if the user consented to adding a new user and if the operation succeeded. Any
     * errors in creating the user will be returned in the result code. If the user cancels the
     * request, the return result will be {@link Activity#RESULT_CANCELED}. On success, the
     * result code will be {@link Activity#RESULT_OK}.
     * <p/>
     * The new user is created but not initialized. After switching into the user for the first
     * time, the preferred user name and account information are used by the setup process for that
@@ -1211,6 +1229,8 @@ public class UserManager {
     *                       Handler)}.
     * @return An Intent that can be launched from an Activity or null if creating users is not
     *         supported on this device.
     * @see #USER_CREATION_FAILED_NOT_PERMITTED
     * @see #USER_CREATION_FAILED_NO_MORE_USERS
     */
    public static Intent createUserCreationIntent(@Nullable String userName,
            @Nullable String accountName,
+8 −4
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ public class ConfirmUserCreationActivity extends AlertActivity

        String message = checkUserCreationRequirements();

        if (message == null) {
            finish();
            return;
        }
        final AlertController.AlertParams ap = mAlertParams;
        ap.mMessage = message;
        ap.mPositiveButtonText = getString(android.R.string.ok);
@@ -104,11 +108,11 @@ public class ConfirmUserCreationActivity extends AlertActivity
        mCanProceed = true;
        final String appName = appInfo.loadLabel(getPackageManager()).toString();
        if (cantCreateUser) {
            message = getString(R.string.user_creation_cannot_add, appName);
            mCanProceed = false;
            setResult(UserManager.USER_CREATION_FAILED_NOT_PERMITTED);
            return null;
        } else if (cantCreateAnyMoreUsers) {
            message = getString(R.string.user_creation_cannot_add_any_more, appName);
            mCanProceed = false;
            setResult(UserManager.USER_CREATION_FAILED_NO_MORE_USERS);
            return null;
        } else if (accountExists) {
            message = getString(R.string.user_creation_account_exists, appName, mAccountName);
        } else {
Loading