Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15fed390 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Add new resources trace, also trace apk dex loading." into jb-mr2-dev

parents efcb252f f7be4800
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app;
package android.app;


import android.os.Trace;
import dalvik.system.PathClassLoader;
import dalvik.system.PathClassLoader;


import java.util.HashMap;
import java.util.HashMap;
@@ -54,14 +55,19 @@ class ApplicationLoaders
                    return loader;
                    return loader;
                }
                }
    
    
                Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, zip);
                PathClassLoader pathClassloader =
                PathClassLoader pathClassloader =
                    new PathClassLoader(zip, libPath, parent);
                    new PathClassLoader(zip, libPath, parent);
                Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);


                mLoaders.put(zip, pathClassloader);
                mLoaders.put(zip, pathClassloader);
                return 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;
        }
        }
    }
    }


+7 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.res;
package android.content.res;


import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor;
import android.os.Trace;
import android.util.Log;
import android.util.Log;
import android.util.TypedValue;
import android.util.TypedValue;


@@ -602,7 +603,12 @@ public final class AssetManager {
     * the cookie of the added asset, or 0 on failure.
     * the cookie of the added asset, or 0 on failure.
     * {@hide}
     * {@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
     * Add multiple sets of assets to the asset manager at once.  See
+2 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,8 @@ public final class Trace {
    public static final long TRACE_TAG_HAL = 1L << 11;
    public static final long TRACE_TAG_HAL = 1L << 11;
    /** @hide */
    /** @hide */
    public static final long TRACE_TAG_APP = 1L << 12;
    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 long TRACE_TAG_NOT_READY = 1L << 63;
    private static final int MAX_SECTION_NAME_LEN = 127;
    private static final int MAX_SECTION_NAME_LEN = 127;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1642,7 +1642,7 @@ static JNINativeMethod gAssetManagerMethods[] = {
        (void*) android_content_AssetManager_getAssetLength },
        (void*) android_content_AssetManager_getAssetLength },
    { "getAssetRemainingLength", "(I)J",
    { "getAssetRemainingLength", "(I)J",
        (void*) android_content_AssetManager_getAssetRemainingLength },
        (void*) android_content_AssetManager_getAssetRemainingLength },
    { "addAssetPath",   "(Ljava/lang/String;)I",
    { "addAssetPathNative", "(Ljava/lang/String;)I",
        (void*) android_content_AssetManager_addAssetPath },
        (void*) android_content_AssetManager_addAssetPath },
    { "isUpToDate",     "()Z",
    { "isUpToDate",     "()Z",
        (void*) android_content_AssetManager_isUpToDate },
        (void*) android_content_AssetManager_isUpToDate },
+12 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
//
//


#define LOG_TAG "asset"
#define LOG_TAG "asset"
#define ATRACE_TAG ATRACE_TAG_RESOURCES
//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0


#include <androidfw/Asset.h>
#include <androidfw/Asset.h>
@@ -32,6 +33,7 @@
#include <utils/threads.h>
#include <utils/threads.h>
#include <utils/Timers.h>
#include <utils/Timers.h>
#include <utils/ZipFileRO.h>
#include <utils/ZipFileRO.h>
#include <cutils/trace.h>


#include <assert.h>
#include <assert.h>
#include <dirent.h>
#include <dirent.h>
@@ -51,6 +53,14 @@
    _rc; })
    _rc; })
#endif
#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;
using namespace android;


/*
/*
@@ -638,6 +648,7 @@ const ResTable* AssetManager::getResTable(bool required) const
        ResTable* sharedRes = NULL;
        ResTable* sharedRes = NULL;
        bool shared = true;
        bool shared = true;
        const asset_path& ap = mAssetPaths.itemAt(i);
        const asset_path& ap = mAssetPaths.itemAt(i);
        MY_TRACE_BEGIN(ap.path.string());
        Asset* idmap = openIdmapLocked(ap);
        Asset* idmap = openIdmapLocked(ap);
        ALOGV("Looking for resource asset in '%s'\n", ap.path.string());
        ALOGV("Looking for resource asset in '%s'\n", ap.path.string());
        if (ap.type != kFileTypeDirectory) {
        if (ap.type != kFileTypeDirectory) {
@@ -702,6 +713,7 @@ const ResTable* AssetManager::getResTable(bool required) const
        if (idmap != NULL) {
        if (idmap != NULL) {
            delete idmap;
            delete idmap;
        }
        }
        MY_TRACE_END();
    }
    }


    if (required && !rt) ALOGW("Unable to find resources file resources.arsc");
    if (required && !rt) ALOGW("Unable to find resources file resources.arsc");