Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 29 | using android::base::StringPrintf; |
| 30 | |
| 31 | namespace android { |
| 32 | namespace installd { |
| 33 | |
| 34 | static const char* parse_null(const char* arg) { |
| 35 | if (strcmp(arg, "!") == 0) { |
| 36 | return nullptr; |
| 37 | } else { |
| 38 | return arg; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | int 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 |