Merge "Snap for 4624340 from f247fa98171dc4078786ba6367d6e08861cf6310 to oreo-cts-release" into oreo-cts-release
diff --git a/apps/CtsVerifier/res/layout/ca_boot_notify.xml b/apps/CtsVerifier/res/layout/ca_boot_notify.xml
index 262c6ad..52df1f1 100644
--- a/apps/CtsVerifier/res/layout/ca_boot_notify.xml
+++ b/apps/CtsVerifier/res/layout/ca_boot_notify.xml
@@ -47,6 +47,11 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/caboot_if_not_installed" />
+            <TextView
+                android:id="@+id/need_to_install_cert_instructions"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/cacert_install_cert" />
 
             <Button
                 android:id="@+id/install"
@@ -55,6 +60,18 @@
                 android:text="@string/caboot_install_cert" />
 
             <TextView
+                android:id="@+id/remove_screen_lock_description"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/cacert_remove_screen_lock" />
+
+            <Button
+                android:id="@+id/remove_screen_lock"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/caboot_remove_screen_lock" />
+
+            <TextView
                 android:id="@+id/reboot"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/uap_buttons_panel.xml b/apps/CtsVerifier/res/layout/uap_buttons_panel.xml
index 3da7247..4fdc757 100644
--- a/apps/CtsVerifier/res/layout/uap_buttons_panel.xml
+++ b/apps/CtsVerifier/res/layout/uap_buttons_panel.xml
@@ -82,24 +82,6 @@
          <Space
             android:layout_width="match_parent"
             android:layout_height="5dp"/>
-
-        <TextView
-            android:text="@string/uapButtonsBtnDLbl"
-            android:id="@+id/uap_buttonsBtnDLabelTx"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            />
-
-        <TextView
-            android:text="@string/uapButtonsNotRecognized"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:id="@+id/uap_buttonsBtnDStatusTx"
-            android:paddingLeft="16dp"/>
-
-         <Space
-            android:layout_width="match_parent"
-            android:layout_height="5dp"/>
         </LinearLayout>
 
     <TextView
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 8e18c9cd..80dedb9 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1656,10 +1656,11 @@
 
     <string name="caboot_test">CA Cert Notification on Boot test</string>
     <string name="caboot_info">This test is to confirm that when the user has installed a trusted credential, the system notifies the user when it boots.</string>
-    <string name="caboot_check_cert_installed">Please check here to see whether a certificate is already installed. (If this button does nothing, pass the test and move on.)</string>
+    <string name="caboot_check_cert_installed">Please check here to see whether a certificate is already installed. If this button does nothing, pass the test and move on.</string>
     <string name="caboot_check_creds">Check Credentials</string>
-    <string name="caboot_if_not_installed">Only if there is no credential currently installed, install one. (If this button does nothing, pass the test and move on.)</string>
+    <string name="caboot_if_not_installed">Only if there is no credential currently installed, install one.</string>
     <string name="caboot_install_cert">Install credential</string>
+    <string name="caboot_remove_screen_lock">Remove screen lock</string>
     <string name="caboot_reboot_desc">Please reboot the device and return to this test.</string>
     <string name="caboot_after_boot">AFTER REBOOTING: Check that there is a notification that the network may be monitored. Opening that notification should show a dialog box giving more information, with a button to check trusted credentials. This should open up the same view of trusted credentials that you get via the "Check credentials" button.</string>
 
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 50742b3..98a7d18 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
@@ -34,18 +34,15 @@
     private boolean mHasBtnA;
     private boolean mHasBtnB;
     private boolean mHasBtnC;
-    private boolean mHasBtnD;
 
     // Widgets
     private TextView mBtnALabelTxt;
     private TextView mBtnBLabelTxt;
     private TextView mBtnCLabelTxt;
-    private TextView mBtnDLabelTxt;
 
     private TextView mBtnAStatusTxt;
     private TextView mBtnBStatusTxt;
     private TextView mBtnCStatusTxt;
-    private TextView mBtnDStatusTxt;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -57,12 +54,10 @@
         mBtnALabelTxt = (TextView)findViewById(R.id.uap_buttonsBtnALabelTx);
         mBtnBLabelTxt = (TextView)findViewById(R.id.uap_buttonsBtnBLabelTx);
         mBtnCLabelTxt = (TextView)findViewById(R.id.uap_buttonsBtnCLabelTx);
