summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-12-19 00:21:10 -0800
committerVasu Nori <vnori@google.com>2010-12-20 13:08:08 -0800
commit2594bae1f551d758c5c88771310d1ee3dc2c71ac (patch)
treea3628391acd770e4744a33673e65a92d1385fb73 /core/java
parent4c7cc34127efa3308e1a09b28728868911b79789 (diff)
downloadframeworks_base-2594bae1f551d758c5c88771310d1ee3dc2c71ac.zip
frameworks_base-2594bae1f551d758c5c88771310d1ee3dc2c71ac.tar.gz
frameworks_base-2594bae1f551d758c5c88771310d1ee3dc2c71ac.tar.bz2
bug:2448371 cursorwindow size moved to resource xml file.
let cursor window size be set per device in device resources file. default is 1MB. for SR, it is 2MB. it can be set to any value (in kB) in the device resource strings.xml file Change-Id: I67b1d04a5c9fc18b0cd4da6184d0b814b64d89e9
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/database/CursorWindow.java12
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java19
2 files changed, 29 insertions, 2 deletions
diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java
index a026eca..9a8f2d2 100644
--- a/core/java/android/database/CursorWindow.java
+++ b/core/java/android/database/CursorWindow.java
@@ -16,6 +16,7 @@
package android.database;
+import android.content.res.Resources;
import android.database.sqlite.SQLiteClosable;
import android.os.IBinder;
import android.os.Parcel;
@@ -25,6 +26,13 @@ import android.os.Parcelable;
* A buffer containing multiple cursor rows.
*/
public class CursorWindow extends SQLiteClosable implements Parcelable {
+ /** The cursor window size. resource xml file specifies the value in kB.
+ * convert it to bytes here by multiplying with 1024.
+ */
+ private static final int sCursorWindowSize =
+ Resources.getSystem().getInteger(
+ com.android.internal.R.integer.config_cursorWindowSize) * 1024;
+
/** The pointer to the native window class */
@SuppressWarnings("unused")
private int nWindow;
@@ -38,7 +46,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
*/
public CursorWindow(boolean localWindow) {
mStartPos = 0;
- native_init(localWindow);
+ native_init(sCursorWindowSize, localWindow);
}
/**
@@ -574,7 +582,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
private native IBinder native_getBinder();
/** Does the native side initialization for an empty window */
- private native void native_init(boolean localOnly);
+ private native void native_init(int cursorWindowSize, boolean localOnly);
/** Does the native side initialization with an existing binder from another process */
private native void native_init(IBinder nativeBinder);
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index 184988b..7d1f175 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -18,6 +18,7 @@ package android.database.sqlite;
import android.app.AppGlobals;
import android.content.ContentValues;
+import android.content.res.Resources;
import android.database.Cursor;
import android.database.DatabaseErrorHandler;
import android.database.DatabaseUtils;
@@ -2670,4 +2671,22 @@ public class SQLiteDatabase extends SQLiteClosable {
* @param statementId statement to be finzlied by sqlite
*/
private final native void native_finalize(int statementId);
+
+ /**
+ * set sqlite soft heap limit
+ * http://www.sqlite.org/c3ref/soft_heap_limit64.html
+ */
+
+ /** sqlite soft heap limit http://www.sqlite.org/c3ref/soft_heap_limit64.html
+ * set it to 4 times the default cursor window size.
+ * TODO what is an appropriate value, considring the WAL feature which could burn
+ * a lot of memory with many connections to the database. needs testing to figure out
+ * optimal value for this.
+ */
+ static {
+ int limit = Resources.getSystem().getInteger(
+ com.android.internal.R.integer.config_cursorWindowSize) * 1024 * 4;
+ native_setSqliteSoftHeapLimit(limit);
+ }
+ private final static native void native_setSqliteSoftHeapLimit(int softHeapLimit);
}