diff options
| author | 2017-11-16 11:54:29 +0000 | |
|---|---|---|
| committer | 2017-11-28 12:52:53 +0000 | |
| commit | 24ed94f83404bff97663142326762506458fd8cc (patch) | |
| tree | b60c8160f256b67348fbc5bc3fa1b818574ce2c5 /runtime/native/dalvik_system_DexFile.cc | |
| parent | b71fe8329fa2bf5a0a4f81fd44a097f43d7dfd8a (diff) | |
Add DexFile.getStaticSizeOfFile function.
Bug: b/69729799
Test: art/test/testrunner/testrunner.py -b -t 071-dexfile-get-static-size
Change-Id: I7d524bd0f8c8bab74b1831b1db35f5952e8ce2aa
Diffstat (limited to 'runtime/native/dalvik_system_DexFile.cc')
| -rw-r--r-- | runtime/native/dalvik_system_DexFile.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 22355638cd..c0de374904 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -744,6 +744,23 @@ static jobjectArray DexFile_getDexFileOutputPaths(JNIEnv* env, return result; } +static jlong DexFile_getStaticSizeOfDexFile(JNIEnv* env, jclass, jobject cookie) { + const OatFile* oat_file = nullptr; + std::vector<const DexFile*> dex_files; + if (!ConvertJavaArrayToDexFiles(env, cookie, /*out */ dex_files, /* out */ oat_file)) { + DCHECK(env->ExceptionCheck()); + return 0; + } + + uint64_t file_size = 0; + for (auto& dex_file : dex_files) { + if (dex_file) { + file_size += dex_file->GetHeader().file_size_; + } + } + return static_cast<jlong>(file_size); +} + static JNINativeMethod gMethods[] = { NATIVE_METHOD(DexFile, closeDexFile, "(Ljava/lang/Object;)Z"), NATIVE_METHOD(DexFile, @@ -779,7 +796,8 @@ static JNINativeMethod gMethods[] = { NATIVE_METHOD(DexFile, getDexFileStatus, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"), NATIVE_METHOD(DexFile, getDexFileOutputPaths, - "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;") + "(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;"), + NATIVE_METHOD(DexFile, getStaticSizeOfDexFile, "(Ljava/lang/Object;)J") }; void register_dalvik_system_DexFile(JNIEnv* env) { |