How not to compile source modules in Android

If you want your own app to replace the system app, for example, use Lightning Browser to replace the system Browser.

First put the lightning browser into vendor/rockchip/common/apps

 Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := Lightning
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := platform
LOCAL_PREBUILT_JNI_LIBS := \
	lib/libjbigi.so
include $(BUILD_PREBUILT)

Regarding the system default Browser, the following processing methods are available:

1. Directly delete the Browser directory plan

This is a violent solution, but it is less portable and maintainable. If some boards require them and some do not, they cannot be deleted.

Or modify Android.mk under Browser so that it will not be compiled.

This plan has major changes

2. The replacement plan given by Yuansheng in Android.
This solution exists in Android Yuansheng. If you look carefully at build/core/*.mk, you will find that there is a variable called LOCAL_OVERRIDES_PACKAGES.

This variable is the same as LOCAL_PACKAGE_NAME. To add the app that needs to be replaced in the Android.mk of the app (so that this app does not participate in compilation), you only need to set this variable.

For example, add LOCAL_OVERRIDES_PACKAGES := Browser in the Android.mk file of Lightning Browser

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := Lightning
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

LOCAL_OVERRIDES_PACKAGES := Browser

LOCAL_CERTIFICATE := platform
LOCAL_PREBUILT_JNI_LIBS := \
	lib/libjbigi.so
include $(BUILD_PREBUILT)

Setting LOCAL_OVERRIDES_PACKAGES  here will prevent Browser from participating in compilation.

Note that this parameter serves as a replacement. For example, after you have launcher3, you do not need to let the system compile launcher2. You can add LOCAL_OVERRIDES_PACKAGES := Launcher2 to Android.mk under launcher3, so that launcher2 will not be compiled into the system. Got it

However, this modification has a disadvantage. If it is a single application, there is no problem in modifying it like this, but if there are many applications, then you need to modify the mk file of each application. This resulted in the third modification plan.

3. Unified management solution
The solution in point 2 seems to have achieved the goal, but if it is not a replacement, but a simple control to prevent it from participating in compilation, this variable cannot be set.

Let’s take a look at the unified management solution here. There is a variable PRODUCT_PACKAGES in the makefile in Android. This variable controls whether the module participates in compilation. We see many such settings in the device directory. At this time, if it is for a project or board For maintenance, just modify the PRODUCT_PACKAGES variable under device directly. However, sometimes you will see that some modules are not controlled under device, but placed under build. At this time, for the sake of project maintainability, variables under build cannot be directly modified.

With such concerns, for the sake of future project maintainability, I thought of a way, which is to use a variable for unified management. In the future, no matter what the project is, it does not need to be generated or the PRODUCT_PACKAGES has been set under the device. You only need to set this Variables will do.

3. Unified management solution
The solution in point 2 seems to have achieved the goal, but if it is not a replacement, but a simple control to prevent it from participating in compilation, this variable cannot be set.

Let’s take a look at the unified management solution here. There is a variable PRODUCT_PACKAGES in the makefile in Android. This variable controls whether the module participates in compilation. We see many such settings in the device directory. At this time, if it is for a project or board For maintenance, just modify the PRODUCT_PACKAGES variable under device directly. However, sometimes you will see that some modules are not controlled under device, but placed under build. At this time, for the sake of project maintainability, variables under build cannot be directly modified.

With such concerns, for the sake of future project maintainability, I thought of a way, which is to use a variable for unified management. In the future, no matter what the project is, it does not need to be generated or the PRODUCT_PACKAGES has been set under the device. You only need to set this Variables will do.

In build/target/product/core.mk

#
# Copyright (C) 2007 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.
#

# Base configuration for communication-oriented android devices
# (phones, tablets, etc.).  If you want a change to apply to ALMOST ALL
# devices (including non-phones and non-tablets), modify
# core_minimal.mk instead. If you care about wearables, you need to modify
# core_tiny.mk in addition to core_minimal.mk.

PRODUCT_PACKAGES += \
    BasicDreams \
    BlockedNumberProvider \
    BookmarkProvider \
    Browser \
    CaptivePortalLogin \
    CertInstaller \
    DocumentsUI \
    DownloadProviderUi \
    ExternalStorageProvider \
    FusedLocation \
    InputDevices \
    KeyChain \
    Keyguard \
    LatinIME \
    Launcher2 \
    ManagedProvisioning \
    MtpDocumentsProvider \
    PicoTts \
    PacProcessor \
    libpac \
    PrintRecommendationService \
    ProxyHandler \
    SharedStorageBackup \
    StorageManager \
    TeleService \
    VpnDialogs \

ifneq ($(strip $(TARGET_BOARD_PLATFORM_PRODUCT)), box)
PRODUCT_PACKAGES += \
    CalendarProvider \
    PrintSpooler \
    Telecom \
    MmsService \
    Settings
endif

$(call inherit-product, $(SRC_TARGET_DIR)/product/core_base.mk)

You can add and remove them uniformly here

Guess you like

Origin blog.csdn.net/u010823818/article/details/132292356