Merge "Always clone golden files before editing them." into qt-dev
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppOpsTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppOpsTest.java
new file mode 100644
index 0000000..5c53f20
--- /dev/null
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppOpsTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.appsecurity.cts;
+
+import android.platform.test.annotations.AppModeFull;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test for app ops behaviors.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+@AppModeFull(reason = "No instant specific behaviors")
+public final class AppOpsTest extends BaseHostJUnit4Test {
+
+    @Test
+    public void testBadConfigCannotCauseBootLoop() throws Exception {
+        setAppOpHistoryParameters("mode=HISTORICAL_MODE_ENABLED_ACTIVE,baseIntervalMillis=1000"
+                + ",intervalMultiplier=10");
+        try {
+            createBadHistoricalFile();
+            getDevice().reboot();
+        } finally {
+            deleteHistoricalFiles();
+            setAppOpHistoryParameters(null);
+        }
+    }
+
+    private void setAppOpHistoryParameters(String value) throws Exception {
+        getDevice().executeShellCommand("settings put global appop_history_parameters " + value);
+    }
+
+    private void createBadHistoricalFile() throws Exception {
+        getDevice().executeShellCommand("touch data/system/appops/history/1000.xml");
+    }
+
+    private void deleteHistoricalFiles() throws Exception {
+        getDevice().executeShellCommand("rm -rf data/system/appops/history");
+    }
+}
diff --git a/tests/camera/utils/src/android/hardware/camera2/cts/helpers/StaticMetadata.java b/tests/camera/utils/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
index d622c23..a0b1542 100644
--- a/tests/camera/utils/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
+++ b/tests/camera/utils/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
@@ -389,7 +389,8 @@
                     minExposure, SENSOR_INFO_EXPOSURE_TIME_RANGE_MIN_AT_MOST));
             minExposure = SENSOR_INFO_EXPOSURE_TIME_RANGE_MIN_AT_MOST;
         }
-        if (maxExposure < SENSOR_INFO_EXPOSURE_TIME_RANGE_MAX_AT_LEAST) {
+        if (isHardwareLevelAtLeastFull() &&
+                maxExposure < SENSOR_INFO_EXPOSURE_TIME_RANGE_MAX_AT_LEAST) {
             failKeyCheck(CameraCharacteristics.SENSOR_INFO_EXPOSURE_TIME_RANGE,
                     String.format(
                     "Max value %d is too small, set to minimal legal value %d",