当前位置:   article > 正文

玩转贝启科技BQ3588C开源鸿蒙系统开发板 —— 语音唤醒失败问题的分析(1)

贝启科技bq3588c

前边经过重重关卡,终于构建好了OpenHarmony系统。而编译好系统只是万里长征走完了第一步,真正的目的是为了实际的项目,以及在完成项目过程中完成具体的任务和实际解决的问题。

这里就开始介绍实际遇到的问题,以及对于它们的分析与解决。

在实际项目中,发现烧录系统后,对于语音唤醒功能进行测试时,并不能正常唤醒,此功能失效。关于语音唤醒这一部分的介绍参见:

鸿蒙(OpenHarmony)系统之智能语音部件(1)

由于笔者也是初次接触OpenHarmony,因此对于此问题采用最直接的方法,从系统日志入手。日志(log)如下(日志文件内容很大,只贴出相关的部分内容):

  1. 01-01 08:00:15.048 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 20
  2. 01-01 08:00:15.049 641-641/? E C015c0/dsoftbus: [LNN][LlGetDeviceUdid:91]get local udid invalid!
  3. 01-01 08:00:15.049 641-641/? E C015c0/dsoftbus: [COMM][GetNodeKeyInfoInner:873]GetNodeKeyInfoInner get key info failed!
  4. 01-01 08:00:15.049 284-296/? E C01510/BinderInvoker: 124: SendRequest: handle=5 result = -267386855
  5. 01-01 08:00:15.049 284-296/? E C015c0/dsoftbus: [LNN][GetNodeKeyInfo:438]GetNodeKeyInfo send request failed!
  6. 01-01 08:00:15.049 284-296/? E C015c0/dsoftbus: [LNN][ServerIpcGetNodeKeyInfo:115]ServerIpcGetNodeKeyInfo get node key info failed!
  7. 01-01 08:00:15.049 284-296/? E C015c0/dsoftbus: [LNN][GetNodeKeyInfoInner:454]Server GetNodeKeyInfo failed, ret = -268369887
  8. 01-01 08:00:15.049 284-296/? E C04100/DHDM: [devicemanagerservice][GetUdidByNetworkId]:[SOFTBUS]GetNodeKeyInfo failed, ret: -268369887.
  9. 01-01 08:00:15.049 1340-1396/? I C01510/IPCObjectProxy: 58: handle = 18 create, descriptor: IPCObjectProxy18
  10. 01-01 08:00:15.049 638-1160/? E C01611/ZDD: DeviceManagerAdapter::GetUdidByNetworkId: failed, result:0, networkId:2aa***2a6
  11. 01-01 08:00:15.049 638-1160/? I C01611/ZDD: DeviceManagerAdapter::GetLocalDevice: [LocalDevice] uuid:01c***040, name:OpenHarmony 3.2, type:0
  12. 01-01 08:00:15.049 1251-1251/? I C03900/Ace: [resource_adapter_impl.cpp(GetTheme)-(4)] themeId=125829872, ret=0, attr size=1, pattern size=53
  13. 01-01 08:00:15.049 638-1160/? I C01611/ZDD: UserDelegate::UpdateUsers: begin, device:01c***040, users:2
  14. 01-01 08:00:15.049 638-1228/? I C04100/DHDM: [devicemanagerkit][GetLocalDeviceInfo]:DeviceManagerImpl::GetLocalDeviceInfo start, pkgName: ohos.distributeddata.service
  15. 01-01 08:00:15.049 638-1228/? I C04100/DHDM: [devicemanagerkit][SendRequest]:IpcClientManager::SendRequest in
  16. 01-01 08:00:15.049 638-1228/? I C04100/DHDM: [devicemanagerkit][SendRequest]:IpcClientManager::SendRequest cmdCode: 4
  17. 01-01 08:00:15.049 638-1160/? I C01611/ZDD: UserDelegate::operator(): end, device:01c***040, users:2
  18. 01-01 08:00:15.049 638-1160/? I C01611/ZDD: UserDelegate::InitLocalUserMeta: put user meta data save meta data
  19. 01-01 08:00:15.049 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 22
  20. 01-01 08:00:15.049 284-296/? I C04100/DHDM: [devicemanagerservice][GetLocalDeviceInfo]:DeviceManagerService::GetLocalDeviceInfo begin.
  21. 01-01 08:00:15.049 284-296/? W C015c0/dsoftbus: mutex is already init
  22. 01-01 08:00:15.049 617-718/? E C02500/"TriggerManagerImpl": [LoadAdapter][line:109]: get adapter device from hal failed, ret:0
  23. 01-01 08:00:15.049 617-718/? E C02500/intell_voice_trigger_manager_st: IntellVoiceTriggerManagerStubLoadAdapter_ failed, error code is -1
  24. 01-01 08:00:15.049 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 24
  25. 01-01 08:00:15.049 415-1358/? E C01510/BinderInvoker: 124: SendRequest: handle=4 result = -1
  26. 01-01 08:00:15.049 415-1358/? E C02500/intell_voice_trigger_manager_pr: LoadAdapter_ failed, error code is -1
  27. 01-01 08:00:15.049 415-1358/? E C02500/TriggerConnector: [TriggerConnector:42]: failed to load adapter, adapterName is primary
  28. 01-01 08:00:15.049 415-1358/? W C01510/IPCObjectProxy: 63: handle = 4 destroyed, descriptor: IPCObjectProxy4
  29. 01-01 08:00:15.049 1340-1396/? E C01400/OHOS::ROSEN: print log error in vsprintf_s
  30. 01-01 08:00:15.050 280-674/? I C01510/IPCObjectProxy: 58: handle = 48 create, descriptor: IPCObjectProxy48
  31. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status hdf_device_manager
  32. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status hci_interface_service
  33. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status codec_image_jpeg_service
  34. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status user_auth_interface_service
  35. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status usb_pnp_manager
  36. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status codec_hdi_service
  37. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status wlan_interface_service
  38. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status usb_ddk_service
  39. 01-01 08:00:15.050 415-415/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:hdf_device_manager, status:0
  40. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status codec_component_manager_service
  41. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status intell_voice_trigger_manager_service
  42. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status codec_hdi_omx_service
  43. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status usb_interface_service
  44. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status allocator_service
  45. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status display_composer_service
  46. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status camera_service
  47. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status thermal_interface_service
  48. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status battery_interface_service
  49. 01-01 08:00:15.050 415-415/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:hci_interface_service, status:0
  50. 01-01 08:00:15.050 280-674/? I C02500/servstat: notify service status power_interface_service
  51. 01-01 08:00:15.050 280-674/? I C02500/devsvc_manager_stub: register servstat listener success
  52. 01-01 08:00:15.050 641-641/? I C015c0/dsoftbus: [COMM][OnRemoteRequest:204]SoftBusServerStub::OnReceived, code = 149
  53. 01-01 08:00:15.050 415-1358/? I C01800/SAMGR: [PerformanceTest] SA:312 OpenSo spend 207 ms
  54. 01-01 08:00:15.050 415-1358/? I C01800/SAFWK: LocalAbilityManager::StartOndemandSystemAbility [PerformanceTest] SAFWK ondemand LoadSaLib systemAbilityId:312, spend:207 ms
  55. 01-01 08:00:15.050 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 26
  56. 01-01 08:00:15.050 415-415/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:codec_image_jpeg_service, status:0
  57. 01-01 08:00:15.050 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 28
  58. 01-01 08:00:15.050 415-415/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:user_auth_interface_service, status:0
  59. 01-01 08:00:15.050 638-1228/? I C04100/DHDM: [devicemanagerkit][GetLocalDeviceInfo]:DeviceManagerImpl::GetLocalDeviceInfo completed, pkgname = ohos.distributeddata.service
  60. 01-01 08:00:15.050 638-1228/? E C04100/DHDM: [devicemanagerkit][SysEventWrite]:GET_LOCAL_DEVICE_INFO_SUCCESS Write HiSysEvent error, res:-6
  61. 01-01 08:00:15.050 638-1228/? I C04100/DHDM: [devicemanagerkit][GetUuidByNetworkId]:GetUuidByNetworkId start, pkgName: ohos.distributeddata.service
  62. 01-01 08:00:15.050 638-1228/? I C04100/DHDM: [devicemanagerkit][SendRequest]:IpcClientManager::SendRequest in
  63. 01-01 08:00:15.050 638-1228/? I C04100/DHDM: [devicemanagerkit][SendRequest]:IpcClientManager::SendRequest cmdCode: 10
  64. 01-01 08:00:15.050 415-452/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:usb_pnp_manager, status:0
  65. 01-01 08:00:15.050 415-452/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:codec_hdi_service, status:0
  66. 01-01 08:00:15.050 415-452/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:wlan_interface_service, status:0
  67. 01-01 08:00:15.050 415-452/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:usb_ddk_service, status:0
  68. 01-01 08:00:15.050 415-452/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:codec_component_manager_service, status:0
  69. 01-01 08:00:15.050 415-452/? I C02500/TriggerConnector: [OnReceive:90]: enter, service name:intell_voice_trigger_manager_service, status:0
  70. 01-01 08:00:15.050 287-294/? I C02c03/PARAM_WATCHER: [watcher_manager.cpp:104]Add watcher debug.graphic.overdraw remoteWatcherId: 13 groupId 8 success
  71. 01-01 08:00:15.050 286-1204/? E C01800/SAMGR: [SA Scheduler][SA: 5100] not in SA profiles
  72. 01-01 08:00:15.051 284-296/? I C04100/DHDM: [devicemanagerservice][CheckPermission]:Enter PermissionManager::CheckPermission
  73. 01-01 08:00:15.051 284-296/? I C04100/DHDM: [devicemanagerservice][CheckPermission]:PermissionManager::tokenCaller ID == 671522511
  74. 01-01 08:00:15.051 284-296/? I C04100/DHDM: [devicemanagerservice][GetUuidByNetworkId]:DeviceManagerService::GetUuidByNetworkId begin for pkgName = ohos.distributeddata.service
  75. 01-01 08:00:15.051 284-296/? W C015c0/dsoftbus: mutex is already init
  76. 01-01 08:00:15.051 1340-1396/? I C02c03/PARAM_WATCHER: [watcher_manager_kits.cpp:171]Add watcher keyPrefix debug.graphic.overdraw remoteWatcherId 13 success
  77. 01-01 08:00:15.051 641-641/? I C015c0/dsoftbus: [COMM][OnRemoteRequest:204]SoftBusServerStub::OnReceived, code = 150
  78. 01-01 08:00:15.051 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 30
  79. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [rosen_window.cpp(SetRootFrameNode)-(4)] Rosenwindow set root frame node
  80. 01-01 08:00:15.051 286-311/? E C01800/SAMGR: [SA Scheduler][SA: 5100] not in SA profiles
  81. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [pipeline_context.cpp(SetupRootElement)-(4)] SetupRootElement success!
  82. 01-01 08:00:15.051 1251-1251/? I C01d03/accessibility_acfwk: [accessibility_config_impl.cpp(SubscribeConfigObserver:321)]id = [3]
  83. 01-01 08:00:15.051 287-294/? I C02c03/PARAM_WATCHER: [watcher_manager.cpp:104]Add watcher debug.graphic.colors_overdraw remoteWatcherId: 13 groupId 9 success
  84. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [pipeline_context.cpp(SetRootRect)-(4)] SetRootRect width 0.000000, height 0.000000, 0.000000
  85. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [ui_content_impl.cpp(CommonInitialize)-(4)] SetMinPlatformVersion code is 9
  86. 01-01 08:00:15.051 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 32
  87. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [layout_inspector.cpp(SetCallback)-(4)] SetCallback start
  88. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [ui_content_impl.cpp(CommonInitialize)-(4)] Initialize UIContentImpl end.
  89. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [ui_content_impl.cpp(Initialize)-(-1)] Initialize startUrl = pages/PrivacyIndicatorComponent
  90. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [frontend_delegate_declarative.cpp(RunPage)-(4)] FrontendDelegateDeclarative RunPage url=pages/PrivacyIndicatorComponent
  91. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [hap_asset_provider.cpp(GetAsMapping)-(4)] Cannot find base path of manifest.json
  92. 01-01 08:00:15.051 1340-1396/? I C02c03/PARAM_WATCHER: [watcher_manager_kits.cpp:171]Add watcher keyPrefix debug.graphic.colors_overdraw remoteWatcherId 13 success
  93. 01-01 08:00:15.051 1251-1251/? W C03900/Ace: [flutter_asset_manager.cpp(GetAsset)-(4)] find asset failed, name = manifest.json
  94. 01-01 08:00:15.051 1251-1251/? W C03900/Ace: [utils.h(GetAssetContentImpl)-(4)] uri:manifest.json Asset is null
  95. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [frontend_delegate_declarative.cpp(RunPage)-(4)] Parse profile main_pages.json
  96. 01-01 08:00:15.051 1251-1251/? I C03900/Ace: [ui_content_impl.cpp(UpdateWindowMode)-(-1)] UIContentImpl: UpdateWindowMode, window mode is 1, hasDeco is 0
  97. 01-01 08:00:15.052 280-674/? I C02500/devsvc_manager_stub: StubGetService service intell_voice_trigger_manager_service found
  98. 01-01 08:00:15.052 638-1228/? I C04100/DHDM: [devicemanagerkit][GetUdidByNetworkId]:GetUdidByNetworkId start, pkgName: ohos.distributeddata.service
  99. 01-01 08:00:15.052 1251-1251/? I A0001a/SystemUI_Default: WindowManager --> create window[SystemUi_PrivacyIndicator] success.
  100. 01-01 08:00:15.052 415-452/? I C01510/IPCObjectProxy: 58: handle = 4 create, descriptor: IPCObjectProxy4
  101. 01-01 08:00:15.052 638-1228/? I C04100/DHDM: [devicemanagerkit][SendRequest]:IpcClientManager::SendRequest in
  102. 01-01 08:00:15.052 638-1228/? I C04100/DHDM: [devicemanagerkit][SendRequest]:IpcClientManager::SendRequest cmdCode: 9
  103. 01-01 08:00:15.052 1251-1251/? I A0001a/SystemUI_Default: NavigationBar_ServiceExtAbility --> addPrivacyIndicator window has created
  104. 01-01 08:00:15.052 1251-1251/? I C04200/JsWindowManager: <533>Window name = SystemUi_PrivacyIndicator, err = 0
  105. 01-01 08:00:15.052 638-1160/? I C01630/DistributedDB: [Syncer] LocalDataChanged no online standard devices, Label=7EDC83
  106. 01-01 08:00:15.052 284-284/? I C04100/DHDM: [devicemanagerservice][CheckPermission]:Enter PermissionManager::CheckPermission
  107. 01-01 08:00:15.052 617-718/? E C02500/"TriggerManagerImpl": [LoadAdapter][line:109]: get adapter device from hal failed, ret:0
  108. 01-01 08:00:15.052 617-718/? E C02500/intell_voice_trigger_manager_st: IntellVoiceTriggerManagerStubLoadAdapter_ failed, error code is -1
  109. 01-01 08:00:15.052 284-284/? I C04100/DHDM: [devicemanagerservice][CheckPermission]:PermissionMa

虽然只是截取了很少的一部分日志,内容也是比较多的,其中有很多不相关内容需要过滤掉,只关注直接相关的。经过笔者认真观察和手工过滤(搜索“intell_voice”关键字),最为核心的相关内容如下:

  1. 01-01 08:00:15.049 617-718/? E C02500/"TriggerManagerImpl": [LoadAdapter][line:109]: get adapter device from hal failed, ret:0
  2. 01-01 08:00:15.049 617-718/? E C02500/intell_voice_trigger_manager_st: IntellVoiceTriggerManagerStubLoadAdapter_ failed, error code is -1
  3. 01-01 08:00:15.049 1340-1340/? I C03900/Ace: [text_pattern.cpp(InitSurfacePositionChangedCallback)-(0)] Add position changed callback id 24
  4. 01-01 08:00:15.049 415-1358/? E C01510/BinderInvoker: 124: SendRequest: handle=4 result = -1
  5. 01-01 08:00:15.049 415-1358/? E C02500/intell_voice_trigger_manager_pr: LoadAdapter_ failed, error code is -1
  6. 01-01 08:00:15.049 415-1358/? E C02500/TriggerConnector: [TriggerConnector:42]: failed to load adapter, adapterName is primary
  7. 01-01 08:00:15.049 415-1358/? W C01510/IPCObjectProxy: 63: handle = 4 destroyed, descriptor: IPCObjectProxy4
  8. 01-01 08:00:15.049 1340-1396/? E C01400/OHOS::ROSEN: print log error in vsprintf_s

