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