本文整理汇总了Java中android.os.Binder.restoreCallingIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java Binder.restoreCallingIdentity方法的具体用法?Java Binder.restoreCallingIdentity怎么用?Java Binder.restoreCallingIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Binder
的用法示例。
在下文中一共展示了Binder.restoreCallingIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryChildDocuments
import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryChildDocuments(String docId, String[] projection, String sortOrder)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final Ident ident = getIdentForDocId(docId);
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
if (TYPE_DOCUMENT_ROOT.equals(ident.type)) {
queryFile(resolver, cursor, result, DOCUMENT_MIMES, "text");
} else if (TYPE_ARCHIVE_ROOT.equals(ident.type)) {
queryFile(resolver, cursor, result, ARCHIVE_MIMES);
} else if (TYPE_APK_ROOT.equals(ident.type)) {
queryFile(resolver, cursor, result, APK_MIMES);
} else {
throw new UnsupportedOperationException("Unsupported document " + docId);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
示例2: queryChildDocumentsForManage
import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryChildDocumentsForManage(
String parentDocumentId, String[] projection, String sortOrder)
throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
cursor = mDm.query(
new DownloadManager.Query());//.setOnlyIncludeVisibleInDownloadsUi(true));
//copyNotificationUri(result, cursor);
while (cursor.moveToNext()) {
includeDownloadFromCursor(result, cursor);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
示例3: queryDocument
import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
if (DOC_ID_ROOT.equals(docId)) {
includeDefaultDocument(result);
} else {
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
cursor = mDm.query(new Query().setFilterById(Long.parseLong(docId)));
//copyNotificationUri(result, cursor);
if (cursor.moveToFirst()) {
includeDownloadFromCursor(result, cursor);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
}
return result;
}
示例4: onDataSetChanged
import android.os.Binder; //导入方法依赖的package包/类
@Override
public void onDataSetChanged() {
if (data != null) {
data.close();
}
// This method is called by the app hosting the widget (e.g., the launcher)
// However, our ContentProvider is not exported so it doesn't have access to the
// data. Therefore we need to clear (and finally restore) the calling identity so
// that calls use our process and permission
final long identityToken = Binder.clearCallingIdentity();
data = mContext.getContentResolver().query(ArticleContract.ArticleEntry.CONTENT_URI,
null,
null,
null,
null);
Binder.restoreCallingIdentity(identityToken);
}
示例5: deleteDocument
import android.os.Binder; //导入方法依赖的package包/类
@Override
public void deleteDocument(String docId) throws FileNotFoundException {
final String packageName = getPackageForDocId(docId);
final long token = Binder.clearCallingIdentity();
try {
if (docId.startsWith(ROOT_ID_USER_APP)) {
PackageManagerUtils.uninstallApp(getContext(), packageName);
}
else if(docId.startsWith(ROOT_ID_PROCESS)) {
activityManager.killBackgroundProcesses(getPackageForDocId(docId));
}
notifyDocumentsChanged(docId);
} finally {
Binder.restoreCallingIdentity(token);
}
}
示例6: deleteDocument
import android.os.Binder; //导入方法依赖的package包/类
@Override
public void deleteDocument(String docId) throws FileNotFoundException {
final Uri target = getUriForDocumentId(docId);
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
try {
getContext().getContentResolver().delete(target, null, null);
} finally {
Binder.restoreCallingIdentity(token);
}
}
示例7: onTransact
import android.os.Binder; //导入方法依赖的package包/类
public final boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
long clearCallingIdentity = Binder.clearCallingIdentity();
try {
Binder.restoreCallingIdentity(getFakeIdentity());
return mBase.transact(code, data, reply, flags);
} finally {
Binder.restoreCallingIdentity(clearCallingIdentity);
}
}
示例8: queryCleared
import android.os.Binder; //导入方法依赖的package包/类
private Cursor queryCleared(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sort) {
final long token = Binder.clearCallingIdentity();
try {
return query(uri, projection, selection, selectionArgs, sort);
} finally {
Binder.restoreCallingIdentity(token);
}
}
示例9: queryRecentDocuments
import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryRecentDocuments(String rootId, String[] projection)
throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
cursor = mDm.query(new DownloadManager.Query()//.setOnlyIncludeVisibleInDownloadsUi(true)
.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL));
//copyNotificationUri(result, cursor);
while (cursor.moveToNext() && result.getCount() < 12) {
final String mimeType = cursor.getString(
cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIA_TYPE));
final String uri = cursor.getString(
cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_MEDIAPROVIDER_URI));
// Skip images that have been inserted into the MediaStore so we
// don't duplicate them in the recents list.
if (mimeType == null
|| (mimeType.startsWith("image/") && !TextUtils.isEmpty(uri))) {
continue;
}
includeDownloadFromCursor(result, cursor);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
示例10: deleteDocument
import android.os.Binder; //导入方法依赖的package包/类
@Override
public void deleteDocument(String docId) throws FileNotFoundException {
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
try {
if (mDm.remove(Long.parseLong(docId)) != 1) {
throw new IllegalStateException("Failed to delete " + docId);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
示例11: onDataSetChanged
import android.os.Binder; //导入方法依赖的package包/类
@Override
public void onDataSetChanged() {
Log.e(TAG, "onDataSetChanged: ");
if (mCursor != null) {
mCursor.close();
}
final long identityToken = Binder.clearCallingIdentity();
mCursor = mContext.getContentResolver()
.query(ArticleContract.ArticleEntry.CONTENT_URI, null, null, null, null);
Binder.restoreCallingIdentity(identityToken);
}
示例12: installContentProviders
import android.os.Binder; //导入方法依赖的package包/类
private void installContentProviders(Context app, List<ProviderInfo> providers) {
long origId = Binder.clearCallingIdentity();
Object mainThread = VirtualCore.mainThread();
try {
for (ProviderInfo cpi : providers) {
if (cpi.enabled) {
ActivityThread.installProvider(mainThread, app, cpi, null);
}
}
} finally {
Binder.restoreCallingIdentity(origId);
}
}
示例13: openDocument
import android.os.Binder; //导入方法依赖的package包/类
@Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
throws FileNotFoundException {
// Delegate to real provider
final long token = Binder.clearCallingIdentity();
try {
//final long id = Long.parseLong(docId);
//final ContentResolver resolver = getContext().getContentResolver();
return null;//resolver.openFileDescriptor(mDm.getUriForDownloadedFile(id), mode);
} finally {
Binder.restoreCallingIdentity(token);
}
}
示例14: queryRecentDocuments
import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryRecentDocuments(String rootId, String[] projection)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
if (TYPE_IMAGES_ROOT.equals(rootId)) {
// include all unique buckets
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
ImageQuery.PROJECTION, null, null, ImageColumns.DATE_MODIFIED + " DESC");
copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext() && result.getCount() < 64) {
includeImage(result, cursor);
}
} else if (TYPE_VIDEOS_ROOT.equals(rootId)) {
// include all unique buckets
cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
VideoQuery.PROJECTION, null, null, VideoColumns.DATE_MODIFIED + " DESC");
copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
while (cursor.moveToNext() && result.getCount() < 64) {
includeVideo(result, cursor);
}
} else {
throw new UnsupportedOperationException("Unsupported root " + rootId);
}
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
return result;
}
示例15: isEmpty
import android.os.Binder; //导入方法依赖的package包/类
private boolean isEmpty(Uri uri) {
final ContentResolver resolver = getContext().getContentResolver();
final long token = Binder.clearCallingIdentity();
Cursor cursor = null;
try {
cursor = resolver.query(uri, new String[] {
BaseColumns._ID }, null, null, null);
return (cursor == null) || (cursor.getCount() == 0);
} finally {
IoUtils.closeQuietly(cursor);
Binder.restoreCallingIdentity(token);
}
}