Merge "Clean up handrolled Binder proxies. Bug: 5332296"
This commit is contained in:
@@ -332,60 +332,60 @@ final class ContentProviderProxy implements IContentProvider
|
|||||||
BulkCursorToCursorAdaptor adaptor) throws RemoteException {
|
BulkCursorToCursorAdaptor adaptor) throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
int length = 0;
|
||||||
|
if (projection != null) {
|
||||||
|
length = projection.length;
|
||||||
|
}
|
||||||
|
data.writeInt(length);
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
data.writeString(projection[i]);
|
||||||
|
}
|
||||||
|
data.writeString(selection);
|
||||||
|
if (selectionArgs != null) {
|
||||||
|
length = selectionArgs.length;
|
||||||
|
} else {
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
data.writeInt(length);
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
data.writeString(selectionArgs[i]);
|
||||||
|
}
|
||||||
|
data.writeString(sortOrder);
|
||||||
|
data.writeStrongBinder(observer.asBinder());
|
||||||
|
window.writeToParcel(data, 0);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
// Flag for whether or not we want the number of rows in the
|
||||||
int length = 0;
|
// cursor and the position of the "_id" column index (or -1 if
|
||||||
if (projection != null) {
|
// non-existent). Only to be returned if binder != null.
|
||||||
length = projection.length;
|
final boolean wantsCursorMetadata = (adaptor != null);
|
||||||
}
|
data.writeInt(wantsCursorMetadata ? 1 : 0);
|
||||||
data.writeInt(length);
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
data.writeString(projection[i]);
|
|
||||||
}
|
|
||||||
data.writeString(selection);
|
|
||||||
if (selectionArgs != null) {
|
|
||||||
length = selectionArgs.length;
|
|
||||||
} else {
|
|
||||||
length = 0;
|
|
||||||
}
|
|
||||||
data.writeInt(length);
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
data.writeString(selectionArgs[i]);
|
|
||||||
}
|
|
||||||
data.writeString(sortOrder);
|
|
||||||
data.writeStrongBinder(observer.asBinder());
|
|
||||||
window.writeToParcel(data, 0);
|
|
||||||
|
|
||||||
// Flag for whether or not we want the number of rows in the
|
mRemote.transact(IContentProvider.QUERY_TRANSACTION, data, reply, 0);
|
||||||
// cursor and the position of the "_id" column index (or -1 if
|
|
||||||
// non-existent). Only to be returned if binder != null.
|
|
||||||
final boolean wantsCursorMetadata = (adaptor != null);
|
|
||||||
data.writeInt(wantsCursorMetadata ? 1 : 0);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.QUERY_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
IBulkCursor bulkCursor = null;
|
||||||
|
IBinder bulkCursorBinder = reply.readStrongBinder();
|
||||||
|
if (bulkCursorBinder != null) {
|
||||||
|
bulkCursor = BulkCursorNative.asInterface(bulkCursorBinder);
|
||||||
|
|
||||||
IBulkCursor bulkCursor = null;
|
if (wantsCursorMetadata) {
|
||||||
IBinder bulkCursorBinder = reply.readStrongBinder();
|
int rowCount = reply.readInt();
|
||||||
if (bulkCursorBinder != null) {
|
int idColumnPosition = reply.readInt();
|
||||||
bulkCursor = BulkCursorNative.asInterface(bulkCursorBinder);
|
if (bulkCursor != null) {
|
||||||
|
adaptor.set(bulkCursor, rowCount, idColumnPosition);
|
||||||
if (wantsCursorMetadata) {
|
}
|
||||||
int rowCount = reply.readInt();
|
|
||||||
int idColumnPosition = reply.readInt();
|
|
||||||
if (bulkCursor != null) {
|
|
||||||
adaptor.set(bulkCursor, rowCount, idColumnPosition);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return bulkCursor;
|
||||||
|
} finally {
|
||||||
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
|
|
||||||
return bulkCursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBulkCursor bulkQuery(Uri url, String[] projection,
|
public IBulkCursor bulkQuery(Uri url, String[] projection,
|
||||||
@@ -416,240 +416,240 @@ final class ContentProviderProxy implements IContentProvider
|
|||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.GET_TYPE_TRANSACTION, data, reply, 0);
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.GET_TYPE_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
String out = reply.readString();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return out;
|
||||||
String out = reply.readString();
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uri insert(Uri url, ContentValues values) throws RemoteException
|
public Uri insert(Uri url, ContentValues values) throws RemoteException
|
||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
values.writeToParcel(data, 0);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.INSERT_TRANSACTION, data, reply, 0);
|
||||||
values.writeToParcel(data, 0);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.INSERT_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
Uri out = Uri.CREATOR.createFromParcel(reply);
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return out;
|
||||||
Uri out = Uri.CREATOR.createFromParcel(reply);
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int bulkInsert(Uri url, ContentValues[] values) throws RemoteException {
|
public int bulkInsert(Uri url, ContentValues[] values) throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
data.writeTypedArray(values, 0);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.BULK_INSERT_TRANSACTION, data, reply, 0);
|
||||||
data.writeTypedArray(values, 0);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.BULK_INSERT_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
int count = reply.readInt();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return count;
|
||||||
int count = reply.readInt();
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
|
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
|
||||||
throws RemoteException, OperationApplicationException {
|
throws RemoteException, OperationApplicationException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
data.writeInt(operations.size());
|
||||||
|
for (ContentProviderOperation operation : operations) {
|
||||||
|
operation.writeToParcel(data, 0);
|
||||||
|
}
|
||||||
|
mRemote.transact(IContentProvider.APPLY_BATCH_TRANSACTION, data, reply, 0);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(reply);
|
||||||
data.writeInt(operations.size());
|
final ContentProviderResult[] results =
|
||||||
for (ContentProviderOperation operation : operations) {
|
reply.createTypedArray(ContentProviderResult.CREATOR);
|
||||||
operation.writeToParcel(data, 0);
|
return results;
|
||||||
|
} finally {
|
||||||
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
}
|
}
|
||||||
mRemote.transact(IContentProvider.APPLY_BATCH_TRANSACTION, data, reply, 0);
|
|
||||||
|
|
||||||
DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(reply);
|
|
||||||
final ContentProviderResult[] results =
|
|
||||||
reply.createTypedArray(ContentProviderResult.CREATOR);
|
|
||||||
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int delete(Uri url, String selection, String[] selectionArgs)
|
public int delete(Uri url, String selection, String[] selectionArgs)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
data.writeString(selection);
|
||||||
|
data.writeStringArray(selectionArgs);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.DELETE_TRANSACTION, data, reply, 0);
|
||||||
data.writeString(selection);
|
|
||||||
data.writeStringArray(selectionArgs);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.DELETE_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
int count = reply.readInt();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return count;
|
||||||
int count = reply.readInt();
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int update(Uri url, ContentValues values, String selection,
|
public int update(Uri url, ContentValues values, String selection,
|
||||||
String[] selectionArgs) throws RemoteException {
|
String[] selectionArgs) throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
values.writeToParcel(data, 0);
|
||||||
|
data.writeString(selection);
|
||||||
|
data.writeStringArray(selectionArgs);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.UPDATE_TRANSACTION, data, reply, 0);
|
||||||
values.writeToParcel(data, 0);
|
|
||||||
data.writeString(selection);
|
|
||||||
data.writeStringArray(selectionArgs);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.UPDATE_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
int count = reply.readInt();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return count;
|
||||||
int count = reply.readInt();
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParcelFileDescriptor openFile(Uri url, String mode)
|
public ParcelFileDescriptor openFile(Uri url, String mode)
|
||||||
throws RemoteException, FileNotFoundException {
|
throws RemoteException, FileNotFoundException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
data.writeString(mode);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.OPEN_FILE_TRANSACTION, data, reply, 0);
|
||||||
data.writeString(mode);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.OPEN_FILE_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
|
||||||
|
int has = reply.readInt();
|
||||||
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
|
ParcelFileDescriptor fd = has != 0 ? reply.readFileDescriptor() : null;
|
||||||
int has = reply.readInt();
|
return fd;
|
||||||
ParcelFileDescriptor fd = has != 0 ? reply.readFileDescriptor() : null;
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetFileDescriptor openAssetFile(Uri url, String mode)
|
public AssetFileDescriptor openAssetFile(Uri url, String mode)
|
||||||
throws RemoteException, FileNotFoundException {
|
throws RemoteException, FileNotFoundException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
data.writeString(mode);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.OPEN_ASSET_FILE_TRANSACTION, data, reply, 0);
|
||||||
data.writeString(mode);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.OPEN_ASSET_FILE_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
|
||||||
|
int has = reply.readInt();
|
||||||
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
|
AssetFileDescriptor fd = has != 0
|
||||||
int has = reply.readInt();
|
? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
|
||||||
AssetFileDescriptor fd = has != 0
|
return fd;
|
||||||
? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bundle call(String method, String request, Bundle args)
|
public Bundle call(String method, String request, Bundle args)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
data.writeString(method);
|
||||||
|
data.writeString(request);
|
||||||
|
data.writeBundle(args);
|
||||||
|
|
||||||
data.writeString(method);
|
mRemote.transact(IContentProvider.CALL_TRANSACTION, data, reply, 0);
|
||||||
data.writeString(request);
|
|
||||||
data.writeBundle(args);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.CALL_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
Bundle bundle = reply.readBundle();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return bundle;
|
||||||
Bundle bundle = reply.readBundle();
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return bundle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException
|
public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException
|
||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
data.writeString(mimeTypeFilter);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.GET_STREAM_TYPES_TRANSACTION, data, reply, 0);
|
||||||
data.writeString(mimeTypeFilter);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.GET_STREAM_TYPES_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
String[] out = reply.createStringArray();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return out;
|
||||||
String[] out = reply.createStringArray();
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
|
public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
|
||||||
throws RemoteException, FileNotFoundException {
|
throws RemoteException, FileNotFoundException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IContentProvider.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IContentProvider.descriptor);
|
url.writeToParcel(data, 0);
|
||||||
|
data.writeString(mimeType);
|
||||||
|
data.writeBundle(opts);
|
||||||
|
|
||||||
url.writeToParcel(data, 0);
|
mRemote.transact(IContentProvider.OPEN_TYPED_ASSET_FILE_TRANSACTION, data, reply, 0);
|
||||||
data.writeString(mimeType);
|
|
||||||
data.writeBundle(opts);
|
|
||||||
|
|
||||||
mRemote.transact(IContentProvider.OPEN_TYPED_ASSET_FILE_TRANSACTION, data, reply, 0);
|
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
|
||||||
|
int has = reply.readInt();
|
||||||
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
|
AssetFileDescriptor fd = has != 0
|
||||||
int has = reply.readInt();
|
? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
|
||||||
AssetFileDescriptor fd = has != 0
|
return fd;
|
||||||
? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
|
} finally {
|
||||||
|
data.recycle();
|
||||||
data.recycle();
|
reply.recycle();
|
||||||
reply.recycle();
|
}
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBinder mRemote;
|
private IBinder mRemote;
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ import android.os.Binder;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native implementation of the bulk cursor. This is only for use in implementing
|
* Native implementation of the bulk cursor. This is only for use in implementing
|
||||||
* IPC, application code should use the Cursor interface.
|
* IPC, application code should use the Cursor interface.
|
||||||
*
|
*
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public abstract class BulkCursorNative extends Binder implements IBulkCursor
|
public abstract class BulkCursorNative extends Binder implements IBulkCursor
|
||||||
@@ -67,7 +68,7 @@ public abstract class BulkCursorNative extends Binder implements IBulkCursor
|
|||||||
}
|
}
|
||||||
reply.writeNoException();
|
reply.writeNoException();
|
||||||
reply.writeInt(1);
|
reply.writeInt(1);
|
||||||
window.writeToParcel(reply, 0);
|
window.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,172 +185,172 @@ final class BulkCursorProxy implements IBulkCursor {
|
|||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
data.writeInt(startPos);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(GET_CURSOR_WINDOW_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
data.writeInt(startPos);
|
CursorWindow window = null;
|
||||||
|
if (reply.readInt() == 1) {
|
||||||
mRemote.transact(GET_CURSOR_WINDOW_TRANSACTION, data, reply, 0);
|
window = CursorWindow.newFromParcel(reply);
|
||||||
|
}
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
return window;
|
||||||
|
} finally {
|
||||||
CursorWindow window = null;
|
data.recycle();
|
||||||
if (reply.readInt() == 1) {
|
reply.recycle();
|
||||||
window = CursorWindow.newFromParcel(reply);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
|
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMove(int position) throws RemoteException {
|
public void onMove(int position) throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
data.writeInt(position);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(ON_MOVE_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
data.writeInt(position);
|
} finally {
|
||||||
|
data.recycle();
|
||||||
mRemote.transact(ON_MOVE_TRANSACTION, data, reply, 0);
|
reply.recycle();
|
||||||
|
}
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
|
||||||
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int count() throws RemoteException
|
public int count() throws RemoteException
|
||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
boolean result = mRemote.transact(COUNT_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
boolean result = mRemote.transact(COUNT_TRANSACTION, data, reply, 0);
|
int count;
|
||||||
|
if (result == false) {
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
count = -1;
|
||||||
|
} else {
|
||||||
int count;
|
count = reply.readInt();
|
||||||
if (result == false) {
|
}
|
||||||
count = -1;
|
return count;
|
||||||
} else {
|
} finally {
|
||||||
count = reply.readInt();
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
}
|
}
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getColumnNames() throws RemoteException
|
public String[] getColumnNames() throws RemoteException
|
||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(GET_COLUMN_NAMES_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
mRemote.transact(GET_COLUMN_NAMES_TRANSACTION, data, reply, 0);
|
String[] columnNames = null;
|
||||||
|
int numColumns = reply.readInt();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
columnNames = new String[numColumns];
|
||||||
|
for (int i = 0; i < numColumns; i++) {
|
||||||
String[] columnNames = null;
|
columnNames[i] = reply.readString();
|
||||||
int numColumns = reply.readInt();
|
}
|
||||||
columnNames = new String[numColumns];
|
return columnNames;
|
||||||
for (int i = 0; i < numColumns; i++) {
|
} finally {
|
||||||
columnNames[i] = reply.readString();
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
return columnNames;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws RemoteException
|
public void deactivate() throws RemoteException
|
||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(DEACTIVATE_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
mRemote.transact(DEACTIVATE_TRANSACTION, data, reply, 0);
|
} finally {
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
data.recycle();
|
}
|
||||||
reply.recycle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws RemoteException
|
public void close() throws RemoteException
|
||||||
{
|
{
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(CLOSE_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
mRemote.transact(CLOSE_TRANSACTION, data, reply, 0);
|
} finally {
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
data.recycle();
|
}
|
||||||
reply.recycle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int requery(IContentObserver observer, CursorWindow window) throws RemoteException {
|
public int requery(IContentObserver observer, CursorWindow window) throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
data.writeStrongInterface(observer);
|
||||||
|
window.writeToParcel(data, 0);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
boolean result = mRemote.transact(REQUERY_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
data.writeStrongInterface(observer);
|
int count;
|
||||||
window.writeToParcel(data, 0);
|
if (!result) {
|
||||||
|
count = -1;
|
||||||
boolean result = mRemote.transact(REQUERY_TRANSACTION, data, reply, 0);
|
} else {
|
||||||
|
count = reply.readInt();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
mExtras = reply.readBundle();
|
||||||
|
}
|
||||||
int count;
|
return count;
|
||||||
if (!result) {
|
} finally {
|
||||||
count = -1;
|
data.recycle();
|
||||||
} else {
|
reply.recycle();
|
||||||
count = reply.readInt();
|
|
||||||
mExtras = reply.readBundle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getWantsAllOnMoveCalls() throws RemoteException {
|
public boolean getWantsAllOnMoveCalls() throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(WANTS_ON_MOVE_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
mRemote.transact(WANTS_ON_MOVE_TRANSACTION, data, reply, 0);
|
int result = reply.readInt();
|
||||||
|
return result != 0;
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
} finally {
|
||||||
|
data.recycle();
|
||||||
int result = reply.readInt();
|
reply.recycle();
|
||||||
data.recycle();
|
}
|
||||||
reply.recycle();
|
|
||||||
return result != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bundle getExtras() throws RemoteException {
|
public Bundle getExtras() throws RemoteException {
|
||||||
if (mExtras == null) {
|
if (mExtras == null) {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(GET_EXTRAS_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
mRemote.transact(GET_EXTRAS_TRANSACTION, data, reply, 0);
|
mExtras = reply.readBundle();
|
||||||
|
} finally {
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
mExtras = reply.readBundle();
|
}
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
}
|
}
|
||||||
return mExtras;
|
return mExtras;
|
||||||
}
|
}
|
||||||
@@ -357,19 +358,19 @@ final class BulkCursorProxy implements IBulkCursor {
|
|||||||
public Bundle respond(Bundle extras) throws RemoteException {
|
public Bundle respond(Bundle extras) throws RemoteException {
|
||||||
Parcel data = Parcel.obtain();
|
Parcel data = Parcel.obtain();
|
||||||
Parcel reply = Parcel.obtain();
|
Parcel reply = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
data.writeInterfaceToken(IBulkCursor.descriptor);
|
||||||
|
data.writeBundle(extras);
|
||||||
|
|
||||||
data.writeInterfaceToken(IBulkCursor.descriptor);
|
mRemote.transact(RESPOND_TRANSACTION, data, reply, 0);
|
||||||
|
DatabaseUtils.readExceptionFromParcel(reply);
|
||||||
|
|
||||||
data.writeBundle(extras);
|
Bundle returnExtras = reply.readBundle();
|
||||||
|
return returnExtras;
|
||||||
mRemote.transact(RESPOND_TRANSACTION, data, reply, 0);
|
} finally {
|
||||||
|
data.recycle();
|
||||||
DatabaseUtils.readExceptionFromParcel(reply);
|
reply.recycle();
|
||||||
|
}
|
||||||
Bundle returnExtras = reply.readBundle();
|
|
||||||
data.recycle();
|
|
||||||
reply.recycle();
|
|
||||||
return returnExtras;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user