1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 14:21:16 +00:00

Added workaround for broken inotify on Marshmallow

This commit is contained in:
Felix Ableitner 2016-09-23 09:37:48 +09:00
parent 336aec5251
commit b38a152f6a

View file

@ -59,8 +59,6 @@ public class ConfigXml {
*/
public static final String CONFIG_FILE = "config.xml";
private static final int OPEN_CONFIG_MAX_TRIES = 10;
private final Context mContext;
private final File mConfigFile;
@ -76,13 +74,11 @@ public class ConfigXml {
generateKeysConfig(context);
}
for (int i = 0; i < OPEN_CONFIG_MAX_TRIES && mConfig == null; i++) {
try {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
mConfig = db.parse(mConfigFile);
} catch (SAXException | ParserConfigurationException | IOException e) {
throw new OpenConfigException();
}
try {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
mConfig = db.parse(mConfigFile);
} catch (SAXException | ParserConfigurationException | IOException e) {
throw new OpenConfigException();
}
if (isFirstStart) {
@ -139,6 +135,16 @@ public class ConfigXml {
changed = true;
}
// FileObserver does not work correctly on Android Marshmallow.
// Nougat seems to have the same problem in emulator, but we should check this again.
// https://code.google.com/p/android/issues/detail?id=189231
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!r.getAttribute("rescanIntervalS").equals("60")) {
r.setAttribute("rescanIntervalS", "60");
changed = true;
}
}
if (applyHashers(r)) {
changed = true;
}