进而,通过日志可以推出条目前边的号(C02500)是一把“钥匙”,笔者目前理解这个号可能是进程号或者标识一个进程的标志(具体代表什么可以请懂的朋友指出,目前我是这样理解的,意思是这意思)。再以“C02500”关键字作为过滤器,就能够滤除与智能语音(强)相关的日志了。

(1)“get adapter device from hal failed, ret:0”

以“get adapter device from hal failed”为关键字,在OpenHarmony源码根目录下进行搜索,结果如下:

  1. ph@ph-virtual-machine:~/OpenHarmony_Source$ grep -rn "get adapter device from" ./
  2. ./drivers/peripheral/intelligent_voice/hdi_service/trigger/intell_voice_trigger_manager_impl.cpp:109: INTELLIGENT_VOICE_LOGE("get adapter device from hal failed, ret:%{public}d", ret);
  3. ./drivers/peripheral/intelligent_voice/hdi_service/engine/intell_voice_engine_manager_impl.cpp:101: INTELLIGENT_VOICE_LOGE("get adapter device from hal failed");

由于日志中带有“ret:0”,因此是第1个搜素结果。看一下./drivers/peripheral/intelligent_voice/hdi_service/trigger/intell_voice_trigger_manager_impl.cpp文件第109行内容,代码如下:

  1. int32_t IntellVoiceTriggerManagerImpl::LoadAdapter(const IntellVoiceTriggerAdapterDsecriptor &descriptor,
  2. sptr<IIntellVoiceTriggerAdapter> &adapter)
  3. {
  4. std::lock_guard<std::mutex> lock(mutex_);
  5. if (inst_ == nullptr) {
  6. INTELLIGENT_VOICE_LOGE("inst is nullptr");
  7. return HDF_FAILURE;
  8. }
  9. auto it = halAdapters_.find(descriptor.adapterName);
  10. if (it != halAdapters_.end()) {
  11. INTELLIGENT_VOICE_LOGW("adapter %{public}s already exist", descriptor.adapterName.c_str());
  12. inst_->UnloadAdapter(descriptor);
  13. it->second = nullptr;
  14. halAdapters_.erase(it);
  15. }
  16. std::unique_ptr<ITrigger> triggerAdapterDevice = nullptr;
  17. int32_t ret = inst_->LoadAdapter(descriptor, triggerAdapterDevice);
  18. if (triggerAdapterDevice == nullptr) {
  19. INTELLIGENT_VOICE_LOGE("get adapter device from hal failed, ret:%{public}d", ret);
  20. return HDF_FAILURE;
  21. }
  22. adapter = sptr<IIntellVoiceTriggerAdapter>(new (std::nothrow) IntellVoiceTriggerAdapterImpl(
  23. std::move(triggerAdapterDevice)));
  24. if (adapter == nullptr) {
  25. INTELLIGENT_VOICE_LOGE("new adapter failed");
  26. return HDF_ERR_MALLOC_FAIL;
  27. }
  28. halAdapters_[descriptor.adapterName] = adapter;
  29. return HDF_SUCCESS;
  30. }

