1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-05 01:31:29 +00:00

Fix + test (fixes #1198)

This commit is contained in:
Catfriend1 2018-07-27 02:01:09 +02:00
parent b975449b69
commit fd2e0309e8

View file

@ -20,8 +20,6 @@ import java.io.IOException;
import java.io.File; import java.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.io.UnsupportedEncodingException;
import eu.chainfire.libsuperuser.Shell; import eu.chainfire.libsuperuser.Shell;
public class Util { public class Util {
@ -141,18 +139,18 @@ public class Util {
useRoot = true; useRoot = true;
} }
// ToDo - For testing purposes only.
absoluteFolderPath = "/storage/emulated/0/Папка"; absoluteFolderPath = "/storage/emulated/0/Папка";
byte absoluteFolderPathBytes[] = absoluteFolderPath.getBytes();
try { // Check for cyrillic characters in the folder path.
absoluteFolderPath = new String(absoluteFolderPathBytes, "Cp1251"); if (absoluteFolderPath.matches(".*\\p{InCyrillic}.*")) {
} catch(UnsupportedEncodingException e) { Log.w(TAG, "nativeBinaryCanWriteToPath: Path '" + absoluteFolderPath +
Log.e(TAG, "Error", e); "' contains cyrillic characters. As this is currently not handled, we'll return true without checking permissions.");
return true;
} }
// Write permission test file. // Write permission test file.
String touchFile = absoluteFolderPath + "/" + TOUCH_FILE_NAME; String touchFile = absoluteFolderPath + "/" + TOUCH_FILE_NAME;
int exitCode = runShellCommand("rm -f \"" + absoluteFolderPath + "\"; echo \"\" > \"" + touchFile + "\"\n", useRoot); int exitCode = runShellCommand("echo \"\" > \"" + touchFile + "\"\n", useRoot);
if (exitCode != 0) { if (exitCode != 0) {
String error; String error;
switch (exitCode) { switch (exitCode) {