summaryrefslogtreecommitdiffstats
path: root/core/java/android/database
diff options
context:
space:
mode:
authoryingying <yingying@codeaurora.org>2014-05-07 17:12:25 +0800
committeryingying <yingying@codeaurora.org>2014-05-07 23:00:28 +0800
commit1ec4f360605ff62c618ca63368a278cddd0e8a74 (patch)
treec79c642613b78f33e687f4f2495143fb42e7392b /core/java/android/database
parenta21ba5bec748e2f10d7e6d38181ec1124991cb60 (diff)
downloadframeworks_base-1ec4f360605ff62c618ca63368a278cddd0e8a74.zip
frameworks_base-1ec4f360605ff62c618ca63368a278cddd0e8a74.tar.gz
frameworks_base-1ec4f360605ff62c618ca63368a278cddd0e8a74.tar.bz2
Init the static member when first used for CursorWindow.
As the CursorWindow will be preloaded by zygote, and there is one static member need use the system resource to initialize. But actually the zygote do not preload the resource now. (In fact, the zygote will preload classes first, then preload the resource.) We need ensure the zygote to create the system resource first. So change to init this static member as -1, and it will be evaluated when first used. Change-Id: Ibccb84e3c410c73788ac682fe76b720306e81dc4
Diffstat (limited to 'core/java/android/database')
-rw-r--r--core/java/android/database/CursorWindow.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java
index 197e3ff..a75372f 100644
--- a/core/java/android/database/CursorWindow.java
+++ b/core/java/android/database/CursorWindow.java
@@ -42,12 +42,8 @@ import android.util.LongSparseArray;
public class CursorWindow extends SQLiteClosable implements Parcelable {
private static final String STATS_TAG = "CursorWindowStats";
- /** 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;
+ // This static member will be evaluated when first used.
+ private static int sCursorWindowSize = -1;
/**
* The native CursorWindow object pointer. (FOR INTERNAL USE ONLY)
@@ -100,6 +96,13 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
public CursorWindow(String name) {
mStartPos = 0;
mName = name != null && name.length() != 0 ? name : "<unnamed>";
+ if (sCursorWindowSize < 0) {
+ /** The cursor window size. resource xml file specifies the value in kB.
+ * convert it to bytes here by multiplying with 1024.
+ */
+ sCursorWindowSize = Resources.getSystem().getInteger(
+ com.android.internal.R.integer.config_cursorWindowSize) * 1024;
+ }
mWindowPtr = nativeCreate(mName, sCursorWindowSize);
if (mWindowPtr == 0) {
throw new CursorWindowAllocationException("Cursor window allocation of " +