blob: 71836c38e0302d3ee71a6f7d3081ae7a1b38bea3 [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#include <stdlib.h>
18#include <string.h>
19#include <sys/types.h>
20#include <sys/stat.h>
21#include <unistd.h>
22
23#include <android-base/logging.h>
24#include <android-base/stringprintf.h>
25
26#include "dexopt.h"
27#include "utils.h"
28
29using android::base::StringPrintf;
30
31namespace android {
32namespace installd {
33
34static const char* parse_null(const char* arg) {
35 if (strcmp(arg, "!") == 0) {
36 return nullptr;
37 } else {
38 return arg;
39 }
40}
41
42int dexopt(const char* const params[DEXOPT_PARAM_COUNT]) {
43 return dexopt(params[0], // apk_path
44 atoi(params[1]), // uid
45 params[2], // pkgname
46 params[3], // instruction_set
47 atoi(params[4]), // dexopt_needed
48 params[5], // oat_dir
49 atoi(params[6]), // dexopt_flags
50 params[7], // compiler_filter
51 parse_null(params[8]), // volume_uuid
52 parse_null(params[9])); // shared_libraries
53 static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param count");
54}
55
56} // namespace installd
57} // namespace android