Small fix to trust agent item in security settings.

Change-Id: Ie3157e0c9c68bbab5ba394f61c12d1bbf075bb06
This commit is contained in:
Ido Ofir
2014-06-12 14:18:23 -07:00
parent 2bd9eeded4
commit 524a63b493

View File

@@ -22,6 +22,7 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@@ -43,6 +44,7 @@ import android.provider.Settings;
import android.security.KeyStore; import android.security.KeyStore;
import android.service.trust.TrustAgentService; import android.service.trust.TrustAgentService;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
@@ -315,27 +317,30 @@ public class SecuritySettings extends RestrictedSettingsFragment
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT, List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
PackageManager.GET_META_DATA); PackageManager.GET_META_DATA);
for (ResolveInfo resolveInfo : resolveInfos) { List<ComponentName> enabledTrustAgents = mLockPatternUtils.getEnabledTrustAgents();
if (resolveInfo.serviceInfo == null) continue; if (enabledTrustAgents != null && !enabledTrustAgents.isEmpty()) {
if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue; for (ResolveInfo resolveInfo : resolveInfos) {
TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo = if (resolveInfo.serviceInfo == null) continue;
TrustAgentUtils.getSettingsComponent(pm, resolveInfo); if (!TrustAgentUtils.checkProvidePermission(resolveInfo, pm)) continue;
if (trustAgentComponentInfo.componentName == null || TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo =
trustAgentComponentInfo.title == null || TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
trustAgentComponentInfo.title == "") continue; if (trustAgentComponentInfo.componentName == null ||
Preference trustAgentPreference = !enabledTrustAgents.contains(trustAgentComponentInfo.componentName) ||
new Preference(securityCategory.getContext()); TextUtils.isEmpty(trustAgentComponentInfo.title)) continue;
trustAgentPreference.setKey(KEY_TRUST_AGENT); Preference trustAgentPreference =
trustAgentPreference.setTitle(trustAgentComponentInfo.title); new Preference(securityCategory.getContext());
trustAgentPreference.setSummary(trustAgentComponentInfo.summary); trustAgentPreference.setKey(KEY_TRUST_AGENT);
// Create intent for this preference. trustAgentPreference.setTitle(trustAgentComponentInfo.title);
Intent intent = new Intent(); trustAgentPreference.setSummary(trustAgentComponentInfo.summary);
intent.setComponent(trustAgentComponentInfo.componentName); // Create intent for this preference.
intent.setAction(Intent.ACTION_MAIN); Intent intent = new Intent();
trustAgentPreference.setIntent(intent); intent.setComponent(trustAgentComponentInfo.componentName);
// Add preference to the settings menu. intent.setAction(Intent.ACTION_MAIN);
securityCategory.addPreference(trustAgentPreference); trustAgentPreference.setIntent(intent);
break; // Only render the first one. // Add preference to the settings menu.
securityCategory.addPreference(trustAgentPreference);
break; // Only render the first one.
}
} }
} }