/Honor5C-7.0/src/main/java/android/content/ContentProviderProxy.java

https://github.com/dstmath/HWFramework · Java · 361 lines · 341 code · 19 blank · 1 comment · 23 complexity · bc5432fa2f99446445ba1546bffbb149 MD5 · raw file

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