PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/core/java/android/content/ContentProviderNative.java

https://gitlab.com/AvayKumar/android_frameworks_base
Java | 763 lines | 621 code | 112 blank | 30 comment | 44 complexity | 8bc58c128967867a39a78eec2c26d004 MD5 | raw file
  1. /*
  2. * Copyright (C) 2006 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package android.content;
  17. import android.content.res.AssetFileDescriptor;
  18. import android.database.BulkCursorDescriptor;
  19. import android.database.BulkCursorToCursorAdaptor;
  20. import android.database.Cursor;
  21. import android.database.CursorToBulkCursorAdaptor;
  22. import android.database.DatabaseUtils;
  23. import android.database.IContentObserver;
  24. import android.net.Uri;
  25. import android.os.Binder;
  26. import android.os.Bundle;
  27. import android.os.IBinder;
  28. import android.os.ICancellationSignal;
  29. import android.os.Parcel;
  30. import android.os.ParcelFileDescriptor;
  31. import android.os.Parcelable;
  32. import android.os.RemoteException;
  33. import java.io.FileNotFoundException;
  34. import java.util.ArrayList;
  35. /**
  36. * {@hide}
  37. */
  38. abstract public class ContentProviderNative extends Binder implements IContentProvider {
  39. public ContentProviderNative()
  40. {
  41. attachInterface(this, descriptor);
  42. }
  43. /**
  44. * Cast a Binder object into a content resolver interface, generating
  45. * a proxy if needed.
  46. */
  47. static public IContentProvider asInterface(IBinder obj)
  48. {
  49. if (obj == null) {
  50. return null;
  51. }
  52. IContentProvider in =
  53. (IContentProvider)obj.queryLocalInterface(descriptor);
  54. if (in != null) {
  55. return in;
  56. }
  57. return new ContentProviderProxy(obj);
  58. }
  59. /**
  60. * Gets the name of the content provider.
  61. * Should probably be part of the {@link IContentProvider} interface.
  62. * @return The content provider name.
  63. */
  64. public abstract String getProviderName();
  65. @Override
  66. public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
  67. throws RemoteException {
  68. try {
  69. switch (code) {
  70. case QUERY_TRANSACTION:
  71. {
  72. data.enforceInterface(IContentProvider.descriptor);
  73. String callingPkg = data.readString();
  74. Uri url = Uri.CREATOR.createFromParcel(data);
  75. // String[] projection
  76. int num = data.readInt();
  77. String[] projection = null;
  78. if (num > 0) {
  79. projection = new String[num];
  80. for (int i = 0; i < num; i++) {
  81. projection[i] = data.readString();
  82. }
  83. }
  84. // String selection, String[] selectionArgs...
  85. String selection = data.readString();
  86. num = data.readInt();
  87. String[] selectionArgs = null;
  88. if (num > 0) {
  89. selectionArgs = new String[num];
  90. for (int i = 0; i < num; i++) {
  91. selectionArgs[i] = data.readString();
  92. }
  93. }
  94. String sortOrder = data.readString();
  95. IContentObserver observer = IContentObserver.Stub.asInterface(
  96. data.readStrongBinder());
  97. ICancellationSignal cancellationSignal = ICancellationSignal.Stub.asInterface(
  98. data.readStrongBinder());
  99. Cursor cursor = query(callingPkg, url, projection, selection, selectionArgs,
  100. sortOrder, cancellationSignal);
  101. if (cursor != null) {
  102. CursorToBulkCursorAdaptor adaptor = null;
  103. try {
  104. adaptor = new CursorToBulkCursorAdaptor(cursor, observer,
  105. getProviderName());
  106. cursor = null;
  107. BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor();
  108. adaptor = null;
  109. reply.writeNoException();
  110. reply.writeInt(1);
  111. d.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  112. } finally {
  113. // Close cursor if an exception was thrown while constructing the adaptor.
  114. if (adaptor != null) {
  115. adaptor.close();
  116. }
  117. if (cursor != null) {
  118. cursor.close();
  119. }
  120. }
  121. } else {
  122. reply.writeNoException();
  123. reply.writeInt(0);
  124. }
  125. return true;
  126. }
  127. case GET_TYPE_TRANSACTION:
  128. {
  129. data.enforceInterface(IContentProvider.descriptor);
  130. Uri url = Uri.CREATOR.createFromParcel(data);
  131. String type = getType(url);
  132. reply.writeNoException();
  133. reply.writeString(type);
  134. return true;
  135. }
  136. case INSERT_TRANSACTION:
  137. {
  138. data.enforceInterface(IContentProvider.descriptor);
  139. String callingPkg = data.readString();
  140. Uri url = Uri.CREATOR.createFromParcel(data);
  141. ContentValues values = ContentValues.CREATOR.createFromParcel(data);
  142. Uri out = insert(callingPkg, url, values);
  143. reply.writeNoException();
  144. Uri.writeToParcel(reply, out);
  145. return true;
  146. }
  147. case BULK_INSERT_TRANSACTION:
  148. {
  149. data.enforceInterface(IContentProvider.descriptor);
  150. String callingPkg = data.readString();
  151. Uri url = Uri.CREATOR.createFromParcel(data);
  152. ContentValues[] values = data.createTypedArray(ContentValues.CREATOR);
  153. int count = bulkInsert(callingPkg, url, values);
  154. reply.writeNoException();
  155. reply.writeInt(count);
  156. return true;
  157. }
  158. case APPLY_BATCH_TRANSACTION:
  159. {
  160. data.enforceInterface(IContentProvider.descriptor);
  161. String callingPkg = data.readString();
  162. final int numOperations = data.readInt();
  163. final ArrayList<ContentProviderOperation> operations =
  164. new ArrayList<ContentProviderOperation>(numOperations);
  165. for (int i = 0; i < numOperations; i++) {
  166. operations.add(i, ContentProviderOperation.CREATOR.createFromParcel(data));
  167. }
  168. final ContentProviderResult[] results = applyBatch(callingPkg, operations);
  169. reply.writeNoException();
  170. reply.writeTypedArray(results, 0);
  171. return true;
  172. }
  173. case DELETE_TRANSACTION:
  174. {
  175. data.enforceInterface(IContentProvider.descriptor);
  176. String callingPkg = data.readString();
  177. Uri url = Uri.CREATOR.createFromParcel(data);
  178. String selection = data.readString();
  179. String[] selectionArgs = data.readStringArray();
  180. int count = delete(callingPkg, url, selection, selectionArgs);
  181. reply.writeNoException();
  182. reply.writeInt(count);
  183. return true;
  184. }
  185. case UPDATE_TRANSACTION:
  186. {
  187. data.enforceInterface(IContentProvider.descriptor);
  188. String callingPkg = data.readString();
  189. Uri url = Uri.CREATOR.createFromParcel(data);
  190. ContentValues values = ContentValues.CREATOR.createFromParcel(data);
  191. String selection = data.readString();
  192. String[] selectionArgs = data.readStringArray();
  193. int count = update(callingPkg, url, values, selection, selectionArgs);
  194. reply.writeNoException();
  195. reply.writeInt(count);
  196. return true;
  197. }
  198. case OPEN_FILE_TRANSACTION:
  199. {
  200. data.enforceInterface(IContentProvider.descriptor);
  201. String callingPkg = data.readString();
  202. Uri url = Uri.CREATOR.createFromParcel(data);
  203. String mode = data.readString();
  204. ICancellationSignal signal = ICancellationSignal.Stub.asInterface(
  205. data.readStrongBinder());
  206. IBinder callerToken = data.readStrongBinder();
  207. ParcelFileDescriptor fd;
  208. fd = openFile(callingPkg, url, mode, signal, callerToken);
  209. reply.writeNoException();
  210. if (fd != null) {
  211. reply.writeInt(1);
  212. fd.writeToParcel(reply,
  213. Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  214. } else {
  215. reply.writeInt(0);
  216. }
  217. return true;
  218. }
  219. case OPEN_ASSET_FILE_TRANSACTION:
  220. {
  221. data.enforceInterface(IContentProvider.descriptor);
  222. String callingPkg = data.readString();
  223. Uri url = Uri.CREATOR.createFromParcel(data);
  224. String mode = data.readString();
  225. ICancellationSignal signal = ICancellationSignal.Stub.asInterface(
  226. data.readStrongBinder());
  227. AssetFileDescriptor fd;
  228. fd = openAssetFile(callingPkg, url, mode, signal);
  229. reply.writeNoException();
  230. if (fd != null) {
  231. reply.writeInt(1);
  232. fd.writeToParcel(reply,
  233. Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  234. } else {
  235. reply.writeInt(0);
  236. }
  237. return true;
  238. }
  239. case CALL_TRANSACTION:
  240. {
  241. data.enforceInterface(IContentProvider.descriptor);
  242. String callingPkg = data.readString();
  243. String method = data.readString();
  244. String stringArg = data.readString();
  245. Bundle args = data.readBundle();
  246. Bundle responseBundle = call(callingPkg, method, stringArg, args);
  247. reply.writeNoException();
  248. reply.writeBundle(responseBundle);
  249. return true;
  250. }
  251. case GET_STREAM_TYPES_TRANSACTION:
  252. {
  253. data.enforceInterface(IContentProvider.descriptor);
  254. Uri url = Uri.CREATOR.createFromParcel(data);
  255. String mimeTypeFilter = data.readString();
  256. String[] types = getStreamTypes(url, mimeTypeFilter);
  257. reply.writeNoException();
  258. reply.writeStringArray(types);
  259. return true;
  260. }
  261. case OPEN_TYPED_ASSET_FILE_TRANSACTION:
  262. {
  263. data.enforceInterface(IContentProvider.descriptor);
  264. String callingPkg = data.readString();
  265. Uri url = Uri.CREATOR.createFromParcel(data);
  266. String mimeType = data.readString();
  267. Bundle opts = data.readBundle();
  268. ICancellationSignal signal = ICancellationSignal.Stub.asInterface(
  269. data.readStrongBinder());
  270. AssetFileDescriptor fd;
  271. fd = openTypedAssetFile(callingPkg, url, mimeType, opts, signal);
  272. reply.writeNoException();
  273. if (fd != null) {
  274. reply.writeInt(1);
  275. fd.writeToParcel(reply,
  276. Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  277. } else {
  278. reply.writeInt(0);
  279. }
  280. return true;
  281. }
  282. case CREATE_CANCELATION_SIGNAL_TRANSACTION:
  283. {
  284. data.enforceInterface(IContentProvider.descriptor);
  285. ICancellationSignal cancellationSignal = createCancellationSignal();
  286. reply.writeNoException();
  287. reply.writeStrongBinder(cancellationSignal.asBinder());
  288. return true;
  289. }
  290. case CANONICALIZE_TRANSACTION:
  291. {
  292. data.enforceInterface(IContentProvider.descriptor);
  293. String callingPkg = data.readString();
  294. Uri url = Uri.CREATOR.createFromParcel(data);
  295. Uri out = canonicalize(callingPkg, url);
  296. reply.writeNoException();
  297. Uri.writeToParcel(reply, out);
  298. return true;
  299. }
  300. case UNCANONICALIZE_TRANSACTION:
  301. {
  302. data.enforceInterface(IContentProvider.descriptor);
  303. String callingPkg = data.readString();
  304. Uri url = Uri.CREATOR.createFromParcel(data);
  305. Uri out = uncanonicalize(callingPkg, url);
  306. reply.writeNoException();
  307. Uri.writeToParcel(reply, out);
  308. return true;
  309. }
  310. }
  311. } catch (Exception e) {
  312. DatabaseUtils.writeExceptionToParcel(reply, e);
  313. return true;
  314. }
  315. return super.onTransact(code, data, reply, flags);
  316. }
  317. public IBinder asBinder()
  318. {
  319. return this;
  320. }
  321. }
  322. final class ContentProviderProxy implements IContentProvider
  323. {
  324. public ContentProviderProxy(IBinder remote)
  325. {
  326. mRemote = remote;
  327. }
  328. public IBinder asBinder()
  329. {
  330. return mRemote;
  331. }
  332. public Cursor query(String callingPkg, Uri url, String[] projection, String selection,
  333. String[] selectionArgs, String sortOrder, ICancellationSignal cancellationSignal)
  334. throws RemoteException {
  335. BulkCursorToCursorAdaptor adaptor = new BulkCursorToCursorAdaptor();
  336. Parcel data = Parcel.obtain();
  337. Parcel reply = Parcel.obtain();
  338. try {
  339. data.writeInterfaceToken(IContentProvider.descriptor);
  340. data.writeString(callingPkg);
  341. url.writeToParcel(data, 0);
  342. int length = 0;
  343. if (projection != null) {
  344. length = projection.length;
  345. }
  346. data.writeInt(length);
  347. for (int i = 0; i < length; i++) {
  348. data.writeString(projection[i]);
  349. }
  350. data.writeString(selection);
  351. if (selectionArgs != null) {
  352. length = selectionArgs.length;
  353. } else {
  354. length = 0;
  355. }
  356. data.writeInt(length);
  357. for (int i = 0; i < length; i++) {
  358. data.writeString(selectionArgs[i]);
  359. }
  360. data.writeString(sortOrder);
  361. data.writeStrongBinder(adaptor.getObserver().asBinder());
  362. data.writeStrongBinder(cancellationSignal != null ? cancellationSignal.asBinder() : null);
  363. mRemote.transact(IContentProvider.QUERY_TRANSACTION, data, reply, 0);
  364. DatabaseUtils.readExceptionFromParcel(reply);
  365. if (reply.readInt() != 0) {
  366. BulkCursorDescriptor d = BulkCursorDescriptor.CREATOR.createFromParcel(reply);
  367. adaptor.initialize(d);
  368. } else {
  369. adaptor.close();
  370. adaptor = null;
  371. }
  372. return adaptor;
  373. } catch (RemoteException ex) {
  374. adaptor.close();
  375. throw ex;
  376. } catch (RuntimeException ex) {
  377. adaptor.close();
  378. throw ex;
  379. } finally {
  380. data.recycle();
  381. reply.recycle();
  382. }
  383. }
  384. public String getType(Uri url) throws RemoteException
  385. {
  386. Parcel data = Parcel.obtain();
  387. Parcel reply = Parcel.obtain();
  388. try {
  389. data.writeInterfaceToken(IContentProvider.descriptor);
  390. url.writeToParcel(data, 0);
  391. mRemote.transact(IContentProvider.GET_TYPE_TRANSACTION, data, reply, 0);
  392. DatabaseUtils.readExceptionFromParcel(reply);
  393. String out = reply.readString();
  394. return out;
  395. } finally {
  396. data.recycle();
  397. reply.recycle();
  398. }
  399. }
  400. public Uri insert(String callingPkg, Uri url, ContentValues values) throws RemoteException
  401. {
  402. Parcel data = Parcel.obtain();
  403. Parcel reply = Parcel.obtain();
  404. try {
  405. data.writeInterfaceToken(IContentProvider.descriptor);
  406. data.writeString(callingPkg);
  407. url.writeToParcel(data, 0);
  408. values.writeToParcel(data, 0);
  409. mRemote.transact(IContentProvider.INSERT_TRANSACTION, data, reply, 0);
  410. DatabaseUtils.readExceptionFromParcel(reply);
  411. Uri out = Uri.CREATOR.createFromParcel(reply);
  412. return out;
  413. } finally {
  414. data.recycle();
  415. reply.recycle();
  416. }
  417. }
  418. public int bulkInsert(String callingPkg, Uri url, ContentValues[] values) throws RemoteException {
  419. Parcel data = Parcel.obtain();
  420. Parcel reply = Parcel.obtain();
  421. try {
  422. data.writeInterfaceToken(IContentProvider.descriptor);
  423. data.writeString(callingPkg);
  424. url.writeToParcel(data, 0);
  425. data.writeTypedArray(values, 0);
  426. mRemote.transact(IContentProvider.BULK_INSERT_TRANSACTION, data, reply, 0);
  427. DatabaseUtils.readExceptionFromParcel(reply);
  428. int count = reply.readInt();
  429. return count;
  430. } finally {
  431. data.recycle();
  432. reply.recycle();
  433. }
  434. }
  435. public ContentProviderResult[] applyBatch(String callingPkg,
  436. ArrayList<ContentProviderOperation> operations)
  437. throws RemoteException, OperationApplicationException {
  438. Parcel data = Parcel.obtain();
  439. Parcel reply = Parcel.obtain();
  440. try {
  441. data.writeInterfaceToken(IContentProvider.descriptor);
  442. data.writeString(callingPkg);
  443. data.writeInt(operations.size());
  444. for (ContentProviderOperation operation : operations) {
  445. operation.writeToParcel(data, 0);
  446. }
  447. mRemote.transact(IContentProvider.APPLY_BATCH_TRANSACTION, data, reply, 0);
  448. DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(reply);
  449. final ContentProviderResult[] results =
  450. reply.createTypedArray(ContentProviderResult.CREATOR);
  451. return results;
  452. } finally {
  453. data.recycle();
  454. reply.recycle();
  455. }
  456. }
  457. public int delete(String callingPkg, Uri url, String selection, String[] selectionArgs)
  458. throws RemoteException {
  459. Parcel data = Parcel.obtain();
  460. Parcel reply = Parcel.obtain();
  461. try {
  462. data.writeInterfaceToken(IContentProvider.descriptor);
  463. data.writeString(callingPkg);
  464. url.writeToParcel(data, 0);
  465. data.writeString(selection);
  466. data.writeStringArray(selectionArgs);
  467. mRemote.transact(IContentProvider.DELETE_TRANSACTION, data, reply, 0);
  468. DatabaseUtils.readExceptionFromParcel(reply);
  469. int count = reply.readInt();
  470. return count;
  471. } finally {
  472. data.recycle();
  473. reply.recycle();
  474. }
  475. }
  476. public int update(String callingPkg, Uri url, ContentValues values, String selection,
  477. String[] selectionArgs) throws RemoteException {
  478. Parcel data = Parcel.obtain();
  479. Parcel reply = Parcel.obtain();
  480. try {
  481. data.writeInterfaceToken(IContentProvider.descriptor);
  482. data.writeString(callingPkg);
  483. url.writeToParcel(data, 0);
  484. values.writeToParcel(data, 0);
  485. data.writeString(selection);
  486. data.writeStringArray(selectionArgs);
  487. mRemote.transact(IContentProvider.UPDATE_TRANSACTION, data, reply, 0);
  488. DatabaseUtils.readExceptionFromParcel(reply);
  489. int count = reply.readInt();
  490. return count;
  491. } finally {
  492. data.recycle();
  493. reply.recycle();
  494. }
  495. }
  496. @Override
  497. public ParcelFileDescriptor openFile(
  498. String callingPkg, Uri url, String mode, ICancellationSignal signal, IBinder token)
  499. throws RemoteException, FileNotFoundException {
  500. Parcel data = Parcel.obtain();
  501. Parcel reply = Parcel.obtain();
  502. try {
  503. data.writeInterfaceToken(IContentProvider.descriptor);
  504. data.writeString(callingPkg);
  505. url.writeToParcel(data, 0);
  506. data.writeString(mode);
  507. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  508. data.writeStrongBinder(token);
  509. mRemote.transact(IContentProvider.OPEN_FILE_TRANSACTION, data, reply, 0);
  510. DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
  511. int has = reply.readInt();
  512. ParcelFileDescriptor fd = has != 0 ? reply.readFileDescriptor() : null;
  513. return fd;
  514. } finally {
  515. data.recycle();
  516. reply.recycle();
  517. }
  518. }
  519. @Override
  520. public AssetFileDescriptor openAssetFile(
  521. String callingPkg, Uri url, String mode, ICancellationSignal signal)
  522. throws RemoteException, FileNotFoundException {
  523. Parcel data = Parcel.obtain();
  524. Parcel reply = Parcel.obtain();
  525. try {
  526. data.writeInterfaceToken(IContentProvider.descriptor);
  527. data.writeString(callingPkg);
  528. url.writeToParcel(data, 0);
  529. data.writeString(mode);
  530. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  531. mRemote.transact(IContentProvider.OPEN_ASSET_FILE_TRANSACTION, data, reply, 0);
  532. DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
  533. int has = reply.readInt();
  534. AssetFileDescriptor fd = has != 0
  535. ? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
  536. return fd;
  537. } finally {
  538. data.recycle();
  539. reply.recycle();
  540. }
  541. }
  542. public Bundle call(String callingPkg, String method, String request, Bundle args)
  543. throws RemoteException {
  544. Parcel data = Parcel.obtain();
  545. Parcel reply = Parcel.obtain();
  546. try {
  547. data.writeInterfaceToken(IContentProvider.descriptor);
  548. data.writeString(callingPkg);
  549. data.writeString(method);
  550. data.writeString(request);
  551. data.writeBundle(args);
  552. mRemote.transact(IContentProvider.CALL_TRANSACTION, data, reply, 0);
  553. DatabaseUtils.readExceptionFromParcel(reply);
  554. Bundle bundle = reply.readBundle();
  555. return bundle;
  556. } finally {
  557. data.recycle();
  558. reply.recycle();
  559. }
  560. }
  561. public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException
  562. {
  563. Parcel data = Parcel.obtain();
  564. Parcel reply = Parcel.obtain();
  565. try {
  566. data.writeInterfaceToken(IContentProvider.descriptor);
  567. url.writeToParcel(data, 0);
  568. data.writeString(mimeTypeFilter);
  569. mRemote.transact(IContentProvider.GET_STREAM_TYPES_TRANSACTION, data, reply, 0);
  570. DatabaseUtils.readExceptionFromParcel(reply);
  571. String[] out = reply.createStringArray();
  572. return out;
  573. } finally {
  574. data.recycle();
  575. reply.recycle();
  576. }
  577. }
  578. @Override
  579. public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri url, String mimeType,
  580. Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
  581. Parcel data = Parcel.obtain();
  582. Parcel reply = Parcel.obtain();
  583. try {
  584. data.writeInterfaceToken(IContentProvider.descriptor);
  585. data.writeString(callingPkg);
  586. url.writeToParcel(data, 0);
  587. data.writeString(mimeType);
  588. data.writeBundle(opts);
  589. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  590. mRemote.transact(IContentProvider.OPEN_TYPED_ASSET_FILE_TRANSACTION, data, reply, 0);
  591. DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
  592. int has = reply.readInt();
  593. AssetFileDescriptor fd = has != 0
  594. ? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
  595. return fd;
  596. } finally {
  597. data.recycle();
  598. reply.recycle();
  599. }
  600. }
  601. public ICancellationSignal createCancellationSignal() throws RemoteException {
  602. Parcel data = Parcel.obtain();
  603. Parcel reply = Parcel.obtain();
  604. try {
  605. data.writeInterfaceToken(IContentProvider.descriptor);
  606. mRemote.transact(IContentProvider.CREATE_CANCELATION_SIGNAL_TRANSACTION,
  607. data, reply, 0);
  608. DatabaseUtils.readExceptionFromParcel(reply);
  609. ICancellationSignal cancellationSignal = ICancellationSignal.Stub.asInterface(
  610. reply.readStrongBinder());
  611. return cancellationSignal;
  612. } finally {
  613. data.recycle();
  614. reply.recycle();
  615. }
  616. }
  617. public Uri canonicalize(String callingPkg, Uri url) throws RemoteException
  618. {
  619. Parcel data = Parcel.obtain();
  620. Parcel reply = Parcel.obtain();
  621. try {
  622. data.writeInterfaceToken(IContentProvider.descriptor);
  623. data.writeString(callingPkg);
  624. url.writeToParcel(data, 0);
  625. mRemote.transact(IContentProvider.CANONICALIZE_TRANSACTION, data, reply, 0);
  626. DatabaseUtils.readExceptionFromParcel(reply);
  627. Uri out = Uri.CREATOR.createFromParcel(reply);
  628. return out;
  629. } finally {
  630. data.recycle();
  631. reply.recycle();
  632. }
  633. }
  634. public Uri uncanonicalize(String callingPkg, Uri url) throws RemoteException {
  635. Parcel data = Parcel.obtain();
  636. Parcel reply = Parcel.obtain();
  637. try {
  638. data.writeInterfaceToken(IContentProvider.descriptor);
  639. data.writeString(callingPkg);
  640. url.writeToParcel(data, 0);
  641. mRemote.transact(IContentProvider.UNCANONICALIZE_TRANSACTION, data, reply, 0);
  642. DatabaseUtils.readExceptionFromParcel(reply);
  643. Uri out = Uri.CREATOR.createFromParcel(reply);
  644. return out;
  645. } finally {
  646. data.recycle();
  647. reply.recycle();
  648. }
  649. }
  650. private IBinder mRemote;
  651. }