當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。