Merge "Deprecate local-only CursorWindows."
This commit is contained in:
@@ -6851,7 +6851,8 @@ package android.database {
|
||||
}
|
||||
|
||||
public class CursorWindow extends android.database.sqlite.SQLiteClosable implements android.os.Parcelable {
|
||||
ctor public CursorWindow(boolean);
|
||||
ctor public CursorWindow(java.lang.String);
|
||||
ctor public deprecated CursorWindow(boolean);
|
||||
method public boolean allocRow();
|
||||
method public void clear();
|
||||
method public void close();
|
||||
|
||||
@@ -188,15 +188,14 @@ public abstract class AbstractWindowedCursor extends AbstractCursor {
|
||||
|
||||
/**
|
||||
* If there is a window, clear it.
|
||||
* Otherwise, creates a local window.
|
||||
* Otherwise, creates a new window.
|
||||
*
|
||||
* @param name The window name.
|
||||
* @hide
|
||||
*/
|
||||
protected void clearOrCreateLocalWindow(String name) {
|
||||
protected void clearOrCreateWindow(String name) {
|
||||
if (mWindow == null) {
|
||||
// If there isn't a window set already it will only be accessed locally
|
||||
mWindow = new CursorWindow(name, true /* the window is local only */);
|
||||
mWindow = new CursorWindow(name);
|
||||
} else {
|
||||
mWindow.clear();
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
|
||||
AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor)mCursor;
|
||||
window = windowedCursor.getWindow();
|
||||
if (window == null) {
|
||||
window = new CursorWindow(mProviderName, false /*localOnly*/);
|
||||
window = new CursorWindow(mProviderName);
|
||||
windowedCursor.setWindow(window);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative
|
||||
} else {
|
||||
window = mWindowForNonWindowedCursor;
|
||||
if (window == null) {
|
||||
window = new CursorWindow(mProviderName, false /*localOnly*/);
|
||||
window = new CursorWindow(mProviderName);
|
||||
mWindowForNonWindowedCursor = window;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import android.util.SparseIntArray;
|
||||
/**
|
||||
* A buffer containing multiple cursor rows.
|
||||
* <p>
|
||||
* A {@link CursorWindow} is read-write when created and used locally. When sent
|
||||
* to a remote process (by writing it to a {@link Parcel}), the remote process
|
||||
* A {@link CursorWindow} is read-write when initially created and used locally.
|
||||
* When sent to a remote process (by writing it to a {@link Parcel}), the remote process
|
||||
* receives a read-only view of the cursor window. Typically the cursor window
|
||||
* will be allocated by the producer, filled with data, and then sent to the
|
||||
* consumer for reading.
|
||||
@@ -58,8 +58,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
|
||||
|
||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||
|
||||
private static native int nativeCreate(String name,
|
||||
int cursorWindowSize, boolean localOnly);
|
||||
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);
|
||||
@@ -93,14 +92,10 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
|
||||
* </p>
|
||||
*
|
||||
* @param name The name of the cursor window, or null if none.
|
||||
* @param localWindow True if this window will be used in this process only,
|
||||
* false if it might be sent to another processes.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CursorWindow(String name, boolean localWindow) {
|
||||
public CursorWindow(String name) {
|
||||
mStartPos = 0;
|
||||
mWindowPtr = nativeCreate(name, sCursorWindowSize, localWindow);
|
||||
mWindowPtr = nativeCreate(name, sCursorWindowSize);
|
||||
if (mWindowPtr == 0) {
|
||||
throw new CursorWindowAllocationException("Cursor window allocation of " +
|
||||
(sCursorWindowSize / 1024) + " kb failed. " + printStats());
|
||||
@@ -117,10 +112,14 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
|
||||
* </p>
|
||||
*
|
||||
* @param localWindow True if this window will be used in this process only,
|
||||
* false if it might be sent to another processes.
|
||||
* false if it might be sent to another processes. This argument is ignored.
|
||||
*
|
||||
* @deprecated There is no longer a distinction between local and remote
|
||||
* cursor windows. Use the {@link #CursorWindow(String)} constructor instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public CursorWindow(boolean localWindow) {
|
||||
this(null, localWindow);
|
||||
this((String)null);
|
||||
}
|
||||
|
||||
private CursorWindow(Parcel source) {
|
||||
|
||||
@@ -155,7 +155,7 @@ public class SQLiteCursor extends AbstractWindowedCursor {
|
||||
}
|
||||
|
||||
private void fillWindow(int startPos) {
|
||||
clearOrCreateLocalWindow(getDatabase().getPath());
|
||||
clearOrCreateWindow(getDatabase().getPath());
|
||||
mWindow.setStartPosition(startPos);
|
||||
int count = getQuery().fillWindow(mWindow);
|
||||
if (startPos == 0) { // fillWindow returns count(*) only for startPos = 0
|
||||
|
||||
@@ -57,8 +57,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, jboolean localOnly) {
|
||||
static jint nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) {
|
||||
String8 name;
|
||||
if (nameObj) {
|
||||
const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
|
||||
@@ -70,7 +69,7 @@ static jint nativeCreate(JNIEnv* env, jclass clazz,
|
||||
}
|
||||
|
||||
CursorWindow* window;
|
||||
status_t status = CursorWindow::create(name, cursorWindowSize, localOnly, &window);
|
||||
status_t status = CursorWindow::create(name, cursorWindowSize, &window);
|
||||
if (status || !window) {
|
||||
LOGE("Could not allocate CursorWindow '%s' of size %d due to error %d.",
|
||||
name.string(), cursorWindowSize, status);
|
||||
@@ -477,7 +476,7 @@ static jboolean nativePutNull(JNIEnv* env, jclass clazz, jint windowPtr,
|
||||
static JNINativeMethod sMethods[] =
|
||||
{
|
||||
/* name, signature, funcPtr */
|
||||
{ "nativeCreate", "(Ljava/lang/String;IZ)I",
|
||||
{ "nativeCreate", "(Ljava/lang/String;I)I",
|
||||
(void*)nativeCreate },
|
||||
{ "nativeCreateFromParcel", "(Landroid/os/Parcel;)I",
|
||||
(void*)nativeCreateFromParcel },
|
||||
|
||||
@@ -80,8 +80,7 @@ public:
|
||||
|
||||
~CursorWindow();
|
||||
|
||||
static status_t create(const String8& name, size_t size, bool localOnly,
|
||||
CursorWindow** outCursorWindow);
|
||||
static status_t create(const String8& name, size_t size, CursorWindow** outCursorWindow);
|
||||
static status_t createFromParcel(Parcel* parcel, CursorWindow** outCursorWindow);
|
||||
|
||||
status_t writeToParcel(Parcel* parcel);
|
||||
|
||||
@@ -40,11 +40,9 @@ CursorWindow::~CursorWindow() {
|
||||
::close(mAshmemFd);
|
||||
}
|
||||
|
||||
status_t CursorWindow::create(const String8& name, size_t size, bool localOnly,
|
||||
CursorWindow** outCursorWindow) {
|
||||
status_t CursorWindow::create(const String8& name, size_t size, CursorWindow** outCursorWindow) {
|
||||
String8 ashmemName("CursorWindow: ");
|
||||
ashmemName.append(name);
|
||||
ashmemName.append(localOnly ? " (local)" : " (remote)");
|
||||
|
||||
status_t result;
|
||||
int ashmemFd = ashmem_create_region(ashmemName.string(), size);
|
||||
|
||||
Reference in New Issue
Block a user