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

Commit 17d8f820 authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Moving /oat folder creation to installd.

Change-Id: I93208d84ff2101f6b8ce63e04fc42c0331ce920b
Test: refactoring CL. Existing unit tests still pass.
Test: atest installd_dexopt_test
parent e416f707
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2055,10 +2055,15 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t
    CHECK_ARGUMENT_PATH(dexMetadataPath);
    std::lock_guard<std::recursive_mutex> lock(mLock);

    const char* oat_dir = getCStr(outputPath);
    const char* instruction_set = instructionSet.c_str();
    if (oat_dir != nullptr && !createOatDir(oat_dir, instruction_set).isOk()) {
        // Can't create oat dir - let dexopt use cache dir.
        oat_dir = nullptr;
    }

    const char* apk_path = apkPath.c_str();
    const char* pkgname = getCStr(packageName, "*");
    const char* instruction_set = instructionSet.c_str();
    const char* oat_dir = getCStr(outputPath);
    const char* compiler_filter = compilerFilter.c_str();
    const char* volume_uuid = getCStr(uuid);
    const char* class_loader_context = getCStr(classLoaderContext);
+14 −8
Original line number Diff line number Diff line
@@ -241,18 +241,14 @@ protected:
    }

    ::testing::AssertionResult create_mock_app() {
        // Create the oat dir.
        app_oat_dir_ = app_apk_dir_ + "/oat";
        // For debug mode, the directory might already exist. Avoid erroring out.
        if (mkdir(app_apk_dir_, kSystemUid, kSystemGid, 0755) != 0 && !kDebug) {
            return ::testing::AssertionFailure() << "Could not create app dir " << app_apk_dir_
                                                 << " : " << strerror(errno);
        }
        binder::Status status = service_->createOatDir(app_oat_dir_, kRuntimeIsa);
        if (!status.isOk()) {
            return ::testing::AssertionFailure() << "Could not create oat dir: "
                                                 << status.toString8().c_str();
        }

        // Initialize the oat dir path.
        app_oat_dir_ = app_apk_dir_ + "/oat";

        // Copy the primary apk.
        apk_path_ = app_apk_dir_ + "/base.jar";
@@ -283,7 +279,7 @@ protected:
          }

        // Create the app user data.
        status = service_->createAppData(
        binder::Status status = service_->createAppData(
                volume_uuid_,
                package_name_,
                kTestUserId,
@@ -647,6 +643,16 @@ TEST_F(DexoptTest, DexoptPrimaryPublic) {
                        DEX2OAT_FROM_SCRATCH);
}

TEST_F(DexoptTest, DexoptPrimaryPublicCreateOatDir) {
    LOG(INFO) << "DexoptPrimaryPublic";
    ASSERT_BINDER_SUCCESS(service_->createOatDir(app_oat_dir_, kRuntimeIsa));
    CompilePrimaryDexOk("verify",
                        DEXOPT_BOOTCOMPLETE | DEXOPT_PUBLIC,
                        app_oat_dir_.c_str(),
                        kTestAppGid,
                        DEX2OAT_FROM_SCRATCH);
}

TEST_F(DexoptTest, DexoptPrimaryFailedInvalidFilter) {
    LOG(INFO) << "DexoptPrimaryFailedInvalidFilter";
    binder::Status status;