Merge "Allow the use of filenames when traking code paths for profiling"
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index f00da9c..3dab025 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -198,7 +198,7 @@
 ART_GTEST_oat_file_assistant_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
 ART_GTEST_dexoptanalyzer_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
 ART_GTEST_image_space_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
-ART_GTEST_oat_file_test_DEX_DEPS := Main MultiDex MainUncompressed MultiDexUncompressed
+ART_GTEST_oat_file_test_DEX_DEPS := Main MultiDex MainUncompressed MultiDexUncompressed MainStripped Nested MultiDexModifiedSecondary
 ART_GTEST_oat_test_DEX_DEPS := Main
 ART_GTEST_oat_writer_test_DEX_DEPS := Main
 ART_GTEST_object_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
diff --git a/build/apex/ld.config.txt b/build/apex/ld.config.txt
index 9e709d8..d5eb9fa 100644
--- a/build/apex/ld.config.txt
+++ b/build/apex/ld.config.txt
@@ -10,9 +10,13 @@
 [runtime]
 additional.namespaces = platform,conscrypt
 
-# Keep in sync with runtime namespace in /system/etc/ld.config.txt.
+# Keep in sync with the runtime namespace in /system/etc/ld.config.txt.
 namespace.default.isolated = true
+# Visible because some libraries are dlopen'ed, e.g. libopenjdk is dlopen'ed by
+# libart.
+namespace.default.visible = true
 namespace.default.search.paths = /apex/com.android.runtime/${LIB}
+namespace.default.asan.search.paths = /apex/com.android.runtime/${LIB}
 # odex files are in /system/framework. dalvikvm has to be able to dlopen the
 # files for CTS.
 namespace.default.permitted.paths = /system/framework
@@ -20,24 +24,32 @@
 # TODO(b/119867084): Restrict fallback to platform namespace to PALette library.
 namespace.default.link.platform.allow_all_shared_libs = true
 
-# Keep in sync with default namespace in /system/etc/ld.config.txt.
+# Keep in sync with the default namespace in /system/etc/ld.config.txt.
 namespace.platform.isolated = true
 namespace.platform.search.paths = /system/${LIB}
+namespace.platform.asan.search.paths = /data/asan/system/${LIB}
 namespace.platform.links = default
 namespace.platform.link.default.shared_libs  = libart.so:libartd.so
 namespace.platform.link.default.shared_libs += libnativebridge.so
 namespace.platform.link.default.shared_libs += libnativehelper.so
 namespace.platform.link.default.shared_libs += libnativeloader.so
 
+# Note that we don't need to link the default namespace with conscrypt:
+# the runtime Java code and binaries do not explicitly load native libraries
+# from it.
+
 ###############################################################################
 # "conscrypt" APEX namespace
 #
 # This namespace is for libraries within the conscrypt APEX.
 ###############################################################################
+
+# Keep in sync with conscrypt namespace in /system/etc/ld.config.txt.
 namespace.conscrypt.isolated = true
 namespace.conscrypt.visible = true
 
 namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
+namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
 namespace.conscrypt.links = platform
 namespace.conscrypt.link.platform.shared_libs  = libc.so
 namespace.conscrypt.link.platform.shared_libs += libm.so
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 3b34e8d..42dbc77 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -1460,22 +1460,27 @@
                                               const debug::MethodDebugInfo& info) {
   const CompilerOptions& compiler_options = GetCompilerDriver()->GetCompilerOptions();
   DCHECK(compiler_options.GenerateAnyDebugInfo());
+  TimingLogger logger("Generate JIT debug info logger", true, VLOG_IS_ON(jit));
+  {
+    TimingLogger::ScopedTiming st("Generate JIT debug info", &logger);
 
-  // If both flags are passed, generate full debug info.
-  const bool mini_debug_info = !compiler_options.GetGenerateDebugInfo();
+    // If both flags are passed, generate full debug info.
+    const bool mini_debug_info = !compiler_options.GetGenerateDebugInfo();
 
-  // Create entry for the single method that we just compiled.
-  std::vector<uint8_t> elf_file = debug::MakeElfFileForJIT(
-      compiler_options.GetInstructionSet(),
-      compiler_options.GetInstructionSetFeatures(),
-      mini_debug_info,
-      info);
-  AddNativeDebugInfoForJit(Thread::Current(),
-                           reinterpret_cast<const void*>(info.code_address),
-                           elf_file,
-                           debug::PackElfFileForJIT,
-                           compiler_options.GetInstructionSet(),
-                           compiler_options.GetInstructionSetFeatures());
+    // Create entry for the single method that we just compiled.
+    std::vector<uint8_t> elf_file = debug::MakeElfFileForJIT(
+        compiler_options.GetInstructionSet(),
+        compiler_options.GetInstructionSetFeatures(),
+        mini_debug_info,
+        info);
+    AddNativeDebugInfoForJit(Thread::Current(),
+                             reinterpret_cast<const void*>(info.code_address),
+                             elf_file,
+                             debug::PackElfFileForJIT,
+                             compiler_options.GetInstructionSet(),
+                             compiler_options.GetInstructionSetFeatures());
+  }
+  Runtime::Current()->GetJit()->AddTimingLogger(logger);
 }
 
 }  // namespace art
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index e914738..5aa8236 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -205,7 +205,7 @@
     target: {
         android: {
             shared_libs: [
-                "libpagemap",
+                "libmeminfo",
             ],
         },
     },
