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

Commit 96bb6c3c authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "More robust createAppData() batching."

parents 2fc37691 8d3848b2
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -189,8 +189,7 @@ cc_binary {
filegroup {
    name: "installd_aidl",
    srcs: [
        "binder/android/os/IInstalld.aidl",
        "binder/android/os/storage/CrateMetadata.aidl",
        "binder/**/*.aidl",
    ],
    path: "binder",
}
+32 −27
Original line number Diff line number Diff line
@@ -420,33 +420,6 @@ static bool prepare_app_profile_dir(const std::string& packageName, int32_t appI
    return true;
}

binder::Status InstalldNativeService::createAppDataBatched(
        const std::optional<std::vector<std::optional<std::string>>>& uuids,
        const std::optional<std::vector<std::optional<std::string>>>& packageNames,
        int32_t userId, int32_t flags, const std::vector<int32_t>& appIds,
        const std::vector<std::string>& seInfos, const std::vector<int32_t>& targetSdkVersions,
        int64_t* _aidl_return) {
    ENFORCE_UID(AID_SYSTEM);
    std::lock_guard<std::recursive_mutex> lock(mLock);

    ATRACE_BEGIN("createAppDataBatched");
    binder::Status ret;
    for (size_t i = 0; i < uuids->size(); i++) {
        std::optional<std::string> packageName = packageNames->at(i);
        if (!packageName) {
            continue;
        }
        ret = createAppData(uuids->at(i), *packageName, userId, flags, appIds[i],
                seInfos[i], targetSdkVersions[i], _aidl_return);
        if (!ret.isOk()) {
            ATRACE_END();
            return ret;
        }
    }
    ATRACE_END();
    return ok();
}

binder::Status InstalldNativeService::createAppData(const std::optional<std::string>& uuid,
        const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
        const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return) {
@@ -528,6 +501,38 @@ binder::Status InstalldNativeService::createAppData(const std::optional<std::str
    return ok();
}


binder::Status InstalldNativeService::createAppData(
        const android::os::CreateAppDataArgs& args,
        android::os::CreateAppDataResult* _aidl_return) {
    ENFORCE_UID(AID_SYSTEM);
    std::lock_guard<std::recursive_mutex> lock(mLock);

    int64_t ceDataInode = -1;
    auto status = createAppData(args.uuid, args.packageName, args.userId, args.flags, args.appId,
                                args.seInfo, args.targetSdkVersion, &ceDataInode);
    _aidl_return->ceDataInode = ceDataInode;
    _aidl_return->exceptionCode = status.exceptionCode();
    _aidl_return->exceptionMessage = status.exceptionMessage();
    return ok();
}

binder::Status InstalldNativeService::createAppDataBatched(
        const std::vector<android::os::CreateAppDataArgs>& args,
        std::vector<android::os::CreateAppDataResult>* _aidl_return) {
    ENFORCE_UID(AID_SYSTEM);
    std::lock_guard<std::recursive_mutex> lock(mLock);

    std::vector<android::os::CreateAppDataResult> results;
    for (auto arg : args) {
        android::os::CreateAppDataResult result;
        createAppData(arg, &result);
        results.push_back(result);
    }
    *_aidl_return = results;
    return ok();
}

binder::Status InstalldNativeService::migrateAppData(const std::optional<std::string>& uuid,
        const std::string& packageName, int32_t userId, int32_t flags) {
    ENFORCE_UID(AID_SYSTEM);
+9 −6
Original line number Diff line number Diff line
@@ -44,15 +44,18 @@ public:
            int32_t userSerial, int32_t flags);
    binder::Status destroyUserData(const std::optional<std::string>& uuid, int32_t userId,
            int32_t flags);
    binder::Status createAppDataBatched(
            const std::optional<std::vector<std::optional<std::string>>>& uuids,
            const std::optional<std::vector<std::optional<std::string>>>& packageNames,
            int32_t userId, int32_t flags, const std::vector<int32_t>& appIds,
            const std::vector<std::string>& seInfos, const std::vector<int32_t>& targetSdkVersions,
            int64_t* _aidl_return);

    binder::Status createAppData(const std::optional<std::string>& uuid,
            const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
            const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return);

    binder::Status createAppData(
            const android::os::CreateAppDataArgs& args,
            android::os::CreateAppDataResult* _aidl_return);
    binder::Status createAppDataBatched(
            const std::vector<android::os::CreateAppDataArgs>& args,
            std::vector<android::os::CreateAppDataResult>* _aidl_return);

    binder::Status restoreconAppData(const std::optional<std::string>& uuid,
            const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
            const std::string& seInfo);
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

package android.os;

/** {@hide} */
parcelable CreateAppDataArgs {
    @nullable @utf8InCpp String uuid;
    @utf8InCpp String packageName;
    int userId;
    int flags;
    int appId;
    @utf8InCpp String seInfo;
    int targetSdkVersion;
}
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

package android.os;

/** {@hide} */
parcelable CreateAppDataResult {
    long ceDataInode;
    int exceptionCode;
    @utf8InCpp String exceptionMessage;
}
Loading