Work around improper ListView recycling in TrustAgentSettings

Previously, the views for our SwitchPreference would never
be recycled because they weren't present in onCreate, which
broke accessibility events.

Bug: 21837103
Change-Id: I01f40b4e6df6d807b77f985116a57334e4ca4868
diff --git a/res/xml/trust_agent_settings.xml b/res/xml/trust_agent_settings.xml
index e9374f3..2bf71fb 100644
--- a/res/xml/trust_agent_settings.xml
+++ b/res/xml/trust_agent_settings.xml
@@ -16,4 +16,9 @@
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
     android:key="trust_agents"
-    android:title="@string/manage_trust_agents" />
+    android:title="@string/manage_trust_agents">
+
+    <!-- Needed so PreferenceGroupAdapter allows SwitchPreference to be
+         recycled. Removed in onResume -->
+    <SwitchPreference android:key="dummy_preference" />
+</PreferenceScreen>
diff --git a/src/com/android/settings/TrustAgentSettings.java b/src/com/android/settings/TrustAgentSettings.java
index 37a86eb..498ec5b 100644
--- a/src/com/android/settings/TrustAgentSettings.java
+++ b/src/com/android/settings/TrustAgentSettings.java
@@ -79,6 +79,7 @@
 
     public void onResume() {
         super.onResume();
+        removePreference("dummy_preference");
         updateAgents();
     };