IntellVoiceTriggerManagerImpl::LoadAdapter()中的以下一行打印出了日志信息:

INTELLIGENT_VOICE_LOGE("get adapter device from hal failed, ret:%{public}d", ret);

相关上下文如下:

  1. std::unique_ptr<ITrigger> triggerAdapterDevice = nullptr;
  2. int32_t ret = inst_->LoadAdapter(descriptor, triggerAdapterDevice);
  3. if (triggerAdapterDevice == nullptr) {
  4. INTELLIGENT_VOICE_LOGE("get adapter device from hal failed, ret:%{public}d", ret);
  5. return HDF_FAILURE;
  6. }

由代码可见,之所以会打印出此信息,是由于调用“inst_->LoadAdapter(descriptor, triggerAdapterDevice);”之后,triggerAdapterDevice仍然是nullptr。

(2)“intell_voice_trigger_manager_st: IntellVoiceTriggerManagerStubLoadAdapter_ failed, error code is -1”

这次不直接搜索,而是直接找到Open Harmony源码根目录/out/rk3588/gen/drivers/interface/intelligent_voice/trigger/v1_0/intell_voice_trigger_manager_stub.cpp文件 。并在其中以“failed, error code is”为关键字进行搜索,可知其在以下函数中:

  1. int32_t OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerManagerStub::IntellVoiceTriggerManagerStubLoadAdapter_(MessageParcel& intellVoiceTriggerManagerData, MessageParcel& intellVoiceTriggerManagerReply, MessageOption& intellVoiceTriggerManagerOption, sptr<OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerManager> impl)
  2. {
  3. if (intellVoiceTriggerManagerData.ReadInterfaceToken() != OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerManager::GetDescriptor()) {
  4. HDF_LOGE("%{public}s: interface token check failed!", __func__);
  5. return HDF_ERR_INVALID_PARAM;
  6. }
  7. IntellVoiceTriggerAdapterDsecriptor descriptor;
  8. if (!IntellVoiceTriggerAdapterDsecriptorBlockUnmarshalling(intellVoiceTriggerManagerData, descriptor)) {
  9. HDF_LOGE("%{public}s: read descriptor failed!", __func__);
  10. return HDF_ERR_INVALID_PARAM;
  11. }
  12. sptr<OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerAdapter> adapter;
  13. if (impl == nullptr) {
  14. HDF_LOGE("%{public}s: impl is nullptr!", __func__);
  15. return HDF_ERR_INVALID_PARAM;
  16. }
  17. int32_t intellVoiceTriggerManagerRet = impl->LoadAdapter(descriptor, adapter);
  18. if (intellVoiceTriggerManagerRet != HDF_SUCCESS) {
  19. HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, intellVoiceTriggerManagerRet);
  20. return intellVoiceTriggerManagerRet;
  21. }
  22. if (adapter == nullptr) {
  23. HDF_LOGE("%{public}s: parameter adapter is nullptr!", __func__);
  24. return HDF_ERR_INVALID_PARAM;
  25. }
  26. if (!intellVoiceTriggerManagerReply.WriteRemoteObject(OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(adapter, OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerAdapter::GetDescriptor()))) {
  27. HDF_LOGE("%{public}s: write adapter failed!", __func__);
  28. return HDF_ERR_INVALID_PARAM;
  29. }
  30. return intellVoiceTriggerManagerRet;
  31. }

