Skip to content

Commit a39a055

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Deprecate local-only CursorWindows."
2 parents 436e270 + 5e5d6d8 commit a39a055

File tree

8 files changed

+24
-29
lines changed

8 files changed

+24
-29
lines changed

api/current.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6851,7 +6851,8 @@ package android.database {
68516851
}
68526852

68536853
public class CursorWindow extends android.database.sqlite.SQLiteClosable implements android.os.Parcelable {
6854-
ctor public CursorWindow(boolean);
6854+
ctor public CursorWindow(java.lang.String);
6855+
ctor public deprecated CursorWindow(boolean);
68556856
method public boolean allocRow();
68566857
method public void clear();
68576858
method public void close();

core/java/android/database/AbstractWindowedCursor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,14 @@ protected void closeWindow() {
188188

189189
/**
190190
* If there is a window, clear it.
191-
* Otherwise, creates a local window.
191+
* Otherwise, creates a new window.
192192
*
193193
* @param name The window name.
194194
* @hide
195195
*/
196-
protected void clearOrCreateLocalWindow(String name) {
196+
protected void clearOrCreateWindow(String name) {
197197
if (mWindow == null) {
198-
// If there isn't a window set already it will only be accessed locally
199-
mWindow = new CursorWindow(name, true /* the window is local only */);
198+
mWindow = new CursorWindow(name);
200199
} else {
201200
mWindow.clear();
202201
}

core/java/android/database/CursorToBulkCursorAdaptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ public CursorWindow getWindow(int startPos) {
144144
AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor)mCursor;
145145
window = windowedCursor.getWindow();
146146
if (window == null) {
147-
window = new CursorWindow(mProviderName, false /*localOnly*/);
147+
window = new CursorWindow(mProviderName);
148148
windowedCursor.setWindow(window);
149149
}
150150

151151
mCursor.moveToPosition(startPos);
152152
} else {
153153
window = mWindowForNonWindowedCursor;
154154
if (window == null) {
155-
window = new CursorWindow(mProviderName, false /*localOnly*/);
155+
window = new CursorWindow(mProviderName);
156156
mWindowForNonWindowedCursor = window;
157157
}
158158

core/java/android/database/CursorWindow.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
/**
3232
* A buffer containing multiple cursor rows.
3333
* <p>
34-
* A {@link CursorWindow} is read-write when created and used locally. When sent
35-
* to a remote process (by writing it to a {@link Parcel}), the remote process
34+
* A {@link CursorWindow} is read-write when initially created and used locally.
35+
* When sent to a remote process (by writing it to a {@link Parcel}), the remote process
3636
* receives a read-only view of the cursor window. Typically the cursor window
3737
* will be allocated by the producer, filled with data, and then sent to the
3838
* consumer for reading.
@@ -58,8 +58,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
5858

5959
private final CloseGuard mCloseGuard = CloseGuard.get();
6060

61-
private static native int nativeCreate(String name,
62-
int cursorWindowSize, boolean localOnly);
61+
private static native int nativeCreate(String name, int cursorWindowSize);
6362
private static native int nativeCreateFromParcel(Parcel parcel);
6463
private static native void nativeDispose(int windowPtr);
6564
private static native void nativeWriteToParcel(int windowPtr, Parcel parcel);
@@ -93,14 +92,10 @@ private static native void nativeCopyStringToBuffer(int windowPtr, int row, int
9392
* </p>
9493
*
9594
* @param name The name of the cursor window, or null if none.
96-
* @param localWindow True if this window will be used in this process only,
97-
* false if it might be sent to another processes.
98-
*
99-
* @hide
10095
*/
101-
public CursorWindow(String name, boolean localWindow) {
96+
public CursorWindow(String name) {
10297
mStartPos = 0;
103-
mWindowPtr = nativeCreate(name, sCursorWindowSize, localWindow);
98+
mWindowPtr = nativeCreate(name, sCursorWindowSize);
10499
if (mWindowPtr == 0) {
105100
throw new CursorWindowAllocationException("Cursor window allocation of " +
106101
(sCursorWindowSize / 1024) + " kb failed. " + printStats());
@@ -117,10 +112,14 @@ public CursorWindow(String name, boolean localWindow) {
117112
* </p>
118113
*
119114
* @param localWindow True if this window will be used in this process only,
120-
* false if it might be sent to another processes.
115+
* false if it might be sent to another processes. This argument is ignored.
116+
*
117+
* @deprecated There is no longer a distinction between local and remote
118+
* cursor windows. Use the {@link #CursorWindow(String)} constructor instead.
121119
*/
120+
@Deprecated
122121
public CursorWindow(boolean localWindow) {
123-
this(null, localWindow);
122+
this((String)null);
124123
}
125124

126125
private CursorWindow(Parcel source) {

core/java/android/database/sqlite/SQLiteCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public int getCount() {
155155
}
156156

157157
private void fillWindow(int startPos) {
158-
clearOrCreateLocalWindow(getDatabase().getPath());
158+
clearOrCreateWindow(getDatabase().getPath());
159159
mWindow.setStartPosition(startPos);
160160
int count = getQuery().fillWindow(mWindow);
161161
if (startPos == 0) { // fillWindow returns count(*) only for startPos = 0

core/jni/android_database_CursorWindow.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ static void throwUnknownTypeException(JNIEnv * env, jint type) {
5757
jniThrowException(env, "java/lang/IllegalStateException", msg.string());
5858
}
5959

60-
static jint nativeCreate(JNIEnv* env, jclass clazz,
61-
jstring nameObj, jint cursorWindowSize, jboolean localOnly) {
60+
static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) {
6261
String8 name;
6362
if (nameObj) {
6463
const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
@@ -70,7 +69,7 @@ static jint nativeCreate(JNIEnv* env, jclass clazz,
7069
}
7170

7271
CursorWindow* window;
73-
status_t status = CursorWindow::create(name, cursorWindowSize, localOnly, &window);
72+
status_t status = CursorWindow::create(name, cursorWindowSize, &window);
7473
if (status || !window) {
7574
LOGE("Could not allocate CursorWindow '%s' of size %d due to error %d.",
7675
name.string(), cursorWindowSize, status);
@@ -477,7 +476,7 @@ static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr,
477476
static JNINativeMethod sMethods[] =
478477
{
479478
/* name, signature, funcPtr */
480-
{ "nativeCreate", "(Ljava/lang/String;IZ)I",
479+
{ "nativeCreate", "(Ljava/lang/String;I)I",
481480
(void*)nativeCreate },
482481
{ "nativeCreateFromParcel", "(Landroid/os/Parcel;)I",
483482
(void*)nativeCreateFromParcel },

include/binder/CursorWindow.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class CursorWindow {
8080

8181
~CursorWindow();
8282

83-
static status_t create(const String8& name, size_t size, bool localOnly,
84-
CursorWindow** outCursorWindow);
83+
static status_t create(const String8& name, size_t size, CursorWindow** outCursorWindow);
8584
static status_t createFromParcel(Parcel* parcel, CursorWindow** outCursorWindow);
8685

8786
status_t writeToParcel(Parcel* parcel);

libs/binder/CursorWindow.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ CursorWindow::~CursorWindow() {
4040
::close(mAshmemFd);
4141
}
4242

43-
status_t CursorWindow::create(const String8& name, size_t size, bool localOnly,
44-
CursorWindow** outCursorWindow) {
43+
status_t CursorWindow::create(const String8& name, size_t size, CursorWindow** outCursorWindow) {
4544
String8 ashmemName("CursorWindow: ");
4645
ashmemName.append(name);
47-
ashmemName.append(localOnly ? " (local)" : " (remote)");
4846

4947
status_t result;
5048
int ashmemFd = ashmem_create_region(ashmemName.string(), size);

0 commit comments

Comments
 (0)