Add new resources trace, also trace apk dex loading.
Change-Id: Ia48566efb21ee018659bd976ddb3a0f4997b9a3a
diff --git a/core/java/android/app/ApplicationLoaders.java b/core/java/android/app/ApplicationLoaders.java
index 9e3cd7e..a26b88c 100644
--- a/core/java/android/app/ApplicationLoaders.java
+++ b/core/java/android/app/ApplicationLoaders.java
@@ -16,6 +16,7 @@
package android.app;
+import android.os.Trace;
import dalvik.system.PathClassLoader;
import java.util.HashMap;
@@ -54,14 +55,19 @@
return loader;
}
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, zip);
PathClassLoader pathClassloader =
new PathClassLoader(zip, libPath, parent);
-
+ Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+
mLoaders.put(zip, pathClassloader);
return pathClassloader;
}
- return new PathClassLoader(zip, parent);
+ Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, zip);
+ PathClassLoader pathClassloader = new PathClassLoader(zip, parent);
+ Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
+ return pathClassloader;
}
}
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index ffefaa2..fc9e486 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -17,6 +17,7 @@
package android.content.res;
import android.os.ParcelFileDescriptor;
+import android.os.Trace;
import android.util.Log;
import android.util.TypedValue;
@@ -602,7 +603,12 @@
* the cookie of the added asset, or 0 on failure.
* {@hide}
*/
- public native final int addAssetPath(String path);
+ public final int addAssetPath(String path) {
+ int res = addAssetPathNative(path);
+ return res;
+ }
+
+ private native final int addAssetPathNative(String path);
/**
* Add multiple sets of assets to the asset manager at once. See
diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java
index 607def7..994e1fc 100644
--- a/core/java/android/os/Trace.java
+++ b/core/java/android/os/Trace.java
@@ -63,6 +63,8 @@
public static final long TRACE_TAG_HAL = 1L << 11;
/** @hide */
public static final long TRACE_TAG_APP = 1L << 12;
+ /** @hide */
+ public static final long TRACE_TAG_RESOURCES = 1L << 13;
private static final long TRACE_TAG_NOT_READY = 1L << 63;
private static final int MAX_SECTION_NAME_LEN = 127;
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 785bf13..dc4d945 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -1642,7 +1642,7 @@
(void*) android_content_AssetManager_getAssetLength },
{ "getAssetRemainingLength", "(I)J",
(void*) android_content_AssetManager_getAssetRemainingLength },
- { "addAssetPath", "(Ljava/lang/String;)I",
+ { "addAssetPathNative", "(Ljava/lang/String;)I",
(void*) android_content_AssetManager_addAssetPath },
{ "isUpToDate", "()Z",
(void*) android_content_AssetManager_isUpToDate },
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 8bd805c..e0d96c9 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -19,6 +19,7 @@
//
#define LOG_TAG "asset"
+#define ATRACE_TAG ATRACE_TAG_RESOURCES
//#define LOG_NDEBUG 0
#include <androidfw/Asset.h>
@@ -32,6 +33,7 @@
#include <utils/threads.h>
#include <utils/Timers.h>
#include <utils/ZipFileRO.h>
+#include <cutils/trace.h>
#include <assert.h>
#include <dirent.h>
@@ -51,6 +53,14 @@
_rc; })
#endif
+#ifdef HAVE_ANDROID_OS
+#define MY_TRACE_BEGIN(x) ATRACE_BEGIN(x)
+#define MY_TRACE_END() ATRACE_END()
+#else
+#define MY_TRACE_BEGIN(x)
+#define MY_TRACE_END()
+#endif
+
using namespace android;
/*
@@ -638,6 +648,7 @@
ResTable* sharedRes = NULL;
bool shared = true;
const asset_path& ap = mAssetPaths.itemAt(i);
+ MY_TRACE_BEGIN(ap.path.string());
Asset* idmap = openIdmapLocked(ap);
ALOGV("Looking for resource asset in '%s'\n", ap.path.string());
if (ap.type != kFileTypeDirectory) {
@@ -702,6 +713,7 @@
if (idmap != NULL) {
delete idmap;
}
+ MY_TRACE_END();
}
if (required && !rt) ALOGW("Unable to find resources file resources.arsc");