use of android.os.UserManager in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
UserManager mgr = (UserManager) getSystemService(USER_SERVICE);
Bundle restrictions = mgr.getUserRestrictions();
if (restrictions.keySet().size() > 0) {
setContentView(R.layout.activity_main);
RestrictionsFragment f = (RestrictionsFragment) getFragmentManager().findFragmentById(R.id.contents);
f.showRestrictions(restrictions);
} else {
Toast.makeText(this, R.string.no_restrictions, Toast.LENGTH_LONG).show();
finish();
}
}
use of android.os.UserManager in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
UserManager mgr = (UserManager) getSystemService(USER_SERVICE);
Bundle restrictions = mgr.getApplicationRestrictions(getPackageName());
if (restrictions.keySet().size() > 0) {
setContentView(R.layout.activity_main);
RestrictionsFragment f = (RestrictionsFragment) getFragmentManager().findFragmentById(R.id.contents);
f.showRestrictions(restrictions);
} else {
Toast.makeText(this, R.string.no_restrictions, Toast.LENGTH_LONG).show();
finish();
}
}
use of android.os.UserManager in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerService method switchUser.
private void switchUser(int userId) {
synchronized (mLock) {
if (mCurrentUserId == userId && mInitialized) {
return;
}
// Disconnect from services for the old user.
UserState oldUserState = getUserStateLocked(mCurrentUserId);
oldUserState.onSwitchToAnotherUser();
// Disable the local managers for the old user.
if (oldUserState.mClients.getRegisteredCallbackCount() > 0) {
mMainHandler.obtainMessage(MainHandler.MSG_SEND_CLEARED_STATE_TO_CLIENTS_FOR_USER, oldUserState.mUserId, 0).sendToTarget();
}
// Announce user changes only if more that one exist.
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
final boolean announceNewUser = userManager.getUsers().size() > 1;
// The user changed.
mCurrentUserId = userId;
UserState userState = getCurrentUserStateLocked();
if (userState.mUiAutomationService != null) {
// Switching users disables the UI automation service.
userState.mUiAutomationService.binderDied();
}
readConfigurationForUserStateLocked(userState);
// Even if reading did not yield change, we have to update
// the state since the context in which the current user
// state was used has changed since it was inactive.
onUserStateChangedLocked(userState);
if (announceNewUser) {
// Schedule announcement of the current user if needed.
mMainHandler.sendEmptyMessageDelayed(MainHandler.MSG_ANNOUNCE_NEW_USER_IF_NEEDED, WAIT_FOR_USER_STATE_FULLY_INITIALIZED_MILLIS);
}
}
}
use of android.os.UserManager in project android_frameworks_base by ParanoidAndroid.
the class NetworkPolicyManagerService method updateRulesForRestrictBackgroundLocked.
/**
* Update rules that might be changed by {@link #mRestrictBackground} value.
*/
private void updateRulesForRestrictBackgroundLocked() {
final PackageManager pm = mContext.getPackageManager();
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
// update rules for all installed applications
final List<UserInfo> users = um.getUsers();
final List<ApplicationInfo> apps = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
for (UserInfo user : users) {
for (ApplicationInfo app : apps) {
final int uid = UserHandle.getUid(user.id, app.uid);
updateRulesForUidLocked(uid);
}
}
// limit data usage for some internal system services
updateRulesForUidLocked(android.os.Process.MEDIA_UID);
updateRulesForUidLocked(android.os.Process.DRM_UID);
}
use of android.os.UserManager in project android_frameworks_base by ParanoidAndroid.
the class SettingsHelper method setGpsLocation.
private void setGpsLocation(String value) {
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
return;
}
final String GPS = LocationManager.GPS_PROVIDER;
boolean enabled = GPS.equals(value) || value.startsWith(GPS + ",") || value.endsWith("," + GPS) || value.contains("," + GPS + ",");
Settings.Secure.setLocationProviderEnabled(mContext.getContentResolver(), GPS, enabled);
}
Aggregations