相关代码片段如下:

  1. int32_t intellVoiceTriggerManagerRet = impl->LoadAdapter(descriptor, adapter);
  2. if (intellVoiceTriggerManagerRet != HDF_SUCCESS) {
  3. HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, intellVoiceTriggerManagerRet);
  4. return intellVoiceTriggerManagerRet;
  5. }

(3)“intell_voice_trigger_manager_pr: LoadAdapter_ failed, error code is -1”

以“intell_voice_trigger_manager_pr”为关键字,在OpenHarmony源码根目录下进行搜索,在众多结果中定位到:

  1. ./out/rk3588/gen/drivers/interface/intelligent_voice/trigger/v1_0/intell_voice_trigger_manager_proxy.cpp:16:#include "v1_0/intell_voice_trigger_manager_proxy.h"
  2. ./out/rk3588/gen/drivers/interface/intelligent_voice/trigger/v1_0/intell_voice_trigger_manager_proxy.cpp:26:#define HDF_LOG_TAG intell_voice_trigger_manager_proxy

打开

./out/rk3588/gen/drivers/interface/intelligent_voice/trigger/v1_0/intell_voice_trigger_manager_proxy.cpp文件 ,并在其中以“failed, error code is”为关键字进行搜索,可知其在以下函数中:

  1. int32_t OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerManagerProxy::LoadAdapter_(const IntellVoiceTriggerAdapterDsecriptor& descriptor, sptr<OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerAdapter>& adapter, const sptr<IRemoteObject> remote)
  2. {
  3. MessageParcel intellVoiceTriggerManagerData;
  4. MessageParcel intellVoiceTriggerManagerReply;
  5. MessageOption intellVoiceTriggerManagerOption(MessageOption::TF_SYNC);
  6. if (!intellVoiceTriggerManagerData.WriteInterfaceToken(OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerManager::GetDescriptor())) {
  7. HDF_LOGE("%{public}s: failed to write interface descriptor!", __func__);
  8. return HDF_ERR_INVALID_PARAM;
  9. }
  10. if (!IntellVoiceTriggerAdapterDsecriptorBlockMarshalling(intellVoiceTriggerManagerData, descriptor)) {
  11. HDF_LOGE("%{public}s: write descriptor failed!", __func__);
  12. return HDF_ERR_INVALID_PARAM;
  13. }
  14. int32_t intellVoiceTriggerManagerRet = remote->SendRequest(CMD_INTELL_VOICE_TRIGGER_MANAGER_LOAD_ADAPTER, intellVoiceTriggerManagerData, intellVoiceTriggerManagerReply, intellVoiceTriggerManagerOption);
  15. if (intellVoiceTriggerManagerRet != HDF_SUCCESS) {
  16. HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, intellVoiceTriggerManagerRet);
  17. return intellVoiceTriggerManagerRet;
  18. }
  19. if (!ReadInterface<OHOS::HDI::IntelligentVoice::Trigger::V1_0::IIntellVoiceTriggerAdapter>(intellVoiceTriggerManagerReply, adapter)) {
  20. HDF_LOGE("%{public}s: failed to read interface object", __func__);
  21. return HDF_ERR_INVALID_PARAM;
  22. }
  23. return intellVoiceTriggerManagerRet;
  24. }

