Search in sources :

Example 86 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class ActivityTestMain method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, "Referrer: " + getReferrer());
    mAm = getSystemService(ActivityManager.class);
    mPower = getSystemService(PowerManager.class);
    mAlarm = getSystemService(AlarmManager.class);
    if (savedInstanceState != null) {
        mOverrideConfig = savedInstanceState.getParcelable(KEY_CONFIGURATION);
        if (mOverrideConfig != null) {
            applyOverrideConfiguration(mOverrideConfig);
        }
    }
    UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
    List<UserInfo> users = um.getUsers();
    mSecondUser = Integer.MAX_VALUE;
    for (UserInfo ui : users) {
        if (ui.id != 0 && mSecondUser > ui.id) {
            mSecondUser = ui.id;
        }
    }
/*
        AlertDialog ad = new AlertDialog.Builder(this).setTitle("title").setMessage("message").create();
        ad.getWindow().getAttributes().type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
        ad.show();
        */
}
Also used : PowerManager(android.os.PowerManager) UserManager(android.os.UserManager) AlarmManager(android.app.AlarmManager) UserInfo(android.content.pm.UserInfo) ActivityManager(android.app.ActivityManager)

Example 87 with UserInfo

use of android.content.pm.UserInfo in project XobotOS by xamarin.

the class ApplicationPackageManager method getUsers.

/**
     * @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;
}
Also used : ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo)

Example 88 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class ResolverActivity method setProfileSwitchMessageId.

private void setProfileSwitchMessageId(int contentUserHint) {
    if (contentUserHint != UserHandle.USER_CURRENT && contentUserHint != UserHandle.myUserId()) {
        UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
        UserInfo originUserInfo = userManager.getUserInfo(contentUserHint);
        boolean originIsManaged = originUserInfo != null ? originUserInfo.isManagedProfile() : false;
        boolean targetIsManaged = userManager.isManagedProfile();
        if (originIsManaged && !targetIsManaged) {
            mProfileSwitchMessageId = com.android.internal.R.string.forward_intent_to_owner;
        } else if (!originIsManaged && targetIsManaged) {
            mProfileSwitchMessageId = com.android.internal.R.string.forward_intent_to_work;
        }
    }
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 89 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class IntentForwarderActivity method getProfileParent.

/**
     * Returns the userId of the profile parent or UserHandle.USER_NULL if there is
     * no parent.
     */
private int getProfileParent() {
    UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
    UserInfo parent = userManager.getProfileParent(UserHandle.myUserId());
    if (parent == null) {
        Slog.wtf(TAG, FORWARD_INTENT_TO_PARENT + " has been called, but there is no parent");
        return UserHandle.USER_NULL;
    }
    return parent.id;
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 90 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class ConfirmUserCreationActivity method onClick.

@Override
public void onClick(DialogInterface dialog, int which) {
    setResult(RESULT_CANCELED);
    if (which == BUTTON_POSITIVE && mCanProceed) {
        Log.i(TAG, "Ok, creating user");
        UserInfo user = mUserManager.createUser(mUserName, 0);
        if (user == null) {
            Log.e(TAG, "Couldn't create user");
            finish();
            return;
        }
        mUserManager.setSeedAccountData(user.id, mAccountName, mAccountType, mAccountOptions);
        setResult(RESULT_OK);
    }
    finish();
}
Also used : UserInfo(android.content.pm.UserInfo)

Aggregations

UserInfo (android.content.pm.UserInfo)814 UserManager (android.os.UserManager)156 RemoteException (android.os.RemoteException)144 ArrayList (java.util.ArrayList)73 UserHandle (android.os.UserHandle)66 Intent (android.content.Intent)58 IOException (java.io.IOException)52 File (java.io.File)47 Bundle (android.os.Bundle)43 ApplicationInfo (android.content.pm.ApplicationInfo)40 PackageManager (android.content.pm.PackageManager)39 ComponentName (android.content.ComponentName)32 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)31 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)30 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)29 AtomicFile (android.util.AtomicFile)28 PackageInfo (android.content.pm.PackageInfo)26 DevicePolicyManager (android.app.admin.DevicePolicyManager)25 LockPatternUtils (com.android.internal.widget.LockPatternUtils)24 PendingIntent (android.app.PendingIntent)23