Make "Unmap Super Devices" option available to A-only devices

Change-Id: Ib3aed724b2e98f66387bdca240b0b4f719054594
(cherry picked from commit 2136fc5b91963fc21e782614ce6cfd55ca065eb9)
diff --git a/data.cpp b/data.cpp
index 4e32dc4..96e4b5e 100755
--- a/data.cpp
+++ b/data.cpp
@@ -818,11 +818,10 @@
 	mData.SetValue("tw_sleep", "5");
 	mData.SetValue("tw_enable_fastboot", "0");
 
-
 	if (android::base::GetBoolProperty("ro.virtual_ab.enabled", false))
-		mConst.SetValue("tw_virtual_ab.enabled", "1");
+		mConst.SetValue(TW_VIRTUAL_AB_ENABLED, "1");
 	else
-		mConst.SetValue("tw_virtual_ab.enabled", "0");
+		mConst.SetValue(TW_VIRTUAL_AB_ENABLED, "0");
 	// Brightness handling
 	string findbright;
 #ifdef TW_BRIGHTNESS_PATH
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 9fb8570..c0d14d8 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -3856,7 +3856,7 @@
 					</actions>
 				</listitem>
 				<listitem name="{@unmap_super_devices=Unmap Super Devices}">
-					<condition var1="tw_virtual_ab.enabled" op="=" var2="1"/>
+					<condition var1="tw_is_super" op="=" var2="1"/>
 					<actions>
 						<action function="set">tw_back=advanced</action>
 						<action function="set">tw_action=unmapsuperdevices</action>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index db8ea38..1e3d0f8 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -3979,7 +3979,7 @@
 					</actions>
 				</listitem>
 				<listitem name="{@unmap_super_devices=Unmap Super Devices}">
-					<condition var1="tw_virtual_ab.enabled" op="=" var2="1"/>
+					<condition var1="tw_is_super" op="=" var2="1"/>
 					<actions>
 						<action function="set">tw_back=advanced</action>
 						<action function="set">tw_action=unmapsuperdevices</action>
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index f82c2d8..7d9888d 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -4466,7 +4466,7 @@
 					</actions>
 				</listitem>
 				<listitem name="{@unmap_super_devices=Unmap Super Devices}">
-					<condition var1="tw_virtual_ab.enabled" op="=" var2="1"/>
+					<condition var1="tw_is_super" op="=" var2="1"/>
 					<actions>
 						<action function="set">tw_back=advanced</action>
 						<action function="set">tw_action=unmapsuperdevices</action>
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 743e928..5aee83f 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -3573,7 +3573,9 @@
 		if ((*iter)->Is_Super) {
 			TWPartition *part = *iter;
 			std::string bare_partition_name = Get_Bare_Partition_Name((*iter)->Get_Mount_Point());
-			std::string blk_device_partition = bare_partition_name + PartitionManager.Get_Active_Slot_Suffix();
+			std::string blk_device_partition = bare_partition_name;
+			if (DataManager::GetStrValue(TW_VIRTUAL_AB_ENABLED) == "1")
+				blk_device_partition.append(PartitionManager.Get_Active_Slot_Suffix());
 			(*iter)->UnMount(false);
 			LOGINFO("removing dynamic partition: %s\n", blk_device_partition.c_str());
 			destroyed = DestroyLogicalPartition(blk_device_partition);
diff --git a/variables.h b/variables.h
index 8ae3469..cc6977c 100755
--- a/variables.h
+++ b/variables.h
@@ -147,6 +147,7 @@
 #define TW_NO_SHA2                  "tw_no_sha2"
 #define TW_UNMOUNT_SYSTEM           "tw_unmount_system"
 #define TW_IS_SUPER                 "tw_is_super"
+#define TW_VIRTUAL_AB_ENABLED       "tw_virtual_ab.enabled"
 #define TW_AUTO_REFLASHTWRP_VAR     "tw_auto_reflashtwrp"
 
 // Theme versioning