1.把Android源码导入Android Studio进行调试
源码下载完成后,先编译。
如下sample, projects不同编译命令不同
$ source build/envsetup.sh
$ lunch aosp_flounder-userdebug
$ make -j8 ( 8代表CPU核数 )
编译idegen这个项目,生成idegen.jar文件.
$ mmm development/tools/idegen/
如果提示”bash: mmm: command not found”, 请先执行”source build/envsetup.sh”
生成:android.iws, android.ipr, android.iml这个三个文件。
$ sh ./development/tools/idegen/idegen.sh
打开Android Studio --> File --> open --> 选中生成的android.ipr文件,确定后就会导入整个源码。
2.Android system ready 后启动Activity
frameworks/base 路劲下面有个services/core/java/com/android/server/policy/PhoneWindowManager.java, 该文件中有一个”public void systemReady()” method
3.Android BSP 打包自己的APK文件
直接打包APK文件
在vendor/wistron/common文件夹下面创建一个folder, 里面放需要包的APK文件,并且创建一个Android.mk 文件, mk 文件内容如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_MODULE := TouchFwUpdate
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
修改common 下面的mk文件,增加下面的内容:
PRODUCT_PACKAGES += \TouchFwUpdate
直接打包source code源文件
在vendor/wistron/common文件夹下面创建一个folder, 里面放res ,src和AndroidManifest.xml文件夹,src下面直接是包名,并且创建一个Android.mk 文件, mk 文件内容如下:
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optional#LOCAL_STATIC_ANDROID_LIBRARIES := \
# setupcompat \
# setupdesign#include frameworks/opt/setupwizard/library/common-gingerbread.mkLOCAL_STATIC_ANDROID_LIBRARIES := \androidx-constraintlayout_constraintlayout \androidx.slice_slice-builders \androidx.slice_slice-core \androidx.slice_slice-view \androidx.core_core \androidx.appcompat_appcompat \androidx.cardview_cardview \androidx.preference_preference \androidx.recyclerview_recyclerview \com.google.android.material_material
# setupcompat \
# setupdesigninclude frameworks/base/packages/SettingsLib/common.mk
include frameworks/base/packages/SettingsLib/search/common.mkLOCAL_PACKAGE_NAME := TouchFwUpdateLOCAL_SRC_FILES := $(call all-java-files-under, src)LOCAL_USE_AAPT2 := true#LOCAL_SDK_VERSION := current
LOCAL_PRIVATE_PLATFORM_APIS := true#LOCAL_MODULE_CLASS := APPS
#LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
#LOCAL_CERTIFICATE := PRESIGNED#LOCAL_PROGUARD_FLAG_FILES := proguard.flagsinclude $(BUILD_PACKAGE)include $(call all-makefiles-under, $(LOCAL_PATH))
修改common 下面的mk文件,增加下面的内容:
PRODUCT_PACKAGES += \TouchFwUpdate