blob: 1f41e67e267f9b8a80729c10c79e6de0b438e17e [file] [log] [blame]
Jeff Sharkey6c2c0562016-12-07 12:12:00 -07001/*
2 * Copyright (C) 2016 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 DEXOPT_H_
18#define DEXOPT_H_
19
Jeff Sharkeyc1149c92017-09-21 14:51:09 -060020#include "installd_constants.h"
21
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070022#include <sys/types.h>
23
Jeff Sharkey90aff262016-12-12 14:28:24 -070024#include <cutils/multiuser.h>
25
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070026namespace android {
27namespace installd {
28
Jeff Sharkey90aff262016-12-12 14:28:24 -070029/* dexopt needed flags matching those in dalvik.system.DexFile */
Calin Juravle80a21252017-01-17 14:43:25 -080030static constexpr int NO_DEXOPT_NEEDED = 0;
Jeff Sharkey90aff262016-12-12 14:28:24 -070031static constexpr int DEX2OAT_FROM_SCRATCH = 1;
32static constexpr int DEX2OAT_FOR_BOOT_IMAGE = 2;
33static constexpr int DEX2OAT_FOR_FILTER = 3;
34static constexpr int DEX2OAT_FOR_RELOCATION = 4;
Jeff Sharkey90aff262016-12-12 14:28:24 -070035
Calin Juravle114f0812017-03-08 19:05:07 -080036// Clear the reference profile for the primary apk of the given package.
37bool clear_primary_reference_profile(const std::string& pkgname);
38// Clear the current profile for the primary apk of the given package and user.
39bool clear_primary_current_profile(const std::string& pkgname, userid_t user);
40// Clear all current profile for the primary apk of the given package.
41bool clear_primary_current_profiles(const std::string& pkgname);
Jeff Sharkey90aff262016-12-12 14:28:24 -070042
43bool move_ab(const char* apk_path, const char* instruction_set, const char* output_path);
44
Calin Juravle114f0812017-03-08 19:05:07 -080045// Decide if profile guided compilation is needed or not based on existing profiles.
46// The analysis is done for the primary apks (base + splits) of the given package.
47// Returns true if there is enough information in the current profiles that makes it
48// worth to recompile the package.
49// If the return value is true all the current profiles would have been merged into
50// the reference profiles accessible with open_reference_profile().
51bool analyze_primary_profiles(uid_t uid, const std::string& pkgname);
52
Calin Juravle76268c52017-03-09 13:19:42 -080053bool dump_profiles(int32_t uid, const std::string& pkgname, const char* code_paths);
Jeff Sharkey90aff262016-12-12 14:28:24 -070054
Mathieu Chartierf966f2a2017-05-10 12:48:37 -070055bool copy_system_profile(const std::string& system_profile,
56 uid_t packageUid,
57 const std::string& data_profile_location);
58
Jeff Sharkey90aff262016-12-12 14:28:24 -070059bool delete_odex(const char* apk_path, const char* instruction_set, const char* output_path);
60
Calin Juravlec9eab382017-01-25 01:17:17 -080061bool reconcile_secondary_dex_file(const std::string& dex_path,
62 const std::string& pkgname, int uid, const std::vector<std::string>& isas,
63 const std::unique_ptr<std::string>& volumeUuid, int storage_flag,
64 /*out*/bool* out_secondary_dex_exists);
65
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070066int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *instruction_set,
67 int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter,
Calin Juravle52c45822017-07-13 22:50:21 -070068 const char* volume_uuid, const char* class_loader_context, const char* se_info,
Shubham Ajmera54ef8622017-06-22 11:10:27 -070069 bool downgrade);
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070070
Jeff Sharkeyc1149c92017-09-21 14:51:09 -060071bool calculate_oat_file_path_default(char path[PKG_PATH_MAX], const char *oat_dir,
72 const char *apk_path, const char *instruction_set);
73
74bool calculate_odex_file_path_default(char path[PKG_PATH_MAX], const char *apk_path,
75 const char *instruction_set);
76
77bool create_cache_path_default(char path[PKG_PATH_MAX], const char *src,
78 const char *instruction_set);
79
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070080} // namespace installd
81} // namespace android
82
83#endif // DEXOPT_H_