Merge "Add limits on BlobHandle label and lease expiry strings." into rvc-dev
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
index 40d8ff4..03746fe 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
@@ -713,6 +713,7 @@
 
         final Uri rootsUri = DocumentsContract.buildRootsUri(PROVIDER_PACKAGE);
         final Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setPackage(getDocumentsUiPackageId());
         intent.setDataAndType(rootsUri, "vnd.android.document/root");
         mActivity.startActivity(intent);
         mDevice.waitForIdle();
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/TouchExplorerTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/TouchExplorerTest.java
index 56d5240..80a3054 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/TouchExplorerTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/TouchExplorerTest.java
@@ -291,28 +291,6 @@
     }
 
     /**
-     * Test the case where we want to long click on the item that has accessibility focus. Note that
-     * this test does not request that double tap and hold be dispatched to the accessibility
-     * service, meaning that it will be handled by the framework and the view will be long clicked.
-     */
-    @Test
-    @AppModeFull
-    public void testDoubleTapAndHoldAccessibilityFocus_performsLongClick() {
-        if (!mHasTouchscreen || !mScreenBigEnough) return;
-        syncAccessibilityFocusToInputFocus();
-        dispatch(doubleTapAndHold(mTapLocation));
-        mHoverListener.assertNonePropagated();
-        // The click should not be delivered via touch events in this case.
-        mTouchListener.assertNonePropagated();
-        mService.assertPropagated(
-                TYPE_VIEW_ACCESSIBILITY_FOCUSED,
-                TYPE_TOUCH_INTERACTION_START,
-                TYPE_VIEW_LONG_CLICKED,
-                TYPE_TOUCH_INTERACTION_END);
-        mLongClickListener.assertLongClicked(mView);
-    }
-
-    /**
      * Test the case where we double tap and hold but there is no accessibility focus. Nothing
      * should happen.
      */
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java
index e303321..036e744 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/DatasetFilteringInlineTest.java
@@ -22,11 +22,19 @@
 import android.autofillservice.cts.DatasetFilteringTest;
 import android.autofillservice.cts.Helper;
 
