Search in sources :

Example 21 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)

Example 22 with UserInfo

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

the class AppWidgetServiceImpl method maskWidgetsViewsLocked.

/**
     * Mask the target widget belonging to the specified provider, or all active widgets
     * of the provider if target widget == null.
     */
private void maskWidgetsViewsLocked(Provider provider, Widget targetWidget) {
    final int widgetCount = provider.widgets.size();
    if (widgetCount == 0) {
        return;
    }
    final String providerPackage = provider.info.provider.getPackageName();
    final int providerUserId = provider.getUserId();
    Bitmap iconBitmap = createMaskedWidgetBitmap(providerPackage, providerUserId);
    if (iconBitmap == null) {
        return;
    }
    final boolean showBadge;
    final Intent onClickIntent;
    final long identity = Binder.clearCallingIdentity();
    try {
        if (provider.maskedBySuspendedPackage) {
            UserInfo userInfo = mUserManager.getUserInfo(providerUserId);
            showBadge = userInfo.isManagedProfile();
            onClickIntent = mDevicePolicyManagerInternal.createPackageSuspendedDialogIntent(providerPackage, providerUserId);
        } else if (provider.maskedByQuietProfile) {
            showBadge = true;
            onClickIntent = UnlaunchableAppActivity.createInQuietModeDialogIntent(providerUserId);
        } else /* provider.maskedByLockedProfile */
        {
            showBadge = true;
            onClickIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, null, providerUserId);
            if (onClickIntent != null) {
                onClickIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            }
        }
        for (int j = 0; j < widgetCount; j++) {
            Widget widget = provider.widgets.get(j);
            if (targetWidget != null && targetWidget != widget)
                continue;
            PendingIntent intent = null;
            if (onClickIntent != null) {
                intent = PendingIntent.getActivity(mContext, widget.appWidgetId, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
            }
            RemoteViews views = createMaskedWidgetRemoteViews(iconBitmap, showBadge, intent);
            if (widget.replaceWithMaskedViewsLocked(views)) {
                scheduleNotifyUpdateAppWidgetLocked(widget, widget.getEffectiveViewsLocked());
            }
        }
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : Bitmap(android.graphics.Bitmap) RemoteViews(android.widget.RemoteViews) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) UserInfo(android.content.pm.UserInfo) PendingIntent(android.app.PendingIntent) Point(android.graphics.Point)

Example 23 with UserInfo

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

the class SettingsProviderTest method testSettingsChangeForOtherUser.

@MediumTest
public void testSettingsChangeForOtherUser() {
    UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
    ContentResolver r = getContext().getContentResolver();
    // Make sure there's an owner
    assertTrue(findUser(um, UserHandle.USER_SYSTEM));
    // create a new user to use for testing
    UserInfo otherUser = um.createUser("TestUser1", UserInfo.FLAG_GUEST);
    assertTrue(otherUser != null);
    try {
        assertNotSame("Current calling user id should not be the new guest user", otherUser.id, UserHandle.getCallingUserId());
        final String testKey = "testSettingsChangeForOtherUser";
        final String testValue1 = "value1";
        final String testValue2 = "value2";
        Settings.Secure.putString(r, testKey, testValue1);
        Settings.Secure.putStringForUser(r, testKey, testValue2, otherUser.id);
        assertEquals(testValue1, Settings.Secure.getString(r, testKey));
        assertEquals(testValue2, Settings.Secure.getStringForUser(r, testKey, otherUser.id));
        assertNotSame("Current calling user id should not be the new guest user", otherUser.id, UserHandle.getCallingUserId());
    } finally {
        // Tidy up
        um.removeUser(otherUser.id);
    }
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo) ContentResolver(android.content.ContentResolver) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 24 with UserInfo

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

the class AccountManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        fout.println("Permission Denial: can't dump AccountsManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " without permission " + android.Manifest.permission.DUMP);
        return;
    }
    final boolean isCheckinRequest = scanArgs(args, "--checkin") || scanArgs(args, "-c");
    final IndentingPrintWriter ipw = new IndentingPrintWriter(fout, "  ");
    final List<UserInfo> users = getUserManager().getUsers();
    for (UserInfo user : users) {
        ipw.println("User " + user + ":");
        ipw.increaseIndent();
        dumpUser(getUserAccounts(user.id), fd, ipw, args, isCheckinRequest);
        ipw.println();
        ipw.decreaseIndent();
    }
}
Also used : UserInfo(android.content.pm.UserInfo) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 25 with UserInfo

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

the class MountService method initIfReadyAndConnected.

private void initIfReadyAndConnected() {
    Slog.d(TAG, "Thinking about init, mSystemReady=" + mSystemReady + ", mDaemonConnected=" + mDaemonConnected);
    if (mSystemReady && mDaemonConnected && !StorageManager.isFileEncryptedNativeOnly()) {
        // When booting a device without native support, make sure that our
        // user directories are locked or unlocked based on the current
        // emulation status.
        final boolean initLocked = StorageManager.isFileEncryptedEmulatedOnly();
        Slog.d(TAG, "Setting up emulation state, initlocked=" + initLocked);
        final List<UserInfo> users = mContext.getSystemService(UserManager.class).getUsers();
        for (UserInfo user : users) {
            try {
                if (initLocked) {
                    mCryptConnector.execute("cryptfs", "lock_user_key", user.id);
                } else {
                    mCryptConnector.execute("cryptfs", "unlock_user_key", user.id, user.serialNumber, "!", "!");
                }
            } catch (NativeDaemonConnectorException e) {
                Slog.w(TAG, "Failed to init vold", e);
            }
        }
    }
}
Also used : UserManager(android.os.UserManager) 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