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);
}
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);
}
}
}
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;
}
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);
}
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);
}
Aggregations