List of usage examples for android.os Binder restoreCallingIdentity
public static final native void restoreCallingIdentity(long token);
From source file:com.skubit.android.billing.BillingServiceBinder.java
private boolean hasAccess(String userId, String packageName) { final long token = Binder.clearCallingIdentity(); Cursor c = null;//from w ww. j a v a 2s . com try { c = mContext.getContentResolver().query(AuthorizationColumns.CONTENT_URI, null, AuthorizationColumns.APP + "=? AND " + AuthorizationColumns.BITID + "=?", new String[] { packageName, userId }, null); if (c == null) { return false; } AuthorizationCursor ac = new AuthorizationCursor(c); ac.moveToFirst(); if (ac.getCount() == 0) { return false; } String scope = ac.getScope(); if (TextUtils.isEmpty(scope)) { return false; } return hasScope(scope, Permissions.PURCHASES) || hasScope(scope, Permissions.MANAGE_MONEY); } finally { if (c != null) { c.close(); } Binder.restoreCallingIdentity(token); } }
From source file:com.skubit.android.billing.BillingServiceBinder.java
@Override public Bundle getUserIds(int apiVersion, String packageName) throws RemoteException { Bundle bundle = new Bundle(); if (apiVersion != 1) { bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE); return bundle; }/* ww w .j a va 2s.c o m*/ int packValidate = validatePackageIsOwnedByCaller(packageName); if (packValidate != BillingResponseCodes.RESULT_OK) { Log.d(TAG, "Package is not owned by caller: " + packageName); bundle.putInt("RESPONSE_CODE", packValidate); return bundle; } ArrayList<String> userIds = new ArrayList<>(); final long token = Binder.clearCallingIdentity(); try { Cursor c = mContext.getContentResolver().query(AuthorizationColumns.CONTENT_URI, null, AuthorizationColumns.APP + "=?", new String[] { packageName }, null); AuthorizationCursor ac = new AuthorizationCursor(c); ac.moveToFirst(); for (int i = 0; i < ac.getCount(); i++) { ac.moveToPosition(i); userIds.add(ac.getBitid()); } c.close(); } finally { Binder.restoreCallingIdentity(token); } bundle.putStringArrayList("USER_ID_LIST", userIds); return bundle; }
From source file:dev.dworks.apps.anexplorer.provider.ExternalStorageProvider.java
public AssetFileDescriptor openOrCreateDocumentThumbnail(String docId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException { // final ContentResolver resolver = getContext().getContentResolver(); final File file = getFileForDocId(docId); final String mimeType = getTypeForFile(file); final String typeOnly = mimeType.split("/")[0]; final long token = Binder.clearCallingIdentity(); try {//from w ww.j av a 2 s . c o m if (MediaDocumentsProvider.TYPE_AUDIO.equals(typeOnly)) { final long id = getAlbumForPathCleared(file.getPath()); return openOrCreateAudioThumbnailCleared(id, signal); } else if (MediaDocumentsProvider.TYPE_IMAGE.equals(typeOnly)) { final long id = getImageForPathCleared(file.getPath()); return openOrCreateImageThumbnailCleared(id, signal); } else if (MediaDocumentsProvider.TYPE_VIDEO.equals(typeOnly)) { final long id = getVideoForPathCleared(file.getPath()); return openOrCreateVideoThumbnailCleared(id, signal); } else { return DocumentsContract.openImageThumbnail(file); } } finally { Binder.restoreCallingIdentity(token); } }