Android 5 之后新增frameworks/base/cmds 补丁

在frameworks新增自己的指令
需修改相应src源码,目录结构如下:

$ tree
.
├── Android.mk
├── MODULE_LICENSE_APACHE2
├── NOTICE
├── orientation
└── src
    └── com
        └── android
            └── commands
                └── orientation
                    └── Orientation.java

其中Android.mk

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

LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_MODULE := orientation
include $(BUILD_JAVA_LIBRARY)


include $(CLEAR_VARS)
ALL_PREBUILT += $(TARGET_OUT)/bin/orientation
$(TARGET_OUT)/bin/orientation : $(LOCAL_PATH)/orientation | $(ACP)
    $(transform-prebuilt-to-target)

其中orientation 内容:

# Script to start "pm" on the device, which has a very rudimentary
# shell.
#
base=/system
export CLASSPATH=$base/framework/orientation.jar
exec app_process $base/bin com.android.commands.orientation.Orientation "$@"

其实就类似windows JVM环境下运行jar包

java -jar xxx.jar args

以上,愉快的编译却发现提示:

platform/android/build/core/main.mk:556: *** Some files have been added to ALL_PREBUILT.
platform/android/build/core/main.mk:557: *
platform/android/build/core/main.mk:558: * ALL_PREBUILT is a deprecated mechanism that
platform/android/build/core/main.mk:559: * should not be used for new files.
platform/android/build/core/main.mk:560: * As an alternative, use PRODUCT_COPY_FILES in
platform/android/build/core/main.mk:561: * the appropriate product definition.
platform/android/build/core/main.mk:562: * build/target/product/core.mk is the product
platform/android/build/core/main.mk:563: * definition used in all products.
platform/android/build/core/main.mk:564: *
platform/android/build/core/main.mk:565: * unexpected orientation in ALL_PREBUILT
platform/android/build/core/main.mk:566: *
platform/android/build/core/main.mk:567: *** ALL_PREBUILT contains unexpected files.  Stop.

查找错误处定义:

ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
  $(warning *** Some files have been added to ALL_PREBUILT.)
  $(warning *)
  $(warning * ALL_PREBUILT is a deprecated mechanism that)
  $(warning * should not be used for new files.)
  $(warning * As an alternative, use PRODUCT_COPY_FILES in)
  $(warning * the appropriate product definition.)
  $(warning * build/target/product/core.mk is the product)
  $(warning * definition used in all products.)
  $(warning *)
  $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
  $(warning *)
  $(error ALL_PREBUILT contains unexpected files)
endif

查找GRANDFATHERED_ALL_PREBUILT 定义:

GRANDFATHERED_ALL_PREBUILT := \
    akmd2 \
    ap_gain.bin \
    AVRCP.kl \
    batch \
    bitmap_size.txt \
... ... ... ...

将自己的定义指令的MODULE_NAME 加进去即可

GRANDFATHERED_ALL_PREBUILT := \
    akmd2 \
    ap_gain.bin \
    AVRCP.kl \
    batch \
    bitmap_size.txt \
    orientation \
... ... ... ...

再次编译顺利通过,不再提示上述错误。

你可能感兴趣的:(Android 5 之后新增frameworks/base/cmds 补丁)