Search in sources :

Example 36 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 37 with EnforcedAdmin

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

the class ConfigureNotificationSettings method setRestrictedIfNotificationFeaturesDisabled.

private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry, CharSequence entryValue, int keyguardNotificationFeatures) {
    EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(mContext, keyguardNotificationFeatures, UserHandle.myUserId());
    if (admin != null && mLockscreen != null) {
        RestrictedDropDownPreference.RestrictedItem item = new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, admin);
        mLockscreen.addRestrictedItem(item);
    }
    if (mProfileChallengeUserId != UserHandle.USER_NULL) {
        EnforcedAdmin profileAdmin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(mContext, keyguardNotificationFeatures, mProfileChallengeUserId);
        if (profileAdmin != null && mLockscreenProfile != null) {
            RestrictedDropDownPreference.RestrictedItem item = new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, profileAdmin);
            mLockscreenProfile.addRestrictedItem(item);
        }
    }
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) RestrictedItem(com.android.settings.RestrictedListPreference.RestrictedItem)

Example 38 with EnforcedAdmin

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

the class AndroidBeam method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(), UserManager.DISALLOW_OUTGOING_BEAM, UserHandle.myUserId());
    final UserManager um = UserManager.get(getActivity());
    mBeamDisallowedByBase = RestrictedLockUtils.hasBaseUserRestriction(getActivity(), UserManager.DISALLOW_OUTGOING_BEAM, UserHandle.myUserId());
    if (!mBeamDisallowedByBase && admin != null) {
        View view = inflater.inflate(R.layout.admin_support_details_empty_view, null);
        ShowAdminSupportDetailsDialog.setAdminSupportDetails(getActivity(), view, admin, false);
        view.setVisibility(View.VISIBLE);
        mBeamDisallowedByOnlyAdmin = true;
        return view;
    }
    mView = inflater.inflate(R.layout.android_beam, container, false);
    return mView;
}
Also used : UserManager(android.os.UserManager) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) View(android.view.View)

Example 39 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 40 with EnforcedAdmin

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

the class DateTimeSettings method initUI.

private void initUI() {
    boolean autoTimeEnabled = getAutoState(Settings.Global.AUTO_TIME);
    boolean autoTimeZoneEnabled = getAutoState(Settings.Global.AUTO_TIME_ZONE);
    mAutoTimePref = (RestrictedSwitchPreference) findPreference(KEY_AUTO_TIME);
    mAutoTimePref.setOnPreferenceChangeListener(this);
    EnforcedAdmin admin = RestrictedLockUtils.checkIfAutoTimeRequired(getActivity());
    mAutoTimePref.setDisabledByAdmin(admin);
    Intent intent = getActivity().getIntent();
    boolean isFirstRun = intent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
    mDummyDate = Calendar.getInstance();
    // If device admin requires auto time device policy manager will set
    // Settings.Global.AUTO_TIME to true. Note that this app listens to that change.
    mAutoTimePref.setChecked(autoTimeEnabled);
    mAutoTimeZonePref = (SwitchPreference) findPreference(KEY_AUTO_TIME_ZONE);
    mAutoTimeZonePref.setOnPreferenceChangeListener(this);
    // TODO: Remove the wifiOnly test when auto-timezone is implemented based on wifi-location.
    if (Utils.isWifiOnly(getActivity()) || isFirstRun) {
        getPreferenceScreen().removePreference(mAutoTimeZonePref);
        autoTimeZoneEnabled = false;
    }
    mAutoTimeZonePref.setChecked(autoTimeZoneEnabled);
    mTimePref = findPreference("time");
    mTime24Pref = findPreference("24 hour");
    mTimeZone = findPreference("timezone");
    mDatePref = findPreference("date");
    if (isFirstRun) {
        getPreferenceScreen().removePreference(mTime24Pref);
    }
    mTimePref.setEnabled(!autoTimeEnabled);
    mDatePref.setEnabled(!autoTimeEnabled);
    mTimeZone.setEnabled(!autoTimeZoneEnabled);
}
Also used : EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) Intent(android.content.Intent)

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