use of com.android.settings.TrustAgentUtils.TrustAgentComponentInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SecuritySettings method addTrustAgentSettings.
private void addTrustAgentSettings(PreferenceGroup securityCategory) {
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
ArrayList<TrustAgentComponentInfo> agents = getActiveTrustAgents(getActivity(), mLockPatternUtils, mDPM);
for (int i = 0; i < agents.size(); i++) {
final TrustAgentComponentInfo agent = agents.get(i);
RestrictedPreference trustAgentPreference = new RestrictedPreference(securityCategory.getContext());
trustAgentPreference.setKey(KEY_TRUST_AGENT);
trustAgentPreference.setTitle(agent.title);
trustAgentPreference.setSummary(agent.summary);
// Create intent for this preference.
Intent intent = new Intent();
intent.setComponent(agent.componentName);
intent.setAction(Intent.ACTION_MAIN);
trustAgentPreference.setIntent(intent);
// Add preference to the settings menu.
securityCategory.addPreference(trustAgentPreference);
trustAgentPreference.setDisabledByAdmin(agent.admin);
if (!trustAgentPreference.isDisabledByAdmin() && !hasSecurity) {
trustAgentPreference.setEnabled(false);
trustAgentPreference.setSummary(R.string.disabled_because_no_backup_security);
}
}
}
use of com.android.settings.TrustAgentUtils.TrustAgentComponentInfo 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;
}
Aggregations