Merge "Build libstaticsharednativelibprovider against the SDK."
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
index 871c2a0..83e68e4 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
@@ -170,8 +170,7 @@
         } else {
             mTestStatusTx.setText("No Peripheral or No Matching Profile.");
         }
-        // Headset not publicly available, violates CTS Verifier additional equipment guidelines.
-        // Allow skipping test. See b/67777923 for details.
-        getPassButton().setEnabled(true /*outPass && inPass*/);
+
+        getPassButton().setEnabled(outPass && inPass);
     }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
index 861af28..98a7d18 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
@@ -122,9 +122,7 @@
             Log.i(TAG, "match:" + match);
             getPassButton().setEnabled(match);
         } else {
-            // Headset not publicly available, violates CTS Verifier additional equipment
-            // guidelines. Allow skipping test. See b/67777923 for details.
-            getPassButton().setEnabled(true /*false*/);
+            getPassButton().setEnabled(false);
         }
     }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
index b4b0999..5389afb 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
@@ -50,10 +50,9 @@
 
     //
     // USBAudioPeripheralActivity
-    // Headset not publicly available, violates CTS Verifier additional equipment guidelines.
-    // Allow skipping test. See b/67777923 for details.
+    //
     public void updateConnectStatus() {
-        getPassButton().setEnabled(true /*mOutputDevInfo != null*/);
+        getPassButton().setEnabled(mOutputDevInfo != null);
     }
 
     public class LocalClickListener implements View.OnClickListener {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
index e878c82..f05bc9e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
@@ -134,10 +134,9 @@
 
     //
     // USBAudioPeripheralActivity
-    // Headset not publicly available, violates CTS Verifier additional equipment guidelines.
-    // Allow skipping test. See b/67777923 for details.
+    //
     public void updateConnectStatus() {
-        getPassButton().setEnabled(true /*mOutputDevInfo != null*/);
+        getPassButton().setEnabled(mOutputDevInfo != null);
     }
 
     public class LocalClickListener implements View.OnClickListener {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java
index 74e168b..e72d85d 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AutoFillServiceTestCase.java
@@ -64,6 +64,7 @@
 
     protected final Context mContext;
     protected final String mPackageName;
+
     /**
      * Stores the previous logging level so it's restored after the test.
      */
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
index 210fab8..e8b183c 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
@@ -68,6 +68,7 @@
                     PostSaveLinkTappedAction.ROTATE_THEN_TAP_BACK_BUTTON);
         } finally {
             sUiBot.setScreenOrientation(UiBot.PORTRAIT);
+            cleanUpAfterScreenOrientationIsBackToPortrait();
         }
     }
 
@@ -84,6 +85,9 @@
     protected abstract void saveUiRestoredAfterTappingLinkTest(PostSaveLinkTappedAction type)
             throws Exception;
 
+    protected void cleanUpAfterScreenOrientationIsBackToPortrait() throws Exception {
+    }
+
     /**
      * Tests scenarios when user taps a link in the custom description, taps back to return to the
      * activity with the Save UI, and touch outside the Save UI to dismiss it.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
index 8e4ec03..24b5e4c 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
@@ -173,6 +173,7 @@
             saveTest(true);
         } finally {
             sUiBot.setScreenOrientation(UiBot.PORTRAIT);
+            cleanUpAfterScreenOrientationIsBackToPortrait();
         }
     }
 
@@ -200,6 +201,9 @@
         UiObject2 saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
 
         if (rotate) {
+            // After the device rotates, the input field get focus and generate a new session.
+            sReplier.addResponse(CannedFillResponse.NO_RESPONSE);
+
             sUiBot.setScreenOrientation(UiBot.LANDSCAPE);
             saveUi = sUiBot.assertSaveShowing(SAVE_DATA_TYPE_GENERIC);
         }
@@ -493,6 +497,9 @@
         // .. then do something to return to previous activity...
         switch (type) {
             case ROTATE_THEN_TAP_BACK_BUTTON:
+                // After the device rotates, the input field get focus and generate a new session.
+                sReplier.addResponse(CannedFillResponse.NO_RESPONSE);
+
                 sUiBot.setScreenOrientation(UiBot.LANDSCAPE);
                 // not breaking on purpose
             case TAP_BACK_BUTTON:
@@ -515,6 +522,12 @@
 
         final SaveRequest saveRequest = sReplier.getNextSaveRequest();
         assertTextAndValue(findNodeByResourceId(saveRequest.structure, ID_INPUT), "108");
+
+    }
+
+    @Override
+    protected void cleanUpAfterScreenOrientationIsBackToPortrait() throws Exception {
+        sReplier.getNextFillRequest();
     }
 
     @Override
diff --git a/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
index e97a9ac..1b29a56 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RttOperationsTest.java
@@ -34,11 +34,23 @@
     };
     private static final int RTT_FAILURE_REASON = 2;
 
+    private boolean mInitialRttMode;
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         if (mShouldTestTelecom) {
             setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
+            mInitialRttMode = getRttMasterSwitch();
+            setRttMasterSwitch(false);
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (mShouldTestTelecom) {
+            setRttMasterSwitch(mInitialRttMode);
         }
     }
 
@@ -60,6 +72,7 @@
             return;
         }
 
+        setRttMasterSwitch(true);
         placeRttCall(true);
         final MockConnection connection = verifyConnectionForIncomingCall();
         final MockInCallService inCallService = mInCallCallbacks.getService();
@@ -85,6 +98,8 @@
         startRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
 
         connection.setRttTextStream((Connection.RttTextStream) startRttCounter.getArgs(0)[0]);
+        connection.setConnectionProperties(
+                connection.getConnectionProperties() | Connection.PROPERTY_IS_RTT);
         connection.sendRttInitiationSuccess();
         TestUtils.waitOnAllHandlers(getInstrumentation());
         verifyRttEnabled(call, connection);
@@ -176,6 +191,8 @@
                 connection.getInvokeCounter(MockConnection.ON_STOP_RTT);
         call.stopRtt();
         stopRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        connection.setConnectionProperties(
+                connection.getConnectionProperties() & ~Connection.PROPERTY_IS_RTT);
         TestUtils.waitOnAllHandlers(getInstrumentation());
         verifyRttDisabled(call);
     }
@@ -196,6 +213,8 @@
                 connection.getInvokeCounter(MockConnection.ON_STOP_RTT);
         call.stopRtt();
         stopRttCounter.waitForCount(1, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS);
+        connection.setConnectionProperties(
+                connection.getConnectionProperties() & ~Connection.PROPERTY_IS_RTT);
         TestUtils.waitOnAllHandlers(getInstrumentation());
         verifyRttDisabled(call);
     }
@@ -273,6 +292,7 @@
 
         }
     }
+
     private void placeRttCall(boolean incoming) {
         Bundle extras = new Bundle();
         extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, true);
@@ -284,4 +304,19 @@
             placeAndVerifyCall(outgoingCallExtras);
         }
     }
+
+    private void setRttMasterSwitch(boolean on) throws Exception {
+        TestUtils.executeShellCommand(getInstrumentation(),
+                "settings put system rtt_calling_mode " + (on ? 1 : 0));
+    }
+
+    private boolean getRttMasterSwitch() throws Exception {
+        try {
+            return Integer.valueOf(TestUtils.executeShellCommand(
+                    getInstrumentation(), "settings get system rtt_calling_mode")) == 1;
+        } catch (NumberFormatException e) {
+            // If the setting hasn't been set yet, assume it's off
+            return false;
+        }
+    }
 }