系统开发(三)——完善关联Camera源码和debug调式

由上一篇文章在AS导入源码阅读成功,查看如framework层,HAL层源码都没有什么问题,但是当我们来开发系统相机时,发现还是有一大串的bug,发现是R文件引用问题导致,今天就来解决这个问题。

一、AS关联Camera2

  1. 上一篇一个小问题:导入的依赖配置保存失败,由于AS没有Android.iml和Android.ipr权限

     修改权限(否则一直报错,无法保存,Modul的依赖设置):
     sudo chmod 777 Android.iml 
     sudo chmod 777 Android.ipr 
    
  2. 修改Android.iml

    • 核心源码:

          <sourceFolder url="file://$MODULE_DIR$/frameworks" isTestSource="false" />
          <sourceFolder url="file://$MODULE_DIR$/hardware" isTestSource="false" />
          <sourceFolder url="file://$MODULE_DIR$/kernel_imx" isTestSource="false" />
          <sourceFolder url="file://$MODULE_DIR$/packages" isTestSource="false" />
          <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
      
    • 关联系统相机R件配置文(classes)

      <!-- 关联系统相机 R -->
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/obj/APPS/Camera2Tests_intermediates" isTestSource="true" />
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/obj/APPS/Camera2_intermediates" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/obj/JAVA_LIBRARIES" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/./out/target/common/obj/APPS/ExtServices_intermediates/src" isTestSource="false"/>
      
      <sourceFolder url="file://$MODULE_DIR$/out/target/product/sabresd_6dq" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/gen" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/R" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/docs" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/out/target/common/System" isTestSource="false" />
      
  3. 关联Camera2使用的第三方库,比如glide ,google common,这里有2种办法:

    • 首先是一个个找到,如下: (在最初生成的Android.iml,如我的:IMX6Q Android 7.1.2 IDEGen生产Android.iml

        <!-- 关联系统引用的jar包,比如glide ,google common-->
        <sourceFolder url="file://$MODULE_DIR$/./external/glide/library/src/main/java" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/glide/testutil/src/main/java" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/glide/third_party/disklrucache/src/main/java" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/glide/third_party/gif_decoder/src/main/java" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/glide/third_party/gif_encoder/src/main/java" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/google-tv-pairing-protocol/java/src" isTestSource="false"/>
        
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/base/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/cache/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/collect/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/escape/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/io/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/math/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/com/google/common/primitives/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/src-super/java/util/super" isTestSource="false"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/base/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/cache/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/collect/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/collect/testing/google/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/collect/testing/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/io/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/math/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/net/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/primitives/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/testing/super" isTestSource="true"/>
        <sourceFolder url="file://$MODULE_DIR$/./external/guava/guava-gwt/test-super/com/google/common/util/concurrent/super" isTestSource="true"/>
      
    • 也可以直接关联external,工程量较大,影响相应速度

        <!-- 关联external -->
        <sourceFolder url="file://$MODULE_DIR$/external" isTestSource="false" />
      

二、debug调式

  1. 在上述关联完成后就可以进行debug调式了,如下,在adb连上开发板设备后,选择AS进程调式按钮,如下图,勾选Show all processes ,选择我们需要调式得进程,如:
    com.android.camera2:
  • 启动软件后,在代码中打上断点,即可进行debug调式

三、总结

接下来就是正常开放咯,如果不需要进行framework改动的,可以直接生产moudle项目,将out/target/product/xx_/system/framework.jar导入即可。
是不是很简单,喜欢点个关注呗。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值