Android10.0(Q) HAL层 light2.0 改动记录及排错过程

2024-08-22 06:18

本文主要是介绍Android10.0(Q) HAL层 light2.0 改动记录及排错过程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

LightsService 灯光服务提供了LCD背光灯、键盘灯、按键灯、警示灯、电池灯、

消息通知灯、蓝牙灯、wifi灯等八种类型灯光;都是基于 android.hardware.light.V2_0.Type

现有需求需要新增第九中类型灯光控制,找到定义 Type 的地方

hardware\interfaces\light\2.0\types.hal

/*** These light IDs correspond to logical lights, not physical.* So for example, if your INDICATOR light is in line with your* BUTTONS, it might make sense to also light the INDICATOR* light to a reasonable color when the BUTTONS are lit.*/
enum Type : int32_t {BACKLIGHT,KEYBOARD,BUTTONS,BATTERY,NOTIFICATIONS,ATTENTION,BLUETOOTH,WIFI,FLASH_TRIG,COUNT,
};

hardware\interfaces\light\2.0\default\Light.cpp

const static std::map<Type, const char*> kLogicalLights = {{Type::BACKLIGHT,     LIGHT_ID_BACKLIGHT},{Type::KEYBOARD,      LIGHT_ID_KEYBOARD},{Type::BUTTONS,       LIGHT_ID_BUTTONS},{Type::BATTERY,       LIGHT_ID_BATTERY},{Type::NOTIFICATIONS, LIGHT_ID_NOTIFICATIONS},{Type::ATTENTION,     LIGHT_ID_ATTENTION},{Type::BLUETOOTH,     LIGHT_ID_BLUETOOTH},{Type::WIFI,          LIGHT_ID_WIFI},{Type::FLASH_TRIG,    LIGHT_ID_FLASH_TRIG}
};

frameworks\base\services\core\java\com\android\server\lights\LightsManager.java


package com.android.server.lights;import android.hardware.light.V2_0.Type;public abstract class LightsManager {public static final int LIGHT_ID_BACKLIGHT = Type.BACKLIGHT;public static final int LIGHT_ID_KEYBOARD = Type.KEYBOARD;public static final int LIGHT_ID_BUTTONS = Type.BUTTONS;public static final int LIGHT_ID_BATTERY = Type.BATTERY;public static final int LIGHT_ID_NOTIFICATIONS = Type.NOTIFICATIONS;public static final int LIGHT_ID_ATTENTION = Type.ATTENTION;public static final int LIGHT_ID_BLUETOOTH = Type.BLUETOOTH;public static final int LIGHT_ID_WIFI = Type.WIFI;public static final int LIGHT_ID_FLASH_TRIG = Type.FLASH_TRIG;public static final int LIGHT_ID_COUNT = Type.COUNT;public abstract Light getLight(int id);
}

修改如上几个地方后,编译报错

错误一、which does not match hash on record. This interface has been frozen. Do not change it!

ERROR: output handler failed.
HIDL c++-sources: hardware/interfaces/light/2.0/types.hal hardware/interfaces/light/2.0/ILight.hal hardware/interfaces/current.txt => 'out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0_genc++/gen/android/hardware/light/2.0/LightAll.cpp'
FAILED: out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0_genc++/gen/android/hardware/light/2.0/LightAll.cpp out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0_genc++/gen/android/hardware/light/2.0/types.cpp
rm -rf out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0_genc++/gen && out/soong/host/linux-x86/bin/hidl-gen -R -p . -d out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0_genc++/gen/android/hardware/light/2.0/LightAll.cpp.d -o out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0_genc++/gen -L c++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.light@2.0
ERROR: android.hardware.light@2.0::types has hash cd082c47c3940f2c4d4ef489c9f34e0c737dfcbd7dd09e0e270563e699a9d91e which does not match hash on record. This interface has been frozen. Do not change it!
ERROR: Could not parse android.hardware.light@2.0::types. Aborting.

