use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SecuritySettings method getActiveTrustAgents.
private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(Context context, LockPatternUtils utils, DevicePolicyManager dpm) {
PackageManager pm = context.getPackageManager();
ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT, PackageManager.GET_META_DATA);
List<ComponentName> enabledTrustAgents = utils.getEnabledTrustAgents(MY_USER_ID);
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context, DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
if (enabledTrustAgents != null && !enabledTrustAgents.isEmpty()) {
for (int i = 0; i < resolveInfos.size(); i++) {
ResolveInfo resolveInfo = resolveInfos.get(i);
if (resolveInfo.serviceInfo == null)
continue;
if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm))
continue;
TrustAgentComponentInfo trustAgentComponentInfo = TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
if (trustAgentComponentInfo.componentName == null || !enabledTrustAgents.contains(TrustAgentUtils.getComponentName(resolveInfo)) || TextUtils.isEmpty(trustAgentComponentInfo.title))
continue;
if (admin != null && dpm.getTrustAgentConfiguration(null, TrustAgentUtils.getComponentName(resolveInfo)) == null) {
trustAgentComponentInfo.admin = admin;
}
result.add(trustAgentComponentInfo);
if (ONLY_ONE_TRUST_AGENT)
break;
}
}
return result;
}
use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SecuritySettings method disableIfPasswordQualityManaged.
/*
* Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
* The preference must be a RestrictedPreference.
*/
private void disableIfPasswordQualityManaged(String preferenceKey, int userId) {
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(getActivity(), userId);
if (admin != null && mDPM.getPasswordQuality(admin.component, userId) == DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
final RestrictedPreference pref = (RestrictedPreference) getPreferenceScreen().findPreference(preferenceKey);
pref.setDisabledByAdmin(admin);
}
}
use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictedSettingsFragment method onDataSetChanged.
@Override
protected void onDataSetChanged() {
highlightPreferenceIfNeeded();
if (mAdminSupportDetails != null && isUiRestrictedByOnlyAdmin()) {
final EnforcedAdmin admin = getRestrictionEnforcedAdmin();
ShowAdminSupportDetailsDialog.setAdminSupportDetails(getActivity(), mAdminSupportDetails, admin, false);
setEmptyView(mAdminSupportDetails);
} else if (mEmptyTextView != null) {
setEmptyView(mEmptyTextView);
}
super.onDataSetChanged();
}
use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TrustAgentSettings method updateAgents.
private void updateAgents() {
final Context context = getActivity();
if (mAvailableAgents == null) {
mAvailableAgents = findAvailableTrustAgents();
}
if (mLockPatternUtils == null) {
mLockPatternUtils = new LockPatternUtils(getActivity());
}
loadActiveAgents();
PreferenceGroup category = (PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
category.removeAll();
final EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context, DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
final int count = mAvailableAgents.size();
for (int i = 0; i < count; i++) {
AgentInfo agent = mAvailableAgents.valueAt(i);
final RestrictedSwitchPreference preference = new RestrictedSwitchPreference(getPrefContext());
preference.useAdminDisabledSummary(true);
agent.preference = preference;
preference.setPersistent(false);
preference.setTitle(agent.label);
preference.setIcon(agent.icon);
preference.setPersistent(false);
preference.setOnPreferenceChangeListener(this);
preference.setChecked(mActiveAgents.contains(agent.component));
if (admin != null && mDpm.getTrustAgentConfiguration(null, agent.component) == null) {
preference.setChecked(false);
preference.setDisabledByAdmin(admin);
}
category.addPreference(agent.preference);
}
}
use of com.android.settingslib.RestrictedLockUtils.EnforcedAdmin in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InstalledAppDetails method onClick.
/*
* Method implementing functionality of buttons clicked
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
public void onClick(View v) {
if (mAppEntry == null) {
setIntentAndFinish(true, true);
return;
}
String packageName = mAppEntry.info.packageName;
if (v == mUninstallButton) {
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
stopListeningToPackageRemove();
Activity activity = getActivity();
Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
uninstallDAIntent.putExtra(DeviceAdminAdd.EXTRA_DEVICE_ADMIN_PACKAGE_NAME, mPackageName);
activity.startActivityForResult(uninstallDAIntent, REQUEST_REMOVE_DEVICE_ADMIN);
return;
}
EnforcedAdmin admin = RestrictedLockUtils.checkIfUninstallBlocked(getActivity(), packageName, mUserId);
boolean uninstallBlockedBySystem = mAppsControlDisallowedBySystem || RestrictedLockUtils.hasBaseUserRestriction(getActivity(), packageName, mUserId);
if (admin != null && !uninstallBlockedBySystem) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), admin);
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
// app for this user.
if (mUpdatedSysApp && isSingleUser()) {
showDialogInner(DLG_SPECIAL_DISABLE, 0);
} else {
showDialogInner(DLG_DISABLE, 0);
}
} else {
new DisableChanger(this, mAppEntry.info, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).execute((Object) null);
}
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
uninstallPkg(packageName, true, false);
} else {
uninstallPkg(packageName, false, false);
}
} else if (v == mForceStopButton) {
if (mAppsControlDisallowedAdmin != null && !mAppsControlDisallowedBySystem) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), mAppsControlDisallowedAdmin);
} else {
showDialogInner(DLG_FORCE_STOP, 0);
//forceStopPackage(mAppInfo.packageName);
}
}
}
Aggregations