Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42063038 authored by Daniel Rosenberg's avatar Daniel Rosenberg Committed by android-build-team Robot
Browse files

installd: Account for empty obb contents on migration

We need /data/media/obb on devices with old kernels. Since that folder
is present, we should check if there are contents there before migrating
data.

This also fixes the check for if the kernel supports the unshared_obb
option. If it does, it only does the migration if there is data to
migrate.

Test: Boot with GSI over P, boot normal Q, with and without data at
      /data/media/obb. With data, it should migrate. Without data it
      shoud skip the migration. On GSI on P it should skip the
      migration.
Bug: 136199978
Change-Id: I41b0ec7a8a6b57b2ea6a530630d56c00f758009a
(cherry picked from commit c0439c78)
parent f42d9f18
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -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