Merge "ITS: test_zoom.py"
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/BaseProxyTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/BaseProxyTest.java
index 1ab183b..cd7c98e 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/BaseProxyTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/BaseProxyTest.java
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, Google Inc.
+/*
+ * Copyright (C) 2020 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
+ *      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,
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package com.android.cts.deviceowner.proxy;
 
 import java.net.Proxy;
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacFileServer.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacFileServer.java
index c879c26..9d736e4 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacFileServer.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacFileServer.java
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, Google Inc.
+/*
+ * Copyright (C) 2020 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
+ *      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,
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacProxyTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacProxyTest.java
index 864f444..0e8f408 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacProxyTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PacProxyTest.java
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, Google Inc.
+/*
+ * Copyright (C) 2020 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
+ *      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,
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package com.android.cts.deviceowner.proxy;
 
 import java.io.IOException;
@@ -35,18 +36,18 @@
   /**
    * PAC file that always returns DIRECT.
    */
-  private static final String DIRECT_PAC = "function FindProxyForURL(url, host)\n" +
-      "{\n" +
-      "\treturn \"DIRECT\";\n" +
-      "}\n";
+  private static final String DIRECT_PAC = "function FindProxyForURL(url, host)" +
+      "{" +
+      "  return \"DIRECT\";" +
+      "}";
 
   /**
    * PAC file that returns three proxies, the third is DIRECT.
    */
-  private static final String LOCAL_PLUS_DIRECT_PAC = "function FindProxyForURL(url, host)\n" +
-      "{\n" +
-      "\treturn \"PROXY localhost:8080; PROXY localhost:8081; DIRECT \";\n" +
-      "}\n";
+  private static final String LOCAL_PLUS_DIRECT_PAC = "function FindProxyForURL(url, host)" +
+      "{" +
+      "  return \"PROXY localhost:8080; PROXY localhost:8081; DIRECT \";" +
+      "}";
 
   /**
    * PAC file that constructs the proxy to contain the host value passed in.
@@ -54,11 +55,11 @@
    * The return result is a bogus proxy that demonstrates that the input variables
    * are passed through correctly.
    */
-  private static final String HOST_PAC = "function FindProxyForURL(url, host)\n" +
-      "{\n" +
+  private static final String HOST_PAC = "function FindProxyForURL(url, host)" +
+      "{" +
       "var res = host.split(\"-\")[1];" +
-      "\treturn \"PROXY localhost:\" + res;\n" +
-      "}\n";
+      "  return \"PROXY localhost:\" + res;" +
+      "}";
 
   /**
    * PAC file that returns either proxy or DIRECT depending on the URL.
@@ -67,13 +68,12 @@
    * are passed through correctly.
    */
   private static final String URL_PAC = "function FindProxyForURL(url, host)\n" +
