【关注我,后续持续新增专题博文,谢谢!!!】
上一篇我们讲了:
这一篇我们开始讲:
目录
[2.2 :分析闪光灯回调流程日志](#2.2 :分析闪光灯回调流程日志)
[2.3 :对比正常回调流程](#2.3 :对比正常回调流程)
[2.4 :回调差异](#2.4 :回调差异)
[2.5 :分析camx hal](#2.5 :分析camx hal)
[2.6 :CameraService分析没回调到SystemUi](#2.6 :CameraService分析没回调到SystemUi)
[2.7 :查看TorchStrengthLevel默认值](#2.7 :查看TorchStrengthLevel默认值)
[2.8 :解决方案](#2.8 :解决方案)
一、问题背景
【操作步骤】【Operation steps】手手电筒打开3档时,达到档位控制温度,在手电筒二级界面中查看档位
【实际结果】【Actual results】手电筒二级界面中档位为0
【期望结果】【Expected results】手电筒保持打开状态,自动到2档
二、问题分析过程
2.1:基于原理分析
手电筒档位调节后,会从APP一直调用到camx hal的闪光灯驱动,闪光灯驱动执行相关动作后,又会回调相关信息告诉APP执行情况。
而当前问题APP有往下调用动作,而没有实际效果,因此大概率是没有回调,是没执行完,还是执行完成,没有回调完成呢?需要看看。
2.2 :分析闪光灯回调流程日志
1:参考闪光灯日志关键字:相机Camera日志分析之三十一:高通Camx HAL十种流程基础分析关键字汇总(后续持续更新中)
2:分析闪光灯回调流程
结合问题发生后录屏的00:42,时间大概在16:24:52左右。
从android日志可以确定,16:24:52前2次,每次设置手电level时都会收回CameraManager.TorchCallback#onTorchStrengthLevelChanged的状态回调,但出问题时并没有收到onTorchStrengthLevelChanged回调
而UI上的真正level状态是要收到CameraManager.TorchCallback回调才会刷新,所以出现手电虽然是开启的,但界面上显示是0档
行 105895: 06-27 16:24:51.102257 3121 4512 D TorchManagerService: onTorchModeChanged, mbTorchMode: false, mbDoSetTorchModeFalseByUs: false
行 108376: 06-27 16:24:52.499691 3121 4512 D TorchManagerService: onTorchModeChanged, mbTorchMode: true, mbDoSetTorchModeFalseByUs: false
行 108386: 06-27 16:24:52.502344 4688 4818 I SystemUi--QuickSettings: FlashlightController-->onTorchModeChanged setTorchMode=true cameraId=0
行 108406: 06-27 16:24:52.509578 3121 3121 D ScreenOffTorchHelper: onTorchModeChanged cameraId = 0 enabled = true
行 108543: 06-27 16:24:52.557953 2323 4469 I CameraService: turnOnTorchWithStrengthLevel: Torch strength for camera id 0 changed to 3 for client PID 4688
2.3 :对比正常回调流程
行 99093: 06-27 16:24:39.059095 3121 3121 D OplusScreenOffTorchHelper: onTorchModeChanged cameraId = 0 enabled = true
行 99099: 06-27 16:24:39.059484 4688 4818 I SystemUi--QuickSettings: FlashlightController-->onTorchModeChanged setTorchMode=true cameraId=0
行 99103: 06-27 16:24:39.059616 3121 4512 D TorchManagerService: onTorchModeChanged, mbTorchMode: true, mbDoSetTorchModeFalseByUs: false
行 99204: 06-27 16:24:39.085281 2323 4469 I CameraService: turnOnTorchWithStrengthLevel: Torch strength for camera id 0 changed to 4 for client PID 4688
行 99207: 06-27 16:24:39.086153 4688 4818 I SystemUi--QuickSettings: FlashlightController-->onTorchStrengthLevelChanged newStrengthLevel=4 cameraId0
2.4 :回调差异
对比日志发现,手电筒调节的回调函数是turnOnTorchWithStrengthLevel,而CameraService回调了,但SystemUi没有回调。
2.5 :分析camx hal
由于回调没收到,一般的底层的问题,我们还是先看下。
cpp//正常日志 行 102052: 06-27 16:24:41.030527 1696 3028 E CamX : [ERROR][SENSOR ] camxflash.cpp:259 GetTorchCurrentEstimate() Torch - Normal/Video Ledcurrent (100, 100)mA 行 102053: 06-27 16:24:41.030588 1696 3028 V CamX : [ VERB][UNKNOWN] camxflash.cpp:1761 FirePMIC() SENSOR_FLASH_DEBUG: Flash[0] Fire ReqId=3 Operation=1 LEDs=2 行 102054: 06-27 16:24:41.030617 1696 3028 I CamX : [CORE_CFG][SENSOR ] camxflash.cpp:1832 FirePMIC() Flash[0] Operation: Low: numberOfFlashs = 2 1:2 = 100 : 100, requestId= 3 //异常日志 行 108306: 06-27 16:24:52.489520 1696 14426 I CamX : [CORE_CFG][SENSOR ] camxflash.cpp:1483 Initialize() Flash[0] [back_pmic_flash] Acquired, pipelineId:0, hCSL: 0x910200, hFlashDevice: 0xee0101 行 108352: 06-27 16:24:52.496049 1696 3026 E CamX : [ERROR][SENSOR ] camxflash.cpp:259 GetTorchCurrentEstimate() Torch - Normal/Video Ledcurrent (110, 110)mA 行 108353: 06-27 16:24:52.496067 1696 3026 V CamX : [ VERB][UNKNOWN] camxflash.cpp:1761 FirePMIC() SENSOR_FLASH_DEBUG: Flash[0] Fire ReqId=1 Operation=1 LEDs=2 行 108354: 06-27 16:24:52.496077 1696 3026 I CamX : [CORE_CFG][SENSOR ] camxflash.cpp:1832 FirePMIC() Flash[0] Operation: Low: numberOfFlashs = 2 1:2 = 110 : 110, requestId= 1似乎也没发现什么异常日志,就多了一个Initialize初始化动作,而初始化也是上层的需要才调用底层初始化动作,除了进程启动,底层不会主动去初始化。何况CameraService回调了,但SystemUi没有回调。还是需要CameraService进程看下流程差异。
2.6 :CameraService分析没回调到SystemUi
由于framework层日志比较少,我们需要加日志或trace定位问题。
cpp行 7772: 01-03 07:17:43.347 4166 4303 D SystemUi--QuickSettings: FlavorOneFlashLightControllerExImpl-->onFlashlightLevelChanged:2 行 10823: 01-03 07:17:46.117 8792 8792 E CameraFlashlight: lgg setTorchMode: set torch mode of camera 0 to 0 行 10959: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #00 pc 000000000023d428 /system/lib64/libcameraservice.so (android::CameraProviderManager::ProviderInfo::torchModeStatusChangeInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, android::TorchModeStatus)+108) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10959: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #00 pc 000000000023d428 /system/lib64/libcameraservice.so (android::CameraProviderManager::ProviderInfo::torchModeStatusChangeInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, android::TorchModeStatus)+108) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10960: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #01 pc 0000000000257a0c /system/lib64/libcameraservice.so (android::AidlProviderInfo::AidlProviderCallbacks::torchModeStatusChange(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, aidl::android::hardware::camera::common::TorchModeStatus)+212) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10961: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #02 pc 0000000000486e4c /system/lib64/libcameraservice.so (aidl::android::hardware::camera::provider::_aidl_android_hardware_camera_provider_ICameraProviderCallback_onTransact(AIBinder*, unsigned int, AParcel const*, AParcel*) (.cfi)+900) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10962: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #03 pc 00000000000112dc /system/lib64/libbinder_ndk.so (ABBinder::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+176) (BuildId: 92da4dc65b8f8a94f002a391b1f61a12) 行 10963: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #04 pc 000000000004c85c /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+892) (BuildId: 7468f307149b84554a77b56ad0dce5df) 行 10964: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #05 pc 0000000000054220 /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+3644) (BuildId: 7468f307149b84554a77b56ad0dce5df) 行 10965: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #06 pc 00000000000749e4 /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+872) (BuildId: 7468f307149b84554a77b56ad0dce5df) 行 10966: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #07 pc 00000000000167d4 /system/lib64/libbinder_ndk.so (AIBinder_transact+1444) (BuildId: 92da4dc65b8f8a94f002a391b1f61a12) 行 10967: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #08 pc 00000000004773f4 /system/lib64/libcameraservice.so (aidl::android::hardware::camera::device::BpCameraDevice::setTorchMode(bool)+372) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10968: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #09 pc 0000000000251bf4 /system/lib64/libcameraservice.so (android::AidlProviderInfo::AidlDeviceInfo3::setTorchMode(bool)+148) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10969: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #10 pc 000000000022e4ec /system/lib64/libcameraservice.so (android::CameraProviderManager::setTorchMode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool)+548) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10970: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #11 pc 000000000021bae8 /system/lib64/libcameraservice.so (android::CameraFlashlight::setTorchMode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool)+244) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10971: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #12 pc 00000000001adb1c /system/lib64/libcameraservice.so (android::CameraService::setTorchMode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, bool, android::sp<android::IBinder> const&, android::content::AttributionSourceState const&, int)+2896) (BuildId: 7d2f4e982ab8727a32e334fbfa19087f) 行 10972: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #13 pc 0000000000044a80 /system/lib64/libcamera_client.so (android::hardware::BnCameraService::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+9764) (BuildId: 86ba904386331dc25b053f6fb7e8c201) 行 10973: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #14 pc 000000000004c85c /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+892) (BuildId: 7468f307149b84554a77b56ad0dce5df) 行 10974: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #15 pc 0000000000057820 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+488) (BuildId: 7468f307149b84554a77b56ad0dce5df) 行 10975: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #16 pc 00000000000050fc /system/bin/cameraserver (main.cfi+264) (BuildId: df4e113bd7f3f8707a096fae905308e9) 行 10976: 01-03 07:17:46.169 8792 8792 D torchModeStatusChangeInternal: #17 pc 000000000007e958 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+124) (BuildId: 1e2ae359e1948f37fcbf470b682bd691) 行 10977: 01-03 07:17:46.169 8792 8792 E CameraProviderManager: lgg Camera device device@1.1/vendor_qti/0 torch status is now AVAILABLE_OFF 行 10978: 01-03 07:17:46.169 8792 8792 E CameraProviderManager: lgg torchModeStatusChangeInternal: deviceInfo->mTorchStrengthLevel =3目前加了log和堆栈追的流程来看,Systemui会调用setTorchMode,这个里面会把默认状态(meta:ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL)赋值给上一个状态,在device的OFF的时候。这样就会导致下一次如果为等级3进行open的手电筒的时候Systemui调用turnOnTorchWithStrengthLevel,就会因带入的等级和上一次等级一样,最终导致回调函数onTorchStrengthLevelChanged走不进去。
而上层未调节,这个值变成了默认值3,而上面闪光灯流程差异多了一个Initialize初始化动作,才导致这里重置为3。我们需要查看这个默认值3的来源。
01-03 07:17:43.347 4166 4303 D SystemUi--QuickSettings: FlavorOneFlashLightControllerExImpl-->onFlashlightLevelChanged:2
01-03 07:17:46.169 8792 8792 E CameraProviderManager: lgg torchModeStatusChangeInternal: deviceInfo->mTorchStrengthLevel =3
2.7 :查看TorchStrengthLevel默认值
结合闪光灯流程分析博文,我们可以分析到默认值就是:
- static const UINT32 FlashDefaultStrengthLevel = 3;
- 通过ImageSensorModuleData::GetStaticCaps()讲pCapability->flashDefaultStrengthLevel = FlashDefaultStrengthLevel;写入静态meta,也就是默认状态(meta:ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL)。
2.8 :解决方案
根据闪光灯需求,我们将static const UINT32 FlashDefaultStrengthLevel = 3;默认值改成2即可解决当前问题。
【关注我,后续持续新增专题博文,谢谢!!!】
下一篇讲解: