Loading core/jni/android_database_SQLiteConnection.cpp +14 −18 Original line number Original line Diff line number Diff line Loading @@ -16,27 +16,22 @@ #define LOG_TAG "SQLiteConnection" #define LOG_TAG "SQLiteConnection" #include <jni.h> #include <android-base/mapped_file.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <android_runtime/Log.h> #include <utils/Log.h> #include <utils/String8.h> #include <utils/String16.h> #include <cutils/ashmem.h> #include <sys/mman.h> #include <string.h> #include <unistd.h> #include <androidfw/CursorWindow.h> #include <androidfw/CursorWindow.h> #include <cutils/ashmem.h> #include <jni.h> #include <nativehelper/JNIHelp.h> #include <sqlite3.h> #include <sqlite3.h> #include <sqlite3_android.h> #include <sqlite3_android.h> #include <string.h> #include <unistd.h> #include <utils/Log.h> #include <utils/String16.h> #include <utils/String8.h> #include "android_database_SQLiteCommon.h" #include "android_database_SQLiteCommon.h" #include "core_jni_helpers.h" #include "core_jni_helpers.h" // Set to 1 to use UTF16 storage for localized indexes. // Set to 1 to use UTF16 storage for localized indexes. Loading Loading @@ -649,13 +644,14 @@ static int createAshmemRegionWithData(JNIEnv* env, const void* data, size_t leng ALOGE("ashmem_create_region failed: %s", strerror(error)); ALOGE("ashmem_create_region failed: %s", strerror(error)); } else { } else { if (length > 0) { if (length > 0) { void* ptr = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); std::unique_ptr<base::MappedFile> mappedFile = if (ptr == MAP_FAILED) { base::MappedFile::FromFd(fd, 0, length, PROT_READ | PROT_WRITE); if (mappedFile == nullptr) { error = errno; error = errno; ALOGE("mmap failed: %s", strerror(error)); ALOGE("mmap failed: %s", strerror(error)); } else { } else { memcpy(ptr, data, length); memcpy(mappedFile->data(), data, length); munmap(ptr, length); mappedFile.reset(); } } } } Loading Loading
core/jni/android_database_SQLiteConnection.cpp +14 −18 Original line number Original line Diff line number Diff line Loading @@ -16,27 +16,22 @@ #define LOG_TAG "SQLiteConnection" #define LOG_TAG "SQLiteConnection" #include <jni.h> #include <android-base/mapped_file.h> #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <android_runtime/Log.h> #include <utils/Log.h> #include <utils/String8.h> #include <utils/String16.h> #include <cutils/ashmem.h> #include <sys/mman.h> #include <string.h> #include <unistd.h> #include <androidfw/CursorWindow.h> #include <androidfw/CursorWindow.h> #include <cutils/ashmem.h> #include <jni.h> #include <nativehelper/JNIHelp.h> #include <sqlite3.h> #include <sqlite3.h> #include <sqlite3_android.h> #include <sqlite3_android.h> #include <string.h> #include <unistd.h> #include <utils/Log.h> #include <utils/String16.h> #include <utils/String8.h> #include "android_database_SQLiteCommon.h" #include "android_database_SQLiteCommon.h" #include "core_jni_helpers.h" #include "core_jni_helpers.h" // Set to 1 to use UTF16 storage for localized indexes. // Set to 1 to use UTF16 storage for localized indexes. Loading Loading @@ -649,13 +644,14 @@ static int createAshmemRegionWithData(JNIEnv* env, const void* data, size_t leng ALOGE("ashmem_create_region failed: %s", strerror(error)); ALOGE("ashmem_create_region failed: %s", strerror(error)); } else { } else { if (length > 0) { if (length > 0) { void* ptr = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); std::unique_ptr<base::MappedFile> mappedFile = if (ptr == MAP_FAILED) { base::MappedFile::FromFd(fd, 0, length, PROT_READ | PROT_WRITE); if (mappedFile == nullptr) { error = errno; error = errno; ALOGE("mmap failed: %s", strerror(error)); ALOGE("mmap failed: %s", strerror(error)); } else { } else { memcpy(ptr, data, length); memcpy(mappedFile->data(), data, length); munmap(ptr, length); mappedFile.reset(); } } } } Loading