From: mauronofrio matarrese Date: Wed, 5 Jun 2019 16:54:42 +0000 (+0200) Subject: Adding a script to fully support OnePlus 7 Pro 5g X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e93a0c47e8bd6e7d9e82f489b55757c4c6255c97;p=GitHub%2Fmoto-9609%2Ftwrp_device_motorola_troika.git Adding a script to fully support OnePlus 7 Pro 5g In this commit i ported a script to set some props and choose the right device. Other this i added a little init.recovery.qcom.rc fix to fully support stock OOS flash for OnePlus 7 Pro 5g --- diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..936cf6c --- /dev/null +++ b/Android.mk @@ -0,0 +1,34 @@ +# +# Copyright (C) 2017 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. +# + +# This contains the module build definitions for the hardware-specific +# components for this device. +# +# As much as possible, those components should be built unconditionally, +# with device-specific names to avoid collisions, to avoid device-specific +# bitrot and build breakages. Building a component unconditionally does +# *not* include it on all devices, so it is safe even with hardware-specific +# components. + +LOCAL_PATH := $(call my-dir) + +ifeq ($(TARGET_DEVICE),guacamole) + +include $(call all-makefiles-under,$(LOCAL_PATH)) + +include $(CLEAR_VARS) + +endif diff --git a/AndroidBoard.mk b/AndroidBoard.mk deleted file mode 100644 index c8f87d5..0000000 --- a/AndroidBoard.mk +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2016 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. -# - -# This contains the module build definitions for the hardware-specific -# components for this device. -# -# As much as possible, those components should be built unconditionally, -# with device-specific names to avoid collisions, to avoid device-specific -# bitrot and build breakages. Building a component unconditionally does -# *not* include it on all devices, so it is safe even with hardware-specific -# components. - -LOCAL_PATH := $(call my-dir) - -ifneq ($(filter guacamole,$(TARGET_DEVICE)),) -include $(call all-makefiles-under,$(LOCAL_PATH)) -endif diff --git a/BoardConfig.mk b/BoardConfig.mk index 2542699..d997493 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -84,6 +84,11 @@ TARGET_RECOVERY_FSTAB := device/oneplus/guacamole/recovery.fstab BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 TARGET_COPY_OUT_VENDOR := vendor +#Init +TARGET_INIT_VENDOR_LIB := libinit_oneplus7pro +TARGET_RECOVERY_DEVICE_MODULES := libinit_oneplus7pro +TARGET_PLATFORM_DEVICE_BASE := /devices/soc/ + # Recovery BOARD_HAS_LARGE_FILESYSTEM := true BOARD_HAS_NO_SELECT_BUTTON := true diff --git a/init/Android.mk b/init/Android.mk new file mode 100644 index 0000000..27c18e8 --- /dev/null +++ b/init/Android.mk @@ -0,0 +1,28 @@ +# +# Copyright (C) 2017-2018 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. +# + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional +LOCAL_C_INCLUDES := \ + system/core/base/include \ + system/core/init +LOCAL_SRC_FILES := init_oneplus7pro.cpp +LOCAL_MODULE := libinit_oneplus7pro + +include $(BUILD_STATIC_LIBRARY) diff --git a/init/init_oneplus7pro.cpp b/init/init_oneplus7pro.cpp new file mode 100644 index 0000000..7ab615e --- /dev/null +++ b/init/init_oneplus7pro.cpp @@ -0,0 +1,88 @@ +/* + Copyright (C) 2017-2018 The Android Open Source 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 +#include + +#include "property_service.h" +#include "log.h" + +namespace android { +namespace init { + +void load_op7pro(const char *model) { + property_set("ro.product.model", model); + property_set("ro.build.product", "OnePlus7Pro"); + property_set("ro.product.device", "OnePlus7Pro"); + property_set("ro.vendor.product.device", "OnePlus7Pro"); + property_set("ro.display.series", "OnePlus 7 Pro"); +} + +void load_op7pro5g(const char *model) { + property_set("ro.product.model", model); + property_set("ro.build.product", "OnePlus7ProNR"); + property_set("ro.product.device", "OnePlus7ProNR"); + property_set("ro.vendor.product.device", "OnePlus7ProNR"); + property_set("ro.display.series", "OnePlus 7 Pro 5G"); +} + +void vendor_load_properties() { + int rf_version = stoi(android::base::GetProperty("ro.boot.rf_version", "")); + + switch (rf_version) { + case 1: + /* 5g Europe */ + load_op7pro5g("GM1920"); + break; + case 2: + /* T-Mobile */ + load_op7pro("GM1915"); + break; + case 3: + /* India*/ + load_op7pro("GM1911"); + break; + case 4: + /* Europe */ + load_op7pro("GM1913"); + break; + case 5: + /* Global / US Unlocked */ + load_op7pro("GM1917"); + break; + default: + LOG(ERROR) << __func__ << ": unexcepted rf version!"; + } +} + +} // namespace init +} // namespace android diff --git a/omni_guacamole.mk b/omni_guacamole.mk index 4efb5b4..e00a3b4 100644 --- a/omni_guacamole.mk +++ b/omni_guacamole.mk @@ -29,7 +29,7 @@ $(call inherit-product, device/oneplus/guacamole/device.mk) PRODUCT_DEVICE := guacamole PRODUCT_NAME := omni_guacamole PRODUCT_BRAND := OnePlus -PRODUCT_MODEL := OnePlus GM1917 +PRODUCT_MODEL := GM1917 PRODUCT_MANUFACTURER := OnePlus PRODUCT_BUILD_PROP_OVERRIDES += \ @@ -37,6 +37,12 @@ PRODUCT_BUILD_PROP_OVERRIDES += \ BUILD_PRODUCT=OnePlus7Pro \ TARGET_DEVICE=OnePlus7Pro +PRODUCT_SYSTEM_PROPERTY_BLACKLIST += \ + ro.product.model \ + ro.product.device \ + ro.product.name \ + ro.display.series + # HACK: Set vendor patch level PRODUCT_PROPERTY_OVERRIDES += \ - ro.vendor.build.security_patch=2099-12-31 \ No newline at end of file + ro.vendor.build.security_patch=2099-12-31 diff --git a/recovery/root/init.recovery.qcom.rc b/recovery/root/init.recovery.qcom.rc index ed18801..fd81196 100644 --- a/recovery/root/init.recovery.qcom.rc +++ b/recovery/root/init.recovery.qcom.rc @@ -33,6 +33,10 @@ on fs symlink /dev/block/bootdevice/by-name/oem_dycnvbk /dev/block/bootdevice/by-name/oem_dycnvbk_a symlink /dev/block/bootdevice/by-name/oem_dycnvbk /dev/block/bootdevice/by-name/oem_dycnvbk_b + # this is for OnePlus 7 Pro 5g stock rom flashing + symlink /dev/block/bootdevice/by-name/mdm_oem_stanvbk /dev/block/bootdevice/by-name/mdm_oem_stanvbk_a + symlink /dev/block/bootdevice/by-name/mdm_oem_stanvbk /dev/block/bootdevice/by-name/mdm_oem_stanvbk_b + # this is not good way for Hydrogen payload reserve write /dev/block/bootdevice/by-name/reserve 0 symlink /dev/block/bootdevice/by-name/reserve /dev/block/bootdevice/by-name/reserve_a