/DVC-AN20_EMUI10.1.1/src/main/java/android/content/ContentProviderProxy.java

https://github.com/dstmath/HWFramework · Java · 379 lines · 357 code · 20 blank · 2 comment · 22 complexity · aa7350eb81e9fd0ae0f0d760372f7582 MD5 · raw file

  1. package android.content;
  2. import android.annotation.UnsupportedAppUsage;
  3. import android.content.res.AssetFileDescriptor;
  4. import android.database.BulkCursorDescriptor;
  5. import android.database.BulkCursorToCursorAdaptor;
  6. import android.database.Cursor;
  7. import android.database.DatabaseUtils;
  8. import android.net.Uri;
  9. import android.os.Binder;
  10. import android.os.Bundle;
  11. import android.os.IBinder;
  12. import android.os.ICancellationSignal;
  13. import android.os.Parcel;
  14. import android.os.ParcelFileDescriptor;
  15. import android.os.RemoteException;
  16. import java.io.FileNotFoundException;
  17. import java.util.ArrayList;
  18. import java.util.Iterator;
  19. /* access modifiers changed from: package-private */
  20. /* compiled from: ContentProviderNative */
  21. public final class ContentProviderProxy implements IContentProvider {
  22. @UnsupportedAppUsage
  23. private IBinder mRemote;
  24. public ContentProviderProxy(IBinder remote) {
  25. this.mRemote = remote;
  26. }
  27. @Override // android.os.IInterface
  28. public IBinder asBinder() {
  29. return this.mRemote;
  30. }
  31. @Override // android.content.IContentProvider
  32. public Cursor query(String callingPkg, Uri url, String[] projection, Bundle queryArgs, ICancellationSignal cancellationSignal) throws RemoteException {
  33. BulkCursorToCursorAdaptor adaptor = new BulkCursorToCursorAdaptor();
  34. Parcel data = Parcel.obtain();
  35. Parcel reply = Parcel.obtain();
  36. try {
  37. data.writeInterfaceToken(IContentProvider.descriptor);
  38. data.writeString(callingPkg);
  39. url.writeToParcel(data, 0);
  40. int length = 0;
  41. if (projection != null) {
  42. length = projection.length;
  43. }
  44. data.writeInt(length);
  45. for (int i = 0; i < length; i++) {
  46. data.writeString(projection[i]);
  47. }
  48. data.writeBundle(queryArgs);
  49. data.writeStrongBinder(adaptor.getObserver().asBinder());
  50. IBinder iBinder = null;
  51. data.writeStrongBinder(cancellationSignal != null ? cancellationSignal.asBinder() : null);
  52. this.mRemote.transact(1, data, reply, 0);
  53. DatabaseUtils.readExceptionFromParcel(reply);
  54. if (reply.readInt() != 0) {
  55. BulkCursorDescriptor d = BulkCursorDescriptor.CREATOR.createFromParcel(reply);
  56. IBinder iBinder2 = this.mRemote;
  57. if (d.cursor != null) {
  58. iBinder = d.cursor.asBinder();
  59. }
  60. Binder.copyAllowBlocking(iBinder2, iBinder);
  61. adaptor.initialize(d);
  62. } else {
  63. adaptor.close();
  64. adaptor = null;
  65. }
  66. data.recycle();
  67. reply.recycle();
  68. return adaptor;
  69. } catch (RemoteException ex) {
  70. adaptor.close();
  71. throw ex;
  72. } catch (RuntimeException ex2) {
  73. adaptor.close();
  74. throw ex2;
  75. } catch (Throwable th) {
  76. data.recycle();
  77. reply.recycle();
  78. throw th;
  79. }
  80. }
  81. @Override // android.content.IContentProvider
  82. public String getType(Uri url) throws RemoteException {
  83. Parcel data = Parcel.obtain();
  84. Parcel reply = Parcel.obtain();
  85. try {
  86. data.writeInterfaceToken(IContentProvider.descriptor);
  87. url.writeToParcel(data, 0);
  88. this.mRemote.transact(2, data, reply, 0);
  89. DatabaseUtils.readExceptionFromParcel(reply);
  90. return reply.readString();
  91. } finally {
  92. data.recycle();
  93. reply.recycle();
  94. }
  95. }
  96. @Override // android.content.IContentProvider
  97. public Uri insert(String callingPkg, Uri url, ContentValues values) throws RemoteException {
  98. Parcel data = Parcel.obtain();
  99. Parcel reply = Parcel.obtain();
  100. try {
  101. data.writeInterfaceToken(IContentProvider.descriptor);
  102. data.writeString(callingPkg);
  103. url.writeToParcel(data, 0);
  104. values.writeToParcel(data, 0);
  105. this.mRemote.transact(3, data, reply, 0);
  106. DatabaseUtils.readExceptionFromParcel(reply);
  107. return Uri.CREATOR.createFromParcel(reply);
  108. } finally {
  109. data.recycle();
  110. reply.recycle();
  111. }
  112. }
  113. @Override // android.content.IContentProvider
  114. public int bulkInsert(String callingPkg, Uri url, ContentValues[] values) throws RemoteException {
  115. Parcel data = Parcel.obtain();
  116. Parcel reply = Parcel.obtain();
  117. try {
  118. data.writeInterfaceToken(IContentProvider.descriptor);
  119. data.writeString(callingPkg);
  120. url.writeToParcel(data, 0);
  121. data.writeTypedArray(values, 0);
  122. this.mRemote.transact(13, data, reply, 0);
  123. DatabaseUtils.readExceptionFromParcel(reply);
  124. return reply.readInt();
  125. } finally {
  126. data.recycle();
  127. reply.recycle();
  128. }
  129. }
  130. @Override // android.content.IContentProvider
  131. public ContentProviderResult[] applyBatch(String callingPkg, String authority, ArrayList<ContentProviderOperation> operations) throws RemoteException, OperationApplicationException {
  132. Parcel data = Parcel.obtain();
  133. Parcel reply = Parcel.obtain();
  134. try {
  135. data.writeInterfaceToken(IContentProvider.descriptor);
  136. data.writeString(callingPkg);
  137. data.writeString(authority);
  138. data.writeInt(operations.size());
  139. Iterator<ContentProviderOperation> it = operations.iterator();
  140. while (it.hasNext()) {
  141. it.next().writeToParcel(data, 0);
  142. }
  143. this.mRemote.transact(20, data, reply, 0);
  144. DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(reply);
  145. return (ContentProviderResult[]) reply.createTypedArray(ContentProviderResult.CREATOR);
  146. } finally {
  147. data.recycle();
  148. reply.recycle();
  149. }
  150. }
  151. @Override // android.content.IContentProvider
  152. public int delete(String callingPkg, Uri url, String selection, String[] selectionArgs) throws RemoteException {
  153. Parcel data = Parcel.obtain();
  154. Parcel reply = Parcel.obtain();
  155. try {
  156. data.writeInterfaceToken(IContentProvider.descriptor);
  157. data.writeString(callingPkg);
  158. url.writeToParcel(data, 0);
  159. data.writeString(selection);
  160. data.writeStringArray(selectionArgs);
  161. this.mRemote.transact(4, data, reply, 0);
  162. DatabaseUtils.readExceptionFromParcel(reply);
  163. return reply.readInt();
  164. } finally {
  165. data.recycle();
  166. reply.recycle();
  167. }
  168. }
  169. @Override // android.content.IContentProvider
  170. public int update(String callingPkg, Uri url, ContentValues values, String selection, String[] selectionArgs) throws RemoteException {
  171. Parcel data = Parcel.obtain();
  172. Parcel reply = Parcel.obtain();
  173. try {
  174. data.writeInterfaceToken(IContentProvider.descriptor);
  175. data.writeString(callingPkg);
  176. url.writeToParcel(data, 0);
  177. values.writeToParcel(data, 0);
  178. data.writeString(selection);
  179. data.writeStringArray(selectionArgs);
  180. this.mRemote.transact(10, data, reply, 0);
  181. DatabaseUtils.readExceptionFromParcel(reply);
  182. return reply.readInt();
  183. } finally {
  184. data.recycle();
  185. reply.recycle();
  186. }
  187. }
  188. @Override // android.content.IContentProvider
  189. public ParcelFileDescriptor openFile(String callingPkg, Uri url, String mode, ICancellationSignal signal, IBinder token) throws RemoteException, FileNotFoundException {
  190. Parcel data = Parcel.obtain();
  191. Parcel reply = Parcel.obtain();
  192. try {
  193. data.writeInterfaceToken(IContentProvider.descriptor);
  194. data.writeString(callingPkg);
  195. url.writeToParcel(data, 0);
  196. data.writeString(mode);
  197. ParcelFileDescriptor fd = null;
  198. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  199. data.writeStrongBinder(token);
  200. this.mRemote.transact(14, data, reply, 0);
  201. DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
  202. if (reply.readInt() != 0) {
  203. fd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
  204. }
  205. return fd;
  206. } finally {
  207. data.recycle();
  208. reply.recycle();
  209. }
  210. }
  211. @Override // android.content.IContentProvider
  212. public AssetFileDescriptor openAssetFile(String callingPkg, Uri url, String mode, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
  213. Parcel data = Parcel.obtain();
  214. Parcel reply = Parcel.obtain();
  215. try {
  216. data.writeInterfaceToken(IContentProvider.descriptor);
  217. data.writeString(callingPkg);
  218. url.writeToParcel(data, 0);
  219. data.writeString(mode);
  220. AssetFileDescriptor fd = null;
  221. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  222. this.mRemote.transact(15, data, reply, 0);
  223. DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
  224. if (reply.readInt() != 0) {
  225. fd = AssetFileDescriptor.CREATOR.createFromParcel(reply);
  226. }
  227. return fd;
  228. } finally {
  229. data.recycle();
  230. reply.recycle();
  231. }
  232. }
  233. @Override // android.content.IContentProvider
  234. public Bundle call(String callingPkg, String authority, String method, String request, Bundle args) throws RemoteException {
  235. Parcel data = Parcel.obtain();
  236. Parcel reply = Parcel.obtain();
  237. try {
  238. data.writeInterfaceToken(IContentProvider.descriptor);
  239. data.writeString(callingPkg);
  240. data.writeString(authority);
  241. data.writeString(method);
  242. data.writeString(request);
  243. data.writeBundle(args);
  244. this.mRemote.transact(21, data, reply, 0);
  245. DatabaseUtils.readExceptionFromParcel(reply);
  246. return reply.readBundle();
  247. } finally {
  248. data.recycle();
  249. reply.recycle();
  250. }
  251. }
  252. @Override // android.content.IContentProvider
  253. public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
  254. Parcel data = Parcel.obtain();
  255. Parcel reply = Parcel.obtain();
  256. try {
  257. data.writeInterfaceToken(IContentProvider.descriptor);
  258. url.writeToParcel(data, 0);
  259. data.writeString(mimeTypeFilter);
  260. this.mRemote.transact(22, data, reply, 0);
  261. DatabaseUtils.readExceptionFromParcel(reply);
  262. return reply.createStringArray();
  263. } finally {
  264. data.recycle();
  265. reply.recycle();
  266. }
  267. }
  268. @Override // android.content.IContentProvider
  269. public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri url, String mimeType, Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
  270. Parcel data = Parcel.obtain();
  271. Parcel reply = Parcel.obtain();
  272. try {
  273. data.writeInterfaceToken(IContentProvider.descriptor);
  274. data.writeString(callingPkg);
  275. url.writeToParcel(data, 0);
  276. data.writeString(mimeType);
  277. data.writeBundle(opts);
  278. AssetFileDescriptor fd = null;
  279. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  280. this.mRemote.transact(23, data, reply, 0);
  281. DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
  282. if (reply.readInt() != 0) {
  283. fd = AssetFileDescriptor.CREATOR.createFromParcel(reply);
  284. }
  285. return fd;
  286. } finally {
  287. data.recycle();
  288. reply.recycle();
  289. }
  290. }
  291. @Override // android.content.IContentProvider
  292. public ICancellationSignal createCancellationSignal() throws RemoteException {
  293. Parcel data = Parcel.obtain();
  294. Parcel reply = Parcel.obtain();
  295. try {
  296. data.writeInterfaceToken(IContentProvider.descriptor);
  297. this.mRemote.transact(24, data, reply, 0);
  298. DatabaseUtils.readExceptionFromParcel(reply);
  299. return ICancellationSignal.Stub.asInterface(reply.readStrongBinder());
  300. } finally {
  301. data.recycle();
  302. reply.recycle();
  303. }
  304. }
  305. @Override // android.content.IContentProvider
  306. public Uri canonicalize(String callingPkg, Uri url) throws RemoteException {
  307. Parcel data = Parcel.obtain();
  308. Parcel reply = Parcel.obtain();
  309. try {
  310. data.writeInterfaceToken(IContentProvider.descriptor);
  311. data.writeString(callingPkg);
  312. url.writeToParcel(data, 0);
  313. this.mRemote.transact(25, data, reply, 0);
  314. DatabaseUtils.readExceptionFromParcel(reply);
  315. return Uri.CREATOR.createFromParcel(reply);
  316. } finally {
  317. data.recycle();
  318. reply.recycle();
  319. }
  320. }
  321. @Override // android.content.IContentProvider
  322. public Uri uncanonicalize(String callingPkg, Uri url) throws RemoteException {
  323. Parcel data = Parcel.obtain();
  324. Parcel reply = Parcel.obtain();
  325. try {
  326. data.writeInterfaceToken(IContentProvider.descriptor);
  327. data.writeString(callingPkg);
  328. url.writeToParcel(data, 0);
  329. this.mRemote.transact(26, data, reply, 0);
  330. DatabaseUtils.readExceptionFromParcel(reply);
  331. return Uri.CREATOR.createFromParcel(reply);
  332. } finally {
  333. data.recycle();
  334. reply.recycle();
  335. }
  336. }
  337. @Override // android.content.IContentProvider
  338. public boolean refresh(String callingPkg, Uri url, Bundle args, ICancellationSignal signal) throws RemoteException {
  339. Parcel data = Parcel.obtain();
  340. Parcel reply = Parcel.obtain();
  341. try {
  342. data.writeInterfaceToken(IContentProvider.descriptor);
  343. data.writeString(callingPkg);
  344. boolean z = false;
  345. url.writeToParcel(data, 0);
  346. data.writeBundle(args);
  347. data.writeStrongBinder(signal != null ? signal.asBinder() : null);
  348. this.mRemote.transact(27, data, reply, 0);
  349. DatabaseUtils.readExceptionFromParcel(reply);
  350. if (reply.readInt() == 0) {
  351. z = true;
  352. }
  353. return z;
  354. } finally {
  355. data.recycle();
  356. reply.recycle();
  357. }
  358. }
  359. }