原因:Android P 开始,Google 对 Hidl 有了严格的限制。Google release 出来的 hidl 接口不允许修改。

需要重新生成修改 hardware 对应的 hashcode,错误中已经包含新的 hashcode 值 cd082c47c3940f2c4d4ef489c9f34e0c737dfcbd7dd09e0e270563e699a9d91e

如果没有此 hashcode 值,可以通过指令 hidl-gen -L hash -r 来生成,得到和错误提示中的hash值一模一样

$ hidl-gen -L hash -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.light@2.0::types
cd082c47c3940f2c4d4ef489c9f34e0c737dfcbd7dd09e0e270563e699a9d91e android.hardware.light@2.0::types

将刚刚得到的新 hashcode 值更新到 hardware/interfaces/current.txt

可直接在文档末尾增加 cd082c47c3940f2c4d4ef489c9f34e0c737dfcbd7dd09e0e270563e699a9d91e android.hardware.light@2.0::types

错误二、error: VNDK library: android.hardware.light@2.0’s ABI has INCOMPATIBLE CHANGES Please check compatibility report at: out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0/android_arm64_armv8-a_cortex-a53_vendor_shared/android.hardware.light@2.0.so.abidiff

Install: out/target/product/full_171_bsp/system/lib64/vndk-29/android.hardware.keymaster@3.0.so
//hardware/interfaces/light/2.0:android.hardware.light@2.0 header-abi-diff android.hardware.light@2.0.so.abidiff
FAILED: out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0/android_arm64_armv8-a_cortex-a53_vendor_shared/android.hardware.light@2.0.so.abidiff
(prebuilts/clang-tools/linux-x86/bin/header-abi-diff -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib android.hardware.light@2.0 -arch arm64 -o 'out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0/android_arm64_armv8-a_cortex-a53_vendor_shared/android.hardware.light@2.0.so.abidiff' -new 'out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0/android_arm64_armv8-a_cortex-a53_vendor_shared/android.hardware.light@2.0.so.lsdump' -old prebuilts/abi-dumps/vndk/29/64/arm64_armv8-a/source-based/android.hardware.light@2.0.so.lsdump)|| (echo 'error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py  -l android.hardware.light@2.0' && (mkdir -p $DIST_DIR/abidiffs && cp 'out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0/android_arm64_armv8-a_cortex-a53_vendor_shared/android.hardware.light@2.0.so.abidiff' $DIST_DIR/abidiffs/) && exit 1)
******************************************************
error: VNDK library: android.hardware.light@2.0's ABI has INCOMPATIBLE CHANGES Please check compatibility report at: out/soong/.intermediates/hardware/interfaces/light/2.0/android.hardware.light@2.0/android_arm64_armv8-a_cortex-a53_vendor_shared/android.hardware.light@2.0.so.abidiff
******************************************************
error: Please update ABI references with: $ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py  -l android.hardware.light@2.0

根据提示执行指令 development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.light@2.0 ,发现报错

$ development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.light@2.0
Removing reference dumps...
removing /platform/prebuilts/abi-dumps/vndk/28/32/arm_armv7-a-neon/source-based/android.hardware.gnss@1.0.so.lsdump.gz
removing /platform/prebuilts/abi-dumps/ndk/28/32/arm_armv7-a-neon/source-based/android.hardware.gnss@1.0.so.lsdump.gz
making libs for product: aosp_arm_ab
Traceback (most recent call last):File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 224, in <module>main()File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 215, in mainmake_libs_for_product(args.libs, args.llndk, product)File "development/vndk/tools/header-checker/utils/create_reference_dumps.py", line 97, in make_libs_for_productmake_libraries(libs, product, llndk_mode)File "/platform/development/vndk/tools/header-checker/utils/utils.py", line 146, in make_librariesmake_targets(lib_targets, product)File "/platform/development/vndk/tools/header-checker/utils/utils.py", line 137, in make_targetsstderr=subprocess.STDOUT)File "/usr/lib/python3.5/subprocess.py", line 581, in check_callraise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['build/soong/soong_ui.bash', '--make-mode', '-j', 'android.hardware.gnss@1.0.vendor', 'TARGET_PRODUCT=aosp_arm_ab']' returned non-zero exit status 1