-      "{\n" +
-      "\tif (url == \"http://localhost/my/url/\") {\n" +
-      "\t\treturn \"PROXY localhost:8080\";\n" +
-      "\t}// else {\n" +
-      "\t\treturn \"DIRECT\";\n" +
-      "\t//}\n" +
-      "}\n";
+      "{" +
+      "  if (url == \"http://localhost/my/url/\") {" +
+      "    return \"PROXY localhost:8080\";" +
+      "  } " +
+      "  return \"DIRECT\";" +
+      "}";
 
   /**
    * Wait for the PacFileServer to tell us it has had a successful
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PassthroughTestHelper.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PassthroughTestHelper.java
index 1500226..2dd1e51 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PassthroughTestHelper.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/PassthroughTestHelper.java
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, Google Inc.
+/*
+ * Copyright (C) 2020 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
+ *      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,
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/StaticProxyTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/StaticProxyTest.java
index 72efaa0..24cbebf 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/StaticProxyTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/proxy/StaticProxyTest.java
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, Google Inc.
+/*
+ * Copyright (C) 2020 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
+ *      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,
@@ -26,8 +26,6 @@
 import java.util.List;
 
 import android.net.ProxyInfo;
-import android.net.Uri;
-import android.text.TextUtils;
 
 public class StaticProxyTest extends BaseProxyTest {
   private static final int PROXY_PORT = 8080;
diff --git a/hostsidetests/devicepolicy/app/DummyIme/Android.bp b/hostsidetests/devicepolicy/app/DummyIme/Android.bp
new file mode 100644
index 0000000..af8013e
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DummyIme/Android.bp
@@ -0,0 +1,29 @@
+// Copyright (C) 2020 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.
+
+android_test_helper_app {
+    name: "DummyIme",
+    resource_dirs: ["res"],
+    defaults: ["cts_defaults"],
+    srcs: ["src/**/*.java"],
+    static_libs: [
+        "cts-devicepolicy-suspensionchecker",
+    ],
+    test_suites: [
+        "arcts",
+        "cts",
+        "vts",
+        "general-tests",
+    ],
+}
diff --git a/hostsidetests/devicepolicy/app/DummyIme/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DummyIme/AndroidManifest.xml
new file mode 100644
index 0000000..aae922a
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DummyIme/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<!--
+/*
+ * Copyright 2020, 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.
+ */
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="com.android.cts.dummyime">
+    <application android:label="Dummy IME">
+        <service android:name="DummyIme"
+                android:permission="android.permission.BIND_INPUT_METHOD">
+            <intent-filter>
+                <action android:name="android.view.InputMethod" />
+            </intent-filter>
+            <meta-data android:name="android.view.im" android:resource="@xml/method" />
+        </service>
+        <activity android:name=".ImePreferences" android:label="Dummy IME Settings">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+            </intent-filter>
+        </activity>
+    </application>
+
+    <instrumentation
+        android:name="androidx.test.runner.AndroidJUnitRunner"
+        android:targetPackage="com.android.cts.dummyime">
+        <meta-data
+            android:name="listener"
+            android:value="com.android.cts.runner.CtsTestRunListener"/>
+    </instrumentation>
+</manifest>
diff --git a/hostsidetests/devicepolicy/app/DummyIme/res/xml/method.xml b/hostsidetests/devicepolicy/app/DummyIme/res/xml/method.xml
new file mode 100644
index 0000000..bb54bbd
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DummyIme/res/xml/method.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2020, 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.
+ */
+-->
+
+<!-- The attributes in this XML file provide configuration information -->
+<!-- for the Search Manager. -->
+
+<input-method xmlns:android="http://schemas.android.com/apk/res/android"
+        android:settingsActivity="com.android.testing.dummyime.ImePreferences">
+    <subtype
+        android:label="Generic"
+        android:imeSubtypeLocale="en_US"
+        android:imeSubtypeMode="keyboard" />
+</input-method>
diff --git a/hostsidetests/devicepolicy/app/DummyIme/src/com/android/cts/dummyime/DummyIme.java b/hostsidetests/devicepolicy/app/DummyIme/src/com/android/cts/dummyime/DummyIme.java
new file mode 100644
index 0000000..b5ca96b
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DummyIme/src/com/android/cts/dummyime/DummyIme.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 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 com.android.cts.dummyime;
+
+import android.inputmethodservice.InputMethodService;
+
+/**
+ * Dummy IME implementation that basically does nothing.
+ */
+public class DummyIme extends InputMethodService {
+
+    @Override
+    public boolean onEvaluateFullscreenMode() {
+        return false;
+    }
+
+    @Override
+    public boolean onEvaluateInputViewShown() {
+        return false;
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/DummyIme/src/com/android/cts/dummyime/ImePreferences.java b/hostsidetests/devicepolicy/app/DummyIme/src/com/android/cts/dummyime/ImePreferences.java
new file mode 100644
index 0000000..f6c838e
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DummyIme/src/com/android/cts/dummyime/ImePreferences.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2020 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 com.android.cts.dummyime;
+
+import android.preference.PreferenceActivity;
+
+/**
+ * Dummy IME preference activity
+ */
+public class ImePreferences extends PreferenceActivity {
+}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/res/drawable-nodpi/black_32x32.png b/hostsidetests/devicepolicy/app/ManagedProfile/res/drawable-nodpi/black_32x32.png
new file mode 100644
index 0000000..a1e25c1
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/res/drawable-nodpi/black_32x32.png
Binary files differ
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/LauncherAppsTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/LauncherAppsTest.java
new file mode 100644
index 0000000..47de9c2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/LauncherAppsTest.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2020 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 com.android.cts.managedprofile;
+
+import static android.app.admin.DevicePolicyManager.FLAG_MANAGED_CAN_ACCESS_PARENT;
+import static android.app.admin.DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED;
+import static android.util.DisplayMetrics.DENSITY_DEFAULT;
+
+import static com.android.cts.managedprofile.BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT;
+
+import static junit.framework.Assert.assertTrue;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.LauncherApps;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.util.DisplayMetrics;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+import static com.google.common.truth.Truth.assertThat;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Collections;
+import java.util.List;
+
+@RunWith(AndroidJUnit4.class)
+public class LauncherAppsTest {
+
+    private static final String INTERACT_ACROSS_USERS_FULL_PERMISSION =
+            "android.permission.INTERACT_ACROSS_USERS_FULL";
+    private static final String ACCESS_SHORTCUTS_PERMISSION = "android.permission.ACCESS_SHORTCUTS";
+
+    private final Context mContext = InstrumentationRegistry.getContext();
+
+    @After
+    public void tearDown() {
+        InstrumentationRegistry.getInstrumentation().getUiAutomation()
+                .dropShellPermissionIdentity();
+    }
+
+    @Test
+    public void addDynamicShortcuts() {
+        Bitmap bitmap = BitmapFactory.decodeResource(
+                mContext.getResources(), R.drawable.black_32x32);
+        final Icon icon1 = Icon.createWithBitmap(bitmap);
+        final ShortcutInfo s1 = new ShortcutInfo.Builder(mContext, "s1")
+                .setShortLabel("shortlabel1")
+                .setIcon(icon1)
+                .setIntents(new Intent[]{new Intent(Intent.ACTION_VIEW)})
+                .build();
+        ShortcutManager shortcutManager = mContext.getSystemService(ShortcutManager.class);
+        shortcutManager.addDynamicShortcuts(Collections.singletonList(s1));
+        shortcutManager.updateShortcuts(Collections.singletonList(s1));
+    }
+
+    @Test
+    public void removeAllDynamicShortcuts() {
+        ShortcutManager shortcutManager = mContext.getSystemService(ShortcutManager.class);
+        shortcutManager.removeAllDynamicShortcuts();
+    }
+
+    @Test
+    public void shortcutIconDrawable_currentToOtherProfile_withUsersFullPermission_isNotNull() {
+        InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
+                INTERACT_ACROSS_USERS_FULL_PERMISSION,
+                ACCESS_SHORTCUTS_PERMISSION);
+        UserHandle otherProfileUserHandle =
+                getOtherProfileUserId(InstrumentationRegistry.getArguments());
+        Context contextAsUser = mContext.createContextAsUser(otherProfileUserHandle, /* flags */ 0);
+        List<ShortcutInfo> shortcuts = getShortcuts(otherProfileUserHandle, contextAsUser);
+        LauncherApps launcherApps = contextAsUser.getSystemService(LauncherApps.class);
+
+        Drawable drawable = launcherApps.getShortcutIconDrawable(shortcuts.get(0), DENSITY_DEFAULT);
+
+        assertThat(drawable).isNotNull();
+    }
+
+    @Test
+    public void shortcutIconDrawable_currentToOtherProfile_withoutUsersFullPermission_isNull() {
+        InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
+                INTERACT_ACROSS_USERS_FULL_PERMISSION,
+                ACCESS_SHORTCUTS_PERMISSION);
+        UserHandle otherProfileUserHandle =
+                getOtherProfileUserId(InstrumentationRegistry.getArguments());
+        Context contextAsUser = mContext.createContextAsUser(otherProfileUserHandle, /* flags */ 0);
+        List<ShortcutInfo> shortcuts = getShortcuts(otherProfileUserHandle, contextAsUser);
+        LauncherApps launcherApps = contextAsUser.getSystemService(LauncherApps.class);
+        InstrumentationRegistry.getInstrumentation().getUiAutomation()
+                .dropShellPermissionIdentity();
+        InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(
+                ACCESS_SHORTCUTS_PERMISSION);
+
+        Drawable drawable = launcherApps.getShortcutIconDrawable(shortcuts.get(0), DENSITY_DEFAULT);
+
+        assertThat(drawable).isNull();
+    }
+
+    private List<ShortcutInfo> getShortcuts(UserHandle otherProfileUserHandle,
+            Context contextAsUser) {
+        LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery()
+                .setPackage(mContext.getPackageName())
+                .setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC);
+        return contextAsUser.getSystemService(LauncherApps.class)
+                .getShortcuts(query, otherProfileUserHandle);
+    }
+
+    private UserHandle getOtherProfileUserId(Bundle bundle) {
+        return UserHandle.of(Integer.parseInt(bundle.getString("otherProfileUserId")));
+    }
+}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index 311890a..2dbc829 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -33,6 +33,9 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Set of tests for Managed Profile use cases.
  */
