@@ -108,21 +108,22 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
108108 String sortOrder = data .readString ();
109109 IContentObserver observer = IContentObserver .Stub .asInterface (
110110 data .readStrongBinder ());
111- CursorWindow window = CursorWindow .CREATOR .createFromParcel (data );
112111
113112 Cursor cursor = query (url , projection , selection , selectionArgs , sortOrder );
114113 if (cursor != null ) {
115114 CursorToBulkCursorAdaptor adaptor = new CursorToBulkCursorAdaptor (
116- cursor , observer , getProviderName (), window );
115+ cursor , observer , getProviderName ());
117116 final IBinder binder = adaptor .asBinder ();
118117 final int count = adaptor .count ();
119118 final int index = BulkCursorToCursorAdaptor .findRowIdColumnIndex (
120119 adaptor .getColumnNames ());
120+ final boolean wantsAllOnMoveCalls = adaptor .getWantsAllOnMoveCalls ();
121121
122122 reply .writeNoException ();
123123 reply .writeStrongBinder (binder );
124124 reply .writeInt (count );
125125 reply .writeInt (index );
126+ reply .writeInt (wantsAllOnMoveCalls ? 1 : 0 );
126127 } else {
127128 reply .writeNoException ();
128129 reply .writeStrongBinder (null );
@@ -324,67 +325,58 @@ public IBinder asBinder()
324325
325326 public Cursor query (Uri url , String [] projection , String selection ,
326327 String [] selectionArgs , String sortOrder ) throws RemoteException {
327- CursorWindow window = new CursorWindow (false /* window will be used remotely */ );
328+ BulkCursorToCursorAdaptor adaptor = new BulkCursorToCursorAdaptor ();
329+ Parcel data = Parcel .obtain ();
330+ Parcel reply = Parcel .obtain ();
328331 try {
329- BulkCursorToCursorAdaptor adaptor = new BulkCursorToCursorAdaptor ();
330- Parcel data = Parcel .obtain ();
331- Parcel reply = Parcel .obtain ();
332- try {
333- data .writeInterfaceToken (IContentProvider .descriptor );
334-
335- url .writeToParcel (data , 0 );
336- int length = 0 ;
337- if (projection != null ) {
338- length = projection .length ;
339- }
340- data .writeInt (length );
341- for (int i = 0 ; i < length ; i ++) {
342- data .writeString (projection [i ]);
343- }
344- data .writeString (selection );
345- if (selectionArgs != null ) {
346- length = selectionArgs .length ;
347- } else {
348- length = 0 ;
349- }
350- data .writeInt (length );
351- for (int i = 0 ; i < length ; i ++) {
352- data .writeString (selectionArgs [i ]);
353- }
354- data .writeString (sortOrder );
355- data .writeStrongBinder (adaptor .getObserver ().asBinder ());
356- window .writeToParcel (data , 0 );
357-
358- mRemote .transact (IContentProvider .QUERY_TRANSACTION , data , reply , 0 );
359-
360- DatabaseUtils .readExceptionFromParcel (reply );
361-
362- IBulkCursor bulkCursor = BulkCursorNative .asInterface (reply .readStrongBinder ());
363- if (bulkCursor != null ) {
364- int rowCount = reply .readInt ();
365- int idColumnPosition = reply .readInt ();
366- adaptor .initialize (bulkCursor , rowCount , idColumnPosition );
367- } else {
368- adaptor .close ();
369- adaptor = null ;
370- }
371- return adaptor ;
372- } catch (RemoteException ex ) {
373- adaptor .close ();
374- throw ex ;
375- } catch (RuntimeException ex ) {
332+ data .writeInterfaceToken (IContentProvider .descriptor );
333+
334+ url .writeToParcel (data , 0 );
335+ int length = 0 ;
336+ if (projection != null ) {
337+ length = projection .length ;
338+ }
339+ data .writeInt (length );
340+ for (int i = 0 ; i < length ; i ++) {
341+ data .writeString (projection [i ]);
342+ }
343+ data .writeString (selection );
344+ if (selectionArgs != null ) {
345+ length = selectionArgs .length ;
346+ } else {
347+ length = 0 ;
348+ }
349+ data .writeInt (length );
350+ for (int i = 0 ; i < length ; i ++) {
351+ data .writeString (selectionArgs [i ]);
352+ }
353+ data .writeString (sortOrder );
354+ data .writeStrongBinder (adaptor .getObserver ().asBinder ());
355+
356+ mRemote .transact (IContentProvider .QUERY_TRANSACTION , data , reply , 0 );
357+
358+ DatabaseUtils .readExceptionFromParcel (reply );
359+
360+ IBulkCursor bulkCursor = BulkCursorNative .asInterface (reply .readStrongBinder ());
361+ if (bulkCursor != null ) {
362+ int rowCount = reply .readInt ();
363+ int idColumnPosition = reply .readInt ();
364+ boolean wantsAllOnMoveCalls = reply .readInt () != 0 ;
365+ adaptor .initialize (bulkCursor , rowCount , idColumnPosition , wantsAllOnMoveCalls );
366+ } else {
376367 adaptor .close ();
377- throw ex ;
378- } finally {
379- data .recycle ();
380- reply .recycle ();
368+ adaptor = null ;
381369 }
370+ return adaptor ;
371+ } catch (RemoteException ex ) {
372+ adaptor .close ();
373+ throw ex ;
374+ } catch (RuntimeException ex ) {
375+ adaptor .close ();
376+ throw ex ;
382377 } finally {
383- // We close the window now because the cursor adaptor does not
384- // take ownership of the window until the first call to onMove.
385- // The adaptor will obtain a fresh reference to the window when
386- // it is filled.
387- window .close ();
378+ data .recycle ();
379+ reply .recycle ();
388380 }
389381 }
390382
0 commit comments