Remove trust agents test if platform has none.

Don't test whether trust agents can be enabled
on devices without trust agents.

Bug: 32134433
Bug: 32981842

Test: Install ctsverifier on aosp_angler-userdebug device run cts verifier check test is missing
Test: Install ctsvierifer on bullhead-userdebug device run ctsvierier check test is present.
Change-Id: I6233e28cdc00960be897bdcacb512f3a470a3443
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
index 5585cbc..27a140c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java
@@ -21,6 +21,8 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
 import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
 import android.provider.Settings;
@@ -32,6 +34,8 @@
 import com.android.cts.verifier.DialogTestListActivity;
 import com.android.cts.verifier.R;
 
+import java.util.List;
+
 public class KeyguardDisabledFeaturesActivity extends DialogTestListActivity {
 
     protected DevicePolicyManager mDpm;
@@ -131,11 +135,20 @@
 
     @Override
     protected void setupTests(ArrayTestListAdapter adapter) {
-        setupDisableTrustAgentsTest(adapter);
+        if (hasTrustAgents()) {
+            setupDisableTrustAgentsTest(adapter);
+        }
         setupDisableUnredactedWorkNotification(adapter);
         setupFingerprintTests(adapter);
     }
 
+    private boolean hasTrustAgents() {
+        PackageManager packageManager = getPackageManager();
+        Intent intent = new Intent("android.service.trust.TrustAgentService");
+        List<ResolveInfo> resolveInfos = packageManager.queryIntentServices(intent, 0);
+        return resolveInfos.size() > 0;
+    }
+
     @Override
     protected void clearRemainingState(final DialogTestListItem test) {
         super.clearRemainingState(test);