diff options
| -rw-r--r-- | cmds/installd/Android.bp | 10 | ||||
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 11 | ||||
| -rw-r--r-- | cmds/installd/InstalldNativeService.h | 2 | ||||
| -rw-r--r-- | cmds/installd/binder/android/os/IInstalld.aidl | 2 | ||||
| -rw-r--r-- | cmds/installd/migrate_legacy_obb_data.sh | 27 |
5 files changed, 52 insertions, 0 deletions
diff --git a/cmds/installd/Android.bp b/cmds/installd/Android.bp index d66066eb42..c80ae3bbf6 100644 --- a/cmds/installd/Android.bp +++ b/cmds/installd/Android.bp @@ -128,6 +128,10 @@ cc_binary { ], }, }, + + // Needs to be wherever installd is as it's execed by + // installd. + required: [ "migrate_legacy_obb_data.sh" ], } // OTA chroot tool @@ -254,3 +258,9 @@ sh_binary { "otapreopt_slot", ], } + +// Script to migrate legacy obb data. +sh_binary { + name: "migrate_legacy_obb_data.sh", + src: "migrate_legacy_obb_data.sh" +} diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 138428588d..caac2e89a7 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -2816,5 +2816,16 @@ binder::Status InstalldNativeService::prepareAppProfile(const std::string& packa return ok(); } +binder::Status InstalldNativeService::migrateLegacyObbData() { + ENFORCE_UID(AID_SYSTEM); + // NOTE: The lint warning doesn't apply to the use of system(3) with + // absolute parse and no command line arguments. + if (system("/system/bin/migrate_legacy_obb_data.sh") != 0) { // NOLINT(cert-env33-c) + LOG(ERROR) << "Unable to migrate legacy obb data"; + } + + return ok(); +} + } // namespace installd } // namespace android diff --git a/cmds/installd/InstalldNativeService.h b/cmds/installd/InstalldNativeService.h index 0e91cb27ba..2b7bf33cbc 100644 --- a/cmds/installd/InstalldNativeService.h +++ b/cmds/installd/InstalldNativeService.h @@ -155,6 +155,8 @@ public: const std::string& codePath, const std::unique_ptr<std::string>& dexMetadata, bool* _aidl_return); + binder::Status migrateLegacyObbData(); + private: std::recursive_mutex mLock; diff --git a/cmds/installd/binder/android/os/IInstalld.aidl b/cmds/installd/binder/android/os/IInstalld.aidl index 4610a66e18..26e9984f11 100644 --- a/cmds/installd/binder/android/os/IInstalld.aidl +++ b/cmds/installd/binder/android/os/IInstalld.aidl @@ -112,6 +112,8 @@ interface IInstalld { void destroyAppDataSnapshot(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, int userId, long ceSnapshotInode, int snapshotId, int storageFlags); + void migrateLegacyObbData(); + const int FLAG_STORAGE_DE = 0x1; const int FLAG_STORAGE_CE = 0x2; const int FLAG_STORAGE_EXTERNAL = 0x4; diff --git a/cmds/installd/migrate_legacy_obb_data.sh b/cmds/installd/migrate_legacy_obb_data.sh new file mode 100644 index 0000000000..4f8a1ecb56 --- /dev/null +++ b/cmds/installd/migrate_legacy_obb_data.sh @@ -0,0 +1,27 @@ +#!/system/bin/sh + +# +# Copyright (C) 2019 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# 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 + +log -p i -t migrate_legacy_obb_data "Migrating legacy obb data." +rm -rf /data/media/0/Android/obb +cp -F -p -R -P -d /data/media/obb /data/media/0/Android +rm -rf /data/media/obb +log -p i -t migrate_legacy_obb_data "Done." |