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:
parent
b975449b69
commit
fd2e0309e8
1 changed files with 7 additions and 9 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue