blob: 5453272153dc007e462fb203c65d6214efac2e53 [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
28class RunDex2Oat {
29 public:
30 explicit RunDex2Oat(const char* dex2oat_bin, ExecVHelper* execv_helper);
31 virtual ~RunDex2Oat();
32
33 void Initialize(int zip_fd,
34 int oat_fd,
35 int input_vdex_fd,
36 int output_vdex_fd,
37 int image_fd,
38 const char* input_file_name,
39 const char* output_file_name,
40 int swap_fd,
41 const char* instruction_set,
42 const char* compiler_filter,
43 bool debuggable,
44 bool post_bootcomplete,
45 bool for_restore,
46 int profile_fd,
47 const char* class_loader_context,
48 const std::string& class_loader_context_fds,
49 int target_sdk_version,
50 bool enable_hidden_api_checks,
51 bool generate_compact_dex,
52 int dex_metadata_fd,
53 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);
60 void PrepareInputFileFlags(int zip_fd,
61 int oat_fd,
62 int input_vdex_fd,
63 int output_vdex_fd,
64 int image_fd,
65 const char* input_file_name,
66 const char* output_file_name,
67 int profile_fd,
68 int dex_metadata_fd,
69 int swap_fd,
70 const char* class_loader_context,
71 const std::string& class_loader_context_fds);
72 void PrepareCompilerConfigFlags(int input_vdex_fd,
73 int output_vdex_fd,
74 const char* instruction_set,
75 const char* compiler_filter,
76 bool debuggable,
77 int target_sdk_version,
78 bool enable_hidden_api_checks,
79 bool generate_compact_dex,
80 const char* compilation_reason);
81 void PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore);
82
Victor Hsiehc9821f12020-08-07 11:32:29 -070083 virtual std::string GetProperty(const std::string& key, const std::string& default_value);
84 virtual bool GetBoolProperty(const std::string& key, bool default_value);
85
86 private:
87 void AddArg(const std::string& arg);
88 void AddRuntimeArg(const std::string& arg);
89
90 std::string MapPropertyToArg(const std::string& property,
91 const std::string& format,
92 const std::string& default_value = "");
93
94 std::string MapPropertyToArgWithBackup(const std::string& property,
95 const std::string& backupProperty,
96 const std::string& format,
97 const std::string& default_value = "");
98
99 const std::string dex2oat_bin_;
100 ExecVHelper* execv_helper_; // not owned
101};
102
103} // namespace installd
104} // namespace android
105
106#endif // ANDROID_INSTALLD_RUN_DEX2OAT_H