相关代码片段如下:

  1. int32_t intellVoiceTriggerManagerRet = remote->SendRequest(CMD_INTELL_VOICE_TRIGGER_MANAGER_LOAD_ADAPTER, intellVoiceTriggerManagerData, intellVoiceTriggerManagerReply, intellVoiceTriggerManagerOption);
  2. if (intellVoiceTriggerManagerRet != HDF_SUCCESS) {
  3. HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, intellVoiceTriggerManagerRet);
  4. return intellVoiceTriggerManagerRet;
  5. }

(4)“TriggerConnector: [TriggerConnector:42]: failed to load adapter, adapterName is primary”

以“failed to load adapter, adapterName”为关键字,在OpenHarmony源码根目录下进行搜索,在众多结果中定位到:

  1. ./foundation/ai/intelligent_voice_framework/services/intell_voice_trigger/server/connector_mgr/trigger_connector.cpp:42: INTELL_VOICE_LOG_ERROR("failed to load adapter, adapterName is %{public}s", desc_.adapterName.c_str());
  2. ./foundation/ai/intelligent_voice_framework/services/intell_voice_trigger/server/connector_mgr/trigger_connector.cpp:108: INTELL_VOICE_LOG_ERROR("failed to load adapter, adapterName is %{public}s", desc_.adapterName.c_str());

打开

./foundation/ai/intelligent_voice_framework/services/intell_voice_trigger/server/connector_mgr/trigger_connector.cpp文件 。根据上边的信息,该文件中共有两处可以产生此日志。到底是哪一处?笔者更倾向于第一处,即构造函数中。代码如下:

  1. TriggerConnector::TriggerConnector(const IntellVoiceTriggerAdapterDsecriptor &desc)
  2. {
  3. desc_.adapterName = desc.adapterName;
  4. auto mgr = IIntellVoiceTriggerManager::Get();
  5. if (mgr != nullptr) {
  6. mgr->LoadAdapter(desc_, adapter_);
  7. if (adapter_ == nullptr) {
  8. INTELL_VOICE_LOG_ERROR("failed to load adapter, adapterName is %{public}s", desc_.adapterName.c_str());
  9. }
  10. } else {
  11. INTELL_VOICE_LOG_INFO("can not get intell voice trigger manager");
  12. }
  13. }

至此,与语音唤醒即intelligent voice相关的日志及其出处(出自于哪个文件中的哪个函数)就弄清楚了。下一回开始对于函数的调用流程进行分析。

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号