Search in sources :

Example 1 with UserManager

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();
    }
}
Also used : UserManager(android.os.UserManager) Bundle(android.os.Bundle)

Example 2 with UserManager

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();
    }
}
Also used : UserManager(android.os.UserManager) Bundle(android.os.Bundle)

Example 3 with UserManager

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);
        }
    }
}
Also used : UserManager(android.os.UserManager)

Example 4 with UserManager

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);
}
Also used : PackageManager(android.content.pm.PackageManager) UserManager(android.os.UserManager) ApplicationInfo(android.content.pm.ApplicationInfo) UserInfo(android.content.pm.UserInfo)

Example 5 with UserManager

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);
}
Also used : UserManager(android.os.UserManager)

Aggregations

UserManager (android.os.UserManager)587 UserInfo (android.content.pm.UserInfo)209 UserHandle (android.os.UserHandle)83 Context (android.content.Context)75 Intent (android.content.Intent)67 Test (org.junit.Test)60 PackageManager (android.content.pm.PackageManager)59 ComponentName (android.content.ComponentName)54 RemoteException (android.os.RemoteException)54 View (android.view.View)54 ArrayList (java.util.ArrayList)50 DevicePolicyManager (android.app.admin.DevicePolicyManager)37 Preference (android.support.v7.preference.Preference)32 TextView (android.widget.TextView)31 ImageView (android.widget.ImageView)29 IOException (java.io.IOException)29 Bitmap (android.graphics.Bitmap)26 Bundle (android.os.Bundle)25 ShadowUserManager (com.android.settings.testutils.shadow.ShadowUserManager)25 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)24