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

Commit fbdfba51 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

Make ApkAssets::IsUpToDate() @CriticalNative

This function keeps being called hundreds times per second

Bug: 237583012
Test: Build + boot + UTs

Change-Id: Id6e0e49d561e0c81f6960a5fd77b2076892bd339
parent a5775147
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.text.TextUtils;

import com.android.internal.annotations.GuardedBy;

import dalvik.annotation.optimization.CriticalNative;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -459,7 +461,7 @@ public final class ApkAssets {
    private static native @NonNull String nativeGetAssetPath(long ptr);
    private static native @NonNull String nativeGetDebugName(long ptr);
    private static native long nativeGetStringBlock(long ptr);
    private static native boolean nativeIsUpToDate(long ptr);
    @CriticalNative private static native boolean nativeIsUpToDate(long ptr);
    private static native long nativeOpenXml(long ptr, @NonNull String fileName) throws IOException;
    private static native @Nullable OverlayableInfo nativeGetOverlayableInfo(long ptr,
            String overlayableName) throws IOException;
+23 −19
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ static jlong NativeGetStringBlock(JNIEnv* /*env*/, jclass /*clazz*/, jlong ptr)
    return reinterpret_cast<jlong>(apk_assets->GetLoadedArsc()->GetStringPool());
}

static jboolean NativeIsUpToDate(JNIEnv* /*env*/, jclass /*clazz*/, jlong ptr) {
static jboolean NativeIsUpToDate(jlong ptr) {
    auto scoped_apk_assets = ScopedLock(ApkAssetsFromLong(ptr));
    auto apk_assets = scoped_apk_assets->get();
    return apk_assets->IsUpToDate() ? JNI_TRUE : JNI_FALSE;
@@ -502,17 +502,21 @@ static jboolean NativeDefinesOverlayable(JNIEnv* env, jclass /*clazz*/, jlong pt
static const JNINativeMethod gApkAssetsMethods[] = {
        {"nativeLoad", "(ILjava/lang/String;ILandroid/content/res/loader/AssetsProvider;)J",
         (void*)NativeLoad},
    {"nativeLoadEmpty", "(ILandroid/content/res/loader/AssetsProvider;)J", (void*)NativeLoadEmpty},
        {"nativeLoadEmpty", "(ILandroid/content/res/loader/AssetsProvider;)J",
         (void*)NativeLoadEmpty},
        {"nativeLoadFd",
     "(ILjava/io/FileDescriptor;Ljava/lang/String;ILandroid/content/res/loader/AssetsProvider;)J",
         "(ILjava/io/FileDescriptor;Ljava/lang/String;ILandroid/content/res/loader/"
         "AssetsProvider;)J",
         (void*)NativeLoadFromFd},
        {"nativeLoadFdOffsets",
     "(ILjava/io/FileDescriptor;Ljava/lang/String;JJILandroid/content/res/loader/AssetsProvider;)J",
         "(ILjava/io/FileDescriptor;Ljava/lang/String;JJILandroid/content/res/loader/"
         "AssetsProvider;)J",
         (void*)NativeLoadFromFdOffset},
        {"nativeDestroy", "(J)V", (void*)NativeDestroy},
        {"nativeGetAssetPath", "(J)Ljava/lang/String;", (void*)NativeGetAssetPath},
        {"nativeGetDebugName", "(J)Ljava/lang/String;", (void*)NativeGetDebugName},
        {"nativeGetStringBlock", "(J)J", (void*)NativeGetStringBlock},
        // @CriticalNative
        {"nativeIsUpToDate", "(J)Z", (void*)NativeIsUpToDate},
        {"nativeOpenXml", "(JLjava/lang/String;)J", (void*)NativeOpenXml},
        {"nativeGetOverlayableInfo", "(JLjava/lang/String;)Landroid/content/om/OverlayableInfo;",