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

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

Merge "Package manager changes to store and update user information."

parents 37e344cb 4b2e9349
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.app;

import com.android.internal.app.IUsageStats;
import com.android.internal.os.PkgUsageStats;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -26,17 +29,15 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Debug;
import android.os.RemoteException;
import android.os.Handler;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import com.android.internal.app.IUsageStats;
import com.android.internal.os.PkgUsageStats;

import java.util.ArrayList;
import java.util.HashMap;
@@ -676,7 +677,7 @@ public class ActivityManager {
    public List<RunningServiceInfo> getRunningServices(int maxNum)
            throws SecurityException {
        try {
            return (List<RunningServiceInfo>)ActivityManagerNative.getDefault()
            return ActivityManagerNative.getDefault()
                    .getServices(maxNum, 0);
        } catch (RemoteException e) {
            // System dead, we will be dead too soon!
@@ -1331,4 +1332,17 @@ public class ActivityManager {
            return new HashMap<String, Integer>();
        }
    }

    /**
     * @param userid the user's id. Zero indicates the default user 
     * @hide
     */
    public boolean switchUser(int userid) {
        try {
            return ActivityManagerNative.getDefault().switchUser(userid);
        } catch (RemoteException e) {
            return false;
        }
    }

}
+22 −0
Original line number Diff line number Diff line
@@ -1397,6 +1397,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case SWITCH_USER_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int userid = data.readInt();
            boolean result = switchUser(userid);
            reply.writeNoException();
            reply.writeInt(result ? 1 : 0);
            return true;
        }

        }

        return super.onTransact(code, data, reply, flags);
@@ -3141,5 +3150,18 @@ class ActivityManagerProxy implements IActivityManager
        return result;
    }

    public boolean switchUser(int userid) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(userid);
        mRemote.transact(SWITCH_USER_TRANSACTION, data, reply, 0);
        reply.readException();
        boolean result = reply.readInt() != 0;
        reply.recycle();
        data.recycle();
        return result;
    }

    private IBinder mRemote;
}
+51 −1
Original line number Diff line number Diff line
@@ -33,13 +33,13 @@ import android.content.pm.IPackageMoveObserver;
import android.content.pm.IPackageStatsObserver;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
@@ -1106,6 +1106,56 @@ final class ApplicationPackageManager extends PackageManager {
        return PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
    }

    // Multi-user support

    /**
     * @hide
     */
    @Override
    public UserInfo createUser(String name, int flags) {
        // TODO
        return null;
    }

    /**
     * @hide
     */
    @Override
    public List<UserInfo> getUsers() {
        // TODO:
        // Dummy code, always returns just the primary user
        ArrayList<UserInfo> users = new ArrayList<UserInfo>();
        UserInfo primary = new UserInfo(0, "Root!",
                UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY);
        users.add(primary);
        return users;
    }

    /**
     * @hide
     */
    @Override
    public boolean removeUser(int id) {
        // TODO:
        return false;
    }

    /**
     * @hide
     */
    @Override
    public void updateUserName(int id, String name) {
        // TODO:
    }

    /**
     * @hide
     */
    @Override
    public void updateUserFlags(int id, int flags) {
        // TODO:
    }

    private final ContextImpl mContext;
    private final IPackageManager mPM;

+4 −0
Original line number Diff line number Diff line
@@ -342,6 +342,9 @@ public interface IActivityManager extends IInterface {
    public int startActivitiesInPackage(int uid,
            Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException;

    // Multi-user APIs
    public boolean switchUser(int userid) throws RemoteException;

    /*
     * Private non-Binder interfaces
     */
@@ -557,4 +560,5 @@ public interface IActivityManager extends IInterface {
    int START_ACTIVITIES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+120;
    int START_ACTIVITIES_IN_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+121;
    int ACTIVITY_SLEPT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+122;
    int SWITCH_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+123;
}
+100 −58
Original line number Diff line number Diff line
@@ -2345,4 +2345,46 @@ public abstract class PackageManager {
     */
    public abstract void movePackage(
            String packageName, IPackageMoveObserver observer, int flags);

    /**
     * Creates a user with the specified name and options.
     *
     * @param name the user's name
     * @param flags flags that identify the type of user and other properties.
     * @see UserInfo
     *
     * @return the UserInfo object for the created user, or null if the user could not be created.
     * @hide
     */
    public abstract UserInfo createUser(String name, int flags);

    /**
     * @return the list of users that were created
     * @hide
     */
    public abstract List<UserInfo> getUsers();

    /**
     * @param id the ID of the user, where 0 is the primary user.
     * @hide
     */
    public abstract boolean removeUser(int id);

    /**
     * Updates the user's name.
     *
     * @param id the user's id
     * @param name the new name for the user
     * @hide
     */
    public abstract void updateUserName(int id, String name);

    /**
     * Changes the user's properties specified by the flags.
     *
     * @param id the user's id
     * @param flags the new flags for the user
     * @hide
     */
    public abstract void updateUserFlags(int id, int flags);
}
Loading