[Android Software Development] Sahil_Sonar:
Patches & Bring-up!​

Now let it finish syncing and after that, we will apply patches. Yes! Patches now most of you must be thinking what are those? Well, patches are nothing more than fixes they are located in your device tree(android/lineage/device/lenovo/k5fpr/patches) Now look there and see which patches you want to apply. If you are confused which to apply then simply apply all. Whoa man, we are new and no idea how to apply those. Well I know don’t worry I will teach you same now.

First of all copy patches from device tree to our source like for e.g I will show you how to apply bionic_libc.patch.

cp ~/android/lineage/device/lenovo/k5fpr/patches/bionic/bionic_libc.patch ~/android/lineage/bionic

Now what comes after bionic_libc.patch is our destination where we are copying our patch. For your info “cp” is nothing then copy. Now just apply it by using below codes.

cd android/lineage
git add .
git commit -m “Patch”

Now you are done with applyin bionic_libc. patch but there are many other patches left do same with those just change their dir location like we choose/bionic/bionic_lib.patch same way for other patches just changes as accordingly.

Now after you are done applying all patches lets build our ROM … Oh! Yea finally.

Well not yet before that will learn a new thing called as “bing-up” well not device is universal for every ROM but there are some changes needed to be done before you build for any ROM like for me my device tree is already on lineage but if in case I want to build aosp or rr or any other ROM I will have to do certain changes in device tree for that particular ROM. Like here we will choose AOSP.

Now move to device tree like here in my case

cd ~/android/lineage/device/lenovo/k5fpr

Now following things will require changes :

*AndroidProducts.mk

*lineage.mk (Now pretty tricky this file name is lineage if your source is for dot just consider then its dot .mk)

*vendorsetup.sh

Just these 3 needed few changes now pay careful attention or else you won't get what I am saying. Now here we are doing bring-up for aosp from lineage so first and for most, we will start with AndroidProducts.mk so I am showing before bring-up and after bring-up (These changes are done using notepad like nano AndroidProducts.mk)

Before

PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/lineage.mk

After

PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/aosp_k5fpr.mk

Now if you can see then we have changed lineage.mk to aosp_k5fpr.mk… yes for newer oses like pie we will have to include device code name as we did so here you are supposed to change lineage to aosp_k5fpr. Well, now we will talk about lineage.mk itself as we have changed it to aosp_k5fpr there then let's change the name of the file itself for that save the change and exit notepad and copy below code to rename it.

mv lineage.mk aosp_k5fpr.mk

Here you can observe we have typed lineage.mk at first so it means we want to change this file name and to what after space we typed aosp_k5fpr.mk. This means you will have to change it as per your current makefile and to which you want. Now open aosp_k5fpr.mk by using nano aosp_k5fpr.mk

Before

#
# Copyright (C) 2015-2016 The CyanogenMod Project
# Copyright 2017-2018 The LineageOS 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.
#

# Inherit some common lineage stuff.
$(call inherit-product, vendor/lineage/config/common_full_phone.mk)

# Inherit device configuration
$(call inherit-product, $(LOCAL_PATH)/device_k5fpr.mk)

# Device display
TARGET_SCREEN_HEIGHT := 1920
TARGET_SCREEN_WIDTH := 1080

# Device identifier
PRODUCT_BRAND := lenovo
PRODUCT_DEVICE := k5fpr
PRODUCT_MANUFACTURER := LENOVO
PRODUCT_MODEL := Lenovo K4 Note
PRODUCT_NAME := lineage_k5fpr
PRODUCT_RELEASE_NAME := k5fpr
PRODUCT_RESTRICT_VENDOR_FILES := false

After

#
# Copyright (C) 2015-2016 The CyanogenMod Project
# Copyright 2017-2018 The LineageOS 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.
#

# Inherit device configuration
$(call inherit-product, $(LOCAL_PATH)/device_k5fpr.mk)

# Device display
TARGET_SCREEN_HEIGHT := 1920
TARGET_SCREEN_WIDTH := 1080

# Device identifier
PRODUCT_BRAND := lenovo
PRODUCT_DEVICE := k5fpr
PRODUCT_MANUFACTURER := LENOVO
PRODUCT_MODEL := Lenovo K4 Note
PRODUCT_NAME := aosp_k5fpr
PRODUCT_RELEASE_NAME := k5fpr
PRODUCT_RESTRICT_VENDOR_FILES := false

Now if you observe we removed a line “

# Inherit some common lineage stuff.

$(call inherit-product, vendor/lineage/config/common_full_phone.mk)

“ Well in aosp there is no common_full_phone.mk so we removed entire but for most of the ROM’s its common.mk So make sure you check that out. Also, path will be changed like vendor/dot/config/common.mk for dot but for aosp there is nothing so we removed. Now also we did a change to PRODUCT_NAME : aosp_k5fpr from lineage_k5fpr.mk Well that all changes needed just save it and move to last but not the least vendorsetup.sh. Just open it by nano vendorsetup.sh

Before

add_lunch_combo lineage_k5fpr-eng
add_lunch_combo lineage_k5fpr-userdebug
add_lunch_combo lineage_k5fpr-user

After

add_lunch_combo aosp_k5fpr-eng
add_lunch_combo aosp_k5fpr-userdebug
add_lunch_combo aosp_k5fpr-user

This was a simple change just aosp from the lineage that all save it and let's start building now … Wait we did bring-up just for teaching you how exactly it works but doesn’t use aosp bring-up for lineage. Also if you still see some error cannot locate makefile for your device then try changing aosp_k5fpr.mk to aosp.mk and also in AndroidProducts.mk If still not then see for common.mk file or can seek your maintainer who has made trees.