summaryrefslogtreecommitdiff
path: root/artd/binder/com/android/server/art/IArtd.aidl
blob: 4532a8fb116d685132e76992148e7d3f5df742b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.art;

/** @hide */
interface IArtd {
    // Test to see if the artd service is available.
    boolean isAlive();

    /**
     * Deletes dexopt artifacts and returns the released space, in bytes.
     *
     * Note that this method doesn't delete runtime artifacts. To delete them, call
     * `deleteRuntimeArtifacts`.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long deleteArtifacts(in com.android.server.art.ArtifactsPath artifactsPath);

    /**
     * Returns the dexopt status of a dex file.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.GetDexoptStatusResult getDexoptStatus(
            @utf8InCpp String dexFile, @utf8InCpp String instructionSet,
            @nullable @utf8InCpp String classLoaderContext);

    /**
     * Returns true if the profile exists and contains entries for the given dex file.
     *
     * Throws fatal and non-fatal errors.
     */
    boolean isProfileUsable(in com.android.server.art.ProfilePath profile,
            @utf8InCpp String dexFile);

    /**
     * Copies the profile and rewrites it for the given dex file. Returns `SUCCESS` and fills
     * `dst.profilePath.id` if the operation succeeds and `src` exists and contains entries that
     * match the given dex file.
     *
     * Throws fatal and non-fatal errors, except if the input is a bad profile.
     */
    com.android.server.art.CopyAndRewriteProfileResult copyAndRewriteProfile(
            in com.android.server.art.ProfilePath src,
            inout com.android.server.art.OutputProfile dst, @utf8InCpp String dexFile);

    /**
     * Similar to above. The difference is that the profile is not taken from a separate file but
     * taken from `dexFile` itself. Specifically, if `dexFile` is a zip file, the profile is taken
     * from `assets/art-profile/baseline.prof` in the zip. Returns `NO_PROFILE` if `dexFile` is not
     * a zip file or it doesn't contain a profile.
     */
    com.android.server.art.CopyAndRewriteProfileResult copyAndRewriteEmbeddedProfile(
            inout com.android.server.art.OutputProfile dst, @utf8InCpp String dexFile);

    /**
     * Moves the temporary profile to the permanent location.
     *
     * Throws fatal and non-fatal errors.
     */
    void commitTmpProfile(in com.android.server.art.ProfilePath.TmpProfilePath profile);

    /**
     * Deletes the profile. Does nothing of the profile doesn't exist.
     *
     * Operates on the whole DM file if given one.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    void deleteProfile(in com.android.server.art.ProfilePath profile);

    /**
     * Returns the visibility of the profile.
     *
     * Operates on the whole DM file if given one.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.FileVisibility getProfileVisibility(
            in com.android.server.art.ProfilePath profile);

    /**
     * Merges profiles. Both `profiles` and `referenceProfile` are inputs, while the difference is
     * that `referenceProfile` is also used as the reference to calculate the diff. `profiles` that
     * don't exist are skipped, while `referenceProfile`, if provided, must exist. Returns true,
     * writes the merge result to `outputProfile` and fills `outputProfile.profilePath.id` and
     * `outputProfile.profilePath.tmpPath` if a merge has been performed.
     *
     * When `options.forceMerge`, `options.dumpOnly`, or `options.dumpClassesAndMethods` is set,
     * `referenceProfile` must not be set. I.e., all inputs must be provided by `profiles`. This is
     * because the merge will always happen, and hence no reference profile is needed to calculate
     * the diff.
     *
     * Throws fatal and non-fatal errors.
     */
    boolean mergeProfiles(in List<com.android.server.art.ProfilePath> profiles,
            in @nullable com.android.server.art.ProfilePath referenceProfile,
            inout com.android.server.art.OutputProfile outputProfile,
            in @utf8InCpp List<String> dexFiles,
            in com.android.server.art.MergeProfileOptions options);

    /**
     * Returns the visibility of the artifacts.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.FileVisibility getArtifactsVisibility(
            in com.android.server.art.ArtifactsPath artifactsPath);

    /**
     * Returns the visibility of the dex file.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.FileVisibility getDexFileVisibility(@utf8InCpp String dexFile);

    /**
     * Returns the visibility of the DM file.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.FileVisibility getDmFileVisibility(
            in com.android.server.art.DexMetadataPath dmFile);

    /**
     * Returns true if dexopt is needed. `dexoptTrigger` is a bit field that consists of values
     * defined in `com.android.server.art.DexoptTrigger`.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.GetDexoptNeededResult getDexoptNeeded(
            @utf8InCpp String dexFile, @utf8InCpp String instructionSet,
            @nullable @utf8InCpp String classLoaderContext, @utf8InCpp String compilerFilter,
            int dexoptTrigger);

    /**
     * Dexopts a dex file for the given instruction set.
     *
     * Throws fatal and non-fatal errors.
     */
    com.android.server.art.ArtdDexoptResult dexopt(
            in com.android.server.art.OutputArtifacts outputArtifacts,
            @utf8InCpp String dexFile, @utf8InCpp String instructionSet,
            @nullable @utf8InCpp String classLoaderContext, @utf8InCpp String compilerFilter,
            in @nullable com.android.server.art.ProfilePath profile,
            in @nullable com.android.server.art.VdexPath inputVdex,
            in @nullable com.android.server.art.DexMetadataPath dmFile,
            com.android.server.art.PriorityClass priorityClass,
            in com.android.server.art.DexoptOptions dexoptOptions,
            in com.android.server.art.IArtdCancellationSignal cancellationSignal);

