Skip to content

Commit

Permalink
fix(android): ensure correct bundle properties are used when saving f…
Browse files Browse the repository at this point in the history
…allback version
  • Loading branch information
lincolnthree committed Jun 29, 2022
1 parent 0839230 commit caac9dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class BundleInfo {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

public static final String VERSION_BUILTIN = "builtin";
public static final String ID_BUILTIN = "builtin";
public static final String VERSION_UNKNOWN = "unknown";
public static final String DOWNLOADED_BUILTIN = "1970-01-01T00:00:00.000Z";

Expand Down Expand Up @@ -43,7 +43,7 @@ public BundleInfo(final String id, final String version, final BundleStatus stat
}

public Boolean isBuiltin() {
return VERSION_BUILTIN.equals(this.id);
return ID_BUILTIN.equals(this.id);
}
public Boolean isUnknown() {
return VERSION_UNKNOWN.equals(this.id);
Expand All @@ -64,15 +64,15 @@ public BundleInfo setDownloaded(Date downloaded) {
}

public String getId() {
return this.isBuiltin() ? VERSION_BUILTIN : this.id;
return this.isBuiltin() ? ID_BUILTIN : this.id;
}

public BundleInfo setId(String id) {
return new BundleInfo(id, this.version, this.status, this.downloaded);
}

public String getVersionName() {
return this.version == null ? VERSION_BUILTIN : this.version;
return this.version == null ? ID_BUILTIN : this.version;
}

public BundleInfo setVersionName(String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public BundleInfo getBundleInfo(String id) {
}
Log.d(TAG, "Getting info for [" + id + "]");
BundleInfo result;
if(BundleInfo.VERSION_BUILTIN.equals(id)) {
if(BundleInfo.ID_BUILTIN.equals(id)) {
result = new BundleInfo(id, (String) null, BundleStatus.SUCCESS, "");
} else {
try {
Expand Down Expand Up @@ -455,16 +455,16 @@ private void removeBundleInfo(final String id) {

private void saveBundleInfo(final String id, final BundleInfo info) {
if(id == null || (info != null && (info.isBuiltin() || info.isUnknown()))) {
Log.d(TAG, "Not saving info for id: [" + id + "] " + info);
Log.d(TAG, "Not saving info for: [" + id + "] " + info);
return;
}

if(info == null) {
Log.d(TAG, "Removing info for id [" + id + "]");
Log.d(TAG, "Removing info for [" + id + "]");
this.editor.remove(id + INFO_SUFFIX);
} else {
final BundleInfo update = info.setId(id);
Log.d(TAG, "Storing info for id [" + id + "] " + update.toString());
Log.d(TAG, "Storing info for [" + id + "] " + update.toString());
this.editor.putString(id + INFO_SUFFIX, update.toString());
}
this.editor.commit();
Expand All @@ -488,7 +488,7 @@ private void setBundleStatus(final String id, final BundleStatus status) {

private String getCurrentBundleId() {
if(this.isUsingBuiltin()) {
return BundleInfo.VERSION_BUILTIN;
return BundleInfo.ID_BUILTIN;
} else {
final String path = this.getCurrentBundlePath();
return path.substring(path.lastIndexOf('/') + 1);
Expand All @@ -508,15 +508,15 @@ public Boolean isUsingBuiltin() {
}

public BundleInfo getFallbackVersion() {
final String id = this.prefs.getString(FALLBACK_VERSION, BundleInfo.VERSION_BUILTIN);
final String id = this.prefs.getString(FALLBACK_VERSION, BundleInfo.ID_BUILTIN);
return this.getBundleInfo(id);
}

private void setFallbackVersion(final BundleInfo fallback) {
this.editor.putString(FALLBACK_VERSION,
fallback == null
? BundleInfo.VERSION_BUILTIN
: fallback.getVersionName()
? BundleInfo.ID_BUILTIN
: fallback.getId()
);
}

Expand Down

0 comments on commit caac9dc

Please sign in to comment.