blob: 325a3a25999ca166f8dd5dfdfe55a7153982ae46 [file] [log] [blame]
Victor Hsiehc9821f12020-08-07 11:32:29 -07001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INSTALLD_RUN_DEX2OAT_H
18#define ANDROID_INSTALLD_RUN_DEX2OAT_H
19
20#include <memory>
21#include <string>
22
23#include "execv_helper.h"
24
25namespace android {
26namespace installd {
27
Victor Hsiehcb35a062020-08-13 16:11:13 -070028class UniqueFile;
29
Victor Hsiehc9821f12020-08-07 11:32:29 -070030class RunDex2Oat {
31 public:
32 explicit RunDex2Oat(const char* dex2oat_bin, ExecVHelper* execv_helper);
33 virtual ~RunDex2Oat();
34
Victor Hsiehcb35a062020-08-13 16:11:13 -070035 void Initialize(const UniqueFile& output_oat,
36 const UniqueFile& output_vdex,
37 const UniqueFile& output_image,
38 const UniqueFile& input_dex,
39 const UniqueFile& input_vdex,
40 const UniqueFile& dex_metadata,
41 const UniqueFile& profile,
42 const char* class_loader_context,
43 const std::string& class_loader_context_fds,
Victor Hsiehc9821f12020-08-07 11:32:29 -070044 int swap_fd,
45 const char* instruction_set,
46 const char* compiler_filter,
47 bool debuggable,
48 bool post_bootcomplete,
49 bool for_restore,
Victor Hsiehc9821f12020-08-07 11:32:29 -070050 int target_sdk_version,
51 bool enable_hidden_api_checks,
52 bool generate_compact_dex,
Victor Hsiehc9821f12020-08-07 11:32:29 -070053 bool use_jitzygote_image,
54 const char* compilation_reason);
55
56 void Exec(int exit_code);
57
58 protected:
Victor Hsiehb3459402020-07-07 12:34:54 -070059 void PrepareBootImageAndBootClasspathFlags(bool use_jitzygote_image);
Victor Hsiehcb35a062020-08-13 16:11:13 -070060 void PrepareInputFileFlags(const UniqueFile& output_oat,
61 const UniqueFile& output_vdex,
62 const UniqueFile& output_image,
63 const UniqueFile& input_dex,
64 const UniqueFile& input_vdex,
65 const UniqueFile& dex_metadata,
66 const UniqueFile& profile,
Victor Hsiehb3459402020-07-07 12:34:54 -070067 int swap_fd,
68 const char* class_loader_context,
69 const std::string& class_loader_context_fds);
Victor Hsiehcb35a062020-08-13 16:11:13 -070070 void PrepareCompilerConfigFlags(const UniqueFile& input_vdex,
71 const UniqueFile& output_vdex,
Victor Hsiehb3459402020-07-07 12:34:54 -070072 const char* instruction_set,
73 const char* compiler_filter,
74 bool debuggable,
75 int target_sdk_version,
76 bool enable_hidden_api_checks,
77 bool generate_compact_dex,
78 const char* compilation_reason);
79 void PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore);
80
Victor Hsiehc9821f12020-08-07 11:32:29 -070081 virtual std::string GetProperty(const std::string& key, const std::string& default_value);
82 virtual bool GetBoolProperty(const std::string& key, bool default_value);
83
84 private:
85 void AddArg(const std::string& arg);
86 void AddRuntimeArg(const std::string& arg);
87
88 std::string MapPropertyToArg(const std::string& property,
89 const std::string& format,
90 const std::string& default_value = "");
91
92 std::string MapPropertyToArgWithBackup(const std::string& property,
93 const std::string& backupProperty,
94 const std::string& format,
95 const std::string& default_value = "");
96
97 const std::string dex2oat_bin_;
98 ExecVHelper* execv_helper_; // not owned
99};
100
101} // namespace installd
102} // namespace android
103
104#endif // ANDROID_INSTALLD_RUN_DEX2OAT_H