    /**
     * Returns a cancellation signal which can be used to cancel {@code dexopt} calls.
     */
    com.android.server.art.IArtdCancellationSignal createCancellationSignal();

    /**
     * Deletes all files that are managed by artd, except those specified in the arguments. Returns
     * the size of the freed space, in bytes.
     *
     * For each entry in `artifactsToKeep`, all three kinds of artifacts (ODEX, VDEX, ART) are
     * kept. For each entry in `vdexFilesToKeep`, only the VDEX file will be kept. Note that VDEX
     * files included in `artifactsToKeep` don't have to be listed in `vdexFilesToKeep`.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long cleanup(in List<com.android.server.art.ProfilePath> profilesToKeep,
            in List<com.android.server.art.ArtifactsPath> artifactsToKeep,
            in List<com.android.server.art.VdexPath> vdexFilesToKeep,
            in List<com.android.server.art.RuntimeArtifactsPath> runtimeArtifactsToKeep);

    /**
     * Returns whether the artifacts of the primary dex files should be in the global dalvik-cache
     * directory.
     *
     * Throws fatal and non-fatal errors.
     */
    boolean isInDalvikCache(@utf8InCpp String dexFile);

    /**
     * Deletes runtime artifacts and returns the released space, in bytes.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long deleteRuntimeArtifacts(
            in com.android.server.art.RuntimeArtifactsPath runtimeArtifactsPath);

    /**
     * Returns the size of the dexopt artifacts, in bytes, or 0 if they don't exist or a non-fatal
     * error occurred.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long getArtifactsSize(in com.android.server.art.ArtifactsPath artifactsPath);

    /**
     * Returns the size of the vdex file, in bytes, or 0 if it doesn't exist or a non-fatal error
     * occurred.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long getVdexFileSize(in com.android.server.art.VdexPath vdexPath);

    /**
     * Returns the size of the runtime artifacts, in bytes, or 0 if they don't exist or a non-fatal
     * error occurred.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long getRuntimeArtifactsSize(
            in com.android.server.art.RuntimeArtifactsPath runtimeArtifactsPath);

    /**
     * Returns the size of the profile, in bytes, or 0 if it doesn't exist or a non-fatal error
     * occurred.
     *
     * Operates on the whole DM file if given one.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal errors. Logs and ignores non-fatal errors.
     */
    long getProfileSize(in com.android.server.art.ProfilePath profile);

    /**
     * Moves the staged files of the given artifacts and profiles to the permanent locations,
     * replacing old files if they exist. Removes the staged files and restores the old files at
     * best effort if any error occurs.
     *
     * This is intended to be called for a superset of the packages that we actually expect to have
     * staged files, so missing files are expected.
     *
     * Not supported in Pre-reboot Dexopt mode.
     *
     * Throws fatal and non-fatal errors.
     */
    void commitPreRebootStagedFiles(
            in List<com.android.server.art.ArtifactsPath> artifacts,
            in List<com.android.server.art.ProfilePath.WritableProfilePath> profiles);

    // The methods below are only for Pre-reboot Dexopt and only supported in Pre-reboot Dexopt
    // mode.

    /**
     * Initializes the environment for Pre-reboot Dexopt. This operation includes initializing
     * environment variables and boot images.
     *
     * Note that this method results in a non-persistent state change, so it must be called every
     * time a new instance of artd is started for Pre-reboot Dexopt.
     *
     * Throws fatal and non-fatal errors.
     */
    void preRebootInit();

    /** For Pre-reboot Dexopt use. See {@link ArtJni#validateDexPath}. */
    @nullable @utf8InCpp String validateDexPath(@utf8InCpp String dexFile);

    /** For Pre-reboot Dexopt use. See {@link ArtJni#validateClassLoaderContext}. */
    @nullable @utf8InCpp String validateClassLoaderContext(
            @utf8InCpp String dexFile, @utf8InCpp String classLoaderContext);
}