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


Java Binder.clearCallingIdentity方法代码示例

本文整理汇总了Java中android.os.Binder.clearCallingIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java Binder.clearCallingIdentity方法的具体用法?Java Binder.clearCallingIdentity怎么用?Java Binder.clearCallingIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Binder的用法示例。


在下文中一共展示了Binder.clearCallingIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: query

import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
        throws Exception {
    List<String> segments = uri.getPathSegments();
    int accountId = Integer.parseInt(segments.get(1));

    /*
     * This method below calls Account.getStats() which uses EmailProvider to do its work.
     * For this to work we need to clear the calling identity. Otherwise accessing
     * EmailProvider will fail because it's not exported so third-party apps can't access it
     * directly.
     */
    long identityToken = Binder.clearCallingIdentity();
    try {
        return getAccountUnread(accountId);
    } finally {
        Binder.restoreCallingIdentity(identityToken);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:MessageProvider.java

示例2: openDocument

import android.os.Binder; //导入方法依赖的package包/类
@Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
        throws FileNotFoundException {

    if (!"r".equals(mode)) {
        throw new IllegalArgumentException("Media is read-only");
    }

    final Uri target = getUriForDocumentId(docId);

    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    try {
        return getContext().getContentResolver().openFileDescriptor(target, mode);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:19,代码来源:NonMediaDocumentsProvider.java

示例3: 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:medalionk,项目名称:simple-share-android,代码行数:17,代码来源:AppsProvider.java

示例4: 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_DOCUMENT_ROOT.equals(rootId)) {
            queryRecentFile(resolver, cursor, result, DOCUMENT_MIMES);
        } else {
            throw new UnsupportedOperationException("Unsupported root " + rootId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:21,代码来源:NonMediaDocumentsProvider.java

示例5: 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:kranthi0987,项目名称:easyfilemanager,代码行数:24,代码来源:DownloadStorageProvider.java

示例6: 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

示例7: queryChildDocuments

import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryChildDocuments(String docId, 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 {
    	Query query = new Query();
    	DownloadManagerUtils.setOnlyIncludeVisibleInDownloadsUi(query);
    	//query.setOnlyIncludeVisibleInDownloadsUi(true);
        query.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL);
    	//query.setFilterByStatus(DownloadManager.STATUS_PENDING | DownloadManager.STATUS_PAUSED | DownloadManager.STATUS_RUNNING | DownloadManager.STATUS_FAILED);
        cursor = mDm.query(query);//.setOnlyIncludeVisibleInDownloadsUi(true)
                //.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL));
        //copyNotificationUri(result, cursor);
        while (cursor.moveToNext()) {
            includeDownloadFromCursor(result, cursor);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:27,代码来源:DownloadStorageProvider.java

示例8: isEmpty

import android.os.Binder; //导入方法依赖的package包/类
private boolean isEmpty(Uri uri, String type) {
    final ContentResolver resolver = getContext().getContentResolver();
    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        String[] mimeType;
        if (TYPE_DOCUMENT_ROOT.equals(type)) {
            mimeType = DOCUMENT_MIMES;
        } else if (TYPE_ARCHIVE_ROOT.equals(type)) {
            mimeType = ARCHIVE_MIMES;
        } else if (TYPE_APK_ROOT.equals(type)) {
            mimeType = APK_MIMES;
        } else {
            return true;
        }
        cursor = resolver.query(FILE_URI,
                FileQuery.PROJECTION,
                FileColumns.MIME_TYPE + " IN "+ "("+toString(mimeType)+")" , null, null);
        return (cursor == null) || (cursor.getCount() == 0);
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:25,代码来源:NonMediaDocumentsProvider.java

示例9: 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:kranthi0987,项目名称:easyfilemanager,代码行数:35,代码来源:MediaDocumentsProvider.java

示例10: 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

示例11: finishRemoveUser

import android.os.Binder; //导入方法依赖的package包/类
void finishRemoveUser(final int userHandle) {
    if (DBG) VLog.i(LOG_TAG, "finishRemoveUser " + userHandle);
    // Let other services shutdown any activity and clean up their state before completely
    // wiping the user's system directory and removing from the user list
    long identity = Binder.clearCallingIdentity();
    try {
        Intent addedIntent = new Intent(Constants.ACTION_USER_REMOVED);
        addedIntent.putExtra(Constants.EXTRA_USER_HANDLE, userHandle);
        VActivityManagerService.get().sendOrderedBroadcastAsUser(addedIntent, VUserHandle.ALL,
               null,
                new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        if (DBG) {
                            VLog.i(LOG_TAG,
                                    "USER_REMOVED broadcast sent, cleaning up user data "
                                    + userHandle);
                        }
                        new Thread() {
                            public void run() {
                                synchronized (mInstallLock) {
                                    synchronized (mPackagesLock) {
                                        removeUserStateLocked(userHandle);
                                    }
                                }
                            }
                        }.start();
                    }
                },
                null, Activity.RESULT_OK, null, null);
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:35,代码来源:VUserManagerService.java

示例12: 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

示例13: 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) {
            try {
                ActivityThread.installProvider(mainThread, app, cpi, null);
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    } finally {
        Binder.restoreCallingIdentity(origId);
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:16,代码来源:VClientImpl.java

示例14: 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

示例15: queryDocument

import android.os.Binder; //导入方法依赖的package包/类
@Override
public Cursor queryDocument(String docId, String[] projection) 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)) {
            includeFileRootDocument(result, TYPE_DOCUMENT_ROOT, R.string.root_document);
        } else if (TYPE_DOCUMENT.equals(ident.type)) {
            queryFile(resolver, cursor, result, DOCUMENT_MIMES, "text");
        } else if (TYPE_ARCHIVE_ROOT.equals(ident.type)) {
            includeFileRootDocument(result, TYPE_ARCHIVE_ROOT, R.string.root_archive);
        } else if (TYPE_ARCHIVE.equals(ident.type)) {
            queryFile(resolver, cursor, result, ARCHIVE_MIMES);
        } else if (TYPE_APK_ROOT.equals(ident.type)) {
            includeFileRootDocument(result, TYPE_APK_ROOT, R.string.root_apk);
        } else if (TYPE_APK.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:kranthi0987,项目名称:easyfilemanager,代码行数:32,代码来源:NonMediaDocumentsProvider.java


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