Merge "openOptionsMenu() should be run on the UI thread" into oreo-cts-dev
diff --git a/hostsidetests/theme/assets/26/hdpi.zip b/hostsidetests/theme/assets/26/hdpi.zip
old mode 100644
new mode 100755
index 68702ef..ba6d573
--- a/hostsidetests/theme/assets/26/hdpi.zip
+++ b/hostsidetests/theme/assets/26/hdpi.zip
Binary files differ
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index 31292c3..ab90d1e 100755
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -26,7 +26,9 @@
 
 import android.accessibilityservice.AccessibilityService;
 import android.accessibilityservice.AccessibilityServiceInfo;
+import android.app.ActivityManager;
 import android.app.UiAutomation;
+import android.content.Context;
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.graphics.Rect;
@@ -599,6 +601,10 @@
 
     @MediumTest
     public void testWindowDockAndUndock_dividerWindowAppearsAndDisappears() throws Exception {
+
+        ActivityManager activityManager = (ActivityManager) getInstrumentation().getContext()
+                                            .getSystemService(Context.ACTIVITY_SERVICE);
+
         if (getInstrumentation().getContext().getPackageManager()
                 .hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
             // Android TV doesn't support the divider window
@@ -617,10 +623,11 @@
             // Do nothing, assume split screen multi window is supported.
         }
 
-        // Get com.android.internal.R.bool.config_supportsMultiWindow
+        // ActivityManager determines Multiwindow support based on config config_supportMultiWindow
+        // and isLowRam.
         if (!getInstrumentation().getContext().getResources().getBoolean(
                 Resources.getSystem().getIdentifier("config_supportsMultiWindow", "bool",
-                        "android"))) {
+                        "android")) || activityManager.isLowRamDevice()) {
             // Check if multiWindow is supported.
             return;
         }
diff --git a/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java b/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java
index 9d41ad8..3a8b43f 100644
--- a/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java
+++ b/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java
@@ -28,6 +28,7 @@
 import android.util.Log;
 
 import com.android.compatibility.common.util.SystemUtil;
+import com.android.compatibility.common.util.CddTest;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -54,6 +55,7 @@
      * receiver.
      */
     @Test
+    @CddTest(requirement="3.5/C-0-6")
     public void testNonSupportedBroadcastsNotDelivered_runtimeReceiver() throws Exception {
 
         // Need a reference here to initialize it in a lambda.
@@ -80,6 +82,7 @@
      * receiver, even if an intent is targeted to the component.
      */
     @Test
+    @CddTest(requirement="3.5/C-0-6")
     public void testNonSupportedBroadcastsNotDelivered_manifestReceiver() throws Exception {
         // Need a reference here to initialize it in a lambda.
         final AtomicReference<BroadcastReceiver> receiverRef = new AtomicReference<>();
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
index 504ae01..b72ebd6 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
@@ -92,6 +92,37 @@
   return err.find("dlopen failed: \"" + library + "\" has unexpected e_machine: ") == 0;
 }
 
+// copied from system/core/base/strings.cpp; libbase isn't available here
+static std::vector<std::string> split(const std::string& s,
+                               const std::string& delimiters) {
+  std::vector<std::string> result;
+
+  size_t base = 0;
+  size_t found;
+  while (true) {
+    found = s.find_first_of(delimiters, base);
+    result.push_back(s.substr(base, found - base));
+    if (found == s.npos) break;
+    base = found + 1;
+  }
+
+  return result;
+}
+
+static bool in_ld_preload(const std::string& path) {
+  static const char* ld_preload = getenv("LD_PRELOAD");
+  if (ld_preload != nullptr) {
+    // ' ' has also been allowed in LD_PRELOAD as well as ':'
+    std::vector<std::string> ld_preload_names =split(ld_preload, " :");
+    auto result = std::find_if(ld_preload_names.begin(), ld_preload_names.end(),
+                               [&path](const std::string& s) {
+                                 return s == path || s == std::string(basename(path.c_str()));
+                               });
+    return result != ld_preload_names.end();
+  }
+  return false;
+}
+
 static bool check_lib(const std::string& path,
                       const std::string& library_path,
                       const std::unordered_set<std::string>& libraries,
@@ -113,8 +144,12 @@
       return false;
     }
   } else if (handle.get() != nullptr) {
-    errors->push_back("The library \"" + path + "\" is not a public library but it loaded.");
-    return false;
+    // LD_PRELOAD libs are shared to the classloader-namespace. So, access to
+    // the lib is okay even when the lib is not a public library.
+    if (!in_ld_preload(path)) {
+      errors->push_back("The library \"" + path + "\" is not a public library but it loaded.");
+      return false;
+    }
   } else { // (handle == nullptr && !shouldBeAccessible(path))
     // Check the error message
     std::string err = dlerror();