From aa69c0c82cc02e043be9c3fd413609716faa95c8 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Thu, 27 Feb 2020 16:04:29 +0530 Subject: [PATCH] deregisters forms on uninstall --- .../android/database/app/models/FormDefRecord.java | 4 ++++ .../resource/installers/XFormAndroidInstaller.java | 1 + app/src/org/commcare/utils/AndroidCommCarePlatform.java | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/app/src/org/commcare/android/database/app/models/FormDefRecord.java b/app/src/org/commcare/android/database/app/models/FormDefRecord.java index 5ad5396e4b..4894fc1b2a 100644 --- a/app/src/org/commcare/android/database/app/models/FormDefRecord.java +++ b/app/src/org/commcare/android/database/app/models/FormDefRecord.java @@ -195,4 +195,8 @@ public Integer getUiVersion() { public int getResourceVersion() { return mResourceVersion; } + + public String getJrFormId() { + return mJrFormId; + } } diff --git a/app/src/org/commcare/android/resource/installers/XFormAndroidInstaller.java b/app/src/org/commcare/android/resource/installers/XFormAndroidInstaller.java index d8de76332a..0a234a4ef4 100755 --- a/app/src/org/commcare/android/resource/installers/XFormAndroidInstaller.java +++ b/app/src/org/commcare/android/resource/installers/XFormAndroidInstaller.java @@ -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); } diff --git a/app/src/org/commcare/utils/AndroidCommCarePlatform.java b/app/src/org/commcare/utils/AndroidCommCarePlatform.java index 4c0a05f0df..8e2bd4f4fe 100644 --- a/app/src/org/commcare/utils/AndroidCommCarePlatform.java +++ b/app/src/org/commcare/utils/AndroidCommCarePlatform.java @@ -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 getInstalledForms() { return xmlnstable.keySet(); }