@@ -615,6 +618,49 @@
                 "testIsManagedProfileReturnsFalse", mPrimaryUserId);
     }
 
+    @Test
+    public void testCanGetWorkShortcutIconDrawableFromPersonalProfile()
+            throws DeviceNotAvailableException {
+        if (!mHasFeature) {
+            return;
+        }
+        runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                "addDynamicShortcuts", mProfileUserId);
+        try {
+            Map<String, String> params = new HashMap<>();
+            params.put("otherProfileUserId", String.valueOf(mProfileUserId));
+            runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                    "shortcutIconDrawable_currentToOtherProfile_withUsersFullPermission_isNotNull",
+                    mPrimaryUserId, params);
+        } finally {
+            runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                    "removeAllDynamicShortcuts", mProfileUserId);
+        }
+    }
+
+    @Test
+    public void testCanGetPersonalShortcutIconDrawableFromWorkProfile()
+            throws DeviceNotAvailableException {
+        if (!mHasFeature) {
+            return;
+        }
+        runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                "addDynamicShortcuts", mPrimaryUserId);
+        try {
+            Map<String, String> params = new HashMap<>();
+            params.put("otherProfileUserId", String.valueOf(mPrimaryUserId));
+            runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                    "shortcutIconDrawable_currentToOtherProfile_withUsersFullPermission_isNotNull",
+                    mProfileUserId, params);
+            runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                    "shortcutIconDrawable_currentToOtherProfile_withoutUsersFullPermission_isNull",
+                    mProfileUserId, params);
+        } finally {
+            runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".LauncherAppsTest",
+                    "removeAllDynamicShortcuts", mPrimaryUserId);
+        }
+    }
+
     private void changeUserRestrictionOrFail(String key, boolean value, int userId)
             throws DeviceNotAvailableException {
         changeUserRestrictionOrFail(key, value, userId, MANAGED_PROFILE_PKG);
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java
index 68feba0..a1bdc5d 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java
@@ -32,6 +32,8 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
+import java.util.concurrent.TimeUnit;
+
 /**
  * Tests for organization-owned Profile Owner.
  */
@@ -43,6 +45,10 @@
     private static final String ACTION_WIPE_DATA =
             "com.android.cts.deviceandprofileowner.WIPE_DATA";
 
+    private static final String DUMMY_IME_APK = "DummyIme.apk";
+    private static final String DUMMY_IME_PKG = "com.android.cts.dummyime";
+    private static final String DUMMY_IME_COMPONENT = DUMMY_IME_PKG + "/.DummyIme";
+
     private int mParentUserId = -1;
     protected int mUserId;
     private boolean mHasProfileToRemove = true;
@@ -362,15 +368,50 @@
     @Test
     public void testPersonalAppsSuspensionNormalApp() throws Exception {
         installAppAsUser(DEVICE_ADMIN_APK, mPrimaryUserId);
+        // Initially the app should be launchable.
         assertCanStartPersonalApp(DEVICE_ADMIN_PKG, true);
-        runDeviceTestsAsUser(DEVICE_ADMIN_PKG,
-                ".PersonalAppsSuspensionTest", "testSuspendPersonalApps", mUserId);
+        setPersonalAppsSuspended(true);
+        // Now the app should be suspended and not launchable
         assertCanStartPersonalApp(DEVICE_ADMIN_PKG, false);
-        runDeviceTestsAsUser(DEVICE_ADMIN_PKG,
-                ".PersonalAppsSuspensionTest", "testUnsuspendPersonalApps", mUserId);
+        setPersonalAppsSuspended(false);
+        // Should be launchable again.
         assertCanStartPersonalApp(DEVICE_ADMIN_PKG, true);
     }
 
+    private void setPersonalAppsSuspended(boolean suspended) throws DeviceNotAvailableException {
+        runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
+                suspended ? "testSuspendPersonalApps" : "testUnsuspendPersonalApps", mUserId);
+    }
+
+    @Test
+    public void testPersonalAppsSuspensionIme() throws Exception {
+        installAppAsUser(DEVICE_ADMIN_APK, mPrimaryUserId);
+        setupIme(mPrimaryUserId, DUMMY_IME_APK, DUMMY_IME_COMPONENT);
+        setPersonalAppsSuspended(true);
+        // Active IME should not be suspended.
+        assertCanStartPersonalApp(DUMMY_IME_PKG, true);
+        setPersonalAppsSuspended(false);
+    }
+
+    private void setupIme(int userId, String imeApk, String imePackage) throws Exception {
+        installAppAsUser(imeApk, userId);
+        // Wait until IMS service is registered by the system.
+        final long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
+        while (true) {
+            final String availableImes = getDevice().executeShellCommand(
+                    String.format("ime list --user %d -s -a", userId));
+            if (availableImes.contains(imePackage)) {
+                break;
+            }
+            assertTrue("Failed waiting for IME to become available", System.nanoTime() < deadline);
+            Thread.sleep(100);
+        }
+
+        executeShellCommand("ime enable " + imePackage);
+        executeShellCommand("ime set " + imePackage);
+    }
+
+
     private void assertCanStartPersonalApp(String packageName, boolean canStart)
             throws DeviceNotAvailableException {
         runDeviceTestsAsUser(packageName, "com.android.cts.suspensionchecker.ActivityLaunchTest",
diff --git a/hostsidetests/userspacereboot/src/com/android/cts/userspacereboot/host/UserspaceRebootHostTest.java b/hostsidetests/userspacereboot/src/com/android/cts/userspacereboot/host/UserspaceRebootHostTest.java
index 4038beb..f953a1d 100644
--- a/hostsidetests/userspacereboot/src/com/android/cts/userspacereboot/host/UserspaceRebootHostTest.java
+++ b/hostsidetests/userspacereboot/src/com/android/cts/userspacereboot/host/UserspaceRebootHostTest.java
@@ -155,6 +155,7 @@
     }
 
     private void rebootUserspaceAndWaitForBootComplete() throws Exception {
+        getDevice().setProperty("test.userspace_reboot.requested", "1");
         getDevice().rebootUserspace();
         assertWithMessage("Device did not boot withing 2 minutes").that(
                 getDevice().waitForBootComplete(Duration.ofMinutes(2).toMillis())).isTrue();
@@ -162,8 +163,8 @@
 
     private void assertUserspaceRebootSucceed() throws Exception {
         // If userspace reboot fails and fallback to hard reboot is triggered then
-        // sys.init.userspace_reboot.last_finished won't be set.
+        // test.userspace_reboot.requested won't be set.
         assertWithMessage("Userspace reboot failed and fallback to full reboot was triggered").that(
-                getDevice().getProperty("sys.init.userspace_reboot.last_finished")).isNotEmpty();
+                getDevice().getProperty("test.userspace_reboot.requested")).isEqualTo("1");
     }
 }
diff --git a/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTestImpl.java b/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTestImpl.java
index c0c1f4f..df74df3 100644
--- a/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTestImpl.java
+++ b/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTestImpl.java
@@ -421,7 +421,7 @@
      * Determines if two color values are approximately equal.
      */
     private static boolean approxEquals(int expected, int actual) {
-        final int MAX_DELTA = 4;
+        final int MAX_DELTA = 7;
         return Math.abs(expected - actual) <= MAX_DELTA;
     }