今天改导入/导出联系人方面的东西,导入/导出联系人的这个面板是一个DialogFragment,跟了下代码发现其实现packages/apps/ContactsCommon中,那么在其中添加了一些Log,进入到packages/apps/ContactsCommon/目录下,mm,编译生成了一个com.android.contacts.common.apk,把此程序push到系统中,添加的Log信息却怎么也打不出来,开始怀疑是不是弄错了,并不是这个地方实现的(Android源码中还是有一些重复的代码的),于是又整个工程搜索了一遍,那个导入/导出联系人的DialogFragment只在这里定义了,于是就郁闷了。。。在Android.mk中也看不出什么问题:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, res)
LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := \
com.android.phone.shared \
com.android.vcard \
guava \
android-common \
android-support-v13 \
android-support-v4 \
LOCAL_PACKAGE_NAME := com.android.contacts.common
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
=========================================================================
后来搜索了一下com.android.contacts.common,发现在packages/apps/Dialer和packages/apps/Contacts中都有引用,
Contacts的Android.mk文件:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
contacts_common_dir := ../ContactsCommon
src_dirs := src $(contacts_common_dir)/src
res_dirs := res $(contacts_common_dir)/res
LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs))
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages com.android.contacts.common
LOCAL_JAVA_LIBRARIES := telephony-common voip-common
LOCAL_STATIC_JAVA_LIBRARIES := \
com.android.phone.shared \
com.android.vcard \
android-common \
guava \
android-support-v13 \
android-support-v4 \
android-ex-variablespeed \
LOCAL_REQUIRED_MODULES := libvariablespeed
LOCAL_PACKAGE_NAME := Contacts
LOCAL_CERTIFICATE := shared
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
=================================================================
其中有这一段:
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages com.android.contacts.common
而且在Contacts的AndroidManifest.xml中也注册了很多ContactsCommon中的类,于是我想ContactsCommon是通过这种方式集成到Contacts这个程序中去了,编译了一下Contacts,push进系统,发现Log果然可以出来了。
在Android系统中,拨号程序(packages/apps/Dialer)和联系人程序(packages/apps/Contacts)之间的耦合性非常的大,在拨号中可以调取联系人信息,在联系人中可以进入到拨号界面(当然,还有一个短信程序也是互相联通的),所以我觉得,为了更好的使这些程序夸进程访问,就引出来了这个ContactsCommon的程序(Android4.3之前是没有这个东西的),相当于一个中间人吧。