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;
}
}
}
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);
}
}
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);
}
}
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();
}
}
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);
}
}
}
}
Aggregations