当前位置: 首页>>代码示例>>Java>>正文


Java Binder.restoreCallingIdentity方法代码示例

本文整理汇总了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;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:26,代码来源:NonMediaDocumentsProvider.java

示例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;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:23,代码来源:DownloadStorageProvider.java

示例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;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:24,代码来源:DownloadStorageProvider.java

示例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);
}
 
开发者ID:ansh94,项目名称:DailyTech,代码行数:22,代码来源:ArticleWidgetRemoteViewsFactory.java

示例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);
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:17,代码来源:AppsProvider.java

示例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);
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:13,代码来源:MediaDocumentsProvider.java

示例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);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:10,代码来源:FakeIdentityBinder.java

示例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);
    }
}
 
开发者ID:redleaf2002,项目名称:downloadmanager,代码行数:10,代码来源:DownloadProvider.java

示例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;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:34,代码来源:DownloadStorageProvider.java

示例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);
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:13,代码来源:DownloadStorageProvider.java

示例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);
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:13,代码来源:WidgetService.java

示例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);
    }
}
 
开发者ID:codehz,项目名称:container,代码行数:14,代码来源:VClientImpl.java

示例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);
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:14,代码来源:AppsProvider.java

示例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;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:35,代码来源:MediaDocumentsProvider.java

示例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);
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:14,代码来源:MediaDocumentsProvider.java


注:本文中的android.os.Binder.restoreCallingIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。