Skip to content

Commit

Permalink
Merge pull request #2187 from dimagi/deregisterForm
Browse files Browse the repository at this point in the history
Deregisters forms on uninstall
  • Loading branch information
shubham1g5 authored Feb 27, 2020
2 parents a8f3814 + aa69c0c commit 3c958ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,8 @@ public Integer getUiVersion() {
public int getResourceVersion() {
return mResourceVersion;
}

public String getJrFormId() {
return mJrFormId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public boolean uninstall(Resource r, AndroidCommCarePlatform platform) throws Un
// // This form def record belongs to an old version which is not part of current version since
// // otherwise it's resource version would have got bumped to the resource
// // version of new resource in the update.
platform.deregisterForm(formDefRecord.getJrFormId(), formDefId);
platform.getFormDefStorage().remove(formDefId);
return super.uninstall(r, platform);
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/org/commcare/utils/AndroidCommCarePlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public void registerXmlns(String xmlns, Integer formDefId) {
xmlnstable.put(xmlns, formDefId);
}

// remove the form from xmlnstable if the form with formDefId is registered agains xmlns
public void deregisterForm(String xmlns, Integer formDefId) {
int existingFormId = xmlnstable.get(xmlns);
if (existingFormId == formDefId) {
xmlnstable.remove(xmlns);
}
}

public Set<String> getInstalledForms() {
return xmlnstable.keySet();
}
Expand Down

0 comments on commit 3c958ae

Please sign in to comment.