Merge "installd: Account for empty  obb contents on migration" into qt-dev
diff --git a/cmds/installd/migrate_legacy_obb_data.sh b/cmds/installd/migrate_legacy_obb_data.sh
index ef9be5c..1075688 100644
--- a/cmds/installd/migrate_legacy_obb_data.sh
+++ b/cmds/installd/migrate_legacy_obb_data.sh
@@ -15,16 +15,21 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if ! test -d /data/media/obb ; then
-  log -p i -t migrate_legacy_obb_data "No legacy obb data to migrate."
-  exit 0
-fi
-
-rm -rf /data/media/0/Android/obb/test_probe
+rm -rf /sdcard/Android/obb/test_probe
+mkdir -p /sdcard/Android/obb/
 touch /sdcard/Android/obb/test_probe
 if ! test -f /data/media/0/Android/obb/test_probe ; then
   log -p i -t migrate_legacy_obb_data "No support for 'unshared_obb'. Not migrating"
-  rm -rf /data/media/0/Android/obb/test_probe
+  rm -rf /sdcard/Android/obb/test_probe
+  exit 0
+fi
+
+# Delete the test file, and remove the obb folder if it is empty
+rm -rf /sdcard/Android/obb/test_probe
+rmdir /data/media/obb
+
+if ! test -d /data/media/obb ; then
+  log -p i -t migrate_legacy_obb_data "No legacy obb data to migrate."
   exit 0
 fi