-
Notifications
You must be signed in to change notification settings - Fork 1
RNMT-4515 Fixes an issue with recent devices running Android 11 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a19159
5d4f4a5
a69fa8f
e52eca7
3cf482d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.liteglue; | ||
|
||
public class SQLiteResponse { | ||
private int result; | ||
private long handle; | ||
|
||
public SQLiteResponse(int result, long handle) { | ||
this.result = result; | ||
this.handle = handle; | ||
} | ||
|
||
public int getResult() { | ||
return this.result; | ||
} | ||
|
||
public long getHandle() { | ||
return this.handle; | ||
} | ||
|
||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#APP_ABI := all | ||
APP_ABI := armeabi armeabi-v7a x86 x86_64 arm64-v8a | ||
APP_ABI := armeabi-v7a x86 x86_64 arm64-v8a | ||
# For future consideration (needs testing): | ||
#APP_ABI += mips mips64 | ||
|
||
APP_PLATFORM := android-23 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we gaining anything from this bump ? Also, reading the docs https://developer.android.com/ndk/guides/application_mk#app_platform it states that this should match the minSdkVersion , 23 is Android 6 but we support Android 5.1 , right ? If there's no gain from this being set as we, I don't see a reason for this to be break change by bumping this to 23 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we only support Android 6+ in MABS 7. Both 5 and 5.1 were dropped. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we're just introducing a breaking change without actually needing it on this package, right? What if tomorrow we need to fix something here that's needs to be applied also on MABS 5, we'll have to deal with release branches and whatnot for no reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your point, but to be honest, I don't see it as a problem. Here are my thoughts regarding this topic:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,13 @@ | |
|
||
/* Java->C glue code: | ||
* Java package: io.liteglue.SQLiteNative | ||
* Java method: long sqlc_api_db_open(int sqlc_api_version, java.lang.String filename, int flags) | ||
* C function: sqlc_handle_t sqlc_api_db_open(int sqlc_api_version, const char * filename, int flags); | ||
* Java method: SQLiteResponse sqlc_api_db_open(int sqlc_api_version, java.lang.String filename, int flags) | ||
* C function: sqlc_handle_ct* sqlc_api_db_open(int sqlc_api_version, const char * filename, int flags); | ||
*/ | ||
JNIEXPORT jlong JNICALL | ||
JNIEXPORT jobject JNICALL | ||
Java_io_liteglue_SQLiteNative_sqlc_1api_1db_1open__ILjava_lang_String_2I(JNIEnv *env, jclass _unused, jint sqlc_api_version, jstring filename, jint flags) { | ||
const char* _strchars_filename = NULL; | ||
sqlc_handle_t _res; | ||
sqlc_handle_ct* _res; | ||
if ( NULL != filename ) { | ||
_strchars_filename = (*env)->GetStringUTFChars(env, filename, (jboolean*)NULL); | ||
if ( NULL == _strchars_filename ) { | ||
|
@@ -27,7 +27,14 @@ Java_io_liteglue_SQLiteNative_sqlc_1api_1db_1open__ILjava_lang_String_2I(JNIEnv | |
if ( NULL != filename ) { | ||
(*env)->ReleaseStringUTFChars(env, filename, _strchars_filename); | ||
} | ||
return _res; | ||
|
||
jclass class = (*env)->FindClass(env,"io/liteglue/SQLiteResponse"); | ||
jmethodID constructor = (*env)->GetMethodID(env, class, "<init>", "(IJ)V"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the convention for the method signature. Check this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will never again complain about JavaScript 😂 |
||
jobject instance = (*env)->NewObject(env, class, constructor, _res->result, _res->handle); | ||
|
||
free(_res); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
|
@@ -124,13 +131,13 @@ Java_io_liteglue_SQLiteNative_sqlc_1db_1last_1insert_1rowid__J(JNIEnv *env, jcla | |
|
||
/* Java->C glue code: | ||
* Java package: io.liteglue.SQLiteNative | ||
* Java method: long sqlc_db_open(java.lang.String filename, int flags) | ||
* C function: sqlc_handle_t sqlc_db_open(const char * filename, int flags); | ||
* Java method: SQLiteResponse sqlc_db_open(java.lang.String filename, int flags) | ||
* C function: sqlc_handle_ct* sqlc_db_open(const char * filename, int flags); | ||
*/ | ||
JNIEXPORT jlong JNICALL | ||
JNIEXPORT jobject JNICALL | ||
Java_io_liteglue_SQLiteNative_sqlc_1db_1open__Ljava_lang_String_2I(JNIEnv *env, jclass _unused, jstring filename, jint flags) { | ||
const char* _strchars_filename = NULL; | ||
sqlc_handle_t _res; | ||
sqlc_handle_ct* _res; | ||
if ( NULL != filename ) { | ||
_strchars_filename = (*env)->GetStringUTFChars(env, filename, (jboolean*)NULL); | ||
if ( NULL == _strchars_filename ) { | ||
|
@@ -143,19 +150,26 @@ Java_io_liteglue_SQLiteNative_sqlc_1db_1open__Ljava_lang_String_2I(JNIEnv *env, | |
if ( NULL != filename ) { | ||
(*env)->ReleaseStringUTFChars(env, filename, _strchars_filename); | ||
} | ||
return _res; | ||
|
||
jclass class = (*env)->FindClass(env,"io/liteglue/SQLiteResponse"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can refactor this code to avoid duplication? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, that will be a good improvement. |
||
jmethodID constructor = (*env)->GetMethodID(env, class, "<init>", "(IJ)V"); | ||
jobject instance = (*env)->NewObject(env, class, constructor, _res->result, _res->handle); | ||
|
||
free(_res); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
/* Java->C glue code: | ||
* Java package: io.liteglue.SQLiteNative | ||
* Java method: long sqlc_db_prepare_st(long db, java.lang.String sql) | ||
* C function: sqlc_handle_t sqlc_db_prepare_st(sqlc_handle_t db, const char * sql); | ||
* Java method: SQLiteResponse sqlc_db_prepare_st(long db, java.lang.String sql) | ||
* C function: sqlc_handle_ct* sqlc_db_prepare_st(sqlc_handle_t db, const char * sql); | ||
*/ | ||
JNIEXPORT jlong JNICALL | ||
JNIEXPORT jobject JNICALL | ||
Java_io_liteglue_SQLiteNative_sqlc_1db_1prepare_1st__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong db, jstring sql) { | ||
const char* _strchars_sql = NULL; | ||
sqlc_handle_t _res; | ||
sqlc_handle_ct* _res; | ||
if ( NULL != sql ) { | ||
_strchars_sql = (*env)->GetStringUTFChars(env, sql, (jboolean*)NULL); | ||
if ( NULL == _strchars_sql ) { | ||
|
@@ -168,7 +182,14 @@ Java_io_liteglue_SQLiteNative_sqlc_1db_1prepare_1st__JLjava_lang_String_2(JNIEnv | |
if ( NULL != sql ) { | ||
(*env)->ReleaseStringUTFChars(env, sql, _strchars_sql); | ||
} | ||
return _res; | ||
|
||
jclass class = (*env)->FindClass(env,"io/liteglue/SQLiteResponse"); | ||
jmethodID constructor = (*env)->GetMethodID(env, class, "<init>", "(IJ)V"); | ||
jobject instance = (*env)->NewObject(env, class, constructor, _res->result, _res->handle); | ||
|
||
free(_res); | ||
|
||
return instance; | ||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,32 +6,36 @@ | |
|
||
#include "sqlite3.h" | ||
|
||
#define BASE_HANDLE_OFFSET 0x100000000LL | ||
|
||
#ifdef SQLC_KEEP_ANDROID_LOG | ||
// ref: http://www.ibm.com/developerworks/opensource/tutorials/os-androidndk/index.html | ||
#define MYLOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "sqlc", __VA_ARGS__) | ||
#else | ||
#define MYLOG(...) ; | ||
#endif | ||
|
||
#define HANDLE_FROM_VP(p) ( BASE_HANDLE_OFFSET + ( (unsigned char *)(p) - (unsigned char *)NULL ) ) | ||
#define HANDLE_TO_VP(h) (void *)( (unsigned char *)NULL + (ptrdiff_t)((h) - BASE_HANDLE_OFFSET) ) | ||
#define HANDLE_FROM_VP(p) (( (unsigned char *)(p) - (unsigned char *)NULL ) ) | ||
#define HANDLE_TO_VP(h) (void *)( (unsigned char *)NULL + (ptrdiff_t)((h)) ) | ||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this no longer is required. Or is there something to it ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the BASE_OFFSET and left it there to be an helper for the conversions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's no longer required because it's no longer +number = pointer -number = error. |
||
|
||
int sqlc_api_version_check(int sqlc_api_version) | ||
{ | ||
return (sqlc_api_version != SQLC_API_VERSION) ? SQLC_RESULT_ERROR : SQLC_RESULT_OK; | ||
} | ||
|
||
sqlc_handle_t sqlc_api_db_open(int sqlc_api_version, const char *filename, int flags) | ||
sqlc_handle_ct* sqlc_api_db_open(int sqlc_api_version, const char *filename, int flags) | ||
{ | ||
if (sqlc_api_version != SQLC_API_VERSION) return SQLC_RESULT_ERROR; | ||
if (sqlc_api_version != SQLC_API_VERSION) { | ||
sqlc_handle_ct* resp = malloc(sizeof(sqlc_handle_ct)); | ||
resp->result = SQLC_RESULT_ERROR; | ||
resp->handle = 0; | ||
return resp; | ||
} | ||
|
||
return sqlc_db_open(filename, flags); | ||
} | ||
|
||
sqlc_handle_t sqlc_db_open(const char *filename, int flags) | ||
sqlc_handle_ct* sqlc_db_open(const char *filename, int flags) | ||
{ | ||
sqlc_handle_ct *resp; | ||
sqlite3 *d1; | ||
int r1; | ||
|
||
|
@@ -41,11 +45,16 @@ sqlc_handle_t sqlc_db_open(const char *filename, int flags) | |
|
||
MYLOG("db_open %s result %d ptr %p", filename, r1, d1); | ||
|
||
return (r1 == 0) ? HANDLE_FROM_VP(d1) : -r1; | ||
resp = malloc (sizeof (sqlc_handle_ct)); | ||
resp->result = (r1 == 0) ? 0 : -r1; | ||
resp->handle = HANDLE_FROM_VP(d1); | ||
|
||
return resp; | ||
} | ||
|
||
sqlc_handle_t sqlc_db_prepare_st(sqlc_handle_t db, const char *sql) | ||
sqlc_handle_ct* sqlc_db_prepare_st(sqlc_handle_t db, const char *sql) | ||
{ | ||
sqlc_handle_ct *resp; | ||
sqlite3 *mydb = HANDLE_TO_VP(db); | ||
sqlite3_stmt *s; | ||
int rv; | ||
|
@@ -54,7 +63,11 @@ sqlc_handle_t sqlc_db_prepare_st(sqlc_handle_t db, const char *sql) | |
|
||
rv = sqlite3_prepare_v2(mydb, sql, -1, &s, NULL); | ||
|
||
return (rv == 0) ? HANDLE_FROM_VP(s) : -rv; | ||
resp = malloc (sizeof (sqlc_handle_ct)); | ||
resp->result = (rv == 0) ? 0 : -rv; | ||
resp->handle = HANDLE_FROM_VP(s); | ||
|
||
return resp; | ||
} | ||
|
||
/** FUTURE TBD (???) for sqlcipher: | ||
|
+1 −1 | README.md | |
+39,667 −23,568 | sqlite3.c | |
+1,256 −259 | sqlite3.h | |
+55 −5 | sqlite3ext.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline at the end