Loading cmds/installd/otapreopt.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <android-base/logging.h> #include <android-base/macros.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <cutils/fs.h> #include <cutils/log.h> #include <cutils/properties.h> Loading @@ -39,7 +40,6 @@ #include <file_parsing.h> #include <globals.h> #include <installd_deps.h> // Need to fill in requirements of commands. #include <string_helpers.h> #include <system_properties.h> #include <utils.h> Loading @@ -51,6 +51,8 @@ #define TOKEN_MAX 16 /* max number of arguments in buffer */ #define REPLY_MAX 256 /* largest reply allowed */ using android::base::Join; using android::base::Split; using android::base::StringPrintf; namespace android { Loading Loading @@ -297,7 +299,7 @@ private: std::vector<std::string> cmd; cmd.push_back("/system/bin/dex2oat"); cmd.push_back(StringPrintf("--image=%s", art_path.c_str())); for (const std::string& boot_part : Split(boot_cp, ':')) { for (const std::string& boot_part : Split(boot_cp, ":")) { cmd.push_back(StringPrintf("--dex-file=%s", boot_part.c_str())); } cmd.push_back(StringPrintf("--oat-file=%s", oat_path.c_str())); Loading Loading @@ -326,7 +328,7 @@ private: const std::string* extra_opts = system_properties_.GetProperty("dalvik.vm.image-dex2oat-flags"); if (extra_opts != nullptr) { std::vector<std::string> extra_vals = Split(*extra_opts, ' '); std::vector<std::string> extra_vals = Split(*extra_opts, " "); cmd.insert(cmd.end(), extra_vals.begin(), extra_vals.end()); } // TODO: Should we lower this? It's usually set close to max, because Loading Loading @@ -368,7 +370,7 @@ private: // Wrapper on fork/execv to run a command in a subprocess. bool Exec(const std::vector<std::string>& arg_vector, std::string* error_msg) { const std::string command_line(Join(arg_vector, ' ')); const std::string command_line = Join(arg_vector, ' '); CHECK_GE(arg_vector.size(), 1U) << command_line; Loading cmds/installd/string_helpers.hdeleted 100644 → 0 +0 −67 Original line number Diff line number Diff line /* * Copyright (C) 2015 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. */ #ifndef ART_OTAPREOPT_STRING_HELPERS_H_ #define ART_OTAPREOPT_STRING_HELPERS_H_ #include <sstream> #include <string> #include <android-base/macros.h> namespace android { namespace installd { static inline bool StringStartsWith(const std::string& target, const char* prefix) { return target.compare(0, strlen(prefix), prefix) == 0; } // Split the input according to the separator character. Doesn't honor quotation. static inline std::vector<std::string> Split(const std::string& in, const char separator) { if (in.empty()) { return std::vector<std::string>(); } std::vector<std::string> ret; std::stringstream strstr(in); std::string token; while (std::getline(strstr, token, separator)) { ret.push_back(token); } return ret; } template <typename StringT> static inline std::string Join(const std::vector<StringT>& strings, char separator) { if (strings.empty()) { return ""; } std::string result(strings[0]); for (size_t i = 1; i < strings.size(); ++i) { result += separator; result += strings[i]; } return result; } } // namespace installd } // namespace android #endif // ART_OTAPREOPT_STRING_HELPERS_H_ Loading
cmds/installd/otapreopt.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <android-base/logging.h> #include <android-base/macros.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <cutils/fs.h> #include <cutils/log.h> #include <cutils/properties.h> Loading @@ -39,7 +40,6 @@ #include <file_parsing.h> #include <globals.h> #include <installd_deps.h> // Need to fill in requirements of commands. #include <string_helpers.h> #include <system_properties.h> #include <utils.h> Loading @@ -51,6 +51,8 @@ #define TOKEN_MAX 16 /* max number of arguments in buffer */ #define REPLY_MAX 256 /* largest reply allowed */ using android::base::Join; using android::base::Split; using android::base::StringPrintf; namespace android { Loading Loading @@ -297,7 +299,7 @@ private: std::vector<std::string> cmd; cmd.push_back("/system/bin/dex2oat"); cmd.push_back(StringPrintf("--image=%s", art_path.c_str())); for (const std::string& boot_part : Split(boot_cp, ':')) { for (const std::string& boot_part : Split(boot_cp, ":")) { cmd.push_back(StringPrintf("--dex-file=%s", boot_part.c_str())); } cmd.push_back(StringPrintf("--oat-file=%s", oat_path.c_str())); Loading Loading @@ -326,7 +328,7 @@ private: const std::string* extra_opts = system_properties_.GetProperty("dalvik.vm.image-dex2oat-flags"); if (extra_opts != nullptr) { std::vector<std::string> extra_vals = Split(*extra_opts, ' '); std::vector<std::string> extra_vals = Split(*extra_opts, " "); cmd.insert(cmd.end(), extra_vals.begin(), extra_vals.end()); } // TODO: Should we lower this? It's usually set close to max, because Loading Loading @@ -368,7 +370,7 @@ private: // Wrapper on fork/execv to run a command in a subprocess. bool Exec(const std::vector<std::string>& arg_vector, std::string* error_msg) { const std::string command_line(Join(arg_vector, ' ')); const std::string command_line = Join(arg_vector, ' '); CHECK_GE(arg_vector.size(), 1U) << command_line; Loading
cmds/installd/string_helpers.hdeleted 100644 → 0 +0 −67 Original line number Diff line number Diff line /* * Copyright (C) 2015 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. */ #ifndef ART_OTAPREOPT_STRING_HELPERS_H_ #define ART_OTAPREOPT_STRING_HELPERS_H_ #include <sstream> #include <string> #include <android-base/macros.h> namespace android { namespace installd { static inline bool StringStartsWith(const std::string& target, const char* prefix) { return target.compare(0, strlen(prefix), prefix) == 0; } // Split the input according to the separator character. Doesn't honor quotation. static inline std::vector<std::string> Split(const std::string& in, const char separator) { if (in.empty()) { return std::vector<std::string>(); } std::vector<std::string> ret; std::stringstream strstr(in); std::string token; while (std::getline(strstr, token, separator)) { ret.push_back(token); } return ret; } template <typename StringT> static inline std::string Join(const std::vector<StringT>& strings, char separator) { if (strings.empty()) { return ""; } std::string result(strings[0]); for (size_t i = 1; i < strings.size(); ++i) { result += separator; result += strings[i]; } return result; } } // namespace installd } // namespace android #endif // ART_OTAPREOPT_STRING_HELPERS_H_