blob: e4450b0d248caa4d69024acffdf691f2fb39e660 [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:
59 virtual std::string GetProperty(const std::string& key, const std::string& default_value);
60 virtual bool GetBoolProperty(const std::string& key, bool default_value);
61
62 private:
63 void AddArg(const std::string& arg);
64 void AddRuntimeArg(const std::string& arg);
65
66 std::string MapPropertyToArg(const std::string& property,
67 const std::string& format,
68 const std::string& default_value = "");
69
70 std::string MapPropertyToArgWithBackup(const std::string& property,
71 const std::string& backupProperty,
72 const std::string& format,
73 const std::string& default_value = "");
74
75 const std::string dex2oat_bin_;
76 ExecVHelper* execv_helper_; // not owned
77};
78
79} // namespace installd
80} // namespace android
81
82#endif // ANDROID_INSTALLD_RUN_DEX2OAT_H