本文整理汇总了Java中org.fdroid.fdroid.data.SanitizedFile.exists方法的典型用法代码示例。如果您正苦于以下问题:Java SanitizedFile.exists方法的具体用法?Java SanitizedFile.exists怎么用?Java SanitizedFile.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fdroid.fdroid.data.SanitizedFile
的用法示例。
在下文中一共展示了SanitizedFile.exists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: symlink
import org.fdroid.fdroid.data.SanitizedFile; //导入方法依赖的package包/类
public static boolean symlink(SanitizedFile source, SanitizedFile dest) {
if (Build.VERSION.SDK_INT >= 21) {
symlinkOs(source, dest);
} else if (Build.VERSION.SDK_INT >= 15) {
symlinkLibcore(source, dest);
} else {
symlinkRuntime(source, dest);
}
return dest.exists();
}
示例2: copyApkToFiles
import org.fdroid.fdroid.data.SanitizedFile; //导入方法依赖的package包/类
/**
* Copy an APK from {@param apkFile} to our internal files directory for 20 minutes.
*
* @param verifyHash If the file was just downloaded, then you should mark this as true and
* request the file to be verified once it has finished copying. Otherwise,
* if the app was installed from part of the system where it can't be tampered
* with (e.g. installed apks on disk) then
*/
private static SanitizedFile copyApkToFiles(Context context, File apkFile, String destinationName,
boolean verifyHash, String hash, String hashType)
throws IOException {
SanitizedFile sanitizedApkFile = new SanitizedFile(context.getFilesDir(), destinationName);
// Don't think this is necessary, but the docs for FileUtils#copyFile() are not clear
// on whether it overwrites destination files (pretty confident it does, as per the docs
// in FileUtils#copyFileToDirectory() - which delegates to copyFile()).
if (sanitizedApkFile.exists()) {
sanitizedApkFile.delete();
}
FileUtils.copyFile(apkFile, sanitizedApkFile);
// verify copied file's hash with expected hash from Apk class
if (verifyHash && !Hasher.isFileMatchingHash(sanitizedApkFile, hash, hashType)) {
FileUtils.deleteQuietly(apkFile);
throw new IOException(apkFile + " failed to verify!");
}
// 20 minutes the start of the install process, delete the file
final File apkToDelete = sanitizedApkFile;
new Thread() {
@Override
public void run() {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
try {
Thread.sleep(1200000);
} catch (InterruptedException ignored) {
} finally {
FileUtils.deleteQuietly(apkToDelete);
}
}
}.start();
return sanitizedApkFile;
}
示例3: LocalRepoManager
import org.fdroid.fdroid.data.SanitizedFile; //导入方法依赖的package包/类
private LocalRepoManager(Context c) {
context = c.getApplicationContext();
pm = c.getPackageManager();
assetManager = c.getAssets();
fdroidPackageName = c.getPackageName();
webRoot = SanitizedFile.knownSanitized(c.getFilesDir());
/* /fdroid/repo is the standard path for user repos */
fdroidDir = new SanitizedFile(webRoot, "fdroid");
fdroidDirCaps = new SanitizedFile(webRoot, "FDROID");
repoDir = new SanitizedFile(fdroidDir, "repo");
repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO");
iconsDir = new SanitizedFile(repoDir, "icons");
xmlIndexJar = new SanitizedFile(repoDir, "index.jar");
xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");
if (!fdroidDir.exists() && !fdroidDir.mkdir()) {
Log.e(TAG, "Unable to create empty base: " + fdroidDir);
}
if (!repoDir.exists() && !repoDir.mkdir()) {
Log.e(TAG, "Unable to create empty repo: " + repoDir);
}
if (!iconsDir.exists() && !iconsDir.mkdir()) {
Log.e(TAG, "Unable to create icons folder: " + iconsDir);
}
}
示例4: LocalRepoManager
import org.fdroid.fdroid.data.SanitizedFile; //导入方法依赖的package包/类
private LocalRepoManager(Context c) {
context = c.getApplicationContext();
pm = c.getPackageManager();
assetManager = c.getAssets();
fdroidPackageName = c.getPackageName();
webRoot = SanitizedFile.knownSanitized(c.getFilesDir());
/* /fdroid/repo is the standard path for user repos */
fdroidDir = new SanitizedFile(webRoot, "fdroid");
fdroidDirCaps = new SanitizedFile(webRoot, "FDROID");
repoDir = new SanitizedFile(fdroidDir, "repo");
repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO");
iconsDir = new SanitizedFile(repoDir, "icons");
xmlIndex = new SanitizedFile(repoDir, "index.xml");
xmlIndexJar = new SanitizedFile(repoDir, "index.jar");
xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar");
if (!fdroidDir.exists() && !fdroidDir.mkdir()) {
Log.e(TAG, "Unable to create empty base: " + fdroidDir);
}
if (!repoDir.exists() && !repoDir.mkdir()) {
Log.e(TAG, "Unable to create empty repo: " + repoDir);
}
if (!iconsDir.exists() && !iconsDir.mkdir()) {
Log.e(TAG, "Unable to create icons folder: " + iconsDir);
}
}
示例5: getApkCacheDir
import org.fdroid.fdroid.data.SanitizedFile; //导入方法依赖的package包/类
/**
* This location is only for caching, do not install directly from this location
* because if the file is on the External Storage, any other app could swap out
* the APK while the install was in process, allowing malware to install things.
* Using {@link org.fdroid.fdroid.installer.Installer#installPackage(File, String, String)}
* is fine since that does the right thing.
*/
public static SanitizedFile getApkCacheDir(Context context) {
final SanitizedFile apkCacheDir = new SanitizedFile(StorageUtils.getCacheDirectory(context, true), "apks");
if (!apkCacheDir.exists()) {
apkCacheDir.mkdir();
}
return apkCacheDir;
}