Search in sources :

Example 1 with TrustAgentComponentInfo

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);
        }
    }
}
Also used : RestrictedPreference(com.android.settingslib.RestrictedPreference) TrustAgentComponentInfo(com.android.settings.TrustAgentUtils.TrustAgentComponentInfo) Intent(android.content.Intent)

Example 2 with TrustAgentComponentInfo

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) TrustAgentComponentInfo(com.android.settings.TrustAgentUtils.TrustAgentComponentInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)

Aggregations

TrustAgentComponentInfo (com.android.settings.TrustAgentUtils.TrustAgentComponentInfo)2 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)1 RestrictedPreference (com.android.settingslib.RestrictedPreference)1 ArrayList (java.util.ArrayList)1