Merge "Enable recording resource access times"

This commit is contained in:
Lee Shombert
2022-09-22 20:36:33 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 1 deletions

View File

@@ -39,6 +39,7 @@
#include "androidfw/AssetManager2.h"
#include "androidfw/AttributeResolution.h"
#include "androidfw/MutexGuard.h"
#include <androidfw/ResourceTimer.h>
#include "androidfw/ResourceTypes.h"
#include "androidfw/ResourceUtils.h"
@@ -630,6 +631,7 @@ static jint NativeGetResourceValue(JNIEnv* env, jclass /*clazz*/, jlong ptr, jin
jshort density, jobject typed_value,
jboolean resolve_references) {
ScopedLock<AssetManager2> assetmanager(AssetManagerFromLong(ptr));
ResourceTimer _tag(ResourceTimer::Counter::GetResourceValue);
auto value = assetmanager->GetResource(static_cast<uint32_t>(resid), false /*may_be_bag*/,
static_cast<uint16_t>(density));
if (!value.has_value()) {
@@ -1232,6 +1234,7 @@ static jboolean NativeRetrieveAttributes(JNIEnv* env, jclass /*clazz*/, jlong pt
}
ScopedLock<AssetManager2> assetmanager(AssetManagerFromLong(ptr));
ResourceTimer _tag(ResourceTimer::Counter::RetrieveAttributes);
ResXMLParser* xml_parser = reinterpret_cast<ResXMLParser*>(xml_parser_ptr);
auto result =
RetrieveAttributes(assetmanager.get(), xml_parser, reinterpret_cast<uint32_t*>(attrs),

View File

@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.IResourcesManager;
import android.content.res.ResourceTimer;
import android.os.Binder;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
@@ -55,7 +56,7 @@ public class ResourcesManagerService extends SystemService {
@Override
public void onStart() {
// Intentionally left empty.
ResourceTimer.start();
}
private final IBinder mService = new IResourcesManager.Stub() {