From f361123c871ea984023032b725f7f80c9e13f8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Wed, 12 Dec 2018 12:57:50 +0100 Subject: [PATCH] Continue process boot even if 'idmap2 --scan' fails Relax the requirement on 'idmap2 --scan' to exit normally (as defined by WIFEXITED) when starting a process. This allows the process to continue booting, but with the caveat that no static="true" overlays targeting "android" will be loaded. The booting process is usually Zygote but can be an app that uses a wrap.sh script (see https://d.android.com/ndk/guides/wrap-script). Because SELinux rules prevent most processes from executing /system/bin/idmap2, 'idmap2 --scan' will fail for "wrapped" apps. Bug: 120854885 Test: atest CtsWrapWrapDebugTestCases CtsWrapWrapDebugMallocDebugTestCases Change-Id: I85225cbcdd945f0026879e89f481d733217825d5 --- core/java/android/content/res/AssetManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 740cdae0dd5b4..f1a4db25cd14f 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -203,11 +203,13 @@ public final class AssetManager implements AutoCloseable { if (FEATURE_FLAG_IDMAP2) { final String[] systemIdmapPaths = nativeCreateIdmapsForStaticOverlaysTargetingAndroid(); - if (systemIdmapPaths == null) { - throw new IOException("idmap2 scan failed"); - } - for (String idmapPath : systemIdmapPaths) { - apkAssets.add(ApkAssets.loadOverlayFromPath(idmapPath, true /*system*/)); + if (systemIdmapPaths != null) { + for (String idmapPath : systemIdmapPaths) { + apkAssets.add(ApkAssets.loadOverlayFromPath(idmapPath, true /*system*/)); + } + } else { + Log.w(TAG, "'idmap2 --scan' failed: no static=\"true\" overlays targeting " + + "\"android\" will be loaded"); } } else { nativeVerifySystemIdmaps();