diff --git a/dexlayout/dexdiag.cc b/dexlayout/dexdiag.cc
index 7a849f2..28d4048 100644
--- a/dexlayout/dexdiag.cc
+++ b/dexlayout/dexdiag.cc
@@ -34,13 +34,18 @@
 #include "dex_ir.h"
 #include "dex_ir_builder.h"
 #ifdef ART_TARGET_ANDROID
-#include "pagemap/pagemap.h"
+#include <meminfo/pageacct.h>
+#include <meminfo/procmeminfo.h>
 #endif
 #include "vdex_file.h"
 
 namespace art {
 
 using android::base::StringPrintf;
+#ifdef ART_TARGET_ANDROID
+using android::meminfo::ProcMemInfo;
+using android::meminfo::Vma;
+#endif
 
 static bool g_verbose = false;
 
@@ -194,7 +199,7 @@
   return DexFile::kDexTypeHeaderItem;
 }
 
-static void ProcessPageMap(uint64_t* pagemap,
+static void ProcessPageMap(const std::vector<uint64_t>& pagemap,
                            size_t start,
                            size_t end,
                            const std::vector<dex_ir::DexFileSection>& sections,
@@ -202,7 +207,7 @@
   static constexpr size_t kLineLength = 32;
   for (size_t page = start; page < end; ++page) {
     char type_char = '.';
-    if (PM_PAGEMAP_PRESENT(pagemap[page])) {
+    if (::android::meminfo::page_present(pagemap[page])) {
       const size_t dex_page_offset = page - start;
       uint16_t type = FindSectionTypeForPage(dex_page_offset, sections);
       page_counts->Increment(type);
@@ -265,7 +270,7 @@
   printer->PrintSkipLine();
 }
 
-static void ProcessOneDexMapping(uint64_t* pagemap,
+static void ProcessOneDexMapping(const std::vector<uint64_t>& pagemap,
                                  uint64_t map_start,
                                  const DexFile* dex_file,
                                  uint64_t vdex_start,
@@ -316,8 +321,8 @@
   return false;
 }
 
-static bool DisplayMappingIfFromVdexFile(pm_map_t* map, Printer* printer) {
-  std::string vdex_name = pm_map_name(map);
+static bool DisplayMappingIfFromVdexFile(ProcMemInfo& proc, const Vma& vma, Printer* printer) {
+  std::string vdex_name = vma.name;
   // Extract all the dex files from the vdex file.
   std::string error_msg;
   std::unique_ptr<VdexFile> vdex(VdexFile::Open(vdex_name,
@@ -344,34 +349,33 @@
     return false;
   }
   // Open the page mapping (one uint64_t per page) for the entire vdex mapping.
-  uint64_t* pagemap;
-  size_t len;
-  if (pm_map_pagemap(map, &pagemap, &len) != 0) {
+  std::vector<uint64_t> pagemap;
+  if (!proc.PageMap(vma, &pagemap)) {
     std::cerr << "Error creating pagemap." << std::endl;
     return false;
   }
   // Process the dex files.
   std::cout << "MAPPING "
-            << pm_map_name(map)
-            << StringPrintf(": %" PRIx64 "-%" PRIx64, pm_map_start(map), pm_map_end(map))
+            << vma.name
+            << StringPrintf(": %" PRIx64 "-%" PRIx64, vma.start, vma.end)
             << std::endl;
   for (const auto& dex_file : dex_files) {
     ProcessOneDexMapping(pagemap,
-                         pm_map_start(map),
+                         vma.start,
                          dex_file.get(),
                          reinterpret_cast<uint64_t>(vdex->Begin()),
                          printer);
   }
-  free(pagemap);
   return true;
 }
 
-static void ProcessOneOatMapping(uint64_t* pagemap, size_t size, Printer* printer) {
+static void ProcessOneOatMapping(const std::vector<uint64_t>& pagemap,
+                                 Printer* printer) {
   static constexpr size_t kLineLength = 32;
   size_t resident_page_count = 0;
-  for (size_t page = 0; page < size; ++page) {
+  for (size_t page = 0; page < pagemap.size(); ++page) {
     char type_char = '.';
-    if (PM_PAGEMAP_PRESENT(pagemap[page])) {
+    if (::android::meminfo::page_present(pagemap[page])) {
       ++resident_page_count;
       type_char = '*';
     }
@@ -383,13 +387,13 @@
     }
   }
   if (g_verbose) {
-    if (size % kLineLength != 0) {
+    if (pagemap.size() % kLineLength != 0) {
       std::cout << std::endl;
     }
   }
-  double percent_of_total = 100.0 * resident_page_count / size;
+  double percent_of_total = 100.0 * resident_page_count / pagemap.size();
   printer->PrintHeader();
-  printer->PrintOne("EXECUTABLE", resident_page_count, size, percent_of_total, percent_of_total);
+  printer->PrintOne("EXECUTABLE", resident_page_count, pagemap.size(), percent_of_total, percent_of_total);
   printer->PrintSkipLine();
 }
 
@@ -405,21 +409,19 @@
   return false;
 }
 
-static bool DisplayMappingIfFromOatFile(pm_map_t* map, Printer* printer) {
+static bool DisplayMappingIfFromOatFile(ProcMemInfo& proc, const Vma& vma, Printer* printer) {
   // Open the page mapping (one uint64_t per page) for the entire vdex mapping.
-  uint64_t* pagemap;
-  size_t len;
-  if (pm_map_pagemap(map, &pagemap, &len) != 0) {
+  std::vector<uint64_t> pagemap;
+  if (!proc.PageMap(vma, &pagemap) != 0) {
     std::cerr << "Error creating pagemap." << std::endl;
     return false;
   }
   // Process the dex files.
   std::cout << "MAPPING "
-            << pm_map_name(map)
-            << StringPrintf(": %" PRIx64 "-%" PRIx64, pm_map_start(map), pm_map_end(map))
+            << vma.name
+            << StringPrintf(": %" PRIx64 "-%" PRIx64, vma.start, vma.end)
             << std::endl;
-  ProcessOneOatMapping(pagemap, len, printer);
-  free(pagemap);
+  ProcessOneOatMapping(pagemap, printer);
   return true;
 }
 
@@ -488,27 +490,11 @@
     return EXIT_FAILURE;
   }
 
-  // get libpagemap kernel information.
-  pm_kernel_t* ker;
-  if (pm_kernel_create(&ker) != 0) {
-    std::cerr << "Error creating kernel interface -- does this kernel have pagemap?" << std::endl;
-    return EXIT_FAILURE;
-  }
-
-  // get libpagemap process information.
-  pm_process_t* proc;
-  if (pm_process_create(ker, pid, &proc) != 0) {
-    std::cerr << "Error creating process interface -- does process "
-              << pid
-              << " really exist?"
-              << std::endl;
-    return EXIT_FAILURE;
-  }
-
+  // get libmeminfo process information.
+  ProcMemInfo proc(pid);
   // Get the set of mappings by the specified process.
-  pm_map_t** maps;
-  size_t num_maps;
-  if (pm_process_maps(proc, &maps, &num_maps) != 0) {
+  const std::vector<Vma>& maps = proc.Maps();
+  if (maps.empty()) {
     std::cerr << "Error listing maps." << std::endl;
     return EXIT_FAILURE;
   }
@@ -516,19 +502,19 @@
   bool match_found = false;
   // Process the mappings that are due to vdex or oat files.
   Printer printer;
-  for (size_t i = 0; i < num_maps; ++i) {
-    std::string mapped_file_name = pm_map_name(maps[i]);
+  for (auto& vma : maps) {
+    std::string mapped_file_name = vma.name;
     // Filter by name contains options (if any).
     if (!FilterByNameContains(mapped_file_name, name_filters)) {
       continue;
     }
     if (IsVdexFileMapping(mapped_file_name)) {
-      if (!DisplayMappingIfFromVdexFile(maps[i], &printer)) {
+      if (!DisplayMappingIfFromVdexFile(proc, vma, &printer)) {
         return EXIT_FAILURE;
       }
       match_found = true;
     } else if (IsOatFileMapping(mapped_file_name)) {
-      if (!DisplayMappingIfFromOatFile(maps[i], &printer)) {
+      if (!DisplayMappingIfFromOatFile(proc, vma, &printer)) {
         return EXIT_FAILURE;
       }
       match_found = true;
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index 9490798..4953bab 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -278,6 +278,17 @@
   }
 }
 
+bool LocationIsOnRuntimeModule(const char* full_path) {
+  std::string error_msg;
+  const char* runtime_path = GetAndroidDirSafe("ANDROID_RUNTIME_ROOT",
+                                               "/apex/com.android.runtime",
+                                               &error_msg);
+  if (runtime_path == nullptr) {
+    return false;
+  }
+  return android::base::StartsWith(full_path, runtime_path);
+}
+
 bool LocationIsOnSystem(const char* path) {
 #ifdef _WIN32
   UNUSED(path);
diff --git a/libartbase/base/file_utils.h b/libartbase/base/file_utils.h
index c249bcc..bddfaa1 100644
--- a/libartbase/base/file_utils.h
+++ b/libartbase/base/file_utils.h
@@ -72,6 +72,9 @@
 //          ReplaceFileExtension("foo", "abc") == "foo.abc"
 std::string ReplaceFileExtension(const std::string& filename, const std::string& new_extension);
 
+// Return whether the location is on apex/com.android.runtime
+bool LocationIsOnRuntimeModule(const char* location);
+
 // Return whether the location is on system (i.e. android root).
 bool LocationIsOnSystem(const char* location);
 
diff --git a/libdexfile/dex/art_dex_file_loader.cc b/libdexfile/dex/art_dex_file_loader.cc
index a814b66..7e93639 100644
--- a/libdexfile/dex/art_dex_file_loader.cc
+++ b/libdexfile/dex/art_dex_file_loader.cc
@@ -539,17 +539,17 @@
                                                                 error_msg,
                                                                 std::move(container),
                                                                 verify_result);
-
-  // Check if this dex file is located in the framework directory.
-  // If it is, set a flag on the dex file. This is used by hidden API
-  // policy decision logic.
-  // Location can contain multidex suffix, so fetch its canonical version. Note
-  // that this will call `realpath`.
-  std::string path = DexFileLoader::GetDexCanonicalLocation(location.c_str());
-  if (dex_file != nullptr && LocationIsOnSystemFramework(path.c_str())) {
-    dex_file->SetHiddenapiDomain(hiddenapi::Domain::kPlatform);
+  if (dex_file != nullptr) {
+    // Set hidden API domain based based on location.
+    // Location can contain multidex suffix, so fetch its canonical version. Note
+    // that this will call `realpath`.
+    std::string path = DexFileLoader::GetDexCanonicalLocation(location.c_str());
+    if (LocationIsOnSystemFramework(path.c_str())) {
+      dex_file->SetHiddenapiDomain(hiddenapi::Domain::kPlatform);
+    } else if (LocationIsOnRuntimeModule(path.c_str())) {
+      dex_file->SetHiddenapiDomain(hiddenapi::Domain::kCorePlatform);
+    }
   }
-
   return dex_file;
 }
 
diff --git a/runtime/hidden_api.h b/runtime/hidden_api.h
index c73a710..8bd59ea 100644
--- a/runtime/hidden_api.h
+++ b/runtime/hidden_api.h
@@ -104,8 +104,8 @@
 
     Domain dex_domain = dex_file->GetHiddenapiDomain();
     if (class_loader.IsNull() && dex_domain == Domain::kApplication) {
-      LOG(WARNING) << "DexFile " << dex_file->GetLocation() << " is in boot classpath "
-                   << "but is assigned untrusted domain";
+      // LOG(WARNING) << "DexFile " << dex_file->GetLocation() << " is in boot classpath "
+      //              << "but is assigned untrusted domain";
       dex_domain = Domain::kPlatform;
     }
     return dex_domain;
@@ -415,7 +415,7 @@
       }
 
       // Access checks are not disabled, report the violation.
-      detail::MaybeReportCorePlatformApiViolation(member, caller_context, access_method);
+      // detail::MaybeReportCorePlatformApiViolation(member, caller_context, access_method);
 
       // Deny access if the policy is enabled.
       return policy == EnforcementPolicy::kEnabled;
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index daf02fe..4f9cf70 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -244,7 +244,7 @@
   }
 
   size_t length = static_cast<size_t>(end - start);
-  memcpy(dex_mem_map.Begin(), base_address, length);
+  memcpy(dex_mem_map.Begin(), base_address + start, length);
   return CreateSingleDexFileCookie(env, std::move(dex_mem_map));
 }
 
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index f4a8c50..e433cbc 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1410,20 +1410,23 @@
 
 std::string OatFile::ResolveRelativeEncodedDexLocation(
       const char* abs_dex_location, const std::string& rel_dex_location) {
-  // For host, we still do resolution as the rel_dex_location might be absolute
-  // for a target dex (for example /system/foo/foo.apk).
-  if (abs_dex_location != nullptr && (rel_dex_location[0] != '/' || !kIsTargetBuild)) {
-    // Strip :classes<N>.dex used for secondary multidex files.
+  if (abs_dex_location != nullptr) {
     std::string base = DexFileLoader::GetBaseLocation(rel_dex_location);
+    // Strip :classes<N>.dex used for secondary multidex files.
     std::string multidex_suffix = DexFileLoader::GetMultiDexSuffix(rel_dex_location);
-
-    // Check if the base is a suffix of the provided abs_dex_location.
-    std::string target_suffix = ((rel_dex_location[0] != '/') ? "/" : "") + base;
-    std::string abs_location(abs_dex_location);
-    if (abs_location.size() > target_suffix.size()) {
-      size_t pos = abs_location.size() - target_suffix.size();
-      if (abs_location.compare(pos, std::string::npos, target_suffix) == 0) {
-        return abs_location + multidex_suffix;
+    if (!kIsTargetBuild) {
+      // For host, we still do resolution as the rel_dex_location might be absolute
+      // for a target dex (for example /system/foo/foo.apk).
+      return std::string(abs_dex_location) + multidex_suffix;
+    } else if (rel_dex_location[0] != '/') {
+      // Check if the base is a suffix of the provided abs_dex_location.
+      std::string target_suffix = ((rel_dex_location[0] != '/') ? "/" : "") + base;
+      std::string abs_location(abs_dex_location);
+      if (abs_location.size() > target_suffix.size()) {
+        size_t pos = abs_location.size() - target_suffix.size();
+        if (abs_location.compare(pos, std::string::npos, target_suffix) == 0) {
+          return abs_location + multidex_suffix;
+        }
       }
     }
   }
diff --git a/runtime/oat_file_test.cc b/runtime/oat_file_test.cc
index b547113..ce09da4d 100644
--- a/runtime/oat_file_test.cc
+++ b/runtime/oat_file_test.cc
@@ -35,10 +35,6 @@
       OatFile::ResolveRelativeEncodedDexLocation(
         nullptr, "/data/app/foo/base.apk"));
 
-  EXPECT_EQ(std::string("/system/framework/base.apk"),
-      OatFile::ResolveRelativeEncodedDexLocation(
-        "/data/app/foo/base.apk", "/system/framework/base.apk"));
-
   EXPECT_EQ(std::string("/data/app/foo/base.apk"),
       OatFile::ResolveRelativeEncodedDexLocation(
         "/data/app/foo/base.apk", "base.apk"));
@@ -55,13 +51,29 @@
       OatFile::ResolveRelativeEncodedDexLocation(
         "/data/app/foo/base.apk", "base.apk!classes11.dex"));
 
-  EXPECT_EQ(std::string("base.apk"),
-      OatFile::ResolveRelativeEncodedDexLocation(
-        "/data/app/foo/sludge.apk", "base.apk"));
-
-  EXPECT_EQ(std::string("o/base.apk"),
-      OatFile::ResolveRelativeEncodedDexLocation(
-        "/data/app/foo/base.apk", "o/base.apk"));
+  // Host and target differ in their way of handling locations
+  // that are prefix of one another, due to boot image files.
+  if (kIsTargetBuild) {
+    EXPECT_EQ(std::string("/system/framework/base.apk"),
+        OatFile::ResolveRelativeEncodedDexLocation(
+          "/data/app/foo/base.apk", "/system/framework/base.apk"));
+    EXPECT_EQ(std::string("base.apk"),
+        OatFile::ResolveRelativeEncodedDexLocation(
+          "/data/app/foo/sludge.apk", "base.apk"));
+    EXPECT_EQ(std::string("o/base.apk"),
+        OatFile::ResolveRelativeEncodedDexLocation(
+          "/data/app/foo/base.apk", "o/base.apk"));
+  } else {
+    EXPECT_EQ(std::string("/data/app/foo/base.apk"),
+        OatFile::ResolveRelativeEncodedDexLocation(
+          "/data/app/foo/base.apk", "/system/framework/base.apk"));
+    EXPECT_EQ(std::string("/data/app/foo/sludge.apk"),
+        OatFile::ResolveRelativeEncodedDexLocation(
+          "/data/app/foo/sludge.apk", "base.apk"));
+    EXPECT_EQ(std::string("/data/app/foo/base.apk"),
+        OatFile::ResolveRelativeEncodedDexLocation(
+          "/data/app/foo/base.apk", "o/base.apk"));
+  }
 }
 
 TEST_F(OatFileTest, LoadOat) {
diff --git a/tools/hiddenapi/hiddenapi.cc b/tools/hiddenapi/hiddenapi.cc
index 97fbcbf..f426d02 100644
--- a/tools/hiddenapi/hiddenapi.cc
+++ b/tools/hiddenapi/hiddenapi.cc
@@ -974,11 +974,8 @@
           auto fn_shared = [&](const DexMember& boot_member) {
             auto it = api_list.find(boot_member.GetApiEntry());
             bool api_list_found = (it != api_list.end());
-            // TODO: Fix ART buildbots and turn this into a CHECK.
-            if (force_assign_all_ && !api_list_found) {
-              LOG(WARNING) << "Could not find hiddenapi flags for dex entry: "
-                           << boot_member.GetApiEntry();
-            }
+            CHECK(!force_assign_all_ || api_list_found)
+                << "Could not find hiddenapi flags for dex entry: " << boot_member.GetApiEntry();
             builder.WriteFlags(api_list_found ? it->second : ApiList::Whitelist());
           };
           auto fn_field = [&](const ClassAccessor::Field& boot_field) {
diff --git a/tools/libcore_network_failures.txt b/tools/libcore_network_failures.txt
index e7e31db..380f56b 100644
--- a/tools/libcore_network_failures.txt
+++ b/tools/libcore_network_failures.txt
@@ -8,7 +8,7 @@
   description: "Ignore failure of network-related tests on new devices running Android O",
   result: EXEC_FAILED,
   bug: 74725685,
-  modes: [device],
+  modes: [device_testdex],
   names: ["libcore.libcore.io.OsTest#test_byteBufferPositions_sendto_recvfrom_af_inet",
           "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithFtpURLConnection",
           "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithHttpURLConnection",
diff --git a/tools/veridex/hidden_api.h b/tools/veridex/hidden_api.h
index 3c7f29a..e1b67a2 100644
--- a/tools/veridex/hidden_api.h
+++ b/tools/veridex/hidden_api.h
@@ -41,7 +41,7 @@
   }
 
   bool IsInAnyList(const std::string& name) const {
-    return GetApiList(name).IsEmpty();
+    return !GetApiList(name).IsEmpty();
   }
 
   static std::string GetApiMethodName(const DexFile& dex_file, uint32_t method_index);
diff --git a/tools/veridex/hidden_api_finder.cc b/tools/veridex/hidden_api_finder.cc
index 3cd7c95..fe6d88a 100644
--- a/tools/veridex/hidden_api_finder.cc
+++ b/tools/veridex/hidden_api_finder.cc
@@ -180,6 +180,7 @@
   for (const std::pair<const std::string,
                        std::vector<MethodReference>>& pair : method_locations_) {
     hiddenapi::ApiList api_list = hidden_api_.GetApiList(pair.first);
+    CHECK(api_list.IsValid());
     stats->api_counts[api_list.GetIntValue()]++;
     os << "#" << ++stats->count << ": Linking " << api_list << " " << pair.first << " use(s):";
     os << std::endl;
@@ -191,6 +192,7 @@
   for (const std::pair<const std::string,
                        std::vector<MethodReference>>& pair : field_locations_) {
     hiddenapi::ApiList api_list = hidden_api_.GetApiList(pair.first);
+    CHECK(api_list.IsValid());
     stats->api_counts[api_list.GetIntValue()]++;
     os << "#" << ++stats->count << ": Linking " << api_list << " " << pair.first << " use(s):";
     os << std::endl;