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

相关文章

将Mybatis升级为Mybatis-Plus的详细过程

《将Mybatis升级为Mybatis-Plus的详细过程》本文详细介绍了在若依管理系统(v3.8.8)中将MyBatis升级为MyBatis-Plus的过程,旨在提升开发效率,通过本文,开发者可实现... 目录说明流程增加依赖修改配置文件注释掉MyBATisConfig里面的Bean代码生成使用IDEA生

Spring Boot 配置文件之类型、加载顺序与最佳实践记录

《SpringBoot配置文件之类型、加载顺序与最佳实践记录》SpringBoot的配置文件是灵活且强大的工具,通过合理的配置管理,可以让应用开发和部署更加高效,无论是简单的属性配置,还是复杂... 目录Spring Boot 配置文件详解一、Spring Boot 配置文件类型1.1 applicatio

C# WinForms存储过程操作数据库的实例讲解

《C#WinForms存储过程操作数据库的实例讲解》:本文主要介绍C#WinForms存储过程操作数据库的实例,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、存储过程基础二、C# 调用流程1. 数据库连接配置2. 执行存储过程(增删改)3. 查询数据三、事务处

JSON Web Token在登陆中的使用过程

《JSONWebToken在登陆中的使用过程》:本文主要介绍JSONWebToken在登陆中的使用过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录JWT 介绍微服务架构中的 JWT 使用结合微服务网关的 JWT 验证1. 用户登录,生成 JWT2. 自定义过滤

java中使用POI生成Excel并导出过程

《java中使用POI生成Excel并导出过程》:本文主要介绍java中使用POI生成Excel并导出过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录需求说明及实现方式需求完成通用代码版本1版本2结果展示type参数为atype参数为b总结注:本文章中代码均为

MySQL INSERT语句实现当记录不存在时插入的几种方法

《MySQLINSERT语句实现当记录不存在时插入的几种方法》MySQL的INSERT语句是用于向数据库表中插入新记录的关键命令,下面:本文主要介绍MySQLINSERT语句实现当记录不存在时... 目录使用 INSERT IGNORE使用 ON DUPLICATE KEY UPDATE使用 REPLACE

Python 中的异步与同步深度解析(实践记录)

《Python中的异步与同步深度解析(实践记录)》在Python编程世界里,异步和同步的概念是理解程序执行流程和性能优化的关键,这篇文章将带你深入了解它们的差异,以及阻塞和非阻塞的特性,同时通过实际... 目录python中的异步与同步:深度解析与实践异步与同步的定义异步同步阻塞与非阻塞的概念阻塞非阻塞同步

Python Dash框架在数据可视化仪表板中的应用与实践记录

《PythonDash框架在数据可视化仪表板中的应用与实践记录》Python的PlotlyDash库提供了一种简便且强大的方式来构建和展示互动式数据仪表板,本篇文章将深入探讨如何使用Dash设计一... 目录python Dash框架在数据可视化仪表板中的应用与实践1. 什么是Plotly Dash?1.1

SpringCloud之LoadBalancer负载均衡服务调用过程

《SpringCloud之LoadBalancer负载均衡服务调用过程》:本文主要介绍SpringCloud之LoadBalancer负载均衡服务调用过程,具有很好的参考价值,希望对大家有所帮助,... 目录前言一、LoadBalancer是什么?二、使用步骤1、启动consul2、客户端加入依赖3、以服务

Oracle存储过程里操作BLOB的字节数据的办法

《Oracle存储过程里操作BLOB的字节数据的办法》该篇文章介绍了如何在Oracle存储过程中操作BLOB的字节数据,作者研究了如何获取BLOB的字节长度、如何使用DBMS_LOB包进行BLOB操作... 目录一、缘由二、办法2.1 基本操作2.2 DBMS_LOB包2.3 字节级操作与RAW数据类型2.