diff --git a/.gitmodules b/.gitmodules index 6babf8d0..31ce5008 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,4 +18,16 @@ url = https://github.com/android/platform_frameworks_base.git [submodule "external/icu4c"] path = external/icu4c - url = https://github.com/android/platform_external_icu4c.git \ No newline at end of file + url = https://github.com/android/platform_external_icu4c.git +[submodule "external/libnativehelper"] + path = external/libnativehelper + url = https://android.googlesource.com/platform/libnativehelper +[submodule "notepadbot"] + path = dist/SQLCipherForAndroid-SDK/samples/notepadbot + url = https://github.com/guardianproject/notepadbot.git +[submodule "external/android-sqlite_lollipop"] + path = external/android-sqlite_lollipop + url = https://android.googlesource.com/platform/external/sqlite +[submodule "external/platform-system-core-lollipop"] + path = external/platform-system-core-lollipop + url = https://android.googlesource.com/platform/system/core diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..13ff31b0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: java +jdk: oraclejdk7 +install: +- sudo apt-get update > /dev/null +- sudo apt-get -qq install --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch +- export TERM=dumb +- wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz +- tar -zxf android-sdk_r24.4.1-linux.tgz +- export ANDROID_HOME=`pwd`/android-sdk-linux +- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools +- wget http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin -O ndk.bin +- chmod +x ndk.bin +- "./ndk.bin > /dev/null" +- ln -sf android-ndk-r10e android-ndk +- export ANDROID_NDK_HOME=`pwd`/android-ndk +- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_NDK_HOME} +- echo "sdk.dir=$ANDROID_HOME" > local.properties +- echo yes | android update sdk -a -t tools,platform-tools,extra-android-support,extra-android-m2repository,android-21,build-tools-21.0.2,extra-google-google_play_services,extra-google-m2repository + --force --no-ui +script: make init && make && zip -r android-sqlcipher-gmetal.zip libs/* assets/* +deploy: + provider: releases + api_key: + secure: cspljT77LBRZpCVq8oF4ltPpBk0Cwk5+DQMvT4fkqM3b+kf3+qBGwxdLO33jDUDwbE2od4xPVZFhFvsgMrl/CJjF0nevFQJzLOc+/35ATqJgWsQ8lujbSG/0J8NtO0cQ7f/gIS/QvPduHyopdmPOGyBEhLnGlSbtZDJWwPdj4h3WkZvPcwFN0rr+9iVYfj4vPby0mLpafvrPYqcOfIrj86qRD5zpSoC/qbBeDR/rahcHOcyw39dpb1mTL8ZcN1v5P6PtMH3e35+eKyBLE0uEEG2xUpocC6bU8tmrM6OsUSUwdpNGC6tpgFfNMRWNi9YvmpTf1aazKA0Xyj5ZJVDVRguI4pfzbjC6pf0b7QtwAMp5O+aSW+NAIP3X2WShTuBuYnJ6L5Ztwhu8a8SYOVhEWHOkpDPgznhd7+KtnZk3wniOLG2gMHvI06iWvrxPnUNSWD1QJBvWPp+HGzopIQz2qlcOD3Hu71lW1+3DshrKrkdRb618v5bsoCtCheWuKus08KI0cOH7ECDEKMufwzVqkpU7ebG/cdQ5mUmtjUEsXcR2cVvbl3WzAIPOu83iCujTYv+GIPnCBnoo3YbZOYcNInX9Vxs+UVAk5nyXZP1H0R64XY8Jx1KIhCduqowv0YZWc/PlmfAKhPpKZJRs/8/ObJ8mpDW4qXjmko4stXAgOmc= + file: android-sqlcipher-gmetal.zip + skip_cleanup: true + on: + repo: gmetal/android-database-sqlcipher diff --git a/Makefile b/Makefile index 31c0d638..07b8987a 100644 --- a/Makefile +++ b/Makefile @@ -83,14 +83,21 @@ clean: -rm ${LIBRARY_ROOT}/armeabi/libsqlcipher_android.so -rm ${LIBRARY_ROOT}/armeabi/libdatabase_sqlcipher.so -rm ${LIBRARY_ROOT}/armeabi/libstlport_shared.so + -rm ${LIBRARY_ROOT}/arm64_v8a/libsqlcipher_android.so + -rm ${LIBRARY_ROOT}/arm64_v8a/libdatabase_sqlcipher.so + -rm ${LIBRARY_ROOT}/arm64_v8a/libstlport_shared.so -rm ${LIBRARY_ROOT}/sqlcipher.jar -rm ${LIBRARY_ROOT}/x86/libsqlcipher_android.so -rm ${LIBRARY_ROOT}/x86/libdatabase_sqlcipher.so -rm ${LIBRARY_ROOT}/x86/libstlport_shared.so + -rm ${LIBRARY_ROOT}/x86_64/libsqlcipher_android.so + -rm ${LIBRARY_ROOT}/x86_64/libdatabase_sqlcipher.so + -rm ${LIBRARY_ROOT}/x86_64/libstlport_shared.so -rm ${LIBRARY_ROOT}/armeabi-v7a/libsqlcipher_android.so -rm ${LIBRARY_ROOT}/armeabi-v7a/libdatabase_sqlcipher.so -rm ${LIBRARY_ROOT}/armeabi-v7a/libstlport_shared.so + copy-libs: mkdir -p ${LIBRARY_ROOT}/armeabi cp ${EXTERNAL_DIR}/libs/armeabi/libsqlcipher_android.so \ @@ -99,6 +106,13 @@ copy-libs: ${LIBRARY_ROOT}/armeabi && \ cp ${EXTERNAL_DIR}/libs/armeabi/libstlport_shared.so \ ${LIBRARY_ROOT}/armeabi + mkdir -p ${LIBRARY_ROOT}/arm64-v8a + cp ${EXTERNAL_DIR}/libs/arm64-v8a/libsqlcipher_android.so \ + ${LIBRARY_ROOT}/arm64-v8a && \ + cp ${JNI_DIR}/libs/arm64-v8a/libdatabase_sqlcipher.so \ + ${LIBRARY_ROOT}/arm64-v8a && \ + cp ${EXTERNAL_DIR}/libs/arm64-v8a/libstlport_shared.so \ + ${LIBRARY_ROOT}/arm64-v8a mkdir -p ${LIBRARY_ROOT}/x86 cp ${EXTERNAL_DIR}/libs/x86/libsqlcipher_android.so \ ${LIBRARY_ROOT}/x86 && \ @@ -106,6 +120,13 @@ copy-libs: ${LIBRARY_ROOT}/x86 && \ cp ${EXTERNAL_DIR}/libs/x86/libstlport_shared.so \ ${LIBRARY_ROOT}/x86 + mkdir -p ${LIBRARY_ROOT}/x86_64 + cp ${EXTERNAL_DIR}/libs/x86_64/libsqlcipher_android.so \ + ${LIBRARY_ROOT}/x86_64 && \ + cp ${JNI_DIR}/libs/x86_64/libdatabase_sqlcipher.so \ + ${LIBRARY_ROOT}/x86_64 && \ + cp ${EXTERNAL_DIR}/libs/x86_64/libstlport_shared.so \ + ${LIBRARY_ROOT}/x86_64 mkdir -p ${LIBRARY_ROOT}/armeabi-v7a cp ${EXTERNAL_DIR}/libs/armeabi-v7a/libsqlcipher_android.so \ ${LIBRARY_ROOT}/armeabi-v7a && \ @@ -116,7 +137,7 @@ copy-libs: copy-libs-dist: cp ${LIBRARY_ROOT}/*.jar dist/SQLCipherForAndroid-SDK/libs/ && \ - cp ${LIBRARY_ROOT}/armeabi/*.so dist/SQLCipherForAndroid-SDK/libs/armeabi/ + cp ${LIBRARY_ROOT}/arm64_v8a/*.so dist/SQLCipherForAndroid-SDK/libs/arm64_v8a/ build-openssl-libraries: ./build-openssl-libraries.sh diff --git a/build-openssl-libraries.sh b/build-openssl-libraries.sh index 4b57013c..290f37d3 100755 --- a/build-openssl-libraries.sh +++ b/build-openssl-libraries.sh @@ -26,7 +26,10 @@ esac rm ../android-libs/armeabi/libcrypto.a \ - ../android-libs/x86/libcrypto.a + ../android-libs/x86/libcrypto.a \ + ../android-libs/arm64-v8a/libcrypto.a \ + ../android-libs/x86_64/libcrypto.a + git clean -dfx && git checkout -f ./Configure dist @@ -98,4 +101,60 @@ make clean make build_crypto mv libcrypto.a ../android-libs/x86/ + + rm -rf ${ANDROID_TOOLCHAIN_DIR} + + make clean + git clean -dfx && git checkout -f + + # Patch openssl to support building for arm64-v8a && x86_64 + # Note, we only patch the Configure script + patch -p1 < ../../openssl_android_64_bit_support.patch + + # arm64-v8a build + ANDROID_PLATFORM_VERSION=android-21 + ${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \ + --platform=${ANDROID_PLATFORM_VERSION} \ + --install-dir=${ANDROID_TOOLCHAIN_DIR} \ + --system=${TOOLCHAIN_SYSTEM} \ + --arch=arm64 + + export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH + + RANLIB=aarch64-linux-android-ranlib \ + AR=aarch64-linux-android-ar \ + CC=aarch64-linux-android-gcc \ + ./Configure android-aarch64 ${OPENSSL_EXCLUSION_LIST} + + make build_crypto + + mv libcrypto.a ../android-libs/arm64-v8a/ + + rm -rf ${ANDROID_TOOLCHAIN_DIR} + + make clean + git clean -dfx && git checkout -f + + patch -p1 < ../../openssl_android_64_bit_support.patch + + # x86_64 build + ANDROID_PLATFORM_VERSION=android-21 + ${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \ + --platform=${ANDROID_PLATFORM_VERSION} \ + --install-dir=${ANDROID_TOOLCHAIN_DIR} \ + --system=${TOOLCHAIN_SYSTEM} \ + --arch=x86_64 + + export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH + + RANLIB=x86_64-linux-android-ranlib \ + AR=x86_64-linux-android-ar \ + CC=x86_64-linux-android-gcc \ + ./Configure android-x86_64 ${OPENSSL_EXCLUSION_LIST} + + make build_crypto + + mv libcrypto.a ../android-libs/x86_64/ + + rm -rf ${ANDROID_TOOLCHAIN_DIR} ) diff --git a/external/Android.mk b/external/Android.mk index 8156c9ae..d413f586 100644 --- a/external/Android.mk +++ b/external/Android.mk @@ -19,7 +19,7 @@ sqlcipher/sqlite3.c: copy-libs-hack: build-local-hack install -p -m644 libs/armeabi/*.so ../obj/local/armeabi/ -project_ldflags:= -Llibs/$(TARGET_ARCH_ABI)/ -Landroid-libs/$(TARGET_ARCH_ABI)/ +project_ldflags:= -Llibs/$(TARGET_ARCH_ABI)/ -Landroid-libs/$(TARGET_ARCH_ABI)/ -fuse-ld=bfd #------------------------------------------------------------------------------# # libsqlite3 @@ -63,17 +63,24 @@ include $(PREBUILT_STATIC_LIBRARY) # libsqlcipher_android (our version of Android's libsqlite_android) # these are all files from various external git repos -libsqlite3_android_local_src_files := \ +libsqlite3_android_local_src_files_32 := \ android-sqlite/android/sqlite3_android.cpp \ android-sqlite/android/PhonebookIndex.cpp \ android-sqlite/android/PhoneNumberUtils.cpp \ android-sqlite/android/OldPhoneNumberUtils.cpp \ android-sqlite/android/PhoneticStringUtils.cpp \ - String16.cpp \ - String8.cpp + String16_32.cpp \ + String8_32.cpp # android-sqlite/android/PhoneNumberUtilsTest.cpp \ # android-sqlite/android/PhoneticStringUtilsTest.cpp \ +libsqlite3_android_local_src_files_64 := \ + android-sqlite_lollipop/android/sqlite3_android.cpp \ + android-sqlite_lollipop/android/PhoneNumberUtils.cpp \ + android-sqlite_lollipop/android/OldPhoneNumberUtils.cpp \ + String16_64.cpp \ + String8_64.cpp + include $(CLEAR_VARS) ## this might save us linking against the private android shared libraries like @@ -87,20 +94,29 @@ LOCAL_STATIC_LIBRARIES := libsqlcipher libicui18n libicuuc static-libcrypto LOCAL_CFLAGS += $(android_sqlite_cflags) $(sqlite_cflags) \ -DOS_PATH_SEPARATOR="'/'" -DHAVE_SYS_UIO_H -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/includes \ - $(LOCAL_PATH)/sqlcipher \ - $(LOCAL_PATH)/icu4c/i18n \ - $(LOCAL_PATH)/icu4c/common \ - $(LOCAL_PATH)/platform-system-core/include \ - $(LOCAL_PATH)/platform-frameworks-base/include - LOCAL_LDFLAGS += -fuse-ld=bfd LOCAL_LDFLAGS += -L${LOCAL_PATH}/android-libs/$(TARGET_ARCH_ABI)/ -L$(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/ LOCAL_LDLIBS := -llog -lutils -lcutils LOCAL_MODULE := libsqlcipher_android LOCAL_MODULE_FILENAME := libsqlcipher_android -LOCAL_SRC_FILES := $(libsqlite3_android_local_src_files) + +ifeq ($(TARGET_ARCH_ABI), $(filter $(TARGET_ARCH_ABI), armeabi armeabi-v7a x86)) + LOCAL_SRC_FILES := $(libsqlite3_android_local_src_files_32) + LOCAL_C_INCLUDES := $(LOCAL_PATH)/includes/arch32 \ + $(LOCAL_PATH)/platform-system-core/include + +else ifeq ($(TARGET_ARCH_ABI), $(filter $(TARGET_ARCH_ABI), x86_64 arm64-v8a)) + LOCAL_SRC_FILES := $(libsqlite3_android_local_src_files_64) + LOCAL_C_INCLUDES := $(LOCAL_PATH)/includes/arch64 \ + $(LOCAL_PATH)/platform-system-core-lollipop/include + +endif + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/sqlcipher \ + $(LOCAL_PATH)/icu4c/i18n \ + $(LOCAL_PATH)/icu4c/common \ + $(LOCAL_PATH)/platform-frameworks-base/include include $(BUILD_SHARED_LIBRARY) diff --git a/external/String16.cpp b/external/String16_32.cpp similarity index 100% rename from external/String16.cpp rename to external/String16_32.cpp diff --git a/external/String16_64.cpp b/external/String16_64.cpp new file mode 100644 index 00000000..91efdaa3 --- /dev/null +++ b/external/String16_64.cpp @@ -0,0 +1,419 @@ +/* + * Copyright (C) 2005 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include + +#include +#include +#include + + +namespace android { + +static SharedBuffer* gEmptyStringBuf = NULL; +static char16_t* gEmptyString = NULL; + +static inline char16_t* getEmptyString() +{ + gEmptyStringBuf->acquire(); + return gEmptyString; +} + +void initialize_string16() +{ + SharedBuffer* buf = SharedBuffer::alloc(sizeof(char16_t)); + char16_t* str = (char16_t*)buf->data(); + *str = 0; + gEmptyStringBuf = buf; + gEmptyString = str; +} + +void terminate_string16() +{ + SharedBuffer::bufferFromData(gEmptyString)->release(); + gEmptyStringBuf = NULL; + gEmptyString = NULL; +} + +// --------------------------------------------------------------------------- + +static char16_t* allocFromUTF8(const char* u8str, size_t u8len) +{ + if (u8len == 0) return getEmptyString(); + + const uint8_t* u8cur = (const uint8_t*) u8str; + + const ssize_t u16len = utf8_to_utf16_length(u8cur, u8len); + if (u16len < 0) { + return getEmptyString(); + } + + SharedBuffer* buf = SharedBuffer::alloc(sizeof(char16_t)*(u16len+1)); + if (buf) { + u8cur = (const uint8_t*) u8str; + char16_t* u16str = (char16_t*)buf->data(); + + utf8_to_utf16(u8cur, u8len, u16str); + + //printf("Created UTF-16 string from UTF-8 \"%s\":", in); + //printHexData(1, str, buf->size(), 16, 1); + //printf("\n"); + + return u16str; + } + + return getEmptyString(); +} + +// --------------------------------------------------------------------------- + +String16::String16() + : mString(getEmptyString()) +{ +} + +String16::String16(StaticLinkage) + : mString(0) +{ + // this constructor is used when we can't rely on the static-initializers + // having run. In this case we always allocate an empty string. It's less + // efficient than using getEmptyString(), but we assume it's uncommon. + + char16_t* data = static_cast( + SharedBuffer::alloc(sizeof(char16_t))->data()); + data[0] = 0; + mString = data; +} + +String16::String16(const String16& o) + : mString(o.mString) +{ + SharedBuffer::bufferFromData(mString)->acquire(); +} + +String16::String16(const String16& o, size_t len, size_t begin) + : mString(getEmptyString()) +{ + setTo(o, len, begin); +} + +String16::String16(const char16_t* o) +{ + size_t len = strlen16(o); + SharedBuffer* buf = SharedBuffer::alloc((len+1)*sizeof(char16_t)); + ALOG_ASSERT(buf, "Unable to allocate shared buffer"); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + strcpy16(str, o); + mString = str; + return; + } + + mString = getEmptyString(); +} + +String16::String16(const char16_t* o, size_t len) +{ + SharedBuffer* buf = SharedBuffer::alloc((len+1)*sizeof(char16_t)); + ALOG_ASSERT(buf, "Unable to allocate shared buffer"); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + memcpy(str, o, len*sizeof(char16_t)); + str[len] = 0; + mString = str; + return; + } + + mString = getEmptyString(); +} + +String16::String16(const String8& o) + : mString(allocFromUTF8(o.string(), o.size())) +{ +} + +String16::String16(const char* o) + : mString(allocFromUTF8(o, strlen(o))) +{ +} + +String16::String16(const char* o, size_t len) + : mString(allocFromUTF8(o, len)) +{ +} + +String16::~String16() +{ + SharedBuffer::bufferFromData(mString)->release(); +} + +void String16::setTo(const String16& other) +{ + SharedBuffer::bufferFromData(other.mString)->acquire(); + SharedBuffer::bufferFromData(mString)->release(); + mString = other.mString; +} + +status_t String16::setTo(const String16& other, size_t len, size_t begin) +{ + const size_t N = other.size(); + if (begin >= N) { + SharedBuffer::bufferFromData(mString)->release(); + mString = getEmptyString(); + return NO_ERROR; + } + if ((begin+len) > N) len = N-begin; + if (begin == 0 && len == N) { + setTo(other); + return NO_ERROR; + } + + if (&other == this) { + LOG_ALWAYS_FATAL("Not implemented"); + } + + return setTo(other.string()+begin, len); +} + +status_t String16::setTo(const char16_t* other) +{ + return setTo(other, strlen16(other)); +} + +status_t String16::setTo(const char16_t* other, size_t len) +{ + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize((len+1)*sizeof(char16_t)); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + memmove(str, other, len*sizeof(char16_t)); + str[len] = 0; + mString = str; + return NO_ERROR; + } + return NO_MEMORY; +} + +status_t String16::append(const String16& other) +{ + const size_t myLen = size(); + const size_t otherLen = other.size(); + if (myLen == 0) { + setTo(other); + return NO_ERROR; + } else if (otherLen == 0) { + return NO_ERROR; + } + + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize((myLen+otherLen+1)*sizeof(char16_t)); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + memcpy(str+myLen, other, (otherLen+1)*sizeof(char16_t)); + mString = str; + return NO_ERROR; + } + return NO_MEMORY; +} + +status_t String16::append(const char16_t* chrs, size_t otherLen) +{ + const size_t myLen = size(); + if (myLen == 0) { + setTo(chrs, otherLen); + return NO_ERROR; + } else if (otherLen == 0) { + return NO_ERROR; + } + + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize((myLen+otherLen+1)*sizeof(char16_t)); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + memcpy(str+myLen, chrs, otherLen*sizeof(char16_t)); + str[myLen+otherLen] = 0; + mString = str; + return NO_ERROR; + } + return NO_MEMORY; +} + +status_t String16::insert(size_t pos, const char16_t* chrs) +{ + return insert(pos, chrs, strlen16(chrs)); +} + +status_t String16::insert(size_t pos, const char16_t* chrs, size_t len) +{ + const size_t myLen = size(); + if (myLen == 0) { + return setTo(chrs, len); + return NO_ERROR; + } else if (len == 0) { + return NO_ERROR; + } + + if (pos > myLen) pos = myLen; + + #if 0 + printf("Insert in to %s: pos=%d, len=%d, myLen=%d, chrs=%s\n", + String8(*this).string(), pos, + len, myLen, String8(chrs, len).string()); + #endif + + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize((myLen+len+1)*sizeof(char16_t)); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + if (pos < myLen) { + memmove(str+pos+len, str+pos, (myLen-pos)*sizeof(char16_t)); + } + memcpy(str+pos, chrs, len*sizeof(char16_t)); + str[myLen+len] = 0; + mString = str; + #if 0 + printf("Result (%d chrs): %s\n", size(), String8(*this).string()); + #endif + return NO_ERROR; + } + return NO_MEMORY; +} + +ssize_t String16::findFirst(char16_t c) const +{ + const char16_t* str = string(); + const char16_t* p = str; + const char16_t* e = p + size(); + while (p < e) { + if (*p == c) { + return p-str; + } + p++; + } + return -1; +} + +ssize_t String16::findLast(char16_t c) const +{ + const char16_t* str = string(); + const char16_t* p = str; + const char16_t* e = p + size(); + while (p < e) { + e--; + if (*e == c) { + return e-str; + } + } + return -1; +} + +bool String16::startsWith(const String16& prefix) const +{ + const size_t ps = prefix.size(); + if (ps > size()) return false; + return strzcmp16(mString, ps, prefix.string(), ps) == 0; +} + +bool String16::startsWith(const char16_t* prefix) const +{ + const size_t ps = strlen16(prefix); + if (ps > size()) return false; + return strncmp16(mString, prefix, ps) == 0; +} + +status_t String16::makeLower() +{ + const size_t N = size(); + const char16_t* str = string(); + char16_t* edit = NULL; + for (size_t i=0; i= 'A' && v <= 'Z') { + if (!edit) { + SharedBuffer* buf = SharedBuffer::bufferFromData(mString)->edit(); + if (!buf) { + return NO_MEMORY; + } + edit = (char16_t*)buf->data(); + mString = str = edit; + } + edit[i] = tolower((char)v); + } + } + return NO_ERROR; +} + +status_t String16::replaceAll(char16_t replaceThis, char16_t withThis) +{ + const size_t N = size(); + const char16_t* str = string(); + char16_t* edit = NULL; + for (size_t i=0; iedit(); + if (!buf) { + return NO_MEMORY; + } + edit = (char16_t*)buf->data(); + mString = str = edit; + } + edit[i] = withThis; + } + } + return NO_ERROR; +} + +status_t String16::remove(size_t len, size_t begin) +{ + const size_t N = size(); + if (begin >= N) { + SharedBuffer::bufferFromData(mString)->release(); + mString = getEmptyString(); + return NO_ERROR; + } + if ((begin+len) > N) len = N-begin; + if (begin == 0 && len == N) { + return NO_ERROR; + } + + if (begin > 0) { + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize((N+1)*sizeof(char16_t)); + if (!buf) { + return NO_MEMORY; + } + char16_t* str = (char16_t*)buf->data(); + memmove(str, str+begin, (N-begin+1)*sizeof(char16_t)); + mString = str; + } + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize((len+1)*sizeof(char16_t)); + if (buf) { + char16_t* str = (char16_t*)buf->data(); + str[len] = 0; + mString = str; + return NO_ERROR; + } + return NO_MEMORY; +} + +}; // namespace android diff --git a/external/String8.cpp b/external/String8_32.cpp similarity index 100% rename from external/String8.cpp rename to external/String8_32.cpp diff --git a/external/String8_64.cpp b/external/String8_64.cpp new file mode 100644 index 00000000..49340bbb --- /dev/null +++ b/external/String8_64.cpp @@ -0,0 +1,648 @@ +/* + * Copyright (C) 2005 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include + +#include + +/* + * Functions outside android is below the namespace android, since they use + * functions and constants in android namespace. + */ + +// --------------------------------------------------------------------------- + +namespace android { + +// Separator used by resource paths. This is not platform dependent contrary +// to OS_PATH_SEPARATOR. +#define RES_PATH_SEPARATOR '/' + +static SharedBuffer* gEmptyStringBuf = NULL; +static char* gEmptyString = NULL; + +extern int gDarwinCantLoadAllObjects; +int gDarwinIsReallyAnnoying; + +void initialize_string8(); + +static inline char* getEmptyString() +{ + gEmptyStringBuf->acquire(); + return gEmptyString; +} + +void initialize_string8() +{ + // HACK: This dummy dependency forces linking libutils Static.cpp, + // which is needed to initialize String8/String16 classes. + // These variables are named for Darwin, but are needed elsewhere too, + // including static linking on any platform. + gDarwinIsReallyAnnoying = gDarwinCantLoadAllObjects; + + SharedBuffer* buf = SharedBuffer::alloc(1); + char* str = (char*)buf->data(); + *str = 0; + gEmptyStringBuf = buf; + gEmptyString = str; +} + +void terminate_string8() +{ + SharedBuffer::bufferFromData(gEmptyString)->release(); + gEmptyStringBuf = NULL; + gEmptyString = NULL; +} + +// --------------------------------------------------------------------------- + +static char* allocFromUTF8(const char* in, size_t len) +{ + if (len > 0) { + SharedBuffer* buf = SharedBuffer::alloc(len+1); + ALOG_ASSERT(buf, "Unable to allocate shared buffer"); + if (buf) { + char* str = (char*)buf->data(); + memcpy(str, in, len); + str[len] = 0; + return str; + } + return NULL; + } + + return getEmptyString(); +} + +static char* allocFromUTF16(const char16_t* in, size_t len) +{ + if (len == 0) return getEmptyString(); + + const ssize_t bytes = utf16_to_utf8_length(in, len); + if (bytes < 0) { + return getEmptyString(); + } + + SharedBuffer* buf = SharedBuffer::alloc(bytes+1); + ALOG_ASSERT(buf, "Unable to allocate shared buffer"); + if (!buf) { + return getEmptyString(); + } + + char* str = (char*)buf->data(); + utf16_to_utf8(in, len, str); + return str; +} + +static char* allocFromUTF32(const char32_t* in, size_t len) +{ + if (len == 0) { + return getEmptyString(); + } + + const ssize_t bytes = utf32_to_utf8_length(in, len); + if (bytes < 0) { + return getEmptyString(); + } + + SharedBuffer* buf = SharedBuffer::alloc(bytes+1); + ALOG_ASSERT(buf, "Unable to allocate shared buffer"); + if (!buf) { + return getEmptyString(); + } + + char* str = (char*) buf->data(); + utf32_to_utf8(in, len, str); + + return str; +} + +// --------------------------------------------------------------------------- + +String8::String8() + : mString(getEmptyString()) +{ +} + +String8::String8(StaticLinkage) + : mString(0) +{ + // this constructor is used when we can't rely on the static-initializers + // having run. In this case we always allocate an empty string. It's less + // efficient than using getEmptyString(), but we assume it's uncommon. + + char* data = static_cast( + SharedBuffer::alloc(sizeof(char))->data()); + data[0] = 0; + mString = data; +} + +String8::String8(const String8& o) + : mString(o.mString) +{ + SharedBuffer::bufferFromData(mString)->acquire(); +} + +String8::String8(const char* o) + : mString(allocFromUTF8(o, strlen(o))) +{ + if (mString == NULL) { + mString = getEmptyString(); + } +} + +String8::String8(const char* o, size_t len) + : mString(allocFromUTF8(o, len)) +{ + if (mString == NULL) { + mString = getEmptyString(); + } +} + +String8::String8(const String16& o) + : mString(allocFromUTF16(o.string(), o.size())) +{ +} + +String8::String8(const char16_t* o) + : mString(allocFromUTF16(o, strlen16(o))) +{ +} + +String8::String8(const char16_t* o, size_t len) + : mString(allocFromUTF16(o, len)) +{ +} + +String8::String8(const char32_t* o) + : mString(allocFromUTF32(o, strlen32(o))) +{ +} + +String8::String8(const char32_t* o, size_t len) + : mString(allocFromUTF32(o, len)) +{ +} + +String8::~String8() +{ + SharedBuffer::bufferFromData(mString)->release(); +} + +String8 String8::format(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + + String8 result(formatV(fmt, args)); + + va_end(args); + return result; +} + +String8 String8::formatV(const char* fmt, va_list args) +{ + String8 result; + result.appendFormatV(fmt, args); + return result; +} + +void String8::clear() { + SharedBuffer::bufferFromData(mString)->release(); + mString = getEmptyString(); +} + +void String8::setTo(const String8& other) +{ + SharedBuffer::bufferFromData(other.mString)->acquire(); + SharedBuffer::bufferFromData(mString)->release(); + mString = other.mString; +} + +status_t String8::setTo(const char* other) +{ + const char *newString = allocFromUTF8(other, strlen(other)); + SharedBuffer::bufferFromData(mString)->release(); + mString = newString; + if (mString) return NO_ERROR; + + mString = getEmptyString(); + return NO_MEMORY; +} + +status_t String8::setTo(const char* other, size_t len) +{ + const char *newString = allocFromUTF8(other, len); + SharedBuffer::bufferFromData(mString)->release(); + mString = newString; + if (mString) return NO_ERROR; + + mString = getEmptyString(); + return NO_MEMORY; +} + +status_t String8::setTo(const char16_t* other, size_t len) +{ + const char *newString = allocFromUTF16(other, len); + SharedBuffer::bufferFromData(mString)->release(); + mString = newString; + if (mString) return NO_ERROR; + + mString = getEmptyString(); + return NO_MEMORY; +} + +status_t String8::setTo(const char32_t* other, size_t len) +{ + const char *newString = allocFromUTF32(other, len); + SharedBuffer::bufferFromData(mString)->release(); + mString = newString; + if (mString) return NO_ERROR; + + mString = getEmptyString(); + return NO_MEMORY; +} + +status_t String8::append(const String8& other) +{ + const size_t otherLen = other.bytes(); + if (bytes() == 0) { + setTo(other); + return NO_ERROR; + } else if (otherLen == 0) { + return NO_ERROR; + } + + return real_append(other.string(), otherLen); +} + +status_t String8::append(const char* other) +{ + return append(other, strlen(other)); +} + +status_t String8::append(const char* other, size_t otherLen) +{ + if (bytes() == 0) { + return setTo(other, otherLen); + } else if (otherLen == 0) { + return NO_ERROR; + } + + return real_append(other, otherLen); +} + +status_t String8::appendFormat(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + + status_t result = appendFormatV(fmt, args); + + va_end(args); + return result; +} + +status_t String8::appendFormatV(const char* fmt, va_list args) +{ + int n, result = NO_ERROR; + va_list tmp_args; + + /* args is undefined after vsnprintf. + * So we need a copy here to avoid the + * second vsnprintf access undefined args. + */ + va_copy(tmp_args, args); + n = vsnprintf(NULL, 0, fmt, tmp_args); + va_end(tmp_args); + + if (n != 0) { + size_t oldLength = length(); + char* buf = lockBuffer(oldLength + n); + if (buf) { + vsnprintf(buf + oldLength, n + 1, fmt, args); + } else { + result = NO_MEMORY; + } + } + return result; +} + +status_t String8::real_append(const char* other, size_t otherLen) +{ + const size_t myLen = bytes(); + + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize(myLen+otherLen+1); + if (buf) { + char* str = (char*)buf->data(); + mString = str; + str += myLen; + memcpy(str, other, otherLen); + str[otherLen] = '\0'; + return NO_ERROR; + } + return NO_MEMORY; +} + +char* String8::lockBuffer(size_t size) +{ + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize(size+1); + if (buf) { + char* str = (char*)buf->data(); + mString = str; + return str; + } + return NULL; +} + +void String8::unlockBuffer() +{ + unlockBuffer(strlen(mString)); +} + +status_t String8::unlockBuffer(size_t size) +{ + if (size != this->size()) { + SharedBuffer* buf = SharedBuffer::bufferFromData(mString) + ->editResize(size+1); + if (! buf) { + return NO_MEMORY; + } + + char* str = (char*)buf->data(); + str[size] = 0; + mString = str; + } + + return NO_ERROR; +} + +ssize_t String8::find(const char* other, size_t start) const +{ + size_t len = size(); + if (start >= len) { + return -1; + } + const char* s = mString+start; + const char* p = strstr(s, other); + return p ? p-mString : -1; +} + +void String8::toLower() +{ + toLower(0, size()); +} + +void String8::toLower(size_t start, size_t length) +{ + const size_t len = size(); + if (start >= len) { + return; + } + if (start+length > len) { + length = len-start; + } + char* buf = lockBuffer(len); + buf += start; + while (length > 0) { + *buf = tolower(*buf); + buf++; + length--; + } + unlockBuffer(len); +} + +void String8::toUpper() +{ + toUpper(0, size()); +} + +void String8::toUpper(size_t start, size_t length) +{ + const size_t len = size(); + if (start >= len) { + return; + } + if (start+length > len) { + length = len-start; + } + char* buf = lockBuffer(len); + buf += start; + while (length > 0) { + *buf = toupper(*buf); + buf++; + length--; + } + unlockBuffer(len); +} + +size_t String8::getUtf32Length() const +{ + return utf8_to_utf32_length(mString, length()); +} + +int32_t String8::getUtf32At(size_t index, size_t *next_index) const +{ + return utf32_from_utf8_at(mString, length(), index, next_index); +} + +void String8::getUtf32(char32_t* dst) const +{ + utf8_to_utf32(mString, length(), dst); +} + +// --------------------------------------------------------------------------- +// Path functions + +void String8::setPathName(const char* name) +{ + setPathName(name, strlen(name)); +} + +void String8::setPathName(const char* name, size_t len) +{ + char* buf = lockBuffer(len); + + memcpy(buf, name, len); + + // remove trailing path separator, if present + if (len > 0 && buf[len-1] == OS_PATH_SEPARATOR) + len--; + + buf[len] = '\0'; + + unlockBuffer(len); +} + +String8 String8::getPathLeaf(void) const +{ + const char* cp; + const char*const buf = mString; + + cp = strrchr(buf, OS_PATH_SEPARATOR); + if (cp == NULL) + return String8(*this); + else + return String8(cp+1); +} + +String8 String8::getPathDir(void) const +{ + const char* cp; + const char*const str = mString; + + cp = strrchr(str, OS_PATH_SEPARATOR); + if (cp == NULL) + return String8(""); + else + return String8(str, cp - str); +} + +String8 String8::walkPath(String8* outRemains) const +{ + const char* cp; + const char*const str = mString; + const char* buf = str; + + cp = strchr(buf, OS_PATH_SEPARATOR); + if (cp == buf) { + // don't include a leading '/'. + buf = buf+1; + cp = strchr(buf, OS_PATH_SEPARATOR); + } + + if (cp == NULL) { + String8 res = buf != str ? String8(buf) : *this; + if (outRemains) *outRemains = String8(""); + return res; + } + + String8 res(buf, cp-buf); + if (outRemains) *outRemains = String8(cp+1); + return res; +} + +/* + * Helper function for finding the start of an extension in a pathname. + * + * Returns a pointer inside mString, or NULL if no extension was found. + */ +char* String8::find_extension(void) const +{ + const char* lastSlash; + const char* lastDot; + const char* const str = mString; + + // only look at the filename + lastSlash = strrchr(str, OS_PATH_SEPARATOR); + if (lastSlash == NULL) + lastSlash = str; + else + lastSlash++; + + // find the last dot + lastDot = strrchr(lastSlash, '.'); + if (lastDot == NULL) + return NULL; + + // looks good, ship it + return const_cast(lastDot); +} + +String8 String8::getPathExtension(void) const +{ + char* ext; + + ext = find_extension(); + if (ext != NULL) + return String8(ext); + else + return String8(""); +} + +String8 String8::getBasePath(void) const +{ + char* ext; + const char* const str = mString; + + ext = find_extension(); + if (ext == NULL) + return String8(*this); + else + return String8(str, ext - str); +} + +String8& String8::appendPath(const char* name) +{ + // TODO: The test below will fail for Win32 paths. Fix later or ignore. + if (name[0] != OS_PATH_SEPARATOR) { + if (*name == '\0') { + // nothing to do + return *this; + } + + size_t len = length(); + if (len == 0) { + // no existing filename, just use the new one + setPathName(name); + return *this; + } + + // make room for oldPath + '/' + newPath + int newlen = strlen(name); + + char* buf = lockBuffer(len+1+newlen); + + // insert a '/' if needed + if (buf[len-1] != OS_PATH_SEPARATOR) + buf[len++] = OS_PATH_SEPARATOR; + + memcpy(buf+len, name, newlen+1); + len += newlen; + + unlockBuffer(len); + + return *this; + } else { + setPathName(name); + return *this; + } +} + +String8& String8::convertToResPath() +{ +#if OS_PATH_SEPARATOR != RES_PATH_SEPARATOR + size_t len = length(); + if (len > 0) { + char * buf = lockBuffer(len); + for (char * end = buf + len; buf < end; ++buf) { + if (*buf == OS_PATH_SEPARATOR) + *buf = RES_PATH_SEPARATOR; + } + unlockBuffer(len); + } +#endif + return *this; +} + +}; // namespace android diff --git a/external/android-libs/arm64-v8a/libandroid_runtime.so b/external/android-libs/arm64-v8a/libandroid_runtime.so new file mode 100755 index 00000000..d84c09f2 Binary files /dev/null and b/external/android-libs/arm64-v8a/libandroid_runtime.so differ diff --git a/external/android-libs/arm64-v8a/libbinder.so b/external/android-libs/arm64-v8a/libbinder.so new file mode 100755 index 00000000..b03cbabd Binary files /dev/null and b/external/android-libs/arm64-v8a/libbinder.so differ diff --git a/external/android-libs/arm64-v8a/libcrypto.a b/external/android-libs/arm64-v8a/libcrypto.a new file mode 100644 index 00000000..e62bb6c2 Binary files /dev/null and b/external/android-libs/arm64-v8a/libcrypto.a differ diff --git a/external/android-libs/arm64-v8a/libcutils.so b/external/android-libs/arm64-v8a/libcutils.so new file mode 100755 index 00000000..be212bf6 Binary files /dev/null and b/external/android-libs/arm64-v8a/libcutils.so differ diff --git a/external/android-libs/arm64-v8a/libnativehelper.so b/external/android-libs/arm64-v8a/libnativehelper.so new file mode 100755 index 00000000..75669453 Binary files /dev/null and b/external/android-libs/arm64-v8a/libnativehelper.so differ diff --git a/external/android-libs/arm64-v8a/libssl.a b/external/android-libs/arm64-v8a/libssl.a new file mode 100644 index 00000000..2a3c014f Binary files /dev/null and b/external/android-libs/arm64-v8a/libssl.a differ diff --git a/external/android-libs/arm64-v8a/libutils.so b/external/android-libs/arm64-v8a/libutils.so new file mode 100755 index 00000000..1ee47825 Binary files /dev/null and b/external/android-libs/arm64-v8a/libutils.so differ diff --git a/external/android-libs/x86_64/libandroid_runtime.so b/external/android-libs/x86_64/libandroid_runtime.so new file mode 100644 index 00000000..0fbb6c92 Binary files /dev/null and b/external/android-libs/x86_64/libandroid_runtime.so differ diff --git a/external/android-libs/x86_64/libbinder.so b/external/android-libs/x86_64/libbinder.so new file mode 100644 index 00000000..6039159b Binary files /dev/null and b/external/android-libs/x86_64/libbinder.so differ diff --git a/external/android-libs/x86_64/libcrypto.a b/external/android-libs/x86_64/libcrypto.a new file mode 100644 index 00000000..e3dc51ee Binary files /dev/null and b/external/android-libs/x86_64/libcrypto.a differ diff --git a/external/android-libs/x86_64/libcutils.so b/external/android-libs/x86_64/libcutils.so new file mode 100644 index 00000000..8456d76b Binary files /dev/null and b/external/android-libs/x86_64/libcutils.so differ diff --git a/external/android-libs/x86_64/libnativehelper.so b/external/android-libs/x86_64/libnativehelper.so new file mode 100644 index 00000000..5333803b Binary files /dev/null and b/external/android-libs/x86_64/libnativehelper.so differ diff --git a/external/android-libs/x86_64/libssl.a b/external/android-libs/x86_64/libssl.a new file mode 100644 index 00000000..6972757d Binary files /dev/null and b/external/android-libs/x86_64/libssl.a differ diff --git a/external/android-libs/x86_64/libutils.so b/external/android-libs/x86_64/libutils.so new file mode 100644 index 00000000..2110f278 Binary files /dev/null and b/external/android-libs/x86_64/libutils.so differ diff --git a/external/android-sqlite_lollipop b/external/android-sqlite_lollipop new file mode 160000 index 00000000..3f8fe414 --- /dev/null +++ b/external/android-sqlite_lollipop @@ -0,0 +1 @@ +Subproject commit 3f8fe414895cd42b17964d3044c2ecb1d5f2dae2 diff --git a/external/includes/utils/String16.h b/external/includes/arch32/utils/String16.h similarity index 100% rename from external/includes/utils/String16.h rename to external/includes/arch32/utils/String16.h diff --git a/external/includes/utils/String8.h b/external/includes/arch32/utils/String8.h similarity index 100% rename from external/includes/utils/String8.h rename to external/includes/arch32/utils/String8.h diff --git a/external/includes/arch64/utils/String16.h b/external/includes/arch64/utils/String16.h new file mode 100644 index 00000000..d131bfc6 --- /dev/null +++ b/external/includes/arch64/utils/String16.h @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2005 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_STRING16_H +#define ANDROID_STRING16_H + +#include +#include +#include +#include + +// --------------------------------------------------------------------------- + +extern "C" { + +} + +// --------------------------------------------------------------------------- + +namespace android { + +// --------------------------------------------------------------------------- + +class String8; +class TextOutput; + +//! This is a string holding UTF-16 characters. +class String16 +{ +public: + /* use String16(StaticLinkage) if you're statically linking against + * libutils and declaring an empty static String16, e.g.: + * + * static String16 sAStaticEmptyString(String16::kEmptyString); + * static String16 sAnotherStaticEmptyString(sAStaticEmptyString); + */ + enum StaticLinkage { kEmptyString }; + + String16(); + explicit String16(StaticLinkage); + String16(const String16& o); + String16(const String16& o, + size_t len, + size_t begin=0); + explicit String16(const char16_t* o); + explicit String16(const char16_t* o, size_t len); + explicit String16(const String8& o); + explicit String16(const char* o); + explicit String16(const char* o, size_t len); + + ~String16(); + + inline const char16_t* string() const; + inline size_t size() const; + + inline const SharedBuffer* sharedBuffer() const; + + void setTo(const String16& other); + status_t setTo(const char16_t* other); + status_t setTo(const char16_t* other, size_t len); + status_t setTo(const String16& other, + size_t len, + size_t begin=0); + + status_t append(const String16& other); + status_t append(const char16_t* other, size_t len); + + inline String16& operator=(const String16& other); + + inline String16& operator+=(const String16& other); + inline String16 operator+(const String16& other) const; + + status_t insert(size_t pos, const char16_t* chrs); + status_t insert(size_t pos, + const char16_t* chrs, size_t len); + + ssize_t findFirst(char16_t c) const; + ssize_t findLast(char16_t c) const; + + bool startsWith(const String16& prefix) const; + bool startsWith(const char16_t* prefix) const; + + status_t makeLower(); + + status_t replaceAll(char16_t replaceThis, + char16_t withThis); + + status_t remove(size_t len, size_t begin=0); + + inline int compare(const String16& other) const; + + inline bool operator<(const String16& other) const; + inline bool operator<=(const String16& other) const; + inline bool operator==(const String16& other) const; + inline bool operator!=(const String16& other) const; + inline bool operator>=(const String16& other) const; + inline bool operator>(const String16& other) const; + + inline bool operator<(const char16_t* other) const; + inline bool operator<=(const char16_t* other) const; + inline bool operator==(const char16_t* other) const; + inline bool operator!=(const char16_t* other) const; + inline bool operator>=(const char16_t* other) const; + inline bool operator>(const char16_t* other) const; + + inline operator const char16_t*() const; + +private: + const char16_t* mString; +}; + +// String16 can be trivially moved using memcpy() because moving does not +// require any change to the underlying SharedBuffer contents or reference count. +ANDROID_TRIVIAL_MOVE_TRAIT(String16) + +// --------------------------------------------------------------------------- +// No user servicable parts below. + +inline int compare_type(const String16& lhs, const String16& rhs) +{ + return lhs.compare(rhs); +} + +inline int strictly_order_type(const String16& lhs, const String16& rhs) +{ + return compare_type(lhs, rhs) < 0; +} + +inline const char16_t* String16::string() const +{ + return mString; +} + +inline size_t String16::size() const +{ + return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; +} + +inline const SharedBuffer* String16::sharedBuffer() const +{ + return SharedBuffer::bufferFromData(mString); +} + +inline String16& String16::operator=(const String16& other) +{ + setTo(other); + return *this; +} + +inline String16& String16::operator+=(const String16& other) +{ + append(other); + return *this; +} + +inline String16 String16::operator+(const String16& other) const +{ + String16 tmp(*this); + tmp += other; + return tmp; +} + +inline int String16::compare(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()); +} + +inline bool String16::operator<(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()) < 0; +} + +inline bool String16::operator<=(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()) <= 0; +} + +inline bool String16::operator==(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()) == 0; +} + +inline bool String16::operator!=(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()) != 0; +} + +inline bool String16::operator>=(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()) >= 0; +} + +inline bool String16::operator>(const String16& other) const +{ + return strzcmp16(mString, size(), other.mString, other.size()) > 0; +} + +inline bool String16::operator<(const char16_t* other) const +{ + return strcmp16(mString, other) < 0; +} + +inline bool String16::operator<=(const char16_t* other) const +{ + return strcmp16(mString, other) <= 0; +} + +inline bool String16::operator==(const char16_t* other) const +{ + return strcmp16(mString, other) == 0; +} + +inline bool String16::operator!=(const char16_t* other) const +{ + return strcmp16(mString, other) != 0; +} + +inline bool String16::operator>=(const char16_t* other) const +{ + return strcmp16(mString, other) >= 0; +} + +inline bool String16::operator>(const char16_t* other) const +{ + return strcmp16(mString, other) > 0; +} + +inline String16::operator const char16_t*() const +{ + return mString; +} + +}; // namespace android + +// --------------------------------------------------------------------------- + +#endif // ANDROID_STRING16_H diff --git a/external/includes/arch64/utils/String8.h b/external/includes/arch64/utils/String8.h new file mode 100644 index 00000000..ef594704 --- /dev/null +++ b/external/includes/arch64/utils/String8.h @@ -0,0 +1,395 @@ +/* + * Copyright (C) 2005 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_STRING8_H +#define ANDROID_STRING8_H + +#include +#include +#include +#include + +#include // for strcmp +#include + +// --------------------------------------------------------------------------- + +namespace android { + +class String16; +class TextOutput; + +//! This is a string holding UTF-8 characters. Does not allow the value more +// than 0x10FFFF, which is not valid unicode codepoint. +class String8 +{ +public: + /* use String8(StaticLinkage) if you're statically linking against + * libutils and declaring an empty static String8, e.g.: + * + * static String8 sAStaticEmptyString(String8::kEmptyString); + * static String8 sAnotherStaticEmptyString(sAStaticEmptyString); + */ + enum StaticLinkage { kEmptyString }; + + String8(); + explicit String8(StaticLinkage); + String8(const String8& o); + explicit String8(const char* o); + explicit String8(const char* o, size_t numChars); + + explicit String8(const String16& o); + explicit String8(const char16_t* o); + explicit String8(const char16_t* o, size_t numChars); + explicit String8(const char32_t* o); + explicit String8(const char32_t* o, size_t numChars); + ~String8(); + + static inline const String8 empty(); + + static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2))); + static String8 formatV(const char* fmt, va_list args); + + inline const char* string() const; + inline size_t size() const; + inline size_t length() const; + inline size_t bytes() const; + inline bool isEmpty() const; + + inline const SharedBuffer* sharedBuffer() const; + + void clear(); + + void setTo(const String8& other); + status_t setTo(const char* other); + status_t setTo(const char* other, size_t numChars); + status_t setTo(const char16_t* other, size_t numChars); + status_t setTo(const char32_t* other, + size_t length); + + status_t append(const String8& other); + status_t append(const char* other); + status_t append(const char* other, size_t numChars); + + status_t appendFormat(const char* fmt, ...) + __attribute__((format (printf, 2, 3))); + status_t appendFormatV(const char* fmt, va_list args); + + // Note that this function takes O(N) time to calculate the value. + // No cache value is stored. + size_t getUtf32Length() const; + int32_t getUtf32At(size_t index, + size_t *next_index) const; + void getUtf32(char32_t* dst) const; + + inline String8& operator=(const String8& other); + inline String8& operator=(const char* other); + + inline String8& operator+=(const String8& other); + inline String8 operator+(const String8& other) const; + + inline String8& operator+=(const char* other); + inline String8 operator+(const char* other) const; + + inline int compare(const String8& other) const; + + inline bool operator<(const String8& other) const; + inline bool operator<=(const String8& other) const; + inline bool operator==(const String8& other) const; + inline bool operator!=(const String8& other) const; + inline bool operator>=(const String8& other) const; + inline bool operator>(const String8& other) const; + + inline bool operator<(const char* other) const; + inline bool operator<=(const char* other) const; + inline bool operator==(const char* other) const; + inline bool operator!=(const char* other) const; + inline bool operator>=(const char* other) const; + inline bool operator>(const char* other) const; + + inline operator const char*() const; + + char* lockBuffer(size_t size); + void unlockBuffer(); + status_t unlockBuffer(size_t size); + + // return the index of the first byte of other in this at or after + // start, or -1 if not found + ssize_t find(const char* other, size_t start = 0) const; + + void toLower(); + void toLower(size_t start, size_t numChars); + void toUpper(); + void toUpper(size_t start, size_t numChars); + + /* + * These methods operate on the string as if it were a path name. + */ + + /* + * Set the filename field to a specific value. + * + * Normalizes the filename, removing a trailing '/' if present. + */ + void setPathName(const char* name); + void setPathName(const char* name, size_t numChars); + + /* + * Get just the filename component. + * + * "/tmp/foo/bar.c" --> "bar.c" + */ + String8 getPathLeaf(void) const; + + /* + * Remove the last (file name) component, leaving just the directory + * name. + * + * "/tmp/foo/bar.c" --> "/tmp/foo" + * "/tmp" --> "" // ????? shouldn't this be "/" ???? XXX + * "bar.c" --> "" + */ + String8 getPathDir(void) const; + + /* + * Retrieve the front (root dir) component. Optionally also return the + * remaining components. + * + * "/tmp/foo/bar.c" --> "tmp" (remain = "foo/bar.c") + * "/tmp" --> "tmp" (remain = "") + * "bar.c" --> "bar.c" (remain = "") + */ + String8 walkPath(String8* outRemains = NULL) const; + + /* + * Return the filename extension. This is the last '.' and any number + * of characters that follow it. The '.' is included in case we + * decide to expand our definition of what constitutes an extension. + * + * "/tmp/foo/bar.c" --> ".c" + * "/tmp" --> "" + * "/tmp/foo.bar/baz" --> "" + * "foo.jpeg" --> ".jpeg" + * "foo." --> "" + */ + String8 getPathExtension(void) const; + + /* + * Return the path without the extension. Rules for what constitutes + * an extension are described in the comment for getPathExtension(). + * + * "/tmp/foo/bar.c" --> "/tmp/foo/bar" + */ + String8 getBasePath(void) const; + + /* + * Add a component to the pathname. We guarantee that there is + * exactly one path separator between the old path and the new. + * If there is no existing name, we just copy the new name in. + * + * If leaf is a fully qualified path (i.e. starts with '/', it + * replaces whatever was there before. + */ + String8& appendPath(const char* leaf); + String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); } + + /* + * Like appendPath(), but does not affect this string. Returns a new one instead. + */ + String8 appendPathCopy(const char* leaf) const + { String8 p(*this); p.appendPath(leaf); return p; } + String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); } + + /* + * Converts all separators in this string to /, the default path separator. + * + * If the default OS separator is backslash, this converts all + * backslashes to slashes, in-place. Otherwise it does nothing. + * Returns self. + */ + String8& convertToResPath(); + +private: + status_t real_append(const char* other, size_t numChars); + char* find_extension(void) const; + + const char* mString; +}; + +// String8 can be trivially moved using memcpy() because moving does not +// require any change to the underlying SharedBuffer contents or reference count. +ANDROID_TRIVIAL_MOVE_TRAIT(String8) + +// --------------------------------------------------------------------------- +// No user servicable parts below. + +inline int compare_type(const String8& lhs, const String8& rhs) +{ + return lhs.compare(rhs); +} + +inline int strictly_order_type(const String8& lhs, const String8& rhs) +{ + return compare_type(lhs, rhs) < 0; +} + +inline const String8 String8::empty() { + return String8(); +} + +inline const char* String8::string() const +{ + return mString; +} + +inline size_t String8::length() const +{ + return SharedBuffer::sizeFromData(mString)-1; +} + +inline size_t String8::size() const +{ + return length(); +} + +inline bool String8::isEmpty() const +{ + return length() == 0; +} + +inline size_t String8::bytes() const +{ + return SharedBuffer::sizeFromData(mString)-1; +} + +inline const SharedBuffer* String8::sharedBuffer() const +{ + return SharedBuffer::bufferFromData(mString); +} + +inline String8& String8::operator=(const String8& other) +{ + setTo(other); + return *this; +} + +inline String8& String8::operator=(const char* other) +{ + setTo(other); + return *this; +} + +inline String8& String8::operator+=(const String8& other) +{ + append(other); + return *this; +} + +inline String8 String8::operator+(const String8& other) const +{ + String8 tmp(*this); + tmp += other; + return tmp; +} + +inline String8& String8::operator+=(const char* other) +{ + append(other); + return *this; +} + +inline String8 String8::operator+(const char* other) const +{ + String8 tmp(*this); + tmp += other; + return tmp; +} + +inline int String8::compare(const String8& other) const +{ + return strcmp(mString, other.mString); +} + +inline bool String8::operator<(const String8& other) const +{ + return strcmp(mString, other.mString) < 0; +} + +inline bool String8::operator<=(const String8& other) const +{ + return strcmp(mString, other.mString) <= 0; +} + +inline bool String8::operator==(const String8& other) const +{ + return strcmp(mString, other.mString) == 0; +} + +inline bool String8::operator!=(const String8& other) const +{ + return strcmp(mString, other.mString) != 0; +} + +inline bool String8::operator>=(const String8& other) const +{ + return strcmp(mString, other.mString) >= 0; +} + +inline bool String8::operator>(const String8& other) const +{ + return strcmp(mString, other.mString) > 0; +} + +inline bool String8::operator<(const char* other) const +{ + return strcmp(mString, other) < 0; +} + +inline bool String8::operator<=(const char* other) const +{ + return strcmp(mString, other) <= 0; +} + +inline bool String8::operator==(const char* other) const +{ + return strcmp(mString, other) == 0; +} + +inline bool String8::operator!=(const char* other) const +{ + return strcmp(mString, other) != 0; +} + +inline bool String8::operator>=(const char* other) const +{ + return strcmp(mString, other) >= 0; +} + +inline bool String8::operator>(const char* other) const +{ + return strcmp(mString, other) > 0; +} + +inline String8::operator const char*() const +{ + return mString; +} + +} // namespace android + +// --------------------------------------------------------------------------- + +#endif // ANDROID_STRING8_H diff --git a/external/libnativehelper b/external/libnativehelper new file mode 160000 index 00000000..221e49a1 --- /dev/null +++ b/external/libnativehelper @@ -0,0 +1 @@ +Subproject commit 221e49a1ca260781ecdabdfa106d2e47d444e6de diff --git a/external/platform-system-core-lollipop b/external/platform-system-core-lollipop new file mode 160000 index 00000000..8032f3b5 --- /dev/null +++ b/external/platform-system-core-lollipop @@ -0,0 +1 @@ +Subproject commit 8032f3b5a501dabc1e28925cca834d2a39efbdee diff --git a/jni/Android.mk b/jni/Android.mk index e179920b..5d54c1df 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -59,7 +59,7 @@ LOCAL_LDLIBS += -lnativehelper -landroid_runtime -lutils -lbinder LOCAL_LDFLAGS += -fuse-ld=bfd LOCAL_LDLIBS += -lsqlcipher_android -LOCAL_LDFLAGS += -L../obj/local/$(TARGET_ARCH_ABI) +LOCAL_LDFLAGS += -L../obj/local/$(TARGET_ARCH_ABI) -fuse-ld=bfd LOCAL_LDLIBS += -licui18n -licuuc ifeq ($(WITH_MALLOC_LEAK_CHECK),true) diff --git a/jni/Application.mk b/jni/Application.mk index c3906879..630efb60 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,5 +1,5 @@ APP_PROJECT_PATH := $(shell pwd) -APP_ABI := armeabi armeabi-v7a x86 +APP_ABI := armeabi armeabi-v7a x86 x86_64 arm64-v8a APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk # fixes this error when building external/android-sqlite/android/sqlite3_android.cpp # icu4c/common/unicode/std_string.h:39:18: error: string: No such file or directory diff --git a/jni/android_util_Binder.cpp b/jni/android_util_Binder.cpp index 7a53874c..c4e5e15c 100644 --- a/jni/android_util_Binder.cpp +++ b/jni/android_util_Binder.cpp @@ -42,6 +42,16 @@ //#undef LOGV //#define LOGV(...) fprintf(stderr, __VA_ARGS__) +#if !defined(__LP64__) +#define M_OBJECT_TYPE "I" +#define GET_M_OBJECT(obj, mobject) env->GetIntField(obj, mobject) +#define SET_M_OBJECT(obj, mobject, val) env->SetIntField(obj, mobject, (int)val) +#else +#define M_OBJECT_TYPE "J" +#define GET_M_OBJECT(obj, mobject) env->GetLongField(obj, mobject); +#define SET_M_OBJECT(obj, mobject, val) env->SetLongField(obj, mobject, (long long int)val) +#endif + using namespace android; // ---------------------------------------------------------------------------- @@ -465,7 +475,7 @@ jobject javaObjectForIBinder(JNIEnv* env, const sp& val) if (object != NULL) { LOGV("objectForBinder %p: created new %p!\n", val.get(), object); // The proxy holds a reference to the native object. - env->SetIntField(object, gBinderProxyOffsets.mObject, (int)val.get()); + SET_M_OBJECT(object, gBinderProxyOffsets.mObject, val.get()); val->incStrong(object); // The native object needs to hold a weak reference back to the @@ -489,13 +499,13 @@ sp ibinderForJavaObject(JNIEnv* env, jobject obj) if (env->IsInstanceOf(obj, gBinderOffsets.mClass)) { JavaBBinderHolder* jbh = (JavaBBinderHolder*) - env->GetIntField(obj, gBinderOffsets.mObject); + GET_M_OBJECT(obj, gBinderOffsets.mObject); return jbh != NULL ? jbh->get(env) : NULL; } if (env->IsInstanceOf(obj, gBinderProxyOffsets.mClass)) { return (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); } LOGW("ibinderForJavaObject: %p is not a Binder object", obj); @@ -630,15 +640,15 @@ static void android_os_Binder_init(JNIEnv* env, jobject clazz) } LOGV("Java Binder %p: acquiring first ref on holder %p", clazz, jbh); jbh->incStrong(clazz); - env->SetIntField(clazz, gBinderOffsets.mObject, (int)jbh); + SET_M_OBJECT(clazz, gBinderOffsets.mObject, jbh); } static void android_os_Binder_destroy(JNIEnv* env, jobject clazz) { JavaBBinderHolder* jbh = (JavaBBinderHolder*) - env->GetIntField(clazz, gBinderOffsets.mObject); + GET_M_OBJECT(clazz, gBinderOffsets.mObject); if (jbh != NULL) { - env->SetIntField(clazz, gBinderOffsets.mObject, 0); + SET_M_OBJECT(clazz, gBinderOffsets.mObject, 0); LOGV("Java Binder %p: removing ref on holder %p", clazz, jbh); jbh->decStrong(clazz); } else { @@ -682,7 +692,7 @@ static int int_register_android_os_Binder(JNIEnv* env) assert(gBinderOffsets.mExecTransact); gBinderOffsets.mObject - = env->GetFieldID(clazz, "mObject", "I"); + = env->GetFieldID(clazz, "mObject", M_OBJECT_TYPE); assert(gBinderOffsets.mObject); return AndroidRuntime::registerNativeMethods( @@ -777,7 +787,7 @@ static int int_register_android_os_BinderInternal(JNIEnv* env) static jboolean android_os_BinderProxy_pingBinder(JNIEnv* env, jobject obj) { IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); if (target == NULL) { return JNI_FALSE; } @@ -787,7 +797,7 @@ static jboolean android_os_BinderProxy_pingBinder(JNIEnv* env, jobject obj) static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobject obj) { - IBinder* target = (IBinder*) env->GetIntField(obj, gBinderProxyOffsets.mObject); + IBinder* target = (IBinder*) GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); if (target != NULL) { const String16& desc = target->getInterfaceDescriptor(); return env->NewString(desc.string(), desc.size()); @@ -800,7 +810,7 @@ static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobjec static jboolean android_os_BinderProxy_isBinderAlive(JNIEnv* env, jobject obj) { IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); if (target == NULL) { return JNI_FALSE; } @@ -921,7 +931,7 @@ static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj, } IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); if (target == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "Binder has been finalized!"); return JNI_FALSE; @@ -964,7 +974,7 @@ static void android_os_BinderProxy_linkToDeath(JNIEnv* env, jobject obj, } IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); if (target == NULL) { LOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient); assert(false); @@ -994,7 +1004,7 @@ static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj, } IBinder* target = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); if (target == NULL) { LOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient); return JNI_FALSE; @@ -1026,9 +1036,9 @@ static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj, static void android_os_BinderProxy_destroy(JNIEnv* env, jobject obj) { IBinder* b = (IBinder*) - env->GetIntField(obj, gBinderProxyOffsets.mObject); + GET_M_OBJECT(obj, gBinderProxyOffsets.mObject); LOGV("Destroying BinderProxy %p: binder=%p\n", obj, b); - env->SetIntField(obj, gBinderProxyOffsets.mObject, 0); + SET_M_OBJECT(obj, gBinderProxyOffsets.mObject, 0); b->decStrong(obj); IPCThreadState::self()->flushCommands(); } @@ -1075,7 +1085,7 @@ static int int_register_android_os_BinderProxy(JNIEnv* env) assert(gBinderProxyOffsets.mSendDeathNotice); gBinderProxyOffsets.mObject - = env->GetFieldID(clazz, "mObject", "I"); + = env->GetFieldID(clazz, "mObject", M_OBJECT_TYPE); assert(gBinderProxyOffsets.mObject); gBinderProxyOffsets.mSelf = env->GetFieldID(clazz, "mSelf", "Ljava/lang/ref/WeakReference;"); @@ -1453,7 +1463,7 @@ static void android_os_Parcel_init(JNIEnv* env, jobject clazz, jint parcelInt) } //LOGI("Initializing obj %p from C++ Parcel %p, own=%d\n", clazz, parcel, own); env->SetIntField(clazz, gParcelOffsets.mOwnObject, own); - env->SetIntField(clazz, gParcelOffsets.mObject, (int)parcel); + SET_M_OBJECT(clazz, gParcelOffsets.mObject, parcel); } static void android_os_Parcel_destroy(JNIEnv* env, jobject clazz) @@ -1461,11 +1471,11 @@ static void android_os_Parcel_destroy(JNIEnv* env, jobject clazz) int32_t own = env->GetIntField(clazz, gParcelOffsets.mOwnObject); if (own) { Parcel* parcel = parcelForJavaObject(env, clazz); - env->SetIntField(clazz, gParcelOffsets.mObject, 0); + SET_M_OBJECT(clazz, gParcelOffsets.mObject, 0); //LOGI("Destroying obj %p: deleting C++ Parcel %p\n", clazz, parcel); delete parcel; } else { - env->SetIntField(clazz, gParcelOffsets.mObject, 0); + SET_M_OBJECT(clazz, gParcelOffsets.mObject, 0); //LOGI("Destroying obj %p: leaving C++ Parcel %p\n", clazz); } } @@ -1666,7 +1676,7 @@ static int int_register_android_os_Parcel(JNIEnv* env) LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.Parcel"); gParcelOffsets.mObject - = env->GetFieldID(clazz, "mObject", "I"); + = env->GetFieldID(clazz, "mObject", M_OBJECT_TYPE); gParcelOffsets.mOwnObject = env->GetFieldID(clazz, "mOwnObject", "I"); diff --git a/jni/net_sqlcipher_CursorWindow.cpp b/jni/net_sqlcipher_CursorWindow.cpp index 98eb9cc9..1c9bc484 100644 --- a/jni/net_sqlcipher_CursorWindow.cpp +++ b/jni/net_sqlcipher_CursorWindow.cpp @@ -37,8 +37,8 @@ static jfieldID gWindowField; static jfieldID gBufferField; static jfieldID gSizeCopiedField; -#define GET_WINDOW(env, object) ((CursorWindow *)env->GetIntField(object, gWindowField)) -#define SET_WINDOW(env, object, window) (env->SetIntField(object, gWindowField, (int)window)) +#define GET_WINDOW(env, object) ((CursorWindow *)env->GetLongField(object, gWindowField)) +#define SET_WINDOW(env, object, window) (env->SetLongField(object, gWindowField, (long long int)window)) #define SET_BUFFER(env, object, buf) (env->SetObjectField(object, gBufferField, buf)) #define SET_SIZE_COPIED(env, object, size) (env->SetIntField(object, gSizeCopiedField, size)) @@ -706,7 +706,7 @@ int register_android_database_CursorWindow(JNIEnv * env) return -1; } - gWindowField = env->GetFieldID(clazz, "nWindow", "I"); + gWindowField = env->GetFieldID(clazz, "nWindow", "J"); if (gWindowField == NULL) { LOGE("Error locating fields"); diff --git a/jni/net_sqlcipher_database_SQLiteCompiledSql.cpp b/jni/net_sqlcipher_database_SQLiteCompiledSql.cpp index 8833bda1..336867c6 100644 --- a/jni/net_sqlcipher_database_SQLiteCompiledSql.cpp +++ b/jni/net_sqlcipher_database_SQLiteCompiledSql.cpp @@ -39,9 +39,9 @@ static jfieldID gStatementField; #define GET_STATEMENT(env, object) \ - (sqlite3_stmt *)env->GetIntField(object, gStatementField) + (sqlite3_stmt *)env->GetLongField(object, gStatementField) #define GET_HANDLE(env, object) \ - (sqlite3 *)env->GetIntField(object, gHandleField) + (sqlite3 *)env->GetLongField(object, gHandleField) sqlite3_stmt * compile(JNIEnv* env, jobject object, @@ -55,7 +55,7 @@ sqlite3_stmt * compile(JNIEnv* env, jobject object, // Make sure not to leak the statement if it already exists if (statement != NULL) { sqlite3_finalize(statement); - env->SetIntField(object, gStatementField, 0); + env->SetLongField(object, gStatementField, 0); } // Compile the SQL @@ -67,7 +67,7 @@ sqlite3_stmt * compile(JNIEnv* env, jobject object, if (err == SQLITE_OK) { // Store the statement in the Java object for future calls LOGV("Prepared statement %p on %p", statement, handle); - env->SetIntField(object, gStatementField, (int)statement); + env->SetLongField(object, gStatementField, (long long int) statement); return statement; } else { // Error messages like 'near ")": syntax error' are not @@ -98,7 +98,7 @@ static void native_finalize(JNIEnv* env, jobject object) if (statement != NULL) { sqlite3_finalize(statement); - env->SetIntField(object, gStatementField, 0); + env->SetLongField(object, gStatementField, 0); } } @@ -119,8 +119,8 @@ int register_android_database_SQLiteCompiledSql(JNIEnv * env) return -1; } - gHandleField = env->GetFieldID(clazz, "nHandle", "I"); - gStatementField = env->GetFieldID(clazz, "nStatement", "I"); + gHandleField = env->GetFieldID(clazz, "nHandle", "J"); + gStatementField = env->GetFieldID(clazz, "nStatement", "J"); if (gHandleField == NULL || gStatementField == NULL) { LOGE("Error locating fields"); diff --git a/jni/net_sqlcipher_database_SQLiteDatabase.cpp b/jni/net_sqlcipher_database_SQLiteDatabase.cpp index 8141b982..d5ebf11c 100644 --- a/jni/net_sqlcipher_database_SQLiteDatabase.cpp +++ b/jni/net_sqlcipher_database_SQLiteDatabase.cpp @@ -100,7 +100,7 @@ int native_status(JNIEnv* env, jobject object, jint operation, jboolean reset) { int value; int highWater; - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); int status = sqlite3_status(operation, &value, &highWater, reset); if(status != SQLITE_OK){ throw_sqlite3_exception(env, handle); @@ -117,7 +117,7 @@ void native_key_char(JNIEnv* env, jobject object, jcharArray jKey) UErrorCode status = U_ZERO_ERROR; UConverter *encoding = 0; - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); keyUtf16 = env->GetCharArrayElements(jKey, 0); lenUtf16 = env->GetArrayLength(jKey); @@ -157,7 +157,7 @@ void native_key_char(JNIEnv* env, jobject object, jcharArray jKey) void native_key_str(JNIEnv* env, jobject object, jstring jKey) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); char const * key = env->GetStringUTFChars(jKey, NULL); jsize keyLen = env->GetStringUTFLength(jKey); @@ -180,7 +180,7 @@ void native_rekey_char(JNIEnv* env, jobject object, jcharArray jKey) UErrorCode status = U_ZERO_ERROR; UConverter *encoding = 0; - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); keyUtf16 = env->GetCharArrayElements(jKey, 0); lenUtf16 = env->GetArrayLength(jKey); @@ -219,7 +219,7 @@ void native_rekey_char(JNIEnv* env, jobject object, jcharArray jKey) void native_rekey_str(JNIEnv* env, jobject object, jstring jKey) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); char const * key = env->GetStringUTFChars(jKey, NULL); jsize keyLen = env->GetStringUTFLength(jKey); @@ -235,7 +235,7 @@ void native_rekey_str(JNIEnv* env, jobject object, jstring jKey) void native_rawExecSQL(JNIEnv* env, jobject object, jstring sql) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); char const * sqlCommand = env->GetStringUTFChars(sql, NULL); int status = sqlite3_exec(handle, sqlCommand, NULL, NULL, NULL); env->ReleaseStringUTFChars(sql, sqlCommand); @@ -334,7 +334,7 @@ void dbopen(JNIEnv* env, jobject object, jstring pathString, jint flags) sqlite3_enable_load_extension(handle, 1); LOGV("Opened '%s' - %p\n", path8, handle); - env->SetIntField(object, offset_db_handle, (int) handle); + env->SetLongField(object, offset_db_handle, (long long int) handle); handle = NULL; // The caller owns the handle now. done: @@ -362,7 +362,7 @@ static void sqlTrace(void *databaseName, const char *sql) { /* public native void enableSqlTracing(); */ static void enableSqlTracing(JNIEnv* env, jobject object, jstring databaseName) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); sqlite3_trace(handle, &sqlTrace, (void *)getDatabaseName(env, handle, databaseName)); } @@ -374,7 +374,7 @@ static void sqlProfile(void *databaseName, const char *sql, sqlite3_uint64 tm) { /* public native void enableSqlProfiling(); */ static void enableSqlProfiling(JNIEnv* env, jobject object, jstring databaseName) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); sqlite3_profile(handle, &sqlProfile, (void *)getDatabaseName(env, handle, databaseName)); } @@ -382,7 +382,7 @@ static void enableSqlProfiling(JNIEnv* env, jobject object, jstring databaseName /* public native void close(); */ static void dbclose(JNIEnv* env, jobject object) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); if (handle != NULL) { // release the memory associated with the traceFuncArg in enableSqlTracing function @@ -399,7 +399,7 @@ static void dbclose(JNIEnv* env, jobject object) int result = sqlite3_close(handle); if (result == SQLITE_OK) { LOGV("Closed %p\n", handle); - env->SetIntField(object, offset_db_handle, 0); + env->SetLongField(object, offset_db_handle, 0); } else { // This can happen if sub-objects aren't closed first. Make sure the caller knows. LOGE("sqlite3_close(%p) failed: %d\n", handle, result); @@ -414,7 +414,7 @@ static void native_execSQL(JNIEnv* env, jobject object, jstring sqlString) int err; int stepErr; sqlite3_stmt * statement = NULL; - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); jchar const * sql = env->GetStringChars(sqlString, NULL); jsize sqlLen = env->GetStringLength(sqlString); @@ -462,7 +462,7 @@ static void native_execSQL(JNIEnv* env, jobject object, jstring sqlString) /* native long lastInsertRow(); */ static jlong lastInsertRow(JNIEnv* env, jobject object) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); return sqlite3_last_insert_rowid(handle); } @@ -470,7 +470,7 @@ static jlong lastInsertRow(JNIEnv* env, jobject object) /* native int lastChangeCount(); */ static jint lastChangeCount(JNIEnv* env, jobject object) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); return sqlite3_changes(handle); } @@ -478,7 +478,7 @@ static jint lastChangeCount(JNIEnv* env, jobject object) /* native int native_getDbLookaside(); */ static jint native_getDbLookaside(JNIEnv* env, jobject object) { - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); int pCur = -1; int unused; sqlite3_db_status(handle, SQLITE_DBSTATUS_LOOKASIDE_USED, &pCur, &unused, 0); @@ -492,7 +492,7 @@ static void native_setLocale(JNIEnv* env, jobject object, jstring localeString, int err; char const* locale8 = env->GetStringUTFChars(localeString, NULL); - sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle); + sqlite3 * handle = (sqlite3 *)env->GetLongField(object, offset_db_handle); sqlite3_stmt* stmt = NULL; char** meta = NULL; int rowCount, colCount; @@ -643,7 +643,7 @@ int register_android_database_SQLiteDatabase(JNIEnv *env) return -1; } - offset_db_handle = env->GetFieldID(clazz, "mNativeHandle", "I"); + offset_db_handle = env->GetFieldID(clazz, "mNativeHandle", "J"); if (offset_db_handle == NULL) { LOGE("Can't find SQLiteDatabase.mNativeHandle\n"); return -1; diff --git a/jni/net_sqlcipher_database_SQLiteProgram.cpp b/jni/net_sqlcipher_database_SQLiteProgram.cpp index 52c66a0f..706c6097 100644 --- a/jni/net_sqlcipher_database_SQLiteProgram.cpp +++ b/jni/net_sqlcipher_database_SQLiteProgram.cpp @@ -39,9 +39,9 @@ static jfieldID gStatementField; #define GET_STATEMENT(env, object) \ - (sqlite3_stmt *)env->GetIntField(object, gStatementField) + (sqlite3_stmt *)env->GetLongField(object, gStatementField) #define GET_HANDLE(env, object) \ - (sqlite3 *)env->GetIntField(object, gHandleField) + (sqlite3 *)env->GetLongField(object, gHandleField) static void native_compile(JNIEnv* env, jobject object, jstring sqlString) { @@ -180,8 +180,8 @@ int register_android_database_SQLiteProgram(JNIEnv * env) return -1; } - gHandleField = env->GetFieldID(clazz, "nHandle", "I"); - gStatementField = env->GetFieldID(clazz, "nStatement", "I"); + gHandleField = env->GetFieldID(clazz, "nHandle", "J"); + gStatementField = env->GetFieldID(clazz, "nStatement", "J"); if (gHandleField == NULL || gStatementField == NULL) { LOGE("Error locating fields"); diff --git a/jni/net_sqlcipher_database_SQLiteQuery.cpp b/jni/net_sqlcipher_database_SQLiteQuery.cpp index 39eb2e29..4157edc8 100644 --- a/jni/net_sqlcipher_database_SQLiteQuery.cpp +++ b/jni/net_sqlcipher_database_SQLiteQuery.cpp @@ -43,11 +43,10 @@ sqlite3_stmt * compile(JNIEnv* env, jobject object, static jfieldID gHandleField; static jfieldID gStatementField; - #define GET_STATEMENT(env, object) \ - (sqlite3_stmt *)env->GetIntField(object, gStatementField) + (sqlite3_stmt *)env->GetLongField(object, gStatementField) #define GET_HANDLE(env, object) \ - (sqlite3 *)env->GetIntField(object, gHandleField) + (sqlite3 *)env->GetLongField(object, gHandleField) static int skip_rows(sqlite3_stmt *statement, int maxRows) { int retryCount = 0; @@ -351,8 +350,8 @@ int register_android_database_SQLiteQuery(JNIEnv * env) return -1; } - gHandleField = env->GetFieldID(clazz, "nHandle", "I"); - gStatementField = env->GetFieldID(clazz, "nStatement", "I"); + gHandleField = env->GetFieldID(clazz, "nHandle", "J"); + gStatementField = env->GetFieldID(clazz, "nStatement", "J"); if (gHandleField == NULL || gStatementField == NULL) { LOGE("Error locating fields"); diff --git a/jni/net_sqlcipher_database_SQLiteStatement.cpp b/jni/net_sqlcipher_database_SQLiteStatement.cpp index 5e000180..c6228011 100644 --- a/jni/net_sqlcipher_database_SQLiteStatement.cpp +++ b/jni/net_sqlcipher_database_SQLiteStatement.cpp @@ -43,10 +43,9 @@ static jfieldID gStatementField; #define GET_STATEMENT(env, object) \ - (sqlite3_stmt *)env->GetIntField(object, gStatementField) + (sqlite3_stmt *)env->GetLongField(object, gStatementField) #define GET_HANDLE(env, object) \ - (sqlite3 *)env->GetIntField(object, gHandleField) - + (sqlite3 *)env->GetLongField(object, gHandleField) static void native_execute(JNIEnv* env, jobject object) { @@ -135,8 +134,8 @@ int register_android_database_SQLiteStatement(JNIEnv * env) return -1; } - gHandleField = env->GetFieldID(clazz, "nHandle", "I"); - gStatementField = env->GetFieldID(clazz, "nStatement", "I"); + gHandleField = env->GetFieldID(clazz, "nHandle", "J"); + gStatementField = env->GetFieldID(clazz, "nStatement", "J"); if (gHandleField == NULL || gStatementField == NULL) { LOGE("Error locating fields"); diff --git a/openssl_android_64_bit_support.patch b/openssl_android_64_bit_support.patch new file mode 100644 index 00000000..fdbd842c --- /dev/null +++ b/openssl_android_64_bit_support.patch @@ -0,0 +1,142 @@ +From 2473df51edf88bb6da659b8f8619b3b4d4af68ae Mon Sep 17 00:00:00 2001 +From: gmetaxas +Date: Sat, 28 Mar 2015 14:03:40 +0200 +Subject: [PATCH 1/3] Support android-arm64-v8a (aarch64) and android-x86_64 + compilation + +--- + Configure | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Configure b/Configure +index f776e23..0bfba8d 100755 +--- a/Configure ++++ b/Configure +@@ -448,6 +448,8 @@ my %table=( + "android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + "android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + "android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-aarch64","gcc:-march=armv8-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86_64","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", + + #### *BSD [do see comment about ${BSDthreads} above!] + "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + +From 95356cfe718563675aa63ca46bdc3c18ba9f407d Mon Sep 17 00:00:00 2001 +From: gmetaxas +Date: Mon, 30 Mar 2015 07:02:09 +0300 +Subject: [PATCH 2/3] Added config changes + +--- + config | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/config b/config +index 77f730f..4f5190b 100755 +--- a/config ++++ b/config +@@ -861,6 +861,8 @@ case "$GUESSOS" in + *-*-qnx6) OUT="QNX6" ;; + x86-*-android|i?86-*-android) OUT="android-x86" ;; + armv[7-9]*-*-android) OUT="android-armv7" ;; ++ aarch64-*-android) OUT="android-aarch64";; ++ x86_64-*-android) OUT="android-x86_64";; + *) OUT=`echo $GUESSOS | awk -F- '{print $3}'`;; + esac + + +From da04212e8a906d489e7cef4502e66db9872942f9 Mon Sep 17 00:00:00 2001 +From: gmetaxas +Date: Mon, 30 Mar 2015 07:07:17 +0300 +Subject: [PATCH 3/3] Updated TABLE + +--- + TABLE | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 68 insertions(+) + +diff --git a/TABLE b/TABLE +index dc3e139..a237b08 100644 +--- a/TABLE ++++ b/TABLE +@@ -1088,6 +1088,40 @@ $ranlib = + $arflags = + $multilib = + ++*** android-aarch64 ++$cc = gcc ++$cflags = -march=armv8-a -mandroid -I$(ANDROID_DEV)/include -B$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall ++$unistd = ++$thread_cflag = -D_REENTRANT ++$sys_id = ++$lflags = -ldl ++$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR ++$cpuid_obj = armcap.o arm64cpuid.o mem_clr.o ++$bn_obj = ++$ec_obj = ++$des_obj = ++$aes_obj = aes_core.o aes_cbc.o aesv8-armx.o ++$bf_obj = ++$md5_obj = ++$sha1_obj = sha1-armv8.o sha256-armv8.o sha512-armv8.o ++$cast_obj = ++$rc4_obj = ++$rmd160_obj = ++$rc5_obj = ++$wp_obj = ++$cmll_obj = ++$modes_obj = ghashv8-armx.o ++$engines_obj = ++$perlasm_scheme = linux64 ++$dso_scheme = dlfcn ++$shared_target= linux-shared ++$shared_cflag = -fPIC ++$shared_ldflag = ++$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR) ++$ranlib = ++$arflags = ++$multilib = ++ + *** android-armv7 + $cc = gcc + $cflags = -march=armv7-a -mandroid -I$(ANDROID_DEV)/include -B$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall +@@ -1190,6 +1224,40 @@ $ranlib = + $arflags = + $multilib = + ++*** android-x86_64 ++$cc = gcc ++$cflags = -mandroid -I$(ANDROID_DEV)/include -B$(ANDROID_DEV)/lib -m64 -DL_ENDIAN -O3 -Wall ++$unistd = ++$thread_cflag = -D_REENTRANT ++$sys_id = ++$lflags = -ldl ++$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL ++$cpuid_obj = x86_64cpuid.o ++$bn_obj = x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o ++$ec_obj = ecp_nistz256.o ecp_nistz256-x86_64.o ++$des_obj = ++$aes_obj = aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o ++$bf_obj = ++$md5_obj = md5-x86_64.o ++$sha1_obj = sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o ++$cast_obj = ++$rc4_obj = rc4-x86_64.o rc4-md5-x86_64.o ++$rmd160_obj = ++$rc5_obj = ++$wp_obj = wp-x86_64.o ++$cmll_obj = cmll-x86_64.o cmll_misc.o ++$modes_obj = ghash-x86_64.o aesni-gcm-x86_64.o ++$engines_obj = ++$perlasm_scheme = elf ++$dso_scheme = dlfcn ++$shared_target= linux-shared ++$shared_cflag = -fPIC ++$shared_ldflag = -m64 ++$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR) ++$ranlib = ++$arflags = ++$multilib = 64 ++ + *** aux3-gcc + $cc = gcc + $cflags = -O2 -DTERMIO diff --git a/project.properties b/project.properties index a5578ba0..bbe203c8 100644 --- a/project.properties +++ b/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-19 +target=android-21 diff --git a/src/net/sqlcipher/CursorWindow.java b/src/net/sqlcipher/CursorWindow.java index 8ab6dbfc..9065d12b 100644 --- a/src/net/sqlcipher/CursorWindow.java +++ b/src/net/sqlcipher/CursorWindow.java @@ -38,7 +38,7 @@ public class CursorWindow extends android.database.CursorWindow implements Parce /** The pointer to the native window class. set by the native methods in * android_database_CursorWindow.cpp */ - private int nWindow; + private long nWindow; private int mStartPos; diff --git a/src/net/sqlcipher/database/SQLiteCompiledSql.java b/src/net/sqlcipher/database/SQLiteCompiledSql.java index 7302311a..1eed5b4b 100644 --- a/src/net/sqlcipher/database/SQLiteCompiledSql.java +++ b/src/net/sqlcipher/database/SQLiteCompiledSql.java @@ -36,7 +36,7 @@ /** * Native linkage, do not modify. This comes from the database. */ - /* package */ int nHandle = 0; + /* package */ long nHandle = 0; /** * Native linkage, do not modify. When non-0 this holds a reference to a valid @@ -44,7 +44,7 @@ * checked in this class when the database lock is held to determine if there * is a valid native-side program or not. */ - /* package */ int nStatement = 0; + /* package */ long nStatement = 0; /** the following are for debugging purposes */ private String mSqlStmt = null; diff --git a/src/net/sqlcipher/database/SQLiteDatabase.java b/src/net/sqlcipher/database/SQLiteDatabase.java index ab5a1626..cbea2171 100644 --- a/src/net/sqlcipher/database/SQLiteDatabase.java +++ b/src/net/sqlcipher/database/SQLiteDatabase.java @@ -346,7 +346,7 @@ public static synchronized void loadLibs (Context context, File workingDir) { /* package */ static final String GET_LOCK_LOG_PREFIX = "GETLOCK:"; /** Used by native code, do not rename */ - /* package */ int mNativeHandle = 0; + /* package */ long mNativeHandle = 0; /** Used to make temp table names unique */ /* package */ int mTempTableSequence = 0; diff --git a/src/net/sqlcipher/database/SQLiteProgram.java b/src/net/sqlcipher/database/SQLiteProgram.java index 658b0b90..15841e47 100644 --- a/src/net/sqlcipher/database/SQLiteProgram.java +++ b/src/net/sqlcipher/database/SQLiteProgram.java @@ -43,7 +43,7 @@ public abstract class SQLiteProgram extends SQLiteClosable { * @deprecated do not use this */ @Deprecated - protected int nHandle = 0; + protected long nHandle = 0; /** * the SQLiteCompiledSql object for the given sql statement. @@ -56,7 +56,7 @@ public abstract class SQLiteProgram extends SQLiteClosable { * @deprecated do not use this */ @Deprecated - protected int nStatement = 0; + protected long nStatement = 0; /* package */ SQLiteProgram(SQLiteDatabase db, String sql) { mDatabase = db; @@ -95,7 +95,7 @@ public abstract class SQLiteProgram extends SQLiteClosable { // it is already in compiled-sql cache. // try to acquire the object. if (!mCompiledSql.acquire()) { - int last = mCompiledSql.nStatement; + long last = mCompiledSql.nStatement; // the SQLiteCompiledSql in cache is in use by some other SQLiteProgram object. // we can't have two different SQLiteProgam objects can't share the same // CompiledSql object. create a new one. @@ -149,7 +149,7 @@ private void releaseCompiledSqlIfNotInCache() { * * @return a unique identifier for this program */ - public final int getUniqueId() { + public final long getUniqueId() { return nStatement; }