use of android.os.UserHandle in project android_frameworks_base by ResurrectionRemix.
the class ResolveInfo method loadIcon.
/**
* Retrieve the current graphical icon associated with this resolution. This
* will call back on the given PackageManager to load the icon from
* the application.
*
* @param pm A PackageManager from which the icon can be loaded; usually
* the PackageManager from which you originally retrieved this item.
*
* @return Returns a Drawable containing the resolution's icon. If the
* item does not have an icon, the default activity icon is returned.
*/
public Drawable loadIcon(PackageManager pm) {
Drawable dr = null;
if (resolvePackageName != null && iconResourceId != 0) {
dr = pm.getDrawable(resolvePackageName, iconResourceId, null);
}
ComponentInfo ci = getComponentInfo();
if (dr == null && iconResourceId != 0) {
ApplicationInfo ai = ci.applicationInfo;
dr = pm.getDrawable(ci.packageName, iconResourceId, ai);
}
if (dr != null) {
return pm.getUserBadgedIcon(dr, new UserHandle(UserHandle.myUserId()));
}
return ci.loadIcon(pm);
}
use of android.os.UserHandle in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceAdminSettings method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Object o = l.getAdapter().getItem(position);
DeviceAdminInfo dpi = (DeviceAdminInfo) o;
final UserHandle user = new UserHandle(getUserId(dpi));
final Activity activity = getActivity();
Intent intent = new Intent(activity, DeviceAdminAdd.class);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, dpi.getComponent());
activity.startActivityAsUser(intent, user);
}
use of android.os.UserHandle in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceAdminSettings method onResume.
@Override
public void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
getActivity().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
final ComponentName deviceOwnerComponent = mDPM.getDeviceOwnerComponentOnAnyUser();
mDeviceOwnerPkg = deviceOwnerComponent != null ? deviceOwnerComponent.getPackageName() : null;
mProfileOwnerComponents.clear();
final List<UserHandle> profiles = mUm.getUserProfiles();
final int profilesSize = profiles.size();
for (int i = 0; i < profilesSize; ++i) {
final int profileId = profiles.get(i).getIdentifier();
mProfileOwnerComponents.put(profileId, mDPM.getProfileOwnerAsUser(profileId));
}
updateList();
}
use of android.os.UserHandle in project android_frameworks_base by ResurrectionRemix.
the class UserManagerTest method testGetUserCreationTime.
public void testGetUserCreationTime() throws Exception {
final int primaryUserId = mUserManager.getPrimaryUser().id;
UserInfo profile = createProfileForUser("Managed 1", UserInfo.FLAG_MANAGED_PROFILE, primaryUserId);
assertNotNull(profile);
assertTrue("creationTime must be set when the profile is created", profile.creationTime > 0);
assertEquals(profile.creationTime, mUserManager.getUserCreationTime(new UserHandle(profile.id)));
long ownerCreationTime = mUserManager.getUserInfo(primaryUserId).creationTime;
assertEquals(ownerCreationTime, mUserManager.getUserCreationTime(new UserHandle(primaryUserId)));
try {
int noSuchUserId = 100500;
mUserManager.getUserCreationTime(new UserHandle(noSuchUserId));
fail("SecurityException should be thrown for nonexistent user");
} catch (Exception e) {
assertTrue("SecurityException should be thrown for nonexistent user, but was: " + e, e instanceof SecurityException);
}
UserInfo user = createUser("User 1", 0);
try {
mUserManager.getUserCreationTime(new UserHandle(user.id));
fail("SecurityException should be thrown for other user");
} catch (Exception e) {
assertTrue("SecurityException should be thrown for other user, but was: " + e, e instanceof SecurityException);
}
}
use of android.os.UserHandle in project android_frameworks_base by ResurrectionRemix.
the class UserManagerTest method testRestrictions.
public void testRestrictions() {
UserInfo testUser = createUser("User 1", 0);
mUserManager.setUserRestriction(UserManager.DISALLOW_INSTALL_APPS, true, new UserHandle(testUser.id));
mUserManager.setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, false, new UserHandle(testUser.id));
Bundle stored = mUserManager.getUserRestrictions(new UserHandle(testUser.id));
// Note this will fail if DO already sets those restrictions.
assertEquals(stored.getBoolean(UserManager.DISALLOW_CONFIG_WIFI), false);
assertEquals(stored.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS), false);
assertEquals(stored.getBoolean(UserManager.DISALLOW_INSTALL_APPS), true);
}
Aggregations