Search in sources :

Example 31 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProviderPreference method checkAccountManagementAndSetDisabled.

public void checkAccountManagementAndSetDisabled(int userId) {
    EnforcedAdmin admin = RestrictedLockUtils.checkIfAccountManagementDisabled(getContext(), getAccountType(), userId);
    setDisabledByAdmin(admin);
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 32 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ShowAdminSupportDetailsDialog method onNewIntent.

@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    EnforcedAdmin admin = getAdminDetailsFromIntent(intent);
    if (!mEnforcedAdmin.equals(admin)) {
        mEnforcedAdmin = admin;
        initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
    }
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 33 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ShowAdminSupportDetailsDialog method initializeDialogViews.

private void initializeDialogViews(View root, ComponentName admin, int userId) {
    if (admin != null) {
        if (!RestrictedLockUtils.isAdminInCurrentUserOrProfile(this, admin) || !RestrictedLockUtils.isCurrentUserOrProfile(this, userId)) {
            admin = null;
        } else {
            ActivityInfo ai = null;
            try {
                ai = AppGlobals.getPackageManager().getReceiverInfo(admin, 0, /* flags */
                userId);
            } catch (RemoteException e) {
                Log.w(TAG, "Missing reciever info", e);
            }
            if (ai != null) {
                Drawable icon = ai.loadIcon(getPackageManager());
                Drawable badgedIcon = getPackageManager().getUserBadgedIcon(icon, new UserHandle(userId));
                ((ImageView) root.findViewById(R.id.admin_support_icon)).setImageDrawable(badgedIcon);
            }
        }
    }
    setAdminSupportDetails(this, root, new EnforcedAdmin(admin, userId), true);
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) UserHandle(android.os.UserHandle) Drawable(android.graphics.drawable.Drawable) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) ImageView(android.widget.ImageView) RemoteException(android.os.RemoteException)

Example 34 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DisplaySettings method onResume.

@Override
public void onResume() {
    super.onResume();
    updateState();
    final long currentTimeout = Settings.System.getLong(getActivity().getContentResolver(), SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
    mScreenTimeoutPreference.setValue(String.valueOf(currentTimeout));
    mScreenTimeoutPreference.setOnPreferenceChangeListener(this);
    final DevicePolicyManager dpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (dpm != null) {
        final EnforcedAdmin admin = RestrictedLockUtils.checkIfMaximumTimeToLockIsSet(getActivity());
        final long maxTimeout = dpm.getMaximumTimeToLockForUserAndProfiles(UserHandle.myUserId());
        mScreenTimeoutPreference.removeUnusableTimeouts(maxTimeout, admin);
    }
    updateTimeoutPreferenceDescription(currentTimeout);
    disablePreferenceIfManaged(KEY_WALLPAPER, UserManager.DISALLOW_SET_WALLPAPER);
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Example 35 with EnforcedAdmin

use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LocationSettings method onModeChanged.

@Override
public void onModeChanged(int mode, boolean restricted) {
    int modeDescription = getLocationString(mode);
    if (modeDescription != 0) {
        mLocationMode.setSummary(modeDescription);
    }
    // Restricted user can't change the location mode, so disable the master switch. But in some
    // corner cases, the location might still be enabled. In such case the master switch should
    // be disabled but checked.
    final boolean enabled = (mode != android.provider.Settings.Secure.LOCATION_MODE_OFF);
    EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(), UserManager.DISALLOW_SHARE_LOCATION, UserHandle.myUserId());
    boolean hasBaseUserRestriction = RestrictedLockUtils.hasBaseUserRestriction(getActivity(), UserManager.DISALLOW_SHARE_LOCATION, UserHandle.myUserId());
    // only, it would be re-enabled again if the switch bar is not disabled.
    if (!hasBaseUserRestriction && admin != null) {
        mSwitchBar.setDisabledByAdmin(admin);
    } else {
        mSwitchBar.setEnabled(!restricted);
    }
    mLocationMode.setEnabled(enabled && !restricted);
    mCategoryRecentLocationRequests.setEnabled(enabled);
    if (enabled != mSwitch.isChecked()) {
        // set listener to null so that that code below doesn't trigger onCheckedChanged()
        if (mValidListener) {
            mSwitchBar.removeOnSwitchChangeListener(this);
        }
        mSwitch.setChecked(enabled);
        if (mValidListener) {
            mSwitchBar.addOnSwitchChangeListener(this);
        }
    }
    changeManagedProfileLocationAccessStatus(enabled);
    // As a safety measure, also reloads on location mode change to ensure the settings are
    // up-to-date even if an affected app doesn't send the setting changed broadcast.
    injector.reloadStatusMessages();
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Aggregations

EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)42 View (android.view.View)5 Context (android.content.Context)4 UserManager (android.os.UserManager)3 RestrictedPreference (com.android.settingslib.RestrictedPreference)3 ComponentName (android.content.ComponentName)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Preference (android.support.v7.preference.Preference)2 TextView (android.widget.TextView)2 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 Activity (android.app.Activity)1 DevicePolicyManager (android.app.admin.DevicePolicyManager)1 ContentResolver (android.content.ContentResolver)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1 ConnectivityManager (android.net.ConnectivityManager)1 Bundle (android.os.Bundle)1