Fix disable-verity when the underlying block device is RO

If verity is enabled and the underlying block device is marked
read-only, disable-verity fails. We cannot use the existing code
for enable-verity to make the device writable as the device in
/proc/mounts will be the verity device instead of the underlying
device we want to change. This change makes the correct device
writable when altering verity state.

Change-Id: I423ee50fb34d78cff2fe843318b9081c03c5142d
diff --git a/set_verity_enable_state_service.c b/set_verity_enable_state_service.c
index 09e2eb9..2660ddd 100644
--- a/set_verity_enable_state_service.c
+++ b/set_verity_enable_state_service.c
@@ -87,9 +87,15 @@
     const uint32_t new_magic = enable ? VERITY_METADATA_MAGIC_NUMBER
                                       : VERITY_METADATA_MAGIC_DISABLE;
     uint64_t device_length;
-    int device;
+    int device = -1;
     int retval = -1;
 
+    if (make_block_device_writable(block_device)) {
+        write_console(fd, "Could not make block device %s writable (%s).\n",
+                      block_device, strerror(errno));
+        goto errout;
+    }
+
     device = adb_open(block_device, O_RDWR | O_CLOEXEC);
     if (device == -1) {
         write_console(fd, "Could not open block device %s (%s).\n",
@@ -191,10 +197,6 @@
         goto errout;
     }
 
-    if (enable && make_system_and_vendor_block_devices_writable(fd)) {
-        goto errout;
-    }
-
     /* Loop through entries looking for ones that vold manages */
     for (i = 0; i < fstab->num_entries; i++) {
         if(fs_mgr_is_verified(&fstab->recs[i])) {