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


Java SanitizedFile.setReadable方法代碼示例

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


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

示例1: getSafeUri

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
private static Uri getSafeUri(Context context, SanitizedFile tempApkFile, boolean useContentUri) {
    if (useContentUri) {
        // return a content Uri using support libs FileProvider
        Uri apkUri = getUriForFile(context, AUTHORITY, tempApkFile);
        context.grantUriPermission("org.fdroid.fdroid.privileged", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
        context.grantUriPermission("com.android.bluetooth", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
        return apkUri;
    }

    // Need the apk to be world readable, so that the installer is able to read it.
    // Note that saving it into external storage for the purpose of letting the installer
    // have access is insecure, because apps with permission to write to the external
    // storage can overwrite the app between F-Droid asking for it to be installed and
    // the installer actually installing it.
    tempApkFile.setReadable(true, false);

    return Uri.fromFile(tempApkFile);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:19,代碼來源:ApkFileProvider.java

示例2: setReadable

import org.fdroid.fdroid.data.SanitizedFile; //導入方法依賴的package包/類
@TargetApi(9)
public static boolean setReadable(SanitizedFile file, boolean readable, boolean ownerOnly) {

    if (Build.VERSION.SDK_INT >= 9) {
        return file.setReadable(readable, ownerOnly);
    }
    String mode;
    if (readable) {
        mode = ownerOnly ? "0600" : "0644";
    } else {
        mode = "0000";
    }
    return setMode(file, mode);

}
 
開發者ID:CmDnoEdition,項目名稱:fdroid,代碼行數:16,代碼來源:FileCompat.java


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