已合并
pc告警修改 #20296
zhangyuhang72创建于 8月25日
pc告警修改 #20296
已合并
共 6 个文件变更+217-45
| @@ -264,7 +264,8 @@ void OH_AbilityRuntime_TypeDescriptor_Release(OH_AbilityRuntime_ModObjDispatcher | |||
| 264 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetVersion( | 264 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetVersion( |
| 265 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, char* pbstrVersion, uint32_t cMaxVersion) | 265 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, char* pbstrVersion, uint32_t cMaxVersion) |
| 266 | { | 266 | { |
| 267 | - if (pTypeDescriptor == nullptr || pbstrVersion == nullptr || cMaxVersion == 0) { | 267 | + if (pTypeDescriptor == nullptr || pbstrVersion == nullptr || cMaxVersion == 0 |
| 268 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 268 | TAG_LOGE(AAFwkTag::EXT, "GetVersion: invalid param"); | 269 | TAG_LOGE(AAFwkTag::EXT, "GetVersion: invalid param"); |
| 269 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 270 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 270 | } | 271 | } |
| @@ -280,7 +281,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetVersion( | |||
| 280 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceCount( | 281 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceCount( |
| 281 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t* pcInterfaces) | 282 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t* pcInterfaces) |
| 282 | { | 283 | { |
| 283 | - if (pTypeDescriptor == nullptr || pcInterfaces == nullptr) { | 284 | + if (pTypeDescriptor == nullptr || pcInterfaces == nullptr |
| 285 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 284 | TAG_LOGE(AAFwkTag::EXT, "GetInterfaceCount: invalid param"); | 286 | TAG_LOGE(AAFwkTag::EXT, "GetInterfaceCount: invalid param"); |
| 285 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 287 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 286 | } | 288 | } |
| @@ -295,7 +297,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceName( | |||
| 295 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t index, char* pbstrName, | 297 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t index, char* pbstrName, |
| 296 | uint32_t cMaxName) | 298 | uint32_t cMaxName) |
| 297 | { | 299 | { |
| 298 | - if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0) { | 300 | + if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0 |
| 301 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 299 | TAG_LOGE(AAFwkTag::EXT, "GetInterfaceName: invalid param"); | 302 | TAG_LOGE(AAFwkTag::EXT, "GetInterfaceName: invalid param"); |
| 300 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 303 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 301 | } | 304 | } |
| @@ -311,7 +314,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceName( | |||
| 311 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceIsCallback( | 314 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceIsCallback( |
| 312 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrName, bool* pIsCallback) | 315 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrName, bool* pIsCallback) |
| 313 | { | 316 | { |
| 314 | - if (pTypeDescriptor == nullptr || pbstrName == nullptr || pIsCallback == nullptr) { | 317 | + if (pTypeDescriptor == nullptr || pbstrName == nullptr || pIsCallback == nullptr |
| 318 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 315 | TAG_LOGE(AAFwkTag::EXT, "GetInterfaceIsCallback: invalid param"); | 319 | TAG_LOGE(AAFwkTag::EXT, "GetInterfaceIsCallback: invalid param"); |
| 316 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 320 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 317 | } | 321 | } |
| @@ -325,7 +329,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceIsCallback | |||
| 325 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMainServiceInterfaceName( | 329 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMainServiceInterfaceName( |
| 326 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, char* pbstrName, uint32_t cMaxName) | 330 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, char* pbstrName, uint32_t cMaxName) |
| 327 | { | 331 | { |
| 328 | - if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0) { | 332 | + if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0 |
| 333 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 329 | TAG_LOGE(AAFwkTag::EXT, "GetMainServiceInterfaceName: invalid param"); | 334 | TAG_LOGE(AAFwkTag::EXT, "GetMainServiceInterfaceName: invalid param"); |
| 330 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 335 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 331 | } | 336 | } |
| @@ -342,7 +347,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodCount( | |||
| 342 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, | 347 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, |
| 343 | const char* pbstrInterfaceName, uint32_t* pcMethods) | 348 | const char* pbstrInterfaceName, uint32_t* pcMethods) |
| 344 | { | 349 | { |
| 345 | - if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pcMethods == nullptr) { | 350 | + if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pcMethods == nullptr |
| 351 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 346 | TAG_LOGE(AAFwkTag::EXT, "GetMethodCount: invalid param"); | 352 | TAG_LOGE(AAFwkTag::EXT, "GetMethodCount: invalid param"); |
| 347 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 353 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 348 | } | 354 | } |
| @@ -353,7 +359,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodName( | |||
| 353 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, | 359 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, |
| 354 | const char* pbstrInterfaceName, uint32_t index, char* pbstrName, uint32_t cMaxName) | 360 | const char* pbstrInterfaceName, uint32_t index, char* pbstrName, uint32_t cMaxName) |
| 355 | { | 361 | { |
| 356 | - if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrName == nullptr || cMaxName == 0) { | 362 | + if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrName == nullptr || cMaxName == 0 |
| 363 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 357 | TAG_LOGE(AAFwkTag::EXT, "GetMethodName: invalid param"); | 364 | TAG_LOGE(AAFwkTag::EXT, "GetMethodName: invalid param"); |
| 358 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 365 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 359 | } | 366 | } |
| @@ -371,7 +378,7 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodMemberId( | |||
| 371 | const char* pbstrInterfaceName, const char* pbstrMethodName, uint32_t* pMemID) | 378 | const char* pbstrInterfaceName, const char* pbstrMethodName, uint32_t* pMemID) |
| 372 | { | 379 | { |
| 373 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr | 380 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr |
| 374 | - || pMemID == nullptr) { | 381 | + || pMemID == nullptr || pTypeDescriptor->metadataManager == nullptr) { |
| 375 | TAG_LOGE(AAFwkTag::EXT, "GetMethodMemberId: invalid param"); | 382 | TAG_LOGE(AAFwkTag::EXT, "GetMethodMemberId: invalid param"); |
| 376 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 383 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 377 | } | 384 | } |
| @@ -384,7 +391,7 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodReturnType( | |||
| 384 | OH_AbilityRuntime_ModObjDispatcher_TypeInfo* pReturnType) | 391 | OH_AbilityRuntime_ModObjDispatcher_TypeInfo* pReturnType) |
| 385 | { | 392 | { |
| 386 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr | 393 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr |
| 387 | - || pReturnType == nullptr) { | 394 | + || pReturnType == nullptr || pTypeDescriptor->metadataManager == nullptr) { |
| 388 | TAG_LOGE(AAFwkTag::EXT, "GetMethodReturnType: invalid param"); | 395 | TAG_LOGE(AAFwkTag::EXT, "GetMethodReturnType: invalid param"); |
| 389 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 396 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 390 | } | 397 | } |
| @@ -397,7 +404,7 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodParamCount( | |||
| 397 | const char* pbstrInterfaceName, const char* pbstrMethodName, uint32_t* pcParams) | 404 | const char* pbstrInterfaceName, const char* pbstrMethodName, uint32_t* pcParams) |
| 398 | { | 405 | { |
| 399 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr | 406 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr |
| 400 | - || pcParams == nullptr) { | 407 | + || pcParams == nullptr || pTypeDescriptor->metadataManager == nullptr) { |
| 401 | TAG_LOGE(AAFwkTag::EXT, "GetMethodParamCount: invalid param"); | 408 | TAG_LOGE(AAFwkTag::EXT, "GetMethodParamCount: invalid param"); |
| 402 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 409 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 403 | } | 410 | } |
| @@ -410,7 +417,7 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodParamType( | |||
| 410 | uint32_t iParamIndex, OH_AbilityRuntime_ModObjDispatcher_TypeInfo* pParamType) | 417 | uint32_t iParamIndex, OH_AbilityRuntime_ModObjDispatcher_TypeInfo* pParamType) |
| 411 | { | 418 | { |
| 412 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr | 419 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr |
| 413 | - || pParamType == nullptr) { | 420 | + || pParamType == nullptr || pTypeDescriptor->metadataManager == nullptr) { |
| 414 | TAG_LOGE(AAFwkTag::EXT, "GetMethodParamType: invalid param"); | 421 | TAG_LOGE(AAFwkTag::EXT, "GetMethodParamType: invalid param"); |
| 415 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 422 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 416 | } | 423 | } |
| @@ -424,7 +431,7 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodParamName( | |||
| 424 | uint32_t iParamIndex, char* pbstrName, uint32_t cMaxName) | 431 | uint32_t iParamIndex, char* pbstrName, uint32_t cMaxName) |
| 425 | { | 432 | { |
| 426 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr | 433 | if (pTypeDescriptor == nullptr || pbstrInterfaceName == nullptr || pbstrMethodName == nullptr |
| 427 | - || pbstrName == nullptr || cMaxName == 0) { | 434 | + || pbstrName == nullptr || cMaxName == 0 || pTypeDescriptor->metadataManager == nullptr) { |
| 428 | TAG_LOGE(AAFwkTag::EXT, "GetMethodParamName: invalid param"); | 435 | TAG_LOGE(AAFwkTag::EXT, "GetMethodParamName: invalid param"); |
| 429 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 436 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 430 | } | 437 | } |
| @@ -440,7 +447,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMethodParamName( | |||
| 440 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumCount( | 447 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumCount( |
| 441 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t* pcEnums) | 448 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t* pcEnums) |
| 442 | { | 449 | { |
| 443 | - if (pTypeDescriptor == nullptr || pcEnums == nullptr) { | 450 | + if (pTypeDescriptor == nullptr || pcEnums == nullptr |
| 451 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 444 | TAG_LOGE(AAFwkTag::EXT, "GetEnumCount: invalid param"); | 452 | TAG_LOGE(AAFwkTag::EXT, "GetEnumCount: invalid param"); |
| 445 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 453 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 446 | } | 454 | } |
| @@ -451,7 +459,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumName( | |||
| 451 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t index, char* pbstrName, | 459 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t index, char* pbstrName, |
| 452 | uint32_t cMaxName) | 460 | uint32_t cMaxName) |
| 453 | { | 461 | { |
| 454 | - if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0) { | 462 | + if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0 |
| 463 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 455 | TAG_LOGE(AAFwkTag::EXT, "GetEnumName: invalid param"); | 464 | TAG_LOGE(AAFwkTag::EXT, "GetEnumName: invalid param"); |
| 456 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 465 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 457 | } | 466 | } |
| @@ -468,7 +477,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumValueCount( | |||
| 468 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrEnumName, | 477 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrEnumName, |
| 469 | uint32_t* pcValues) | 478 | uint32_t* pcValues) |
| 470 | { | 479 | { |
| 471 | - if (pTypeDescriptor == nullptr || pbstrEnumName == nullptr || pcValues == nullptr) { | 480 | + if (pTypeDescriptor == nullptr || pbstrEnumName == nullptr || pcValues == nullptr |
| 481 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 472 | TAG_LOGE(AAFwkTag::EXT, "GetEnumValueCount: invalid param"); | 482 | TAG_LOGE(AAFwkTag::EXT, "GetEnumValueCount: invalid param"); |
| 473 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 483 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 474 | } | 484 | } |
| @@ -479,7 +489,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumValueName( | |||
| 479 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrEnumName, | 489 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrEnumName, |
| 480 | uint32_t iValueIndex, char* pbstrValueName, uint32_t cMaxName) | 490 | uint32_t iValueIndex, char* pbstrValueName, uint32_t cMaxName) |
| 481 | { | 491 | { |
| 482 | - if (pTypeDescriptor == nullptr || pbstrEnumName == nullptr || pbstrValueName == nullptr || cMaxName == 0) { | 492 | + if (pTypeDescriptor == nullptr || pbstrEnumName == nullptr || pbstrValueName == nullptr || cMaxName == 0 |
| 493 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 483 | TAG_LOGE(AAFwkTag::EXT, "GetEnumValueName: invalid param"); | 494 | TAG_LOGE(AAFwkTag::EXT, "GetEnumValueName: invalid param"); |
| 484 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 495 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 485 | } | 496 | } |
| @@ -496,7 +507,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumValue( | |||
| 496 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrEnumName, | 507 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrEnumName, |
| 497 | const char* pbstrValueName, int32_t* pValue) | 508 | const char* pbstrValueName, int32_t* pValue) |
| 498 | { | 509 | { |
| 499 | - if (pTypeDescriptor == nullptr || pbstrEnumName == nullptr || pbstrValueName == nullptr || pValue == nullptr) { | 510 | + if (pTypeDescriptor == nullptr || pbstrEnumName == nullptr || pbstrValueName == nullptr |
| 511 | + || pValue == nullptr || pTypeDescriptor->metadataManager == nullptr) { | ||
| 500 | TAG_LOGE(AAFwkTag::EXT, "GetEnumValue: invalid param"); | 512 | TAG_LOGE(AAFwkTag::EXT, "GetEnumValue: invalid param"); |
| 501 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 513 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 502 | } | 514 | } |
| @@ -506,7 +518,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumValue( | |||
| 506 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructCount( | 518 | AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructCount( |
| 507 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t* pcStructs) | 519 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t* pcStructs) |
| 508 | { | 520 | { |
| 509 | - if (pTypeDescriptor == nullptr || pcStructs == nullptr) { | 521 | + if (pTypeDescriptor == nullptr || pcStructs == nullptr |
| 522 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 510 | TAG_LOGE(AAFwkTag::EXT, "GetStructCount: invalid param"); | 523 | TAG_LOGE(AAFwkTag::EXT, "GetStructCount: invalid param"); |
| 511 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 524 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 512 | } | 525 | } |
| @@ -517,7 +530,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructName( | |||
| 517 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t index, char* pbstrName, | 530 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, uint32_t index, char* pbstrName, |
| 518 | uint32_t cMaxName) | 531 | uint32_t cMaxName) |
| 519 | { | 532 | { |
| 520 | - if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0) { | 533 | + if (pTypeDescriptor == nullptr || pbstrName == nullptr || cMaxName == 0 |
| 534 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 521 | TAG_LOGE(AAFwkTag::EXT, "GetStructName: invalid param"); | 535 | TAG_LOGE(AAFwkTag::EXT, "GetStructName: invalid param"); |
| 522 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 536 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 523 | } | 537 | } |
| @@ -534,7 +548,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructFieldCount( | |||
| 534 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrStructName, | 548 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrStructName, |
| 535 | uint32_t* pcFields) | 549 | uint32_t* pcFields) |
| 536 | { | 550 | { |
| 537 | - if (pTypeDescriptor == nullptr || pbstrStructName == nullptr || pcFields == nullptr) { | 551 | + if (pTypeDescriptor == nullptr || pbstrStructName == nullptr || pcFields == nullptr |
| 552 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 538 | TAG_LOGE(AAFwkTag::EXT, "GetStructFieldCount: invalid param"); | 553 | TAG_LOGE(AAFwkTag::EXT, "GetStructFieldCount: invalid param"); |
| 539 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 554 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 540 | } | 555 | } |
| @@ -545,7 +560,8 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructFieldName( | |||
| 545 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrStructName, | 560 | OH_AbilityRuntime_ModObjDispatcher_TypeDescriptorHandle pTypeDescriptor, const char* pbstrStructName, |
| 546 | uint32_t iFieldIndex, char* pbstrFieldName, uint32_t cMaxName) | 561 | uint32_t iFieldIndex, char* pbstrFieldName, uint32_t cMaxName) |
| 547 | { | 562 | { |
| 548 | - if (pTypeDescriptor == nullptr || pbstrStructName == nullptr || pbstrFieldName == nullptr || cMaxName == 0) { | 563 | + if (pTypeDescriptor == nullptr || pbstrStructName == nullptr || pbstrFieldName == nullptr || cMaxName == 0 |
| 564 | + || pTypeDescriptor->metadataManager == nullptr) { | ||
| 549 | TAG_LOGE(AAFwkTag::EXT, "GetStructFieldName: invalid param"); | 565 | TAG_LOGE(AAFwkTag::EXT, "GetStructFieldName: invalid param"); |
| 550 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 566 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 551 | } | 567 | } |
| @@ -563,7 +579,7 @@ AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructFieldType( | |||
| 563 | const char* pbstrFieldName, OH_AbilityRuntime_ModObjDispatcher_TypeInfo* pFieldType) | 579 | const char* pbstrFieldName, OH_AbilityRuntime_ModObjDispatcher_TypeInfo* pFieldType) |
| 564 | { | 580 | { |
| 565 | if (pTypeDescriptor == nullptr || pbstrStructName == nullptr || pbstrFieldName == nullptr || | 581 | if (pTypeDescriptor == nullptr || pbstrStructName == nullptr || pbstrFieldName == nullptr || |
| 566 | - pFieldType == nullptr) { | 582 | + pFieldType == nullptr || pTypeDescriptor->metadataManager == nullptr) { |
| 567 | TAG_LOGE(AAFwkTag::EXT, "GetStructFieldType: invalid param"); | 583 | TAG_LOGE(AAFwkTag::EXT, "GetStructFieldType: invalid param"); |
| 568 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; | 584 | return ABILITY_RUNTIME_ERROR_CODE_PARAM_INVALID; |
| 569 | } | 585 | } |
| @@ -84,6 +84,10 @@ void EtsAbilityAutoStartupCallback::Register(ani_object value) | |||
| 84 | TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null env"); | 84 | TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null env"); |
| 85 | return; | 85 | return; |
| 86 | } | 86 | } |
| 87 | + if (value == nullptr) { | ||
| 88 | + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null value"); | ||
| 89 | + return; | ||
| 90 | + } | ||
| 87 | if ((status = env->GlobalReference_Create(value, &ref)) != ANI_OK || ref == nullptr) { | 91 | if ((status = env->GlobalReference_Create(value, &ref)) != ANI_OK || ref == nullptr) { |
| 88 | TAG_LOGE(AAFwkTag::AUTO_STARTUP, "status : %{public}d or null ref", status); | 92 | TAG_LOGE(AAFwkTag::AUTO_STARTUP, "status : %{public}d or null ref", status); |
| 89 | return; | 93 | return; |
| @@ -103,8 +107,17 @@ void EtsAbilityAutoStartupCallback::Unregister(ani_object value) | |||
| 103 | TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null env"); | 107 | TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null env"); |
| 104 | return; | 108 | return; |
| 105 | } | 109 | } |
| 106 | - if (env->Reference_IsUndefined(value, &isUndefined) != ANI_OK || isUndefined) { | 110 | + if (value == nullptr) { |
| 107 | - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "invalid callback, clear all callback"); | 111 | + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null value"); |
| 112 | + return; | ||
| 113 | + } | ||
| 114 | + ani_status status = env->Reference_IsUndefined(value, &isUndefined); | ||
| 115 | + if (status != ANI_OK) { | ||
| 116 | + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Reference_IsUndefined failed: %{public}d", status); | ||
| 117 | + return; | ||
| 118 | + } | ||
| 119 | + if (isUndefined) { | ||
| 120 | + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "undefined callback, clear all callback"); | ||
| 108 | for (auto &callback : callbacks_) { | 121 | for (auto &callback : callbacks_) { |
| 109 | env->GlobalReference_Delete(callback); | 122 | env->GlobalReference_Delete(callback); |
| 110 | } | 123 | } |
| @@ -899,11 +899,11 @@ ani_object CreateKeepAliveInfoArray(ani_env *env, const std::vector<AbilityRunti | |||
| 899 | return nullptr; | 899 | return nullptr; |
| 900 | } | 900 | } |
| 901 | 901 | ||
| 902 | - ani_object arrayObj; | 902 | + ani_object arrayObj = nullptr; |
| 903 | status = env->Object_New(arrayCls, arrayCtor, &arrayObj, infos.size()); | 903 | status = env->Object_New(arrayCls, arrayCtor, &arrayObj, infos.size()); |
| 904 | if (status != ANI_OK) { | 904 | if (status != ANI_OK) { |
| 905 | TAG_LOGE(AAFwkTag::APPMGR, "Object_New array status : %{public}d", status); | 905 | TAG_LOGE(AAFwkTag::APPMGR, "Object_New array status : %{public}d", status); |
| 906 | - return arrayObj; | 906 | + return nullptr; |
| 907 | } | 907 | } |
| 908 | ani_size index = 0; | 908 | ani_size index = 0; |
| 909 | for (auto &info : infos) { | 909 | for (auto &info : infos) { |
| @@ -324,7 +324,7 @@ private: | |||
| 324 | TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); | 324 | TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); |
| 325 | errCode = ERR_NOT_OK; | 325 | errCode = ERR_NOT_OK; |
| 326 | } else { | 326 | } else { |
| 327 | - if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName)) { | 327 | + if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName) || bundleName.empty()) { |
| 328 | TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); | 328 | TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); |
| 329 | errCode = ERR_NOT_OK; | 329 | errCode = ERR_NOT_OK; |
| 330 | } | 330 | } |
| @@ -368,7 +368,7 @@ private: | |||
| 368 | TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); | 368 | TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); |
| 369 | errCode = ERR_NOT_OK; | 369 | errCode = ERR_NOT_OK; |
| 370 | } else { | 370 | } else { |
| 371 | - if (!ConvertFromJsValue(env, argv[0], bundleName)) { | 371 | + if (!ConvertFromJsValue(env, argv[0], bundleName) || bundleName.empty()) { |
| 372 | TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed"); | 372 | TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed"); |
| 373 | errCode = ERR_NOT_OK; | 373 | errCode = ERR_NOT_OK; |
| 374 | } else { | 374 | } else { |
| @@ -417,7 +417,7 @@ private: | |||
| 417 | TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); | 417 | TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); |
| 418 | errCode = ERR_NOT_OK; | 418 | errCode = ERR_NOT_OK; |
| 419 | } else { | 419 | } else { |
| 420 | - if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName)) { | 420 | + if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName) || bundleName.empty()) { |
| 421 | TAG_LOGE(AAFwkTag::APPMGR, "Parse bundleName failed"); | 421 | TAG_LOGE(AAFwkTag::APPMGR, "Parse bundleName failed"); |
| 422 | errCode = ERR_NOT_OK; | 422 | errCode = ERR_NOT_OK; |
| 423 | } | 423 | } |


🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)
🟡 异步API GetKeepAliveAppServiceExtensions在callback为空时静默返回,未向前端抛出错误
位置:
L1566-L1569| 严重程度: Medium❓ 问题描述
GetKeepAliveAppServiceExtensions是一个异步API,接受callback参数。当callback为nullptr时,代码仅打印日志并return,既未调用ani环境抛出错误,也未调用任何回调通知前端。这导致JS侧调用方既无法获得成功响应也无法获得错误信息,形成静默失败。根据OpenHarmony平台规范,面向前端的API在参数无效时应返回明确定义的错误对象而非静默返回,以避免前端出现undefined或挂起状态。
💡 修复建议
修改建议:当callback为空时,应通过EtsErrorUtil::ThrowInvalidParamError向前端抛出参数错误异常,而非静默返回,确保JS侧能收到明确的错误反馈。
1566: if (callback == nullptr) { 1567: TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr"); 1568: AbilityRuntime::EtsErrorUtil::ThrowInvalidParamError(env, "Parse param callback failed, must be a AsyncCallback."); 1569: return; 1570: }