fix crashes related to broken excludes parsing

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 2 years ago
parent aa34e36559
commit 1a45f984fe

@ -157,26 +157,28 @@ public class BackgroundUpdateChecker extends Worker {
if (repoModule != null) {
remoteVersionCode = String.valueOf(repoModule.moduleInfo.versionCode);
}
int localVersionCode = Integer.parseInt(String.valueOf(localModuleInfo.versionCode));
int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode);
int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", ""));
// now find out if user wants up to and including this version, or this version and newer
// if it starts with ^, it's this version and newer, if it ends with $, it's this version and older
if (version.startsWith("^")) {
// this version and newer
if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) {
if (!version.isEmpty()) {
int localVersionCode = Integer.parseInt(String.valueOf(localModuleInfo.versionCode));
int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode);
int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", ""));
// now find out if user wants up to and including this version, or this version and newer
// if it starts with ^, it's this version and newer, if it ends with $, it's this version and older
if (version.startsWith("^")) {
// this version and newer
if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) {
// if it is, we skip it
continue;
}
} else if (version.endsWith("$")) {
// this version and older
if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) {
// if it is, we skip it
continue;
}
} else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) {
// if it is, we skip it
continue;
}
} else if (version.endsWith("$")) {
// this version and older
if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) {
// if it is, we skip it
continue;
}
} else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) {
// if it is, we skip it
continue;
}
if (localModuleInfo.updateVersionCode > localModuleInfo.versionCode && !PropUtils.isNullString(localModuleInfo.updateVersion)) {
moduleUpdateCount++;

@ -156,40 +156,43 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
if (repoModule != null) {
remoteVersionCode = String.valueOf(repoModule.moduleInfo.versionCode);
}
// now, coerce everything into an int
int localVersionCode = Integer.parseInt(String.valueOf(moduleInfo.versionCode));
int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode);
int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", ""));
// now find out if user wants up to and including this version, or this version and newer
// if it starts with ^, it's this version and newer, if it ends with $, it's this version and older
if (version.startsWith("^")) {
// this version and newer
if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) {
if (!version.isEmpty()) {
// now, coerce everything into an int
int localVersionCode = Integer.parseInt(String.valueOf(moduleInfo.versionCode));
int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode);
int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", ""));
// now find out if user wants up to and including this version, or this version and newer
// if it starts with ^, it's this version and newer, if it ends with $, it's this version and older
if (version.startsWith("^")) {
// this version and newer
if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) {
// if it is, we skip it
ignoreUpdate = true;
}
} else if (version.endsWith("$")) {
// this version and older
if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) {
// if it is, we skip it
ignoreUpdate = true;
}
} else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) {
// if it is, we skip it
ignoreUpdate = true;
}
} else if (version.endsWith("$")) {
// this version and older
if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) {
// if it is, we skip it
ignoreUpdate = true;
}
} else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) {
// if it is, we skip it
ignoreUpdate = true;
}
MainApplication.getINSTANCE().modulesHaveUpdates = true;
if (!MainApplication.getINSTANCE().updateModules.contains(this.moduleId)) {
MainApplication.getINSTANCE().updateModules.add(this.moduleId);
MainApplication.getINSTANCE().updateModuleCount++;
}
Timber.d("modulesHaveUpdates = %s, updateModuleCount = %s", MainApplication.getINSTANCE().modulesHaveUpdates, MainApplication.getINSTANCE().updateModuleCount);
if (ignoreUpdate) {
Timber.d("Module %s has update, but is ignored", this.moduleId);
return Type.INSTALLABLE;
} else {
MainApplication.getINSTANCE().modulesHaveUpdates = true;
if (!MainApplication.getINSTANCE().updateModules.contains(this.moduleId)) {
MainApplication.getINSTANCE().updateModules.add(this.moduleId);
MainApplication.getINSTANCE().updateModuleCount++;
}
Timber.d("modulesHaveUpdates = %s, updateModuleCount = %s", MainApplication.getINSTANCE().modulesHaveUpdates, MainApplication.getINSTANCE().updateModuleCount);
Timber.d("Module %s has update", this.moduleId);
return Type.UPDATABLE;
}
Timber.d("Module %s has update", this.moduleId);
return Type.UPDATABLE;
} else {
return Type.INSTALLED;
}

@ -671,8 +671,9 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
EditText editText = (EditText) layout.getChildAt(i);
String text = editText.getText().toString();
if (!text.isEmpty()) {
// text can only contain numbers
text = text.replaceAll("[^0-9]", "");
// text can only contain numbers and the characters ^ and $
// so we remove all non-numbers and non ^ and $
text = text.replaceAll("[^0-9^$]", "");
// we have to use module id even though we show name
stringSetTemp.add(localModuleInfos.stream().filter(localModuleInfo -> localModuleInfo.name.equals(editText.getHint().toString())).findFirst().orElse(null).id + ":" + text);
Timber.d("text is %s for %s", text, editText.getHint().toString());

Loading…
Cancel
Save