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

Commit b1755d8b authored by Bart Sears's avatar Bart Sears Committed by Android (Google) Code Review
Browse files

Merge "Revert "Added --restricted option for create-user command""

parents b0204d86 9249a909
Loading
Loading
Loading
Loading
+5 −17
Original line number Diff line number Diff line
@@ -22,13 +22,11 @@ import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATIO
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;

import android.accounts.IAccountManager;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.PackageInstallObserver;
import android.content.ComponentName;
import android.content.Context;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.Intent;
@@ -94,7 +92,6 @@ public final class Pm {
    IPackageManager mPm;
    IPackageInstaller mInstaller;
    IUserManager mUm;
    IAccountManager mAm;

    private WeakHashMap<String, Resources> mResourceCache
            = new WeakHashMap<String, Resources>();
@@ -125,10 +122,9 @@ public final class Pm {
        if (args.length < 1) {
            return showUsage();
        }
        mAm = IAccountManager.Stub.asInterface(ServiceManager.getService(Context.ACCOUNT_SERVICE));
        mUm = IUserManager.Stub.asInterface(ServiceManager.getService(Context.USER_SERVICE));
        mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));

        mUm = IUserManager.Stub.asInterface(ServiceManager.getService("user"));
        mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
        if (mPm == null) {
            System.err.println(PM_NOT_RUNNING_ERR);
            return 1;
@@ -1385,8 +1381,6 @@ public final class Pm {
                }
            } else if ("--managed".equals(opt)) {
                flags |= UserInfo.FLAG_MANAGED_PROFILE;
            } else if ("--restricted".equals(opt)) {
                flags |= UserInfo.FLAG_RESTRICTED;
            } else {
                System.err.println("Error: unknown option " + opt);
                showUsage();
@@ -1400,18 +1394,12 @@ public final class Pm {
        }
        name = arg;
        try {
            UserInfo info;
            if ((flags & UserInfo.FLAG_RESTRICTED) != 0) {
                // In non-split user mode, userId can only be SYSTEM
                int parentUserId = userId >= 0 ? userId : UserHandle.USER_SYSTEM;
                info = mUm.createRestrictedProfile(name, parentUserId);
                mAm.addSharedAccountsFromParentUser(userId, parentUserId);
            } else if (userId < 0) {
            UserInfo info = null;
            if (userId < 0) {
                info = mUm.createUser(name, flags);
            } else {
                info = mUm.createProfileForUser(name, flags, userId);
            }

            if (info != null) {
                System.out.println("Success: created user id " + info.id);
                return 1;
@@ -2134,7 +2122,7 @@ public final class Pm {
        System.err.println("       pm get-install-location");
        System.err.println("       pm set-permission-enforced PERMISSION [true|false]");
        System.err.println("       pm trim-caches DESIRED_FREE_SPACE [internal|UUID]");
        System.err.println("       pm create-user [--profileOf USER_ID] [--managed] [--restricted] USER_NAME");
        System.err.println("       pm create-user [--profileOf USER_ID] [--managed] USER_NAME");
        System.err.println("       pm remove-user USER_ID");
        System.err.println("       pm get-max-users");
        System.err.println("");
+9 −15
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.accounts;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.Size;
import android.app.Activity;
@@ -424,7 +423,6 @@ public class AccountManager {
     * @return An array of {@link Account}, one for each account.  Empty
     *     (never null) if no accounts have been added.
     */
    @NonNull
    @RequiresPermission(GET_ACCOUNTS)
    public Account[] getAccounts() {
        try {
@@ -450,7 +448,6 @@ public class AccountManager {
     * @return An array of {@link Account}, one for each account.  Empty
     *     (never null) if no accounts have been added.
     */
    @NonNull
    @RequiresPermission(GET_ACCOUNTS)
    public Account[] getAccountsAsUser(int userId) {
        try {
@@ -469,7 +466,6 @@ public class AccountManager {
     * @param uid the uid of the calling app.
     * @return the accounts that are available to this package and user.
     */
    @NonNull
    public Account[] getAccountsForPackage(String packageName, int uid) {
        try {
            return mService.getAccountsForPackage(packageName, uid, mContext.getOpPackageName());
@@ -487,7 +483,6 @@ public class AccountManager {
     * @return An array of {@link Account}, one per matching account.  Empty
     *     (never null) if no accounts of the specified type have been added.
     */
    @NonNull
    public Account[] getAccountsByTypeForPackage(String type, String packageName) {
        try {
            return mService.getAccountsByTypeForPackage(type, packageName,
@@ -520,14 +515,12 @@ public class AccountManager {
     * @return An array of {@link Account}, one per matching account.  Empty
     *     (never null) if no accounts of the specified type have been added.
     */
    @NonNull
    @RequiresPermission(GET_ACCOUNTS)
    public Account[] getAccountsByType(String type) {
        return getAccountsByTypeAsUser(type, Process.myUserHandle());
    }

    /** @hide Same as {@link #getAccountsByType(String)} but for a specific user. */
    @NonNull
    public Account[] getAccountsByTypeAsUser(String type, UserHandle userHandle) {
        try {
            return mService.getAccountsAsUser(type, userHandle.getIdentifier(),
@@ -1544,22 +1537,23 @@ public class AccountManager {
        }.start();
    }


    /**
     * Adds shared accounts from a parent user to a secondary user. Adding the shared account
     * Adds a shared account from the primary user to a secondary user. Adding the shared account
     * doesn't take effect immediately. When the target user starts up, any pending shared accounts
     * are attempted to be copied to the target user from the primary via calls to the
     * authenticator.
     * @param parentUser parent user
     * @param user target user
     * @param account the account to share
     * @param user the target user
     * @return
     * @hide
     */
    public void addSharedAccountsFromParentUser(UserHandle parentUser, UserHandle user) {
    public boolean addSharedAccount(final Account account, UserHandle user) {
        try {
            mService.addSharedAccountsFromParentUser(parentUser.getIdentifier(),
                    user.getIdentifier());
            boolean val = mService.addSharedAccountAsUser(account, user.getIdentifier());
            return val;
        } catch (RemoteException re) {
            throw new IllegalStateException(re);
            // won't ever happen
            throw new RuntimeException(re);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -74,9 +74,9 @@ interface IAccountManager {
        String authTokenType);

    /* Shared accounts */
    boolean addSharedAccountAsUser(in Account account, int userId);
    Account[] getSharedAccountsAsUser(int userId);
    boolean removeSharedAccountAsUser(in Account account, int userId);
    void addSharedAccountsFromParentUser(int parentUserId, int userId);

    /* Account renaming. */
    void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName);
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ public class Binder implements IBinder {
     * incoming transaction, then its own UserHandle is returned.
     */
    public static final UserHandle getCallingUserHandle() {
        return UserHandle.of(UserHandle.getUserId(getCallingUid()));
        return new UserHandle(UserHandle.getUserId(getCallingUid()));
    }

    /**
+0 −1
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ interface IUserManager {

    UserInfo createUser(in String name, int flags);
    UserInfo createProfileForUser(in String name, int flags, int userHandle);
    UserInfo createRestrictedProfile(String name, int parentUserId);
    void setUserEnabled(int userHandle);
    boolean removeUser(int userHandle);
    void setUserName(int userHandle, String name);
Loading