android.hardware.usb.host.xml文件的作用

用户遇到Type-C外接USB设备问题,由于缺少android.hardware.usb.host.xml文件,系统无法进入USBHost模式。实际故障在于USB电气兼容性而非文件本身,硬件问题可能需要更深入的调试。
摘要由CSDN通过智能技术生成

最近一个用户提了一个故障,用户的描述为

更新了好几次版本,都不能完美实现使用Type-C to Type-C线外接USB音频解码器或者U盘/移动硬盘。查询资料后发现是因为系统.\system\etc\permissions目录下缺少android.hardware.usb.host.xml文件,导致系统无法在正常情况下进入USB Host模式,而必须使用额外的USB Type-C to Type-A Hub才能触发OTG默认。

首先android.hardware.usb.host.xml,手机是有的,目录在这个地方

./vendor/etc/permissions/android.hardware.usb.host.xml

作用是,声明设备支持OTG功能,给Android系统中的API或者apk读写usb设备加入访问权限。Google CTS测试也会检查这一文件,检查到这个文件后就会进行otg相关的测试。

低端项目如果没有otg功能,比如硬件不满足,为了避免CTS进行相关测试,需要将改文件删除,如

data/vendor/etc/permissions/android.hardware.usb.host.xml added

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- This is the standard feature indicating that the device can communicate
    with USB devices as the USB host. -->
<permissions>
</permissions>

moduleconfig.mk 


ifeq ($(TEST_OTG_NONE),true)
USB_HOST_DISABLE_ITEM :=$(dir $(lastword $(MAKEFILE_LIST)))data/vendor/etc/permissions/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml
PRODUCT_COPY_FILES := $(USB_HOST_DISABLE_ITEM) $(PRODUCT_COPY_FILES)
endif

所以用户说的这个文件和故障本身不是一个问题。用户的故障是USB电气兼容性问题,需要调试参数解决。如果有硬件问题,调试参数也是解决不了的。

  • 7
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值