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 UsageStatsService method cleanUpRemovedUsersLocked.
private void cleanUpRemovedUsersLocked() {
final List<UserInfo> users = mUserManager.getUsers(true);
if (users == null || users.size() == 0) {
throw new IllegalStateException("There can't be no users");
}
ArraySet<String> toDelete = new ArraySet<>();
String[] fileNames = mUsageStatsDir.list();
if (fileNames == null) {
// No users to delete.
return;
}
toDelete.addAll(Arrays.asList(fileNames));
final int userCount = users.size();
for (int i = 0; i < userCount; i++) {
final UserInfo userInfo = users.get(i);
toDelete.remove(Integer.toString(userInfo.id));
}
final int deleteCount = toDelete.size();
for (int i = 0; i < deleteCount; i++) {
deleteRecursively(new File(mUsageStatsDir, toDelete.valueAt(i)));
}
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerTest method testRemoveUser.
public void testRemoveUser() throws Exception {
UserInfo userInfo = createUser("Guest 1", UserInfo.FLAG_GUEST);
removeUser(userInfo.id);
assertFalse(findUser(userInfo.id));
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerTest method testGetSerialNumbersOfUsers.
public void testGetSerialNumbersOfUsers() {
UserInfo user1 = createUser("User 1", 0);
UserInfo user2 = createUser("User 2", 0);
long[] serialNumbersOfUsers = mUserManager.getSerialNumbersOfUsers(false);
String errMsg = "Array " + Arrays.toString(serialNumbersOfUsers) + " should contain ";
assertTrue(errMsg + user1.serialNumber, ArrayUtils.contains(serialNumbersOfUsers, user1.serialNumber));
assertTrue(errMsg + user2.serialNumber, ArrayUtils.contains(serialNumbersOfUsers, user2.serialNumber));
}
Aggregations