Fix Optional Features Being Required

Bug 4597917

Some features required in Froyo are now optional in GB, but
appeared as required in GB. Fix this by using a set and
placing the latest requirements in the set first.

Change-Id: I0e8ad11bfc3179b8fd312cafdddacaaa2f40a3b5
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index aad97ad..4c5694b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -40,6 +40,8 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 public class FeatureSummaryActivity extends PassFailButtons.ListActivity {
     /**
@@ -74,6 +76,23 @@
             this.required = required;
             this.present = false;
         }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) {
+                return true;
+            } else if (o == null || !(o instanceof Feature)) {
+                return false;
+            } else {
+                Feature feature = (Feature) o;
+                return name.equals(feature.name);
+            }
+        }
+
+        @Override
+        public int hashCode() {
+            return name.hashCode();
+        }
     }
 
     /**
@@ -115,6 +134,15 @@
     };
 
     public static final Feature[] ALL_GINGERBREAD_FEATURES = {
+            // Required features in prior releases that became optional in GB
+            new Feature("android.hardware.bluetooth", false),
+            new Feature("android.hardware.camera", false),
+            new Feature("android.hardware.location.gps", false),
+            new Feature("android.hardware.microphone", false),
+            new Feature("android.hardware.sensor.accelerometer", false),
+            new Feature("android.hardware.sensor.compass", false),
+
+            // New features in GB
             new Feature("android.hardware.audio.low_latency", false),
             new Feature("android.hardware.camera.front", false),
             new Feature("android.hardware.nfc", false),
@@ -151,16 +179,18 @@
         // roll over all known features & check whether device reports them
         boolean present = false;
         int statusIcon;
-        ArrayList<Feature> features = new ArrayList<Feature>();
+        Set<Feature> features = new LinkedHashSet<Feature>();
+
+        // add features from latest to last so that the latest requirements are put in the set first
         int apiVersion = Build.VERSION.SDK_INT;
-        if (apiVersion >= Build.VERSION_CODES.ECLAIR_MR1) {
-            Collections.addAll(features, ALL_ECLAIR_FEATURES);
+        if (apiVersion >= Build.VERSION_CODES.GINGERBREAD) {
+            Collections.addAll(features, ALL_GINGERBREAD_FEATURES);
         }
         if (apiVersion >= Build.VERSION_CODES.FROYO) {
             Collections.addAll(features, ALL_FROYO_FEATURES);
         }
-        if (apiVersion >= Build.VERSION_CODES.GINGERBREAD) {
-            Collections.addAll(features, ALL_GINGERBREAD_FEATURES);
+        if (apiVersion >= Build.VERSION_CODES.ECLAIR_MR1) {
+            Collections.addAll(features, ALL_ECLAIR_FEATURES);
         }
         for (Feature f : features) {
             HashMap<String, Object> row = new HashMap<String, Object>();