+import org.junit.rules.TestRule;
+
 public class DatasetFilteringInlineTest extends DatasetFilteringTest {
     public DatasetFilteringInlineTest() {
         super(getInlineUiBot());
     }
 
+
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Override
     protected boolean isInlineMode() {
         return true;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java
index d645834..332c645 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAugmentedLoginActivityTest.java
@@ -43,6 +43,7 @@
 import android.widget.EditText;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 import java.util.List;
 
@@ -66,6 +67,11 @@
         };
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testAugmentedAutoFill_oneDatasetThenFilled() throws Exception {
         // Set services
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java
index 43c2abc..5c63891 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineAuthenticationTest.java
@@ -38,6 +38,7 @@
 import android.platform.test.annotations.AppModeFull;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 import java.util.regex.Pattern;
 
@@ -61,6 +62,11 @@
         Helper.enableAutofillService(getContext(), SERVICE_NAME);
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testDatasetAuthTwoFields() throws Exception {
         datasetAuthTwoFields(/* cancelFirstAttempt */ false);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java
index feba57c..595b7ea 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFillEventHistoryTest.java
@@ -39,6 +39,7 @@
 import android.support.test.uiautomator.UiObject2;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 import java.util.List;
 
@@ -62,6 +63,11 @@
         Helper.enableAutofillService(getContext(), SERVICE_NAME);
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testOneDatasetAndSave() throws Exception {
         enableService();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java
index e9675b1..c761d02 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineFilteringTest.java
@@ -26,6 +26,7 @@
 import android.autofillservice.cts.Helper;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 // TODO: Move any tests needed from here into DatasetFilteringInlineTest.
 /**
@@ -45,6 +46,11 @@
         Helper.enableAutofillService(getContext(), SERVICE_NAME);
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testFiltering_filtersByPrefix() throws Exception {
         enableService();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
index eff7b97..6aff0d5 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginActivityTest.java
@@ -48,6 +48,7 @@
 import com.android.cts.mockime.MockImeSession;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 public class InlineLoginActivityTest extends LoginActivityCommonTestCase {
 
@@ -67,6 +68,11 @@
         return true;
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testAutofill_disjointDatasets() throws Exception {
         // Set service.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java
index c2b5515..42f4f16 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineSimpleSaveActivityTest.java
@@ -36,6 +36,7 @@
 import androidx.annotation.NonNull;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 public class InlineSimpleSaveActivityTest
         extends AutoFillServiceTestCase.AutoActivityLaunch<SimpleSaveActivity> {
@@ -63,6 +64,11 @@
         };
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testAutofillSave() throws Exception {
         // Set service.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java
index ca8e473..af53383 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineUiBot.java
@@ -21,14 +21,19 @@
 import static android.autofillservice.cts.Timeouts.UI_TIMEOUT;
 
 import android.autofillservice.cts.UiBot;
+import android.content.pm.PackageManager;
 import android.support.test.uiautomator.By;
 import android.support.test.uiautomator.BySelector;
 import android.support.test.uiautomator.Direction;
 import android.support.test.uiautomator.UiObject2;
 
+import com.android.compatibility.common.util.RequiredFeatureRule;
 import com.android.compatibility.common.util.Timeout;
 import com.android.cts.mockime.MockIme;
 
+import org.junit.rules.RuleChain;
+import org.junit.rules.TestRule;
+
 /**
  * UiBot for the inline suggestion.
  */
@@ -39,6 +44,9 @@
 
     private static final BySelector SUGGESTION_STRIP_SELECTOR = By.desc(SUGGESTION_STRIP_DESC);
 
+    private static final RequiredFeatureRule REQUIRES_IME_RULE = new RequiredFeatureRule(
+            PackageManager.FEATURE_INPUT_METHODS);
+
     public InlineUiBot() {
         this(UI_TIMEOUT);
     }
@@ -47,6 +55,10 @@
         super(defaultTimeout);
     }
 
+    public static RuleChain annotateRule(TestRule rule) {
+        return RuleChain.outerRule(REQUIRES_IME_RULE).around(rule);
+    }
+
     @Override
     public void assertNoDatasets() throws Exception {
         assertNoDatasetsEver();
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java
index d5f0503..63cf648 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineWebViewActivityTest.java
@@ -40,6 +40,7 @@
 import android.view.ViewStructure.HtmlInfo;
 
 import org.junit.Test;
+import org.junit.rules.TestRule;
 
 public class InlineWebViewActivityTest extends AbstractWebViewTestCase<WebViewActivity> {
 
@@ -77,6 +78,11 @@
         return true;
     }
 
+    @Override
+    public TestRule getMainTestRule() {
+        return InlineUiBot.annotateRule(super.getMainTestRule());
+    }
+
     @Test
     public void testAutofillNoDatasets() throws Exception {
         // Set service.
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/SurfaceControlTest.java b/tests/framework/base/windowmanager/src/android/server/wm/SurfaceControlTest.java
index e3566b9..d0aa669 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/SurfaceControlTest.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/SurfaceControlTest.java
@@ -102,7 +102,7 @@
     public void testSameSurface() {
         final SurfaceControl.Builder b = new SurfaceControl.Builder();
         final SurfaceControl sc = b.setName("CTS").build();
-        SurfaceControl copy = new SurfaceControl(sc);
+        SurfaceControl copy = new SurfaceControl(sc, "SurfaceControlTest.testSameSurface");
         assertTrue(copy.isSameSurface(sc));
         sc.release();
         copy.release();
diff --git a/tests/tests/content/HelloWorldApp/AndroidManifest.xml b/tests/tests/content/HelloWorldApp/AndroidManifest.xml
index f7c6c23..f195701 100644
--- a/tests/tests/content/HelloWorldApp/AndroidManifest.xml
+++ b/tests/tests/content/HelloWorldApp/AndroidManifest.xml
@@ -4,6 +4,7 @@
 
     <application
         android:allowBackup="true"
+        android:debuggable="true"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:roundIcon="@mipmap/ic_launcher_round"
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index 62c6012..8c90275 100644
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -35,6 +35,7 @@
 import android.media.MediaCodecInfo.CodecCapabilities;
 import android.media.MediaExtractor;
 import android.media.MediaFormat;
+import android.os.Build;
 import android.platform.test.annotations.AppModeFull;
 import android.util.Log;
 import android.view.Display;
@@ -42,6 +43,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 
+import com.android.compatibility.common.util.ApiLevelUtil;
 import com.android.compatibility.common.util.CddTest;
 import com.android.compatibility.common.util.DeviceReportLog;
 import com.android.compatibility.common.util.DynamicConfigDeviceSide;
@@ -50,6 +52,8 @@
 import com.android.compatibility.common.util.ResultType;
 import com.android.compatibility.common.util.ResultUnit;
 
+import androidx.test.filters.SdkSuppress;
+
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -70,6 +74,7 @@
 public class DecoderTest extends MediaPlayerTestBase {
     private static final String TAG = "DecoderTest";
     private static final String REPORT_LOG_NAME = "CtsMediaTestCases";
+    private static boolean mIsAtLeastR = ApiLevelUtil.isAtLeast(Build.VERSION_CODES.R);
 
     private static final int RESET_MODE_NONE = 0;
     private static final int RESET_MODE_RECONFIGURE = 1;
@@ -274,6 +279,8 @@
     private void verifyChannelsAndRates(String[] mimetypes, int[] sampleRates,
                                        int[] channelMasks) throws Exception {
 
+        if (!MediaUtils.check(mIsAtLeastR, "test invalid before Android 11")) return;
+
         for (String mimetype : mimetypes) {
             // ensure we find a codec for all listed mime/channel/rate combinations
             MediaCodecList mcl = new MediaCodecList(MediaCodecList.ALL_CODECS);
@@ -3579,6 +3586,7 @@
         return pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
     }
 
+    @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
     public void testLowLatencyVp9At1280x720() throws Exception {
         testLowLatencyVideo(
                 R.raw.video_1280x720_webm_vp9_csd_309kbps_25fps_vorbis_stereo_128kbps_48000hz, 300,
@@ -3588,6 +3596,7 @@
                 true /* useNdk */);
     }
 
+    @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
     public void testLowLatencyVp9At1920x1080() throws Exception {
         testLowLatencyVideo(
                 R.raw.bbb_s2_1920x1080_webm_vp9_0p41_10mbps_60fps_vorbis_6ch_384kbps_22050hz, 300,
@@ -3597,6 +3606,7 @@
                 true /* useNdk */);
     }
 
+    @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
     public void testLowLatencyVp9At3840x2160() throws Exception {
         testLowLatencyVideo(
                 R.raw.bbb_s2_3840x2160_webm_vp9_0p51_20mbps_60fps_vorbis_6ch_384kbps_32000hz, 300,