本文整理匯總了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);
}
示例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);
}