介绍USB服务在Android服务体系中的位置,源码的位置及使用AndroidStudio 查看USB模块FWK的配置方式。
Android 主要有如下7类服务:
frameworks/base/core/java/android/hardware/usb/
frameworks/base/core/java/com/android/internal/usb
frameworks/base/services/usb
(Java)frameworks/base/services/core/jni/
(cpp)system/core/libusbhost
©hardware/interfaces/usb
bionic/libc/kernel/uapi/linux/usb
过滤规则编辑,在aosp源码根目录下添加名为 excluded-paths 的文件
# 几个根目录的规则
^art/.*
^packages/.*
^bootable/.*
^build/.*
^cts/.*
^dalvik/.*
^developers/.*
^external/.*
^platform_testing/.*
^pdk/.*
^sdk/.*
^system/.*
^test/.*
# platform-compat中有注解的类
^tools/(?!(platform-compat))
^development/.*
^device/.*
^prebuilts/*
# 这里我们查看这两个模块,所以注释掉
#^libcore/.*
#^frameworks/.*
# 关于out其他的一些规则
#^out/*
^out/soong/.intermediates/.*/stubsDir/.*
^out/soong/.intermediates/.*/aapt2/.*
#^out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/stubsDir/android/hardware/usb/UsbDevice.java
^out/soong/.intermediates/(?!((frameworks)|(libcore)))
# ./out/soong/.intermediates/frameworks/native/libs/binder/libbinder/android_x86_64_shared/gen/aidl/android/os/BnServiceManager.h
# ^out/soong/.intermediates/.*
#^out/target/.*
# 根据实际运行情况补充的规则
# 移除可能的jar
# 如 ./frameworks/base/tools/aapt2/integration-tests/CommandTests/android-28.jar
^frameworks/(?!base)
^frameworks/base/tools/aapt2/.*\.jar
# 排除一干测试文件目录
^frameworks/.*/tests
^frameworks/base/(?!((core)|(services)))
^hardware/interfaces/(?!usb)
^bionic/libc/kernel/uapi/linux/(?!usb)
^libcore/*
gradle-wrapper.jar
^tools/*
# 对于sdk源码的隐藏,我们exclude掉,以使可以找到真正的源码
^libcore/ojluni/annotations
执行如下命令生成 android.ipr 文件以供 AndroidStudio 使用:
# 在源码根目录执行
source build/envsetup.sh
# 加载正确的Java
lunch aosp_x86_64-eng
cd development/tools/idegen
mm
croot
development/tools/idegen/idegen.sh
idea.case.sensitive.fs=true
打开之后需要一定时间建立索引。
我们使用vscode 查看c/c++代码,字节在ubuntu中使用命令行打开对应目录即可,vscode会自动提示安装对应的本地及远程的c++插件,按提示安装即可。
code frameworks/base/services/core/jni/
配置 C++ 的头文件查找地址:
在包含路径中输入:aosp/** (如: /home/hanlyjiang/aosp/**)
find . -type d -name "usb"
./bionic/libc/kernel/uapi/linux/usb
./cts/apps/CtsVerifier/src/com/android/cts/verifier/usb
./cts/hostsidetests/usb
./cts/hostsidetests/usb/SerialTestApp/src/com/android/cts/usb
./cts/hostsidetests/usb/src/com/android/cts/usb
./cts/tests/tests/usb
./cts/tests/tests/usb/src/android/usb
./development/host/windows/prebuilt/usb
./development/host/windows/usb
./device/google/bonito/usb
./device/google/bramble/usb
./device/google/coral/usb
./device/google/crosshatch/usb
./device/google/redfin/usb
./device/google/sunfish/usb
./external/autotest/client/common_lib/cros/cfm/usb
./external/crosvm/devices/src/usb
./external/kernel-headers/original/uapi/linux/usb
./external/linux-kselftest/tools/testing/selftests/drivers/usb
./external/ltp/testcases/kernel/device-drivers/usb
./external/u-boot/doc/device-tree-bindings/usb
./external/u-boot/drivers/usb
./external/u-boot/include/dt-bindings/usb
./external/u-boot/include/linux/usb
./external/u-boot/include/usb
./frameworks/base/core/java/android/hardware/usb
./frameworks/base/core/java/com/android/internal/usb
./frameworks/base/libs/usb
./frameworks/base/libs/usb/src/com/android/future/usb
./frameworks/base/libs/usb/tests/AccessoryChat/accessorychat/linux/usb
./frameworks/base/packages/SystemUI/src/com/android/systemui/usb
./frameworks/base/services/usb
./frameworks/base/services/usb/java/com/android/server/usb
./frameworks/base/tests/UsbHostExternalManagmentTest/AoapTestDevice/src/com/android/hardware/usb
./frameworks/base/tests/UsbHostExternalManagmentTest/AoapTestHost/src/com/android/hardware/usb
./frameworks/base/tests/UsbHostExternalManagmentTest/UsbHostExternalManagmentTestApp/src/com/android/hardware/usb
./frameworks/base/tests/UsbTests/src/com/android/server/usb
./hardware/google/pixel/usb
./hardware/interfaces/usb
./packages/apps/Settings/src/com/android/settings/connecteddevice/usb
./packages/apps/Settings/tests/robotests/src/com/android/settings/connecteddevice/usb
./packages/services/Car/car-usb-handler/src/android/car/usb
./packages/services/Car/tests/CarDeveloperOptions/src/com/android/car/developeroptions/connecteddevice/usb
./packages/services/Car/tests/usb
./packages/services/Car/tests/usb/AoapHostApp/src/com/google/android/car/usb
./packages/services/Car/tests/usb/AoapPhoneCompanionApp/src/com/google/android/car/usb
./prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/include/linux/usb
./test/framework/harnesses/host_controller/utils/usb
./test/vts-testcase/fuzz/config/usb
./test/vts-testcase/hal/usb
./test/vts-testcase/hal/usb/gadget/V1_1/host/src/com/android/usb
./test/vts-testcase/hal-trace/usb
./tools/test/connectivity/acts/tests/google/usb
相关文件:
./hardware/interfaces/usb
./bionic/libc/kernel/uapi/linux/usb
./frameworks/base/services/usb
./frameworks/base/libs/usb
./frameworks/base/core/java/android/hardware/usb
./frameworks/base/core/java/com/android/internal/usb
./frameworks/base/services/core/jni/
com_android_server_UsbAlsaJackDetector.cpp
com_android_server_UsbDescriptorParser.cpp
com_android_server_UsbDeviceManager.cpp
com_android_server_UsbHostManager.cpp
com_android_server_UsbMidiDevice.cpp