-        mBtnDLabelTxt = (TextView)findViewById(R.id.uap_buttonsBtnDLabelTx);
 
         mBtnAStatusTxt = (TextView)findViewById(R.id.uap_buttonsBtnAStatusTx);
         mBtnBStatusTxt = (TextView)findViewById(R.id.uap_buttonsBtnBStatusTx);
         mBtnCStatusTxt = (TextView)findViewById(R.id.uap_buttonsBtnCStatusTx);
-        mBtnDStatusTxt = (TextView)findViewById(R.id.uap_buttonsBtnDStatusTx);
 
         setPassFailButtonClickListeners();
         setInfoResources(R.string.usbaudio_buttons_test, R.string.usbaudio_buttons_info, -1);
@@ -93,13 +88,6 @@
                     mBtnCLabelTxt.setTextColor(Color.WHITE);
                     mBtnCStatusTxt.setTextColor(Color.WHITE);
                 }
-                if (!mButtonAttributes.mHasBtnD) {
-                    mBtnDLabelTxt.setTextColor(Color.GRAY);
-                    mBtnDStatusTxt.setTextColor(Color.GRAY);
-                } else {
-                    mBtnDLabelTxt.setTextColor(Color.WHITE);
-                    mBtnDStatusTxt.setTextColor(Color.WHITE);
-                }
             } else {
                 mBtnALabelTxt.setTextColor(Color.GRAY);
                 mBtnAStatusTxt.setTextColor(Color.GRAY);
@@ -107,8 +95,6 @@
                 mBtnBStatusTxt.setTextColor(Color.GRAY);
                 mBtnCLabelTxt.setTextColor(Color.GRAY);
                 mBtnCStatusTxt.setTextColor(Color.GRAY);
-                mBtnDLabelTxt.setTextColor(Color.GRAY);
-                mBtnDStatusTxt.setTextColor(Color.GRAY);
             }
         }
 
@@ -118,8 +104,6 @@
             mHasBtnB ? R.string.uapButtonsRecognized : R.string.uapButtonsNotRecognized));
         mBtnCStatusTxt.setText(getString(
             mHasBtnC ? R.string.uapButtonsRecognized : R.string.uapButtonsNotRecognized));
-        mBtnDStatusTxt.setText(getString(
-            mHasBtnD ? R.string.uapButtonsRecognized : R.string.uapButtonsNotRecognized));
     }
 
     private void calculateMatch() {
@@ -135,15 +119,10 @@
             if (match && mButtonAttributes.mHasBtnC != mHasBtnC) {
                 match = false;
             }
-            if (match && mButtonAttributes.mHasBtnD != mHasBtnD) {
-                match = false;
-            }
             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);
         }
     }
 
@@ -165,11 +144,6 @@
         case KeyEvent.KEYCODE_VOLUME_DOWN:
             mHasBtnC = true;
             break;
-
-        // Function D control event
-        case KeyEvent.KEYCODE_VOICE_ASSIST:
-            mHasBtnD = true;
-            break;
         }
 
         showButtonsState();
@@ -182,7 +156,7 @@
     // USBAudioPeripheralActivity
     //
     public void updateConnectStatus() {
-        mHasBtnA = mHasBtnB = mHasBtnC = mHasBtnD = false;
+        mHasBtnA = mHasBtnB = mHasBtnC = false;
         showButtonsState();
         calculateMatch();
     }
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/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java
index 5537b15..a4f63ad 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/security/CANotifyOnBootActivity.java
@@ -1,5 +1,6 @@
 package com.android.cts.verifier.security;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.ActivityNotFoundException;
 import android.content.Intent;
 import android.os.Bundle;
@@ -32,6 +33,9 @@
         Button installButton = (Button) view.findViewById(R.id.install);
         checkCredsButton.setOnClickListener(new OpenTrustedCredentials());
         installButton.setOnClickListener(new InstallCert());
