Check if idmap2 is accessible before executing it.

When wrap.sh is used in a debuggable app, AssetManager tries to execute
idmap2 in the app's security context, not in zygote context. And idmap2
isn't allowed to execute in the app's context, thus making an abort.

The abort makes Android studio can't debug the app. To avoid the abort,
check if idmap2 is accessible before executing it.

Bug: 124109020
Test: test manually that android studio can debug the app with this
Test: change.

Change-Id: I82d772358b2266433f82319896a4ca662cc3c273
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index af2d413..bf56ef4 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -238,6 +238,11 @@
     return env->NewObjectArray(0, g_stringClass, nullptr);
   }
 
+  if (access("/system/bin/idmap2", X_OK) == -1) {
+    PLOG(WARNING) << "unable to execute idmap2";
+    return nullptr;
+  }
+
   std::vector<std::string> argv{"/system/bin/idmap2",
     "scan",
     "--recursive",