當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.checkCallingOrSelfUriPermission方法代碼示例

本文整理匯總了Java中android.content.Context.checkCallingOrSelfUriPermission方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.checkCallingOrSelfUriPermission方法的具體用法?Java Context.checkCallingOrSelfUriPermission怎麽用?Java Context.checkCallingOrSelfUriPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Context的用法示例。


在下文中一共展示了Context.checkCallingOrSelfUriPermission方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCallingOrSelfUriPermissionModeFlags

import android.content.Context; //導入方法依賴的package包/類
private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) {
    // TODO: move this to a direct AMS call
    int modeFlags = 0;
    if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
            == PackageManager.PERMISSION_GRANTED) {
        modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION;
    }
    if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
            == PackageManager.PERMISSION_GRANTED) {
        modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
    }
    if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION
            | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
            == PackageManager.PERMISSION_GRANTED) {
        modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION;
    }
    return modeFlags;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:19,代碼來源:DocumentsProvider.java

示例2: getCallingOrSelfUriPermissionModeFlags

import android.content.Context; //導入方法依賴的package包/類
private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) {
    // TODO: move this to a direct AMS call
    int modeFlags = 0;
    if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
            == PackageManager.PERMISSION_GRANTED) {
        modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION;
    }
    if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
            == PackageManager.PERMISSION_GRANTED) {
        modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
    }
    if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION
            | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
            == PackageManager.PERMISSION_GRANTED) {
        modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION;
    }
    return modeFlags;
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:19,代碼來源:DocumentsProvider.java

示例3: canWrite

import android.content.Context; //導入方法依賴的package包/類
public static boolean canWrite(Context context, Uri self) {
    if (context.checkCallingOrSelfUriPermission(self, 2) != 0) {
        return false;
    }
    String type = getRawType(context, self);
    int flags = queryForInt(context, self, "flags", 0);
    if (TextUtils.isEmpty(type)) {
        return false;
    }
    if ((flags & 4) != 0) {
        return true;
    }
    if ("vnd.android.document/directory".equals(type) && (flags & 8) != 0) {
        return true;
    }
    if (TextUtils.isEmpty(type) || (flags & 2) == 0) {
        return false;
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:DocumentsContractApi19.java

示例4: canRead

import android.content.Context; //導入方法依賴的package包/類
public static boolean canRead(Context context, Uri self) {
    // Ignore if grant doesn't allow read
    if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_READ_URI_PERMISSION)
            != PackageManager.PERMISSION_GRANTED) {
        return false;
    }

    // Ignore documents without MIME
    if (TextUtils.isEmpty(getRawType(context, self))) {
        return false;
    }

    return true;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:15,代碼來源:DocumentsContractCompat.java

示例5: canWrite

import android.content.Context; //導入方法依賴的package包/類
public static boolean canWrite(Context context, Uri self) {
    // Ignore if grant doesn't allow write
    if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
            != PackageManager.PERMISSION_GRANTED) {
        return false;
    }

    final String type = getRawType(context, self);
    final int flags = queryForInt(context, self, DocumentsContract.Document.COLUMN_FLAGS, 0);

    // Ignore documents without MIME
    if (TextUtils.isEmpty(type)) {
        return false;
    }

    // Deletable documents considered writable
    if ((flags & DocumentsContract.Document.FLAG_SUPPORTS_DELETE) != 0) {
        return true;
    }

    if (DocumentsContract.Document.MIME_TYPE_DIR.equals(type)
            && (flags & DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE) != 0) {
        // Directories that allow create considered writable
        return true;
    } else if (!TextUtils.isEmpty(type)
            && (flags & DocumentsContract.Document.FLAG_SUPPORTS_WRITE) != 0) {
        // Writable normal files considered writable
        return true;
    }

    return false;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:33,代碼來源:DocumentsContractCompat.java

示例6: canRead

import android.content.Context; //導入方法依賴的package包/類
public static boolean canRead(Context context, Uri self) {
    if (context.checkCallingOrSelfUriPermission(self, 1) == 0 && !TextUtils.isEmpty(getRawType(context, self))) {
        return true;
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:DocumentsContractApi19.java


注:本文中的android.content.Context.checkCallingOrSelfUriPermission方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。