Loading core/java/android/database/CursorWindow.java +27 −26 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Parcelable; import android.os.Process; import android.util.Log; import android.util.SparseIntArray; import android.util.LongSparseArray; /** * A buffer containing multiple cursor rows. Loading @@ -52,40 +53,40 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { * The native CursorWindow object pointer. (FOR INTERNAL USE ONLY) * @hide */ public int mWindowPtr; public long mWindowPtr; private int mStartPos; private final String mName; private final CloseGuard mCloseGuard = CloseGuard.get(); private static native int nativeCreate(String name, int cursorWindowSize); private static native int nativeCreateFromParcel(Parcel parcel); private static native void nativeDispose(int windowPtr); private static native void nativeWriteToParcel(int windowPtr, Parcel parcel); private static native long nativeCreate(String name, int cursorWindowSize); private static native long nativeCreateFromParcel(Parcel parcel); private static native void nativeDispose(long windowPtr); private static native void nativeWriteToParcel(long windowPtr, Parcel parcel); private static native void nativeClear(int windowPtr); private static native void nativeClear(long windowPtr); private static native int nativeGetNumRows(int windowPtr); private static native boolean nativeSetNumColumns(int windowPtr, int columnNum); private static native boolean nativeAllocRow(int windowPtr); private static native void nativeFreeLastRow(int windowPtr); private static native int nativeGetNumRows(long windowPtr); private static native boolean nativeSetNumColumns(long windowPtr, int columnNum); private static native boolean nativeAllocRow(long windowPtr); private static native void nativeFreeLastRow(long windowPtr); private static native int nativeGetType(int windowPtr, int row, int column); private static native byte[] nativeGetBlob(int windowPtr, int row, int column); private static native String nativeGetString(int windowPtr, int row, int column); private static native long nativeGetLong(int windowPtr, int row, int column); private static native double nativeGetDouble(int windowPtr, int row, int column); private static native void nativeCopyStringToBuffer(int windowPtr, int row, int column, private static native int nativeGetType(long windowPtr, int row, int column); private static native byte[] nativeGetBlob(long windowPtr, int row, int column); private static native String nativeGetString(long windowPtr, int row, int column); private static native long nativeGetLong(long windowPtr, int row, int column); private static native double nativeGetDouble(long windowPtr, int row, int column); private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column, CharArrayBuffer buffer); private static native boolean nativePutBlob(int windowPtr, byte[] value, int row, int column); private static native boolean nativePutString(int windowPtr, String value, int row, int column); private static native boolean nativePutLong(int windowPtr, long value, int row, int column); private static native boolean nativePutDouble(int windowPtr, double value, int row, int column); private static native boolean nativePutNull(int windowPtr, int row, int column); private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column); private static native boolean nativePutString(long windowPtr, String value, int row, int column); private static native boolean nativePutLong(long windowPtr, long value, int row, int column); private static native boolean nativePutDouble(long windowPtr, double value, int row, int column); private static native boolean nativePutNull(long windowPtr, int row, int column); private static native String nativeGetName(int windowPtr); private static native String nativeGetName(long windowPtr); /** * Creates a new empty cursor window and gives it a name. Loading Loading @@ -713,9 +714,9 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { dispose(); } private static final SparseIntArray sWindowToPidMap = new SparseIntArray(); private static final LongSparseArray<Integer> sWindowToPidMap = new LongSparseArray<Integer>(); private void recordNewWindow(int pid, int window) { private void recordNewWindow(int pid, long window) { synchronized (sWindowToPidMap) { sWindowToPidMap.put(window, pid); if (Log.isLoggable(STATS_TAG, Log.VERBOSE)) { Loading @@ -724,7 +725,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { } } private void recordClosingOfWindow(int window) { private void recordClosingOfWindow(long window) { synchronized (sWindowToPidMap) { if (sWindowToPidMap.size() == 0) { // this means we are not in the ContentProvider. Loading Loading @@ -771,6 +772,6 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { @Override public String toString() { return getName() + " {" + Integer.toHexString(mWindowPtr) + "}"; return getName() + " {" + Long.toHexString(mWindowPtr) + "}"; } } core/java/android/database/sqlite/SQLiteConnection.java +33 −33 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen private final OperationLog mRecentOperations = new OperationLog(); // The native SQLiteConnection pointer. (FOR INTERNAL USE ONLY) private int mConnectionPtr; private long mConnectionPtr; private boolean mOnlyAllowReadOnlyOperations; Loading @@ -117,45 +117,45 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen // we can ensure that we detach the signal at the right time. private int mCancellationSignalAttachCount; private static native int nativeOpen(String path, int openFlags, String label, private static native long nativeOpen(String path, int openFlags, String label, boolean enableTrace, boolean enableProfile); private static native void nativeClose(int connectionPtr); private static native void nativeRegisterCustomFunction(int connectionPtr, private static native void nativeClose(long connectionPtr); private static native void nativeRegisterCustomFunction(long connectionPtr, SQLiteCustomFunction function); private static native void nativeRegisterLocalizedCollators(int connectionPtr, String locale); private static native int nativePrepareStatement(int connectionPtr, String sql); private static native void nativeFinalizeStatement(int connectionPtr, int statementPtr); private static native int nativeGetParameterCount(int connectionPtr, int statementPtr); private static native boolean nativeIsReadOnly(int connectionPtr, int statementPtr); private static native int nativeGetColumnCount(int connectionPtr, int statementPtr); private static native String nativeGetColumnName(int connectionPtr, int statementPtr, private static native void nativeRegisterLocalizedCollators(long connectionPtr, String locale); private static native long nativePrepareStatement(long connectionPtr, String sql); private static native void nativeFinalizeStatement(long connectionPtr, long statementPtr); private static native int nativeGetParameterCount(long connectionPtr, long statementPtr); private static native boolean nativeIsReadOnly(long connectionPtr, long statementPtr); private static native int nativeGetColumnCount(long connectionPtr, long statementPtr); private static native String nativeGetColumnName(long connectionPtr, long statementPtr, int index); private static native void nativeBindNull(int connectionPtr, int statementPtr, private static native void nativeBindNull(long connectionPtr, long statementPtr, int index); private static native void nativeBindLong(int connectionPtr, int statementPtr, private static native void nativeBindLong(long connectionPtr, long statementPtr, int index, long value); private static native void nativeBindDouble(int connectionPtr, int statementPtr, private static native void nativeBindDouble(long connectionPtr, long statementPtr, int index, double value); private static native void nativeBindString(int connectionPtr, int statementPtr, private static native void nativeBindString(long connectionPtr, long statementPtr, int index, String value); private static native void nativeBindBlob(int connectionPtr, int statementPtr, private static native void nativeBindBlob(long connectionPtr, long statementPtr, int index, byte[] value); private static native void nativeResetStatementAndClearBindings( int connectionPtr, int statementPtr); private static native void nativeExecute(int connectionPtr, int statementPtr); private static native long nativeExecuteForLong(int connectionPtr, int statementPtr); private static native String nativeExecuteForString(int connectionPtr, int statementPtr); long connectionPtr, long statementPtr); private static native void nativeExecute(long connectionPtr, long statementPtr); private static native long nativeExecuteForLong(long connectionPtr, long statementPtr); private static native String nativeExecuteForString(long connectionPtr, long statementPtr); private static native int nativeExecuteForBlobFileDescriptor( int connectionPtr, int statementPtr); private static native int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr); long connectionPtr, long statementPtr); private static native int nativeExecuteForChangedRowCount(long connectionPtr, long statementPtr); private static native long nativeExecuteForLastInsertedRowId( int connectionPtr, int statementPtr); long connectionPtr, long statementPtr); private static native long nativeExecuteForCursorWindow( int connectionPtr, int statementPtr, int windowPtr, long connectionPtr, long statementPtr, long windowPtr, int startPos, int requiredPos, boolean countAllRows); private static native int nativeGetDbLookaside(int connectionPtr); private static native void nativeCancel(int connectionPtr); private static native void nativeResetCancel(int connectionPtr, boolean cancelable); private static native int nativeGetDbLookaside(long connectionPtr); private static native void nativeCancel(long connectionPtr); private static native void nativeResetCancel(long connectionPtr, boolean cancelable); private SQLiteConnection(SQLiteConnectionPool pool, SQLiteDatabaseConfiguration configuration, Loading Loading @@ -886,7 +886,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen skipCache = true; } final int statementPtr = nativePrepareStatement(mConnectionPtr, sql); final long statementPtr = nativePrepareStatement(mConnectionPtr, sql); try { final int numParameters = nativeGetParameterCount(mConnectionPtr, statementPtr); final int type = DatabaseUtils.getSqlStatementType(sql); Loading Loading @@ -987,7 +987,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen return; } final int statementPtr = statement.mStatementPtr; final long statementPtr = statement.mStatementPtr; for (int i = 0; i < count; i++) { final Object arg = bindArgs[i]; switch (DatabaseUtils.getTypeOfObject(arg)) { Loading Loading @@ -1072,7 +1072,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen void dumpUnsafe(Printer printer, boolean verbose) { printer.println("Connection #" + mConnectionId + ":"); if (verbose) { printer.println(" connectionPtr: 0x" + Integer.toHexString(mConnectionPtr)); printer.println(" connectionPtr: 0x" + Long.toHexString(mConnectionPtr)); } printer.println(" isPrimaryConnection: " + mIsPrimaryConnection); printer.println(" onlyAllowReadOnlyOperations: " + mOnlyAllowReadOnlyOperations); Loading Loading @@ -1178,7 +1178,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen return "SQLiteConnection: " + mConfiguration.path + " (" + mConnectionId + ")"; } private PreparedStatement obtainPreparedStatement(String sql, int statementPtr, private PreparedStatement obtainPreparedStatement(String sql, long statementPtr, int numParameters, int type, boolean readOnly) { PreparedStatement statement = mPreparedStatementPool; if (statement != null) { Loading Loading @@ -1225,7 +1225,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen // The native sqlite3_stmt object pointer. // Lifetime is managed explicitly by the connection. public int mStatementPtr; public long mStatementPtr; // The number of parameters that the prepared statement has. public int mNumParameters; Loading Loading @@ -1271,7 +1271,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen if (statement.mInCache) { // might be false due to a race with entryRemoved String sql = entry.getKey(); printer.println(" " + i + ": statementPtr=0x" + Integer.toHexString(statement.mStatementPtr) + Long.toHexString(statement.mStatementPtr) + ", numParameters=" + statement.mNumParameters + ", type=" + statement.mType + ", readOnly=" + statement.mReadOnly Loading core/jni/android_database_CursorWindow.cpp +44 −44 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ static void throwUnknownTypeException(JNIEnv * env, jint type) { jniThrowException(env, "java/lang/IllegalStateException", msg.string()); } static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { static jlong nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { String8 name; const char* nameStr = env->GetStringUTFChars(nameObj, NULL); name.setTo(nameStr); Loading @@ -73,10 +73,10 @@ static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursor } LOG_WINDOW("nativeInitializeEmpty: window = %p", window); return reinterpret_cast<jint>(window); return reinterpret_cast<jlong>(window); } static jint nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { static jlong nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); CursorWindow* window; Loading @@ -88,10 +88,10 @@ static jint nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) LOG_WINDOW("nativeInitializeFromBinder: numRows = %d, numColumns = %d, window = %p", window->getNumRows(), window->getNumColumns(), window); return reinterpret_cast<jint>(window); return reinterpret_cast<jlong>(window); } static void nativeDispose(JNIEnv* env, jclass clazz, jint windowPtr) { static void nativeDispose(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); if (window) { LOG_WINDOW("Closing window %p", window); Loading @@ -99,12 +99,12 @@ static void nativeDispose(JNIEnv* env, jclass clazz, jint windowPtr) { } } static jstring nativeGetName(JNIEnv* env, jclass clazz, jint windowPtr) { static jstring nativeGetName(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); return env->NewStringUTF(window->name().string()); } static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jint windowPtr, static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jlong windowPtr, jobject parcelObj) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); Parcel* parcel = parcelForJavaObject(env, parcelObj); Loading @@ -117,7 +117,7 @@ static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jint windowPtr, } } static void nativeClear(JNIEnv * env, jclass clazz, jint windowPtr) { static void nativeClear(JNIEnv * env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Clearing window %p", window); status_t status = window->clear(); Loading @@ -126,30 +126,30 @@ static void nativeClear(JNIEnv * env, jclass clazz, jint windowPtr) { } } static jint nativeGetNumRows(JNIEnv* env, jclass clazz, jint windowPtr) { static jint nativeGetNumRows(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); return window->getNumRows(); } static jboolean nativeSetNumColumns(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativeSetNumColumns(JNIEnv* env, jclass clazz, jlong windowPtr, jint columnNum) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->setNumColumns(columnNum); return status == OK; } static jboolean nativeAllocRow(JNIEnv* env, jclass clazz, jint windowPtr) { static jboolean nativeAllocRow(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->allocRow(); return status == OK; } static void nativeFreeLastRow(JNIEnv* env, jclass clazz, jint windowPtr) { static void nativeFreeLastRow(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); window->freeLastRow(); } static jint nativeGetType(JNIEnv* env, jclass clazz, jint windowPtr, static jint nativeGetType(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("returning column type affinity for %d,%d from %p", row, column, window); Loading @@ -164,7 +164,7 @@ static jint nativeGetType(JNIEnv* env, jclass clazz, jint windowPtr, return window->getFieldSlotType(fieldSlot); } static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jint windowPtr, static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window); Loading Loading @@ -199,7 +199,7 @@ static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jint windowPtr, return NULL; } static jstring nativeGetString(JNIEnv* env, jclass clazz, jint windowPtr, static jstring nativeGetString(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting string for %d,%d from %p", row, column, window); Loading Loading @@ -291,7 +291,7 @@ static void clearCharArrayBuffer(JNIEnv* env, jobject bufferObj) { } } static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jint windowPtr, static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column, jobject bufferObj) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Copying string for %d,%d from %p", row, column, window); Loading Loading @@ -330,7 +330,7 @@ static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jint windowPtr, } } static jlong nativeGetLong(JNIEnv* env, jclass clazz, jint windowPtr, static jlong nativeGetLong(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting long for %d,%d from %p", row, column, window); Loading Loading @@ -361,7 +361,7 @@ static jlong nativeGetLong(JNIEnv* env, jclass clazz, jint windowPtr, } } static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jint windowPtr, static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting double for %d,%d from %p", row, column, window); Loading Loading @@ -392,7 +392,7 @@ static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jint windowPtr, } } static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jlong windowPtr, jbyteArray valueObj, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); jsize len = env->GetArrayLength(valueObj); Loading @@ -410,7 +410,7 @@ static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutString(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutString(JNIEnv* env, jclass clazz, jlong windowPtr, jstring valueObj, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); Loading @@ -432,7 +432,7 @@ static jboolean nativePutString(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutLong(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutLong(JNIEnv* env, jclass clazz, jlong windowPtr, jlong value, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putLong(row, column, value); Loading @@ -446,7 +446,7 @@ static jboolean nativePutLong(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jlong windowPtr, jdouble value, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putDouble(row, column, value); Loading @@ -460,7 +460,7 @@ static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutNull(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putNull(row, column); Loading @@ -477,47 +477,47 @@ static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ { "nativeCreate", "(Ljava/lang/String;I)I", { "nativeCreate", "(Ljava/lang/String;I)J", (void*)nativeCreate }, { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I", { "nativeCreateFromParcel", "(Landroid/os/Parcel;)J", (void*)nativeCreateFromParcel }, { "nativeDispose", "(I)V", { "nativeDispose", "(J)V", (void*)nativeDispose }, { "nativeWriteToParcel", "(ILandroid/os/Parcel;)V", { "nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, { "nativeGetName", "(I)Ljava/lang/String;", { "nativeGetName", "(J)Ljava/lang/String;", (void*)nativeGetName }, { "nativeClear", "(I)V", { "nativeClear", "(J)V", (void*)nativeClear }, { "nativeGetNumRows", "(I)I", { "nativeGetNumRows", "(J)I", (void*)nativeGetNumRows }, { "nativeSetNumColumns", "(II)Z", { "nativeSetNumColumns", "(JI)Z", (void*)nativeSetNumColumns }, { "nativeAllocRow", "(I)Z", { "nativeAllocRow", "(J)Z", (void*)nativeAllocRow }, { "nativeFreeLastRow", "(I)V", { "nativeFreeLastRow", "(J)V", (void*)nativeFreeLastRow }, { "nativeGetType", "(III)I", { "nativeGetType", "(JII)I", (void*)nativeGetType }, { "nativeGetBlob", "(III)[B", { "nativeGetBlob", "(JII)[B", (void*)nativeGetBlob }, { "nativeGetString", "(III)Ljava/lang/String;", { "nativeGetString", "(JII)Ljava/lang/String;", (void*)nativeGetString }, { "nativeGetLong", "(III)J", { "nativeGetLong", "(JII)J", (void*)nativeGetLong }, { "nativeGetDouble", "(III)D", { "nativeGetDouble", "(JII)D", (void*)nativeGetDouble }, { "nativeCopyStringToBuffer", "(IIILandroid/database/CharArrayBuffer;)V", { "nativeCopyStringToBuffer", "(JIILandroid/database/CharArrayBuffer;)V", (void*)nativeCopyStringToBuffer }, { "nativePutBlob", "(I[BII)Z", { "nativePutBlob", "(J[BII)Z", (void*)nativePutBlob }, { "nativePutString", "(ILjava/lang/String;II)Z", { "nativePutString", "(JLjava/lang/String;II)Z", (void*)nativePutString }, { "nativePutLong", "(IJII)Z", { "nativePutLong", "(JJII)Z", (void*)nativePutLong }, { "nativePutDouble", "(IDII)Z", { "nativePutDouble", "(JDII)Z", (void*)nativePutDouble }, { "nativePutNull", "(III)Z", { "nativePutNull", "(JII)Z", (void*)nativePutNull }, }; Loading core/jni/android_database_SQLiteConnection.cpp +66 −66 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/database/CursorWindow.java +27 −26 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Parcelable; import android.os.Process; import android.util.Log; import android.util.SparseIntArray; import android.util.LongSparseArray; /** * A buffer containing multiple cursor rows. Loading @@ -52,40 +53,40 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { * The native CursorWindow object pointer. (FOR INTERNAL USE ONLY) * @hide */ public int mWindowPtr; public long mWindowPtr; private int mStartPos; private final String mName; private final CloseGuard mCloseGuard = CloseGuard.get(); private static native int nativeCreate(String name, int cursorWindowSize); private static native int nativeCreateFromParcel(Parcel parcel); private static native void nativeDispose(int windowPtr); private static native void nativeWriteToParcel(int windowPtr, Parcel parcel); private static native long nativeCreate(String name, int cursorWindowSize); private static native long nativeCreateFromParcel(Parcel parcel); private static native void nativeDispose(long windowPtr); private static native void nativeWriteToParcel(long windowPtr, Parcel parcel); private static native void nativeClear(int windowPtr); private static native void nativeClear(long windowPtr); private static native int nativeGetNumRows(int windowPtr); private static native boolean nativeSetNumColumns(int windowPtr, int columnNum); private static native boolean nativeAllocRow(int windowPtr); private static native void nativeFreeLastRow(int windowPtr); private static native int nativeGetNumRows(long windowPtr); private static native boolean nativeSetNumColumns(long windowPtr, int columnNum); private static native boolean nativeAllocRow(long windowPtr); private static native void nativeFreeLastRow(long windowPtr); private static native int nativeGetType(int windowPtr, int row, int column); private static native byte[] nativeGetBlob(int windowPtr, int row, int column); private static native String nativeGetString(int windowPtr, int row, int column); private static native long nativeGetLong(int windowPtr, int row, int column); private static native double nativeGetDouble(int windowPtr, int row, int column); private static native void nativeCopyStringToBuffer(int windowPtr, int row, int column, private static native int nativeGetType(long windowPtr, int row, int column); private static native byte[] nativeGetBlob(long windowPtr, int row, int column); private static native String nativeGetString(long windowPtr, int row, int column); private static native long nativeGetLong(long windowPtr, int row, int column); private static native double nativeGetDouble(long windowPtr, int row, int column); private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column, CharArrayBuffer buffer); private static native boolean nativePutBlob(int windowPtr, byte[] value, int row, int column); private static native boolean nativePutString(int windowPtr, String value, int row, int column); private static native boolean nativePutLong(int windowPtr, long value, int row, int column); private static native boolean nativePutDouble(int windowPtr, double value, int row, int column); private static native boolean nativePutNull(int windowPtr, int row, int column); private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column); private static native boolean nativePutString(long windowPtr, String value, int row, int column); private static native boolean nativePutLong(long windowPtr, long value, int row, int column); private static native boolean nativePutDouble(long windowPtr, double value, int row, int column); private static native boolean nativePutNull(long windowPtr, int row, int column); private static native String nativeGetName(int windowPtr); private static native String nativeGetName(long windowPtr); /** * Creates a new empty cursor window and gives it a name. Loading Loading @@ -713,9 +714,9 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { dispose(); } private static final SparseIntArray sWindowToPidMap = new SparseIntArray(); private static final LongSparseArray<Integer> sWindowToPidMap = new LongSparseArray<Integer>(); private void recordNewWindow(int pid, int window) { private void recordNewWindow(int pid, long window) { synchronized (sWindowToPidMap) { sWindowToPidMap.put(window, pid); if (Log.isLoggable(STATS_TAG, Log.VERBOSE)) { Loading @@ -724,7 +725,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { } } private void recordClosingOfWindow(int window) { private void recordClosingOfWindow(long window) { synchronized (sWindowToPidMap) { if (sWindowToPidMap.size() == 0) { // this means we are not in the ContentProvider. Loading Loading @@ -771,6 +772,6 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { @Override public String toString() { return getName() + " {" + Integer.toHexString(mWindowPtr) + "}"; return getName() + " {" + Long.toHexString(mWindowPtr) + "}"; } }
core/java/android/database/sqlite/SQLiteConnection.java +33 −33 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen private final OperationLog mRecentOperations = new OperationLog(); // The native SQLiteConnection pointer. (FOR INTERNAL USE ONLY) private int mConnectionPtr; private long mConnectionPtr; private boolean mOnlyAllowReadOnlyOperations; Loading @@ -117,45 +117,45 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen // we can ensure that we detach the signal at the right time. private int mCancellationSignalAttachCount; private static native int nativeOpen(String path, int openFlags, String label, private static native long nativeOpen(String path, int openFlags, String label, boolean enableTrace, boolean enableProfile); private static native void nativeClose(int connectionPtr); private static native void nativeRegisterCustomFunction(int connectionPtr, private static native void nativeClose(long connectionPtr); private static native void nativeRegisterCustomFunction(long connectionPtr, SQLiteCustomFunction function); private static native void nativeRegisterLocalizedCollators(int connectionPtr, String locale); private static native int nativePrepareStatement(int connectionPtr, String sql); private static native void nativeFinalizeStatement(int connectionPtr, int statementPtr); private static native int nativeGetParameterCount(int connectionPtr, int statementPtr); private static native boolean nativeIsReadOnly(int connectionPtr, int statementPtr); private static native int nativeGetColumnCount(int connectionPtr, int statementPtr); private static native String nativeGetColumnName(int connectionPtr, int statementPtr, private static native void nativeRegisterLocalizedCollators(long connectionPtr, String locale); private static native long nativePrepareStatement(long connectionPtr, String sql); private static native void nativeFinalizeStatement(long connectionPtr, long statementPtr); private static native int nativeGetParameterCount(long connectionPtr, long statementPtr); private static native boolean nativeIsReadOnly(long connectionPtr, long statementPtr); private static native int nativeGetColumnCount(long connectionPtr, long statementPtr); private static native String nativeGetColumnName(long connectionPtr, long statementPtr, int index); private static native void nativeBindNull(int connectionPtr, int statementPtr, private static native void nativeBindNull(long connectionPtr, long statementPtr, int index); private static native void nativeBindLong(int connectionPtr, int statementPtr, private static native void nativeBindLong(long connectionPtr, long statementPtr, int index, long value); private static native void nativeBindDouble(int connectionPtr, int statementPtr, private static native void nativeBindDouble(long connectionPtr, long statementPtr, int index, double value); private static native void nativeBindString(int connectionPtr, int statementPtr, private static native void nativeBindString(long connectionPtr, long statementPtr, int index, String value); private static native void nativeBindBlob(int connectionPtr, int statementPtr, private static native void nativeBindBlob(long connectionPtr, long statementPtr, int index, byte[] value); private static native void nativeResetStatementAndClearBindings( int connectionPtr, int statementPtr); private static native void nativeExecute(int connectionPtr, int statementPtr); private static native long nativeExecuteForLong(int connectionPtr, int statementPtr); private static native String nativeExecuteForString(int connectionPtr, int statementPtr); long connectionPtr, long statementPtr); private static native void nativeExecute(long connectionPtr, long statementPtr); private static native long nativeExecuteForLong(long connectionPtr, long statementPtr); private static native String nativeExecuteForString(long connectionPtr, long statementPtr); private static native int nativeExecuteForBlobFileDescriptor( int connectionPtr, int statementPtr); private static native int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr); long connectionPtr, long statementPtr); private static native int nativeExecuteForChangedRowCount(long connectionPtr, long statementPtr); private static native long nativeExecuteForLastInsertedRowId( int connectionPtr, int statementPtr); long connectionPtr, long statementPtr); private static native long nativeExecuteForCursorWindow( int connectionPtr, int statementPtr, int windowPtr, long connectionPtr, long statementPtr, long windowPtr, int startPos, int requiredPos, boolean countAllRows); private static native int nativeGetDbLookaside(int connectionPtr); private static native void nativeCancel(int connectionPtr); private static native void nativeResetCancel(int connectionPtr, boolean cancelable); private static native int nativeGetDbLookaside(long connectionPtr); private static native void nativeCancel(long connectionPtr); private static native void nativeResetCancel(long connectionPtr, boolean cancelable); private SQLiteConnection(SQLiteConnectionPool pool, SQLiteDatabaseConfiguration configuration, Loading Loading @@ -886,7 +886,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen skipCache = true; } final int statementPtr = nativePrepareStatement(mConnectionPtr, sql); final long statementPtr = nativePrepareStatement(mConnectionPtr, sql); try { final int numParameters = nativeGetParameterCount(mConnectionPtr, statementPtr); final int type = DatabaseUtils.getSqlStatementType(sql); Loading Loading @@ -987,7 +987,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen return; } final int statementPtr = statement.mStatementPtr; final long statementPtr = statement.mStatementPtr; for (int i = 0; i < count; i++) { final Object arg = bindArgs[i]; switch (DatabaseUtils.getTypeOfObject(arg)) { Loading Loading @@ -1072,7 +1072,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen void dumpUnsafe(Printer printer, boolean verbose) { printer.println("Connection #" + mConnectionId + ":"); if (verbose) { printer.println(" connectionPtr: 0x" + Integer.toHexString(mConnectionPtr)); printer.println(" connectionPtr: 0x" + Long.toHexString(mConnectionPtr)); } printer.println(" isPrimaryConnection: " + mIsPrimaryConnection); printer.println(" onlyAllowReadOnlyOperations: " + mOnlyAllowReadOnlyOperations); Loading Loading @@ -1178,7 +1178,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen return "SQLiteConnection: " + mConfiguration.path + " (" + mConnectionId + ")"; } private PreparedStatement obtainPreparedStatement(String sql, int statementPtr, private PreparedStatement obtainPreparedStatement(String sql, long statementPtr, int numParameters, int type, boolean readOnly) { PreparedStatement statement = mPreparedStatementPool; if (statement != null) { Loading Loading @@ -1225,7 +1225,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen // The native sqlite3_stmt object pointer. // Lifetime is managed explicitly by the connection. public int mStatementPtr; public long mStatementPtr; // The number of parameters that the prepared statement has. public int mNumParameters; Loading Loading @@ -1271,7 +1271,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen if (statement.mInCache) { // might be false due to a race with entryRemoved String sql = entry.getKey(); printer.println(" " + i + ": statementPtr=0x" + Integer.toHexString(statement.mStatementPtr) + Long.toHexString(statement.mStatementPtr) + ", numParameters=" + statement.mNumParameters + ", type=" + statement.mType + ", readOnly=" + statement.mReadOnly Loading
core/jni/android_database_CursorWindow.cpp +44 −44 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ static void throwUnknownTypeException(JNIEnv * env, jint type) { jniThrowException(env, "java/lang/IllegalStateException", msg.string()); } static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { static jlong nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) { String8 name; const char* nameStr = env->GetStringUTFChars(nameObj, NULL); name.setTo(nameStr); Loading @@ -73,10 +73,10 @@ static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursor } LOG_WINDOW("nativeInitializeEmpty: window = %p", window); return reinterpret_cast<jint>(window); return reinterpret_cast<jlong>(window); } static jint nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { static jlong nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); CursorWindow* window; Loading @@ -88,10 +88,10 @@ static jint nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) LOG_WINDOW("nativeInitializeFromBinder: numRows = %d, numColumns = %d, window = %p", window->getNumRows(), window->getNumColumns(), window); return reinterpret_cast<jint>(window); return reinterpret_cast<jlong>(window); } static void nativeDispose(JNIEnv* env, jclass clazz, jint windowPtr) { static void nativeDispose(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); if (window) { LOG_WINDOW("Closing window %p", window); Loading @@ -99,12 +99,12 @@ static void nativeDispose(JNIEnv* env, jclass clazz, jint windowPtr) { } } static jstring nativeGetName(JNIEnv* env, jclass clazz, jint windowPtr) { static jstring nativeGetName(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); return env->NewStringUTF(window->name().string()); } static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jint windowPtr, static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jlong windowPtr, jobject parcelObj) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); Parcel* parcel = parcelForJavaObject(env, parcelObj); Loading @@ -117,7 +117,7 @@ static void nativeWriteToParcel(JNIEnv * env, jclass clazz, jint windowPtr, } } static void nativeClear(JNIEnv * env, jclass clazz, jint windowPtr) { static void nativeClear(JNIEnv * env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Clearing window %p", window); status_t status = window->clear(); Loading @@ -126,30 +126,30 @@ static void nativeClear(JNIEnv * env, jclass clazz, jint windowPtr) { } } static jint nativeGetNumRows(JNIEnv* env, jclass clazz, jint windowPtr) { static jint nativeGetNumRows(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); return window->getNumRows(); } static jboolean nativeSetNumColumns(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativeSetNumColumns(JNIEnv* env, jclass clazz, jlong windowPtr, jint columnNum) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->setNumColumns(columnNum); return status == OK; } static jboolean nativeAllocRow(JNIEnv* env, jclass clazz, jint windowPtr) { static jboolean nativeAllocRow(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->allocRow(); return status == OK; } static void nativeFreeLastRow(JNIEnv* env, jclass clazz, jint windowPtr) { static void nativeFreeLastRow(JNIEnv* env, jclass clazz, jlong windowPtr) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); window->freeLastRow(); } static jint nativeGetType(JNIEnv* env, jclass clazz, jint windowPtr, static jint nativeGetType(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("returning column type affinity for %d,%d from %p", row, column, window); Loading @@ -164,7 +164,7 @@ static jint nativeGetType(JNIEnv* env, jclass clazz, jint windowPtr, return window->getFieldSlotType(fieldSlot); } static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jint windowPtr, static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting blob for %d,%d from %p", row, column, window); Loading Loading @@ -199,7 +199,7 @@ static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jint windowPtr, return NULL; } static jstring nativeGetString(JNIEnv* env, jclass clazz, jint windowPtr, static jstring nativeGetString(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting string for %d,%d from %p", row, column, window); Loading Loading @@ -291,7 +291,7 @@ static void clearCharArrayBuffer(JNIEnv* env, jobject bufferObj) { } } static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jint windowPtr, static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column, jobject bufferObj) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Copying string for %d,%d from %p", row, column, window); Loading Loading @@ -330,7 +330,7 @@ static void nativeCopyStringToBuffer(JNIEnv* env, jclass clazz, jint windowPtr, } } static jlong nativeGetLong(JNIEnv* env, jclass clazz, jint windowPtr, static jlong nativeGetLong(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting long for %d,%d from %p", row, column, window); Loading Loading @@ -361,7 +361,7 @@ static jlong nativeGetLong(JNIEnv* env, jclass clazz, jint windowPtr, } } static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jint windowPtr, static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); LOG_WINDOW("Getting double for %d,%d from %p", row, column, window); Loading Loading @@ -392,7 +392,7 @@ static jdouble nativeGetDouble(JNIEnv* env, jclass clazz, jint windowPtr, } } static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jlong windowPtr, jbyteArray valueObj, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); jsize len = env->GetArrayLength(valueObj); Loading @@ -410,7 +410,7 @@ static jboolean nativePutBlob(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutString(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutString(JNIEnv* env, jclass clazz, jlong windowPtr, jstring valueObj, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); Loading @@ -432,7 +432,7 @@ static jboolean nativePutString(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutLong(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutLong(JNIEnv* env, jclass clazz, jlong windowPtr, jlong value, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putLong(row, column, value); Loading @@ -446,7 +446,7 @@ static jboolean nativePutLong(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jlong windowPtr, jdouble value, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putDouble(row, column, value); Loading @@ -460,7 +460,7 @@ static jboolean nativePutDouble(JNIEnv* env, jclass clazz, jint windowPtr, return true; } static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, static jboolean nativePutNull(JNIEnv* env, jclass clazz, jlong windowPtr, jint row, jint column) { CursorWindow* window = reinterpret_cast<CursorWindow*>(windowPtr); status_t status = window->putNull(row, column); Loading @@ -477,47 +477,47 @@ static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr, static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ { "nativeCreate", "(Ljava/lang/String;I)I", { "nativeCreate", "(Ljava/lang/String;I)J", (void*)nativeCreate }, { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I", { "nativeCreateFromParcel", "(Landroid/os/Parcel;)J", (void*)nativeCreateFromParcel }, { "nativeDispose", "(I)V", { "nativeDispose", "(J)V", (void*)nativeDispose }, { "nativeWriteToParcel", "(ILandroid/os/Parcel;)V", { "nativeWriteToParcel", "(JLandroid/os/Parcel;)V", (void*)nativeWriteToParcel }, { "nativeGetName", "(I)Ljava/lang/String;", { "nativeGetName", "(J)Ljava/lang/String;", (void*)nativeGetName }, { "nativeClear", "(I)V", { "nativeClear", "(J)V", (void*)nativeClear }, { "nativeGetNumRows", "(I)I", { "nativeGetNumRows", "(J)I", (void*)nativeGetNumRows }, { "nativeSetNumColumns", "(II)Z", { "nativeSetNumColumns", "(JI)Z", (void*)nativeSetNumColumns }, { "nativeAllocRow", "(I)Z", { "nativeAllocRow", "(J)Z", (void*)nativeAllocRow }, { "nativeFreeLastRow", "(I)V", { "nativeFreeLastRow", "(J)V", (void*)nativeFreeLastRow }, { "nativeGetType", "(III)I", { "nativeGetType", "(JII)I", (void*)nativeGetType }, { "nativeGetBlob", "(III)[B", { "nativeGetBlob", "(JII)[B", (void*)nativeGetBlob }, { "nativeGetString", "(III)Ljava/lang/String;", { "nativeGetString", "(JII)Ljava/lang/String;", (void*)nativeGetString }, { "nativeGetLong", "(III)J", { "nativeGetLong", "(JII)J", (void*)nativeGetLong }, { "nativeGetDouble", "(III)D", { "nativeGetDouble", "(JII)D", (void*)nativeGetDouble }, { "nativeCopyStringToBuffer", "(IIILandroid/database/CharArrayBuffer;)V", { "nativeCopyStringToBuffer", "(JIILandroid/database/CharArrayBuffer;)V", (void*)nativeCopyStringToBuffer }, { "nativePutBlob", "(I[BII)Z", { "nativePutBlob", "(J[BII)Z", (void*)nativePutBlob }, { "nativePutString", "(ILjava/lang/String;II)Z", { "nativePutString", "(JLjava/lang/String;II)Z", (void*)nativePutString }, { "nativePutLong", "(IJII)Z", { "nativePutLong", "(JJII)Z", (void*)nativePutLong }, { "nativePutDouble", "(IDII)Z", { "nativePutDouble", "(JDII)Z", (void*)nativePutDouble }, { "nativePutNull", "(III)Z", { "nativePutNull", "(JII)Z", (void*)nativePutNull }, }; Loading
core/jni/android_database_SQLiteConnection.cpp +66 −66 File changed.Preview size limit exceeded, changes collapsed. Show changes