本文整理汇总了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);
}