Search in sources :

Example 51 with UserInfo

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

the class PackageManagerService method prepareAppDataAfterInstallLIF.

/**
     * Prepare app data for the given app just after it was installed or
     * upgraded. This method carefully only touches users that it's installed
     * for, and it forces a restorecon to handle any seinfo changes.
     * <p>
     * Verifies that directories exist and that ownership and labeling is
     * correct for all installed apps. If there is an ownership mismatch, it
     * will try recovering system apps by wiping data; third-party app data is
     * left intact.
     * <p>
     * <em>Note: To avoid a deadlock, do not call this method with {@code mPackages} lock held</em>
     */
private void prepareAppDataAfterInstallLIF(PackageParser.Package pkg) {
    final PackageSetting ps;
    synchronized (mPackages) {
        ps = mSettings.mPackages.get(pkg.packageName);
        mSettings.writeKernelMappingLPr(ps);
    }
    final UserManager um = mContext.getSystemService(UserManager.class);
    UserManagerInternal umInternal = getUserManagerInternal();
    for (UserInfo user : um.getUsers()) {
        final int flags;
        if (umInternal.isUserUnlockingOrUnlocked(user.id)) {
            flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
        } else if (umInternal.isUserRunning(user.id)) {
            flags = StorageManager.FLAG_STORAGE_DE;
        } else {
            continue;
        }
        if (ps.getInstalled(user.id)) {
            // TODO: when user data is locked, mark that we're still dirty
            prepareAppDataLIF(pkg, user.id, flags);
        }
    }
}
Also used : UserManagerInternal(android.os.UserManagerInternal) UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 52 with UserInfo

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

the class PackageManagerService method userNeedsBadging.

private boolean userNeedsBadging(int userId) {
    int index = mUserNeedsBadging.indexOfKey(userId);
    if (index < 0) {
        final UserInfo userInfo;
        final long token = Binder.clearCallingIdentity();
        try {
            userInfo = sUserManager.getUserInfo(userId);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        final boolean b;
        if (userInfo != null && userInfo.isManagedProfile()) {
            b = true;
        } else {
            b = false;
        }
        mUserNeedsBadging.put(userId, b);
        return b;
    }
    return mUserNeedsBadging.valueAt(index);
}
Also used : UserInfo(android.content.pm.UserInfo)

Example 53 with UserInfo

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

the class BaseSettingsProviderTest method setContext.

@Override
public void setContext(Context context) {
    super.setContext(context);
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    List<UserInfo> users = userManager.getUsers();
    final int userCount = users.size();
    for (int i = 0; i < userCount; i++) {
        UserInfo user = users.get(i);
        if (!user.isPrimary() && !user.isManagedProfile()) {
            mSecondaryUserId = user.id;
            break;
        }
    }
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 54 with UserInfo

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

the class SettingsProvider method dump.

@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    synchronized (mLock) {
        final long identity = Binder.clearCallingIdentity();
        try {
            List<UserInfo> users = mUserManager.getUsers(true);
            final int userCount = users.size();
            for (int i = 0; i < userCount; i++) {
                UserInfo user = users.get(i);
                dumpForUserLocked(user.id, pw);
            }
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
}
Also used : UserInfo(android.content.pm.UserInfo)

Example 55 with UserInfo

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

the class PhoneStatusBarPolicy method updateQuietState.

private void updateQuietState() {
    mManagedProfileInQuietMode = false;
    int currentUserId = ActivityManager.getCurrentUser();
    for (UserInfo ui : mUserManager.getEnabledProfiles(currentUserId)) {
        if (ui.isManagedProfile() && ui.isQuietModeEnabled()) {
            mManagedProfileInQuietMode = true;
            return;
        }
    }
}
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