Debian Codegraph @

libartservice/service/java/com/android/server/art/model/DexoptStatus.java

raw
1 /*
2 * Copyright (C) 2022 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 package com.android.server.art.model;
18
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21
22 import com.android.internal.annotations.Immutable;
23
24 import com.google.auto.value.AutoValue;
25
26 import java.util.List;
27
28 /**
29 * Describes the dexopt status of a package.
30 *
31 * @hide
32 */
33 @SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
34 @Immutable
35 @AutoValue
36 public abstract class DexoptStatus {
37 /** @hide */
38 protected DexoptStatus() {}
39
40 /** @hide */
41 public static @NonNull DexoptStatus create(
42 @NonNull List<DexContainerFileDexoptStatus> dexContainerFileDexoptStatuses) {
43 return new AutoValue_DexoptStatus(dexContainerFileDexoptStatuses);
44 }
45
46 /**
47 * The statuses of the dex container file dexopts. Note that there can be multiple entries
48 * for the same dex container file, but for different ABIs.
49 */
50 @NonNull public abstract List<DexContainerFileDexoptStatus> getDexContainerFileDexoptStatuses();
51
52 /**
53 * Describes the dexopt status of a dex container file.
54 *
55 * @hide
56 */
57 @SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
58 @Immutable
59 @AutoValue
60 public abstract static class DexContainerFileDexoptStatus {
61 /** @hide */
62 protected DexContainerFileDexoptStatus() {}
63
64 /** @hide */
65 public static @NonNull DexContainerFileDexoptStatus create(@NonNull String dexContainerFile,
66 boolean isPrimaryDex, boolean isPrimaryAbi, @NonNull String abi,
67 @NonNull String compilerFilter, @NonNull String compilationReason,
68 @NonNull String locationDebugString) {
69 return new AutoValue_DexoptStatus_DexContainerFileDexoptStatus(dexContainerFile,
70 isPrimaryDex, isPrimaryAbi, abi, compilerFilter, compilationReason,
71 locationDebugString);
72 }
73
74 /** The absolute path to the dex container file. */
75 public abstract @NonNull String getDexContainerFile();
76
77 /**
78 * If true, the dex container file is a primary dex (the base APK or a split APK).
79 * Otherwise, it's a secondary dex (a APK or a JAR that the package sideloaded into its data
80 * directory).
81 */
82 public abstract boolean isPrimaryDex();
83
84 /**
85 * If true, the dexopt is for the primary ABI of the package (the ABI that the
86 * application is launched with). Otherwise, the dexopt is for an ABI that other
87 * applications might be launched with when using this application's code.
88 */
89 public abstract boolean isPrimaryAbi();
90
91 /**
92 * Returns the ABI that the dexopt is for. Possible values are documented at
93 * https://developer.android.com/ndk/guides/abis#sa.
94 */
95 public abstract @NonNull String getAbi();
96
97 /**
98 * A human-readable string that describes the compiler filter.
99 *
100 * Possible values are:
101 * <ul>
102 * <li>A valid value of the {@code --compiler-filer} option passed to {@code dex2oat}, if
103 * the dexopt artifacts are valid. See
104 * https://source.android.com/docs/core/dalvik/configure#compilation_options.
105 * <li>{@code "run-from-apk"}, if the dexopt artifacts do not exist.
106 * <li>{@code "run-from-apk-fallback"}, if the dexopt artifacts exist but are invalid
107 * because the dex container file has changed.
108 * <li>{@code "error"}, if an unexpected error occurs.
109 * </ul>
110 */
111 public abstract @NonNull String getCompilerFilter();
112
113 /**
114 * A string that describes the compilation reason.
115 *
116 * Possible values are:
117 * <ul>
118 * <li>The compilation reason, in text format, passed to {@code dex2oat}.
119 * <li>{@code "unknown"}: if the reason is empty or the dexopt artifacts do not exist.
120 * <li>{@code "error"}: if an unexpected error occurs.
121 * </ul>
122 *
123 * Note that this value can differ from the requested compilation reason passed to {@link
124 * DexoptParams.Builder}. Specifically, if the requested reason is for app install (e.g.,
125 * "install"), and a DM file is passed to {@code dex2oat}, a "-dm" suffix will be appended
126 * to the actual reason (e.g., "install-dm"). Other compilation reasons remain unchanged
127 * even if a DM file is passed to {@code dex2oat}.
128 *
129 * Also note that the "-dm" suffix does <b>not</b> imply anything in the DM file being used
130 * by {@code dex2oat}. The compilation reason can still be "install-dm" even if {@code
131 * dex2oat} left all contents of the DM file unused or an empty DM file is passed to
132 * {@code dex2oat}.
133 */
134 public abstract @NonNull String getCompilationReason();
135
136 /**
137 * A human-readable string that describes the location of the dexopt artifacts.
138 *
139 * Note that this string is for debugging purposes only. There is no stability guarantees
140 * for the format of the string. DO NOT use it programmatically.
141 */
142 public abstract @NonNull String getLocationDebugString();
143 }
144 }