+        Button removeScreenLockButton = (Button) view.findViewById(R.id.remove_screen_lock);
+        removeScreenLockButton.setOnClickListener(
+                v -> startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD)));
 
         setContentView(view);
 
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java b/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java
index e765a78..593cf34 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/frametestapp/src/android/server/frametestapp/DialogTestActivity.java
@@ -19,38 +19,26 @@
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.Intent;
-import android.graphics.Rect;
 import android.os.Bundle;
-import android.view.View;
-import android.view.WindowInsets;
 import android.view.WindowManager;
 import android.view.Window;
 import android.view.Gravity;
 
-public class DialogTestActivity extends Activity implements View.OnApplyWindowInsetsListener{
+public class DialogTestActivity extends Activity {
 
     AlertDialog mDialog;
-    private Rect mOutsets = new Rect();
 
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
-        View content = new View(this);
-        content.setOnApplyWindowInsetsListener(this);
-        setContentView(content);
     }
 
     protected void onStop() {
         super.onStop();
         mDialog.dismiss();
     }
-
-    public WindowInsets onApplyWindowInsets(View v, WindowInsets in) {
-        if (in.isRound()) {
-            mOutsets = new Rect(in.getSystemWindowInsetLeft(), in.getSystemWindowInsetTop(),
-                    in.getSystemWindowInsetRight(), in.getSystemWindowInsetBottom());
-        }
+    protected void onResume() {
+        super.onResume();
         setupTest(getIntent());
-        return in;
     }
 
     private void setupTest(Intent intent) {
@@ -141,23 +129,23 @@
 
     private void testExplicitSize() {
         doLayoutParamTest((WindowManager.LayoutParams params) -> {
-            params.width = 200 - mOutsets.left - mOutsets.right;
-            params.height = 200 - mOutsets.bottom - mOutsets.top;
+            params.width = 200;
+            params.height = 200;
         });
     }
 
     private void testExplicitSizeTopLeftGravity() {
         doLayoutParamTest((WindowManager.LayoutParams params) -> {
-            params.width = 200 - mOutsets.left - mOutsets.right;
-            params.height = 200 - mOutsets.bottom - mOutsets.top;
+            params.width = 200;
+            params.height = 200;
             params.gravity = Gravity.TOP | Gravity.LEFT;
         });
     }
 
     private void testExplicitSizeBottomRightGravity() {
         doLayoutParamTest((WindowManager.LayoutParams params) -> {
-            params.width = 200 - mOutsets.left - mOutsets.right;
-            params.height = 200 - mOutsets.bottom - mOutsets.top;
+            params.width = 200;
+            params.height = 200;
             params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
         });
     }
@@ -182,6 +170,8 @@
         doLayoutParamTest((WindowManager.LayoutParams params) -> {
             params.width = WindowManager.LayoutParams.MATCH_PARENT;
             params.height = WindowManager.LayoutParams.MATCH_PARENT;
+            params.x = 100;
+            params.y = 100;
         });
     }
 
@@ -191,6 +181,8 @@
             params.height = WindowManager.LayoutParams.MATCH_PARENT;
             params.gravity = Gravity.LEFT | Gravity.TOP;
             params.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+            params.x = 100;
+            params.y = 100;
         });
     }
 
@@ -204,9 +196,9 @@
         doLayoutParamTest((WindowManager.LayoutParams params) -> {
             params.gravity = Gravity.LEFT | Gravity.TOP;
             params.horizontalMargin = .25f;
-            params.verticalMargin = .25f;
-            params.width = 200 - mOutsets.left - mOutsets.right;
-            params.height = 200 - mOutsets.bottom - mOutsets.top;
+            params.verticalMargin = .35f;
+            params.width = 200;
+            params.height = 200;
             params.x = 0;
             params.y = 0;
         });
diff --git a/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java b/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
index 9125a99..c99f001 100644
--- a/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
+++ b/hostsidetests/services/activityandwindowmanager/windowmanager/src/android/server/cts/DialogFrameTests.java
@@ -190,7 +190,7 @@
 
     public void testMarginsArePercentagesOfContentFrame() throws Exception {
         float horizontalMargin = .25f;
-        float verticalMargin = .25f;
+        float verticalMargin = .35f;
         doParentChildTest("WithMargins",
             (WindowState parent, WindowState dialog) -> {
                 Rectangle frame = parent.getContentFrame();