Adnroid MK BP Stub编译jar包隐藏方法具体实现

Stub编译

android.mk 和android.bp编译生成的jar包 隐藏方式具体实现
举例说明

Android.mk需要加的

# Note: The make target is android.car-stub-docs
LOCAL_MODULE := android.car-stub
LOCAL_DROIDDOC_OPTIONS := \
-stubs $(call intermediates-dir-for,JAVA_LIBRARIES,android.car-stubs,,COMMON)/src \
-stubpackages $(subst $(space),:,$(android_car_stub_packages)) \
-api $(android_car_api) \
-nodocs

LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)/java/
LOCAL_DROIDDOC_HTML_DIR :=

LOCAL_MODULE_CLASS := JAVA_LIBRARIES

LOCAL_UNINSTALLABLE_MODULE := true

include $(BUILD_DROIDDOC)

$(android_car_api): $(full_target)

android.car-stubs_stamp := $(full_target)

###############################################
# Build the stubs java files into a jar. This build rule relies on the
# stubs_stamp make variable being set from the droiddoc rule.

include $(CLEAR_VARS)

# CAR_API_CHECK uses the same name to generate a module, but BUILD_DROIDDOC
# appends "-docs" to module name.
LOCAL_MODULE := android.car-stubs
LOCAL_SOURCE_FILES_ALL_GENERATED := true

# Make sure to run droiddoc first to generate the stub source files.
LOCAL_ADDITIONAL_DEPENDENCIES := $(android.car-stubs_stamp)

include $(BUILD_STATIC_JAVA_LIBRARY)

android.car-stubs_stamp :=
android_car_stub_packages :=
android_car_api :=

include $(call all-makefiles-under,$(LOCAL_PATH))

android.bp需要加的

java_library {
    name: "android.car",
	defaults: ["libcar_default"],
    srcs: [
        "src/**/*.java",
        "src/**/I*.aidl",
    ],
    aidl: {
        include_dirs: [
            "system/bt/binder",
        ],
    },
    exclude_srcs: [
        "src/android/car/storagemonitoring/IoStats.aidl",
        "src/android/car/storagemonitoring/IoStatsEntry.aidl",
    ],
    static_libs: [
        "android.car.internal.event-log-tags",
    ],
    product_variables: {
        pdk: {
            enabled: false,
        },
    },
    installable: true,
}

droidstubs {
    name: "android.car-stub-docs",
    srcs: [
        "src/**/*.java",
    ],
    libs: [
        "android.car",
    ],
    api_filename: "api.txt",
    args: "--hide HiddenSuperclass --hide UnavailableSymbol --no-docs --stub-packages android.car* ",
    installable: false,
    product_variables: {
        pdk: {
            enabled: false,
        },
    },
}

java_library {
    name: "android.car-stubs",
    srcs: [
        ":android.car-stub-docs",
    ],
    sdk_version: "current",
    product_variables: {
        pdk: {
            enabled: false,
        },
    },
    installable: false,
    dist: {
        targets: ["dist_files"],
    }
}

java_library {
    name: "android.car-stubs-dex",
    static_libs: ["android.car-stubs"],
    sdk_version: "current",
    product_variables: {
        pdk: {
            enabled: false,
        },
    },
    compile_dex: true,
}

目前没有验证, 先记录一下, 后续验证研究之后会更新

你可能感兴趣的:(android系统,android)