看到 making libs for product: aosp_arm_ab 这行,这个是因为我的项目 product名字不一样导致的,加上参数-product product_name 即可,product_name 是你的项目的 product 名称。

development/vndk/tools/header-checker/utils/create_reference_dumps.py -l android.hardware.light@2.0 -product full_171_bsp

AllowBuildBrokenUsesNetwork: trueBuildBrokenUsesNetwork: true
//hardware/interfaces/light/2.0:android.hardware.light@2.0 header-abi-linker android.hardware.light@2.0.so.lsdump [arm]
Creating dumps for target_arch: arm and variant  armv8-a
Created abi dump at /prebuilts/abi-dumps/vndk/29/64/arm_armv8-a/source-based/android.hardware.light@2.0.so.lsdump
Creating dumps for target_arch: arm64 and variant  armv8-a
Created abi dump at /prebuilts/abi-dumps/vndk/29/64/arm64_armv8-a/source-based/android.hardware.light@2.0.so.lsdumpmsg: Processed 2 libraries in  14.642458236217498  minutes

参考文章

Android P VNDK报错

这篇关于Android10.0(Q) HAL层 light2.0 改动记录及排错过程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1095470

相关文章

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

canal实现mysql数据同步的详细过程

《canal实现mysql数据同步的详细过程》:本文主要介绍canal实现mysql数据同步的详细过程,本文通过实例图文相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的... 目录1、canal下载2、mysql同步用户创建和授权3、canal admin安装和启动4、canal

MySQL存储过程之循环遍历查询的结果集详解

《MySQL存储过程之循环遍历查询的结果集详解》:本文主要介绍MySQL存储过程之循环遍历查询的结果集,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录前言1. 表结构2. 存储过程3. 关于存储过程的SQL补充总结前言近来碰到这样一个问题:在生产上导入的数据发现

SpringBoot集成LiteFlow实现轻量级工作流引擎的详细过程

《SpringBoot集成LiteFlow实现轻量级工作流引擎的详细过程》LiteFlow是一款专注于逻辑驱动流程编排的轻量级框架,它以组件化方式快速构建和执行业务流程,有效解耦复杂业务逻辑,下面给大... 目录一、基础概念1.1 组件(Component)1.2 规则(Rule)1.3 上下文(Conte

统一返回JsonResult踩坑的记录

《统一返回JsonResult踩坑的记录》:本文主要介绍统一返回JsonResult踩坑的记录,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录统一返回jsonResult踩坑定义了一个统一返回类在使用时,JsonResult没有get/set方法时响应总结统一返回

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

java对接海康摄像头的完整步骤记录

《java对接海康摄像头的完整步骤记录》在Java中调用海康威视摄像头通常需要使用海康威视提供的SDK,下面这篇文章主要给大家介绍了关于java对接海康摄像头的完整步骤,文中通过代码介绍的非常详细,需... 目录一、开发环境准备二、实现Java调用设备接口(一)加载动态链接库(二)结构体、接口重定义1.类型

Spring Boot 整合 Apache Flink 的详细过程

《SpringBoot整合ApacheFlink的详细过程》ApacheFlink是一个高性能的分布式流处理框架,而SpringBoot提供了快速构建企业级应用的能力,下面给大家介绍Spri... 目录Spring Boot 整合 Apache Flink 教程一、背景与目标二、环境准备三、创建项目 & 添

pytest+allure环境搭建+自动化实践过程

《pytest+allure环境搭建+自动化实践过程》:本文主要介绍pytest+allure环境搭建+自动化实践过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录一、pytest下载安装1.1、安装pytest1.2、检测是否安装成功二、allure下载安装2.