Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update some C++ files to match recent changes to the Android core. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
dec1c9374f66c4f062721a7c410a4cae |
User & Date: | dan 2017-11-27 20:59:39.369 |
Context
2017-11-28
| ||
08:22 | Update a couple of java source files to more closely match their Android counterparts. (check-in: 20bdb663b0 user: dan tags: trunk) | |
2017-11-27
| ||
20:59 | Update some C++ files to match recent changes to the Android core. (check-in: dec1c9374f user: dan tags: trunk) | |
19:22 | Remove out of date "package.html" files. (check-in: e9352bdf96 user: dan tags: trunk) | |
Changes
Changes to sqlite3/src/main/jni/sqlite/android_database_SQLiteConnection.cpp.
︙ | ︙ | |||
26 27 28 29 30 31 32 | #include <sys/mman.h> #include <string.h> #include <unistd.h> #include <assert.h> | < < < < < < < | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <sys/mman.h> #include <string.h> #include <unistd.h> #include <assert.h> #include <sqlite3.h> #include "android_database_SQLiteCommon.h" #include <string> // Set to 1 to use UTF16 storage for localized indexes. #define UTF16_STORAGE 0 |
︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | * WAL, a timeout could occur if one connection is busy performing an auto-checkpoint * operation. The busy timeout needs to be long enough to tolerate slow I/O write * operations but not so long as to cause the application to hang indefinitely if * there is a problem acquiring a database lock. */ static const int BUSY_TIMEOUT_MS = 2500; static JavaVM *gpJavaVM = 0; static struct { jfieldID name; jfieldID numArgs; jmethodID dispatchCallback; } gSQLiteCustomFunctionClassInfo; | > > > > | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | * WAL, a timeout could occur if one connection is busy performing an auto-checkpoint * operation. The busy timeout needs to be long enough to tolerate slow I/O write * operations but not so long as to cause the application to hang indefinitely if * there is a problem acquiring a database lock. */ static const int BUSY_TIMEOUT_MS = 2500; /* The original code uses AndroidRuntime::getJNIEnv() to obtain a ** pointer to the VM. This is not available in the NDK, so instead ** the following global variable is set as part of this module's ** JNI_OnLoad method. */ static JavaVM *gpJavaVM = 0; static struct { jfieldID name; jfieldID numArgs; jmethodID dispatchCallback; } gSQLiteCustomFunctionClassInfo; |
︙ | ︙ | |||
184 185 186 187 188 189 190 | err = sqlite3_busy_timeout(db, BUSY_TIMEOUT_MS); if (err != SQLITE_OK) { throw_sqlite3_exception(env, db, "Could not set busy timeout"); sqlite3_close(db); return 0; } | < < < < < < < < < < | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | err = sqlite3_busy_timeout(db, BUSY_TIMEOUT_MS); if (err != SQLITE_OK) { throw_sqlite3_exception(env, db, "Could not set busy timeout"); sqlite3_close(db); return 0; } // Create wrapper object. SQLiteConnection* connection = new SQLiteConnection(db, openFlags, path, label); // Enable tracing and profiling if requested. if (enableTrace) { sqlite3_trace(db, &sqliteTraceCallback, connection); } |
︙ | ︙ | |||
307 308 309 310 311 312 313 | throw_sqlite3_exception(env, connection->db); return; } } static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jlong connectionPtr, jstring localeStr) { | < | < < < < < < < < < | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | throw_sqlite3_exception(env, connection->db); return; } } static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jlong connectionPtr, jstring localeStr) { /* Localized collators are not supported. */ } static jlong nativePrepareStatement(JNIEnv* env, jclass clazz, jlong connectionPtr, jstring sqlString) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); jsize sqlLength = env->GetStringLength(sqlString); |
︙ | ︙ | |||
365 366 367 368 369 370 371 | // is always finalized regardless. ALOGV("Finalized statement %p on connection %p", statement, connection->db); sqlite3_finalize(statement); } static jint nativeGetParameterCount(JNIEnv* env, jclass clazz, jlong connectionPtr, jlong statementPtr) { | < < < < | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | // is always finalized regardless. ALOGV("Finalized statement %p on connection %p", statement, connection->db); sqlite3_finalize(statement); } static jint nativeGetParameterCount(JNIEnv* env, jclass clazz, jlong connectionPtr, jlong statementPtr) { sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); return sqlite3_bind_parameter_count(statement); } static jboolean nativeIsReadOnly(JNIEnv* env, jclass clazz, jlong connectionPtr, jlong statementPtr) { sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); return sqlite3_stmt_readonly(statement) != 0; } static jint nativeGetColumnCount(JNIEnv* env, jclass clazz, jlong connectionPtr, jlong statementPtr) { sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); return sqlite3_column_count(statement); } static jstring nativeGetColumnName(JNIEnv* env, jclass clazz, jlong connectionPtr, jlong statementPtr, jint index) { sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr); const jchar* name = static_cast<const jchar*>(sqlite3_column_name16(statement, index)); if (name) { size_t length = 0; while (name[length]) { length += 1; |
︙ | ︙ | |||
554 555 556 557 558 559 560 | return env->NewString(text, length); } } return NULL; } static int createAshmemRegionWithData(JNIEnv* env, const void* data, size_t length) { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | return env->NewString(text, length); } } return NULL; } static int createAshmemRegionWithData(JNIEnv* env, const void* data, size_t length) { jniThrowIOException(env, -1); return -1; } static jint nativeExecuteForBlobFileDescriptor(JNIEnv* env, jclass clazz, jlong connectionPtr, jlong statementPtr) { SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr); |
︙ | ︙ |
Changes to sqlite3/src/main/jni/sqlite/android_database_SQLiteGlobal.cpp.
︙ | ︙ | |||
18 19 20 21 22 23 24 | ** sqlite-dev@sqlite.org. */ #define LOG_TAG "SQLiteGlobal" #include <jni.h> #include <JNIHelp.h> | < < < < < < > | > | > | > > | < < < | | < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | ** sqlite-dev@sqlite.org. */ #define LOG_TAG "SQLiteGlobal" #include <jni.h> #include <JNIHelp.h> #include <sqlite3.h> #include "android_database_SQLiteCommon.h" #include "ALog-priv.h" namespace android { // Limit heap to 8MB for now. This is 4 times the maximum cursor window // size, as has been used by the original code in SQLiteDatabase for // a long time. static const int SOFT_HEAP_LIMIT = 8 * 1024 * 1024; // Called each time a message is logged. static void sqliteLogCallback(void* data, int err, const char* msg) { bool verboseLog = !!data; int errType = err & 255; if (errType == 0 || errType == SQLITE_CONSTRAINT || errType == SQLITE_SCHEMA || errType == SQLITE_NOTICE || err == SQLITE_WARNING_AUTOINDEX) { if (verboseLog) { ALOG(LOG_VERBOSE, SQLITE_LOG_TAG, "(%d) %s\n", err, msg); } } else if (errType == SQLITE_WARNING) { ALOG(LOG_WARN, SQLITE_LOG_TAG, "(%d) %s\n", err, msg); } else { ALOG(LOG_ERROR, SQLITE_LOG_TAG, "(%d) %s\n", err, msg); } } // Sets the global SQLite configuration. // This must be called before any other SQLite functions are called. static void sqliteInitialize() { // Enable multi-threaded mode. In this mode, SQLite is safe to use by multiple // threads as long as no two threads use the same database connection at the same // time (which we guarantee in the SQLite database wrappers). sqlite3_config(SQLITE_CONFIG_MULTITHREAD); // Redirect SQLite log messages to the Android log. bool verboseLog = false; sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, verboseLog ? (void*)1 : NULL); // The soft heap limit prevents the page cache allocations from growing // beyond the given limit, no matter what the max page cache sizes are // set to. The limit does not, as of 3.5.0, affect any other allocations. sqlite3_soft_heap_limit(SOFT_HEAP_LIMIT); // Initialize SQLite. sqlite3_initialize(); } static jint nativeReleaseMemory(JNIEnv* env, jclass clazz) { return sqlite3_release_memory(SOFT_HEAP_LIMIT); } static const JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ { "nativeReleaseMemory", "()I", (void*)nativeReleaseMemory }, }; int register_android_database_SQLiteGlobal(JNIEnv *env) { sqliteInitialize(); return jniRegisterNativeMethods(env, "org/sqlite/database/sqlite/SQLiteGlobal", sMethods, NELEM(sMethods)); } } // namespace android |