/libraries/Lipland/src/com/qihoo/plugin/core/ContentProviderProxy.java

https://github.com/Qihoo360/Lipland · Java · 288 lines · 188 code · 46 blank · 54 comment · 0 complexity · dff4d1a807ed01a485fd6764490fc61b MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-2017 Qihoo 360 Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * 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, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.qihoo.plugin.core;
  17. import java.io.FileDescriptor;
  18. import java.io.FileNotFoundException;
  19. import java.util.ArrayList;
  20. import android.app.Service;
  21. import android.content.ContentProvider;
  22. import android.content.ContentProviderOperation;
  23. import android.content.ContentProviderResult;
  24. import android.content.ContentValues;
  25. import android.content.IContentProvider;
  26. import android.content.OperationApplicationException;
  27. import android.content.res.AssetFileDescriptor;
  28. import android.database.Cursor;
  29. import android.net.Uri;
  30. import android.os.Bundle;
  31. import android.os.IBinder;
  32. import android.os.IInterface;
  33. import android.os.Parcel;
  34. import android.os.ParcelFileDescriptor;
  35. import android.os.RemoteException;
  36. /**
  37. *
  38. * @author xupengpai
  39. * @date 2015年11月10日 下午3:36:25
  40. */
  41. public class ContentProviderProxy implements IContentProvider {
  42. private String auths;
  43. private ContentProvider contentProvider;
  44. Service service;
  45. public ContentProviderProxy(ContentProvider contentProvider,
  46. String auths) {
  47. this.auths = auths;
  48. this.contentProvider = contentProvider;
  49. }
  50. @Override
  51. public IBinder asBinder() {
  52. // TODO Auto-generated method stub
  53. return new IBinder() {
  54. @Override
  55. public boolean isBinderAlive() {
  56. // TODO Auto-generated method stub
  57. return true;
  58. }
  59. @Override
  60. public String getInterfaceDescriptor() throws RemoteException {
  61. // TODO Auto-generated method stub
  62. return null;
  63. }
  64. @Override
  65. public boolean pingBinder() {
  66. // TODO Auto-generated method stub
  67. return true;
  68. }
  69. @Override
  70. public IInterface queryLocalInterface(String descriptor) {
  71. // TODO Auto-generated method stub
  72. return null;
  73. }
  74. @Override
  75. public void dump(FileDescriptor fd, String[] args)
  76. throws RemoteException {
  77. // TODO Auto-generated method stub
  78. }
  79. @Override
  80. public void dumpAsync(FileDescriptor fd, String[] args)
  81. throws RemoteException {
  82. // TODO Auto-generated method stub
  83. }
  84. @Override
  85. public boolean transact(int code, Parcel data, Parcel reply,
  86. int flags) throws RemoteException {
  87. // TODO Auto-generated method stub
  88. return false;
  89. }
  90. @Override
  91. public void linkToDeath(DeathRecipient recipient, int flags)
  92. throws RemoteException {
  93. // TODO Auto-generated method stub
  94. }
  95. @Override
  96. public boolean unlinkToDeath(DeathRecipient recipient, int flags) {
  97. // TODO Auto-generated method stub
  98. return false;
  99. }
  100. };
  101. }
  102. @Override
  103. public ContentProviderResult[] applyBatch(
  104. ArrayList<ContentProviderOperation> operations)
  105. throws RemoteException, OperationApplicationException {
  106. // TODO Auto-generated method stub
  107. return contentProvider.applyBatch(operations);
  108. }
  109. public ContentProviderResult[] applyBatch(String packageName,
  110. ArrayList<ContentProviderOperation> operations)
  111. throws RemoteException, OperationApplicationException {
  112. // TODO Auto-generated method stub
  113. return contentProvider.applyBatch(operations);
  114. }
  115. @Override
  116. public int bulkInsert(Uri uri, ContentValues[] values)
  117. throws RemoteException {
  118. // TODO Auto-generated method stub
  119. return contentProvider.bulkInsert(uri, values);
  120. }
  121. public int bulkInsert(String packageName,Uri uri, ContentValues[] values)
  122. throws RemoteException {
  123. // TODO Auto-generated method stub
  124. return contentProvider.bulkInsert(uri, values);
  125. }
  126. @Override
  127. public Bundle call(String method, String arg, Bundle extras)
  128. throws RemoteException {
  129. // TODO Auto-generated method stub
  130. return contentProvider.call(method, arg, extras);
  131. }
  132. public Bundle call(String packageName,String method, String arg, Bundle extras)
  133. throws RemoteException {
  134. // TODO Auto-generated method stub
  135. return contentProvider.call(method, arg, extras);
  136. }
  137. @Override
  138. public int delete(Uri uri, String selection, String[] selectionArgs)
  139. throws RemoteException {
  140. // TODO Auto-generated method stub
  141. return contentProvider.delete(uri, selection, selectionArgs);
  142. }
  143. public int delete(String packageName,Uri uri, String selection, String[] selectionArgs)
  144. throws RemoteException {
  145. // TODO Auto-generated method stub
  146. return contentProvider.delete(uri, selection, selectionArgs);
  147. }
  148. @Override
  149. public String[] getStreamTypes(Uri uri, String mimeTypeFilter)
  150. throws RemoteException {
  151. // TODO Auto-generated method stub
  152. return contentProvider.getStreamTypes(uri, mimeTypeFilter);
  153. }
  154. public String[] getStreamTypes(String packageName,Uri uri, String mimeTypeFilter)
  155. throws RemoteException {
  156. // TODO Auto-generated method stub
  157. return contentProvider.getStreamTypes(uri, mimeTypeFilter);
  158. }
  159. @Override
  160. public String getType(Uri uri) throws RemoteException {
  161. // TODO Auto-generated method stub
  162. return contentProvider.getType(uri);
  163. }
  164. public String getType(String packageName,Uri uri) throws RemoteException {
  165. // TODO Auto-generated method stub
  166. return contentProvider.getType(uri);
  167. }
  168. public Uri insert(String packageName,Uri uri, ContentValues values) throws RemoteException {
  169. // TODO Auto-generated method stub
  170. return contentProvider.insert(uri, values);
  171. }
  172. @Override
  173. public Uri insert(Uri uri, ContentValues values) throws RemoteException {
  174. // TODO Auto-generated method stub
  175. return contentProvider.insert(uri, values);
  176. }
  177. public AssetFileDescriptor openAssetFile(String packageName,Uri uri, String mode)
  178. throws RemoteException, FileNotFoundException {
  179. // TODO Auto-generated method stub
  180. return contentProvider.openAssetFile(uri, mode);
  181. }
  182. @Override
  183. public AssetFileDescriptor openAssetFile(Uri uri, String mode)
  184. throws RemoteException, FileNotFoundException {
  185. // TODO Auto-generated method stub
  186. return contentProvider.openAssetFile(uri, mode);
  187. }
  188. @Override
  189. public ParcelFileDescriptor openFile(Uri uri, String mode)
  190. throws RemoteException, FileNotFoundException {
  191. // TODO Auto-generated method stub
  192. return contentProvider.openFile(uri, mode);
  193. }
  194. public ParcelFileDescriptor openFile(String packageName,Uri uri, String mode)
  195. throws RemoteException, FileNotFoundException {
  196. // TODO Auto-generated method stub
  197. return contentProvider.openFile(uri, mode);
  198. }
  199. @Override
  200. public AssetFileDescriptor openTypedAssetFile(Uri uri,
  201. String mimeTypeFilter, Bundle opts) throws RemoteException,
  202. FileNotFoundException {
  203. // TODO Auto-generated method stub
  204. return contentProvider
  205. .openTypedAssetFile(uri, mimeTypeFilter, opts);
  206. }
  207. public AssetFileDescriptor openTypedAssetFile(String packageName,Uri uri,
  208. String mimeTypeFilter, Bundle opts) throws RemoteException,
  209. FileNotFoundException {
  210. // TODO Auto-generated method stub
  211. return contentProvider
  212. .openTypedAssetFile(uri, mimeTypeFilter, opts);
  213. }
  214. @Override
  215. public Cursor query(Uri uri, String[] projection, String selection,
  216. String[] selectionArgs, String sortOrder)
  217. throws RemoteException {
  218. // TODO Auto-generated method stub
  219. return contentProvider.query(uri, projection, selection,
  220. selectionArgs, sortOrder);
  221. }
  222. public Cursor query(String packageName,Uri uri, String[] projection, String selection,
  223. String[] selectionArgs, String sortOrder)
  224. throws RemoteException {
  225. // TODO Auto-generated method stub
  226. return contentProvider.query(uri, projection, selection,
  227. selectionArgs, sortOrder);
  228. }
  229. @Override
  230. public int update(Uri uri, ContentValues values, String selection,
  231. String[] selectionArgs) throws RemoteException {
  232. // TODO Auto-generated method stub
  233. return contentProvider
  234. .update(uri, values, selection, selectionArgs);
  235. }
  236. public int update(String packageName,Uri uri, ContentValues values, String selection,
  237. String[] selectionArgs) throws RemoteException {
  238. // TODO Auto-generated method stub
  239. return contentProvider
  240. .update(uri, values, selection, selectionArgs);
  241. }
  242. }