From 1456a1e3e7811f42b8645aaae498f2cb075778ed Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Sun, 2 Sep 2018 23:35:25 +0300 Subject: shinano-common: Fix init compilation for Pie * Add import_kernel_cmdline locally to avoid build errors from weird headers dependency chain * Rework on bacons implementation Change-Id: I9a0c9c5d0691340f24808348e679ed2a11ac12d5 --- init/init_shinano.cpp | 66 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'init') diff --git a/init/init_shinano.cpp b/init/init_shinano.cpp index da3395f..77b4a2d 100644 --- a/init/init_shinano.cpp +++ b/init/init_shinano.cpp @@ -1,41 +1,63 @@ /* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (C) 2014 The CyanogenMod 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. + Copyright (c) 2016, The CyanogenMod Project + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of The Linux Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include +#include +#include + #include "vendor_init.h" #include "property_service.h" -#include "log.h" -#include "util.h" -#include +void import_kernel_cmdline(const std::function& fn) { + std::string cmdline; + android::base::ReadFileToString("/proc/cmdline", &cmdline); + + for (const auto& entry : android::base::Split(android::base::Trim(cmdline), " ")) { + std::vector pieces = android::base::Split(entry, "="); + if (pieces.size() == 2) { + fn(pieces[0], pieces[1]); + } + } +} -static void import_kernel_nv(const std::string& key, - const std::string& value, bool for_emulator __attribute__((unused))) +static void import_kernel_nv(const std::string& key, const std::string& value) { if (key.empty()) return; // We only want the bootloader version if (key == "oemandroidboot.s1boot") { - android::init::property_set("ro.boot.oemandroidboot.s1boot", value.c_str()); + android::init::property_set("ro.boot.oemandroidboot.s1boot", value.c_str()); } } -void vendor_load_properties() +void init_target_properties() { - android::init::import_kernel_cmdline(0, import_kernel_nv); + import_kernel_cmdline(import_kernel_nv); } -- cgit v1.2.3