已合并
pc告警修改 #20296
pc告警修改 #20296
已合并
zhangyuhang72创建于 8月25日
共 6 个文件变更+217-45
@@ -264,7 +264,8 @@ void OH_AbilityRuntime_TypeDescriptor_Release(OH_AbilityRuntime_ModObjDispatcher
264AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetVersion(264AbilityRuntime_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(
280AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceCount(281AbilityRuntime_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(
311AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetInterfaceIsCallback(314AbilityRuntime_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
325AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetMainServiceInterfaceName(329AbilityRuntime_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 == nullptr380 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 == nullptr393 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 == nullptr406 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 == nullptr419 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 == nullptr433 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(
440AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetEnumCount(447AbilityRuntime_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(
506AbilityRuntime_ErrorCode OH_AbilityRuntime_TypeDescriptor_GetStructCount(518AbilityRuntime_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 }
@@ -15,6 +15,8 @@
15 15 
16#include "ets_app_manager.h"16#include "ets_app_manager.h"
17 17 
18+#include <atomic>
19+ 
18#include "ability_business_error.h"20#include "ability_business_error.h"
19#include "ability_manager_client.h"21#include "ability_manager_client.h"
20#include "ability_manager_interface.h"22#include "ability_manager_interface.h"
@@ -148,13 +150,13 @@ private:
148 static void OnOnAbilityFirstFrameStateInner(ani_env *env, ani_object aniObserver, const std::string &strBundleName);150 static void OnOnAbilityFirstFrameStateInner(ani_env *env, ani_object aniObserver, const std::string &strBundleName);
149 static void OnOffInner(ani_env *env, ani_int etsObserverId, ani_object callback);151 static void OnOffInner(ani_env *env, ani_int etsObserverId, ani_object callback);
150 static int32_t GetObserverId();152 static int32_t GetObserverId();
151- static int32_t serialNumber_;153+ static std::atomic<int32_t> serialNumber_;
152 static sptr<AbilityRuntime::EtsAppStateObserver> appStateObserver_;154 static sptr<AbilityRuntime::EtsAppStateObserver> appStateObserver_;
153 static sptr<OHOS::AbilityRuntime::ETSAppForegroundStateObserver> observerForeground_;155 static sptr<OHOS::AbilityRuntime::ETSAppForegroundStateObserver> observerForeground_;
154 static std::mutex appStateObserverLock_;156 static std::mutex appStateObserverLock_;
155};157};
156 158 
157-int32_t EtsAppManager::serialNumber_ = 0;159+std::atomic<int32_t> EtsAppManager::serialNumber_(0);
158sptr<AbilityRuntime::EtsAppStateObserver> EtsAppManager::appStateObserver_ = nullptr;160sptr<AbilityRuntime::EtsAppStateObserver> EtsAppManager::appStateObserver_ = nullptr;
159sptr<OHOS::AbilityRuntime::ETSAppForegroundStateObserver> EtsAppManager::observerForeground_ = nullptr;161sptr<OHOS::AbilityRuntime::ETSAppForegroundStateObserver> EtsAppManager::observerForeground_ = nullptr;
160std::mutex EtsAppManager::appStateObserverLock_;162std::mutex EtsAppManager::appStateObserverLock_;
@@ -192,6 +194,10 @@ void EtsAppManager::PreloadApplication(ani_env *env, ani_object callback, ani_st
192 TAG_LOGE(AAFwkTag::APPMGR, "env is null");194 TAG_LOGE(AAFwkTag::APPMGR, "env is null");
193 return;195 return;
194 }196 }
197+ if (callback == nullptr) {
198+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
199+ return;
200+ }
195 std::string bundleName;201 std::string bundleName;
196 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName)) {202 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName)) {
197 TAG_LOGE(AAFwkTag::APPMGR, "param bundlename err");203 TAG_LOGE(AAFwkTag::APPMGR, "param bundlename err");
@@ -251,6 +257,10 @@ void EtsAppManager::GetRunningProcessInformation(ani_env *env, ani_object callba
251 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");257 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
252 return;258 return;
253 }259 }
260+ if (callback == nullptr) {
261+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
262+ return;
263+ }
254 ani_object emptyArray = CreateEmptyAniArray(env);264 ani_object emptyArray = CreateEmptyAniArray(env);
255 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();265 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
256 if (appMgr == nullptr) {266 if (appMgr == nullptr) {
@@ -287,6 +297,10 @@ void EtsAppManager::GetForegroundApplications(ani_env *env, ani_object callback)
287 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");297 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
288 return;298 return;
289 }299 }
300+ if (callback == nullptr) {
301+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
302+ return;
303+ }
290 ani_object emptyArray = CreateEmptyAniArray(env);304 ani_object emptyArray = CreateEmptyAniArray(env);
291 auto appManager = GetAppManagerInstance();305 auto appManager = GetAppManagerInstance();
292 if (appManager == nullptr) {306 if (appManager == nullptr) {
@@ -348,6 +362,10 @@ void EtsAppManager::GetRunningMultiAppInfo(ani_env *env, ani_string aniBundleNam
348 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");362 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
349 return;363 return;
350 }364 }
365+ if (callback == nullptr) {
366+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
367+ return;
368+ }
351 ani_object emptyMultiAppInfo = CreateEmptyMultiAppInfo(env);369 ani_object emptyMultiAppInfo = CreateEmptyMultiAppInfo(env);
352#ifdef SUPPORT_SCREEN370#ifdef SUPPORT_SCREEN
353 if (!AppExecFwk::CheckCallerIsSystemApp()) {371 if (!AppExecFwk::CheckCallerIsSystemApp()) {
@@ -397,6 +415,10 @@ void EtsAppManager::GetRunningProcessInfoByBundleNameAndUserId(
397 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");415 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
398 return;416 return;
399 }417 }
418+ if (callback == nullptr) {
419+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
420+ return;
421+ }
400 ani_object emptyArray = CreateEmptyAniArray(env);422 ani_object emptyArray = CreateEmptyAniArray(env);
401 if (aniBundleName == nullptr) {423 if (aniBundleName == nullptr) {
402 TAG_LOGE(AAFwkTag::APPMGR, "aniBundleName null ptr");424 TAG_LOGE(AAFwkTag::APPMGR, "aniBundleName null ptr");
@@ -444,17 +466,24 @@ void EtsAppManager::GetRunningProcessInfoByBundleNameAndUserId(
444 466 
445void EtsAppManager::GetRunningProcessInfoByBundleName(ani_env *env, ani_string aniBundleName, ani_object callback)467void EtsAppManager::GetRunningProcessInfoByBundleName(ani_env *env, ani_string aniBundleName, ani_object callback)
446{468{
469+ if (env == nullptr) {
470+ TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
471+ return;
472+ }
473+ if (callback == nullptr) {
474+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
475+ return;
476+ }
447 int userId = IPCSkeleton::GetCallingUid() / AppExecFwk::Constants::BASE_USER_RANGE;477 int userId = IPCSkeleton::GetCallingUid() / AppExecFwk::Constants::BASE_USER_RANGE;
448 GetRunningProcessInfoByBundleNameAndUserId(env, aniBundleName, userId, callback);478 GetRunningProcessInfoByBundleNameAndUserId(env, aniBundleName, userId, callback);
449}479}
450 480 
451int32_t EtsAppManager::GetObserverId()481int32_t EtsAppManager::GetObserverId()
452{482{
453- int32_t observerId = serialNumber_;483+ int32_t observerId = serialNumber_.load(std::memory_order_relaxed);
454- if (serialNumber_ < INT32_MAX) {484+ int32_t next = (observerId < INT32_MAX) ? observerId + 1 : 0;
455- serialNumber_++;485+ while (!serialNumber_.compare_exchange_weak(observerId, next, std::memory_order_relaxed)) {
456- } else {486+ next = (observerId < INT32_MAX) ? observerId + 1 : 0;
457- serialNumber_ = 0;
458 }487 }
459 return observerId;488 return observerId;
460}489}
@@ -664,6 +693,10 @@ void EtsAppManager::OnOff(ani_env *env, ani_string type, ani_int etsObserverId,
664 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");693 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
665 return;694 return;
666 }695 }
696+ if (callback == nullptr) {
697+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
698+ return;
699+ }
667 std::string strType;700 std::string strType;
668 if (!AppExecFwk::GetStdString(env, type, strType) || strType != ON_OFF_TYPE) {701 if (!AppExecFwk::GetStdString(env, type, strType) || strType != ON_OFF_TYPE) {
669 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString failed");702 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString failed");
@@ -685,6 +718,14 @@ void EtsAppManager::OnOff(ani_env *env, ani_string type, ani_int etsObserverId,
685 718 
686void EtsAppManager::OnOffInner(ani_env *env, ani_int etsObserverId, ani_object callback)719void EtsAppManager::OnOffInner(ani_env *env, ani_int etsObserverId, ani_object callback)
687{720{
721+ if (env == nullptr) {
722+ TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
723+ return;
724+ }
725+ if (callback == nullptr) {
726+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
727+ return;
728+ }
688 int32_t observerId = static_cast<int32_t>(etsObserverId);729 int32_t observerId = static_cast<int32_t>(etsObserverId);
689 if (!appStateObserver_->FindObserverByObserverId(observerId)) {730 if (!appStateObserver_->FindObserverByObserverId(observerId)) {
690 TAG_LOGE(AAFwkTag::APPMGR, "not find observer:%{public}d", static_cast<int32_t>(observerId));731 TAG_LOGE(AAFwkTag::APPMGR, "not find observer:%{public}d", static_cast<int32_t>(observerId));
@@ -729,6 +770,10 @@ void EtsAppManager::GetAppMemorySize(ani_env *env, ani_object callback)
729 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");770 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
730 return;771 return;
731 }772 }
773+ if (callback == nullptr) {
774+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
775+ return;
776+ }
732 auto abilityManager = GetAbilityManagerInstance();777 auto abilityManager = GetAbilityManagerInstance();
733 if (abilityManager == nullptr) {778 if (abilityManager == nullptr) {
734 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");779 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");
@@ -755,6 +800,10 @@ void EtsAppManager::IsRamConstrainedDevice(ani_env *env, ani_object callback)
755 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");800 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
756 return;801 return;
757 }802 }
803+ if (callback == nullptr) {
804+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
805+ return;
806+ }
758 auto abilityManager = GetAbilityManagerInstance();807 auto abilityManager = GetAbilityManagerInstance();
759 if (abilityManager == nullptr) {808 if (abilityManager == nullptr) {
760 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");809 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");
@@ -781,6 +830,10 @@ void EtsAppManager::IsRunningInStabilityTest(ani_env *env, ani_object callback)
781 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");830 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
782 return;831 return;
783 }832 }
833+ if (callback == nullptr) {
834+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
835+ return;
836+ }
784 auto abilityManager = GetAbilityManagerInstance();837 auto abilityManager = GetAbilityManagerInstance();
785 if (abilityManager == nullptr) {838 if (abilityManager == nullptr) {
786 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");839 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");
@@ -806,6 +859,10 @@ void EtsAppManager::NativeKillProcessesByBundleNameSync(ani_env *env, ani_string
806 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");859 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
807 return;860 return;
808 }861 }
862+ if (callback == nullptr) {
863+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
864+ return;
865+ }
809 ani_ref undefined = nullptr;866 ani_ref undefined = nullptr;
810 env->GetUndefined(&undefined);867 env->GetUndefined(&undefined);
811 KillProcessesByBundleNameInner(env, callback, bundleName, false, static_cast<ani_object>(undefined));868 KillProcessesByBundleNameInner(env, callback, bundleName, false, static_cast<ani_object>(undefined));
@@ -814,6 +871,14 @@ void EtsAppManager::NativeKillProcessesByBundleNameSync(ani_env *env, ani_string
814void EtsAppManager::NativeKillProcessesByBundleName(ani_env *env, ani_object callback, ani_string bundleName,871void EtsAppManager::NativeKillProcessesByBundleName(ani_env *env, ani_object callback, ani_string bundleName,
815 ani_boolean clearPageStack, ani_object etsAppIndex)872 ani_boolean clearPageStack, ani_object etsAppIndex)
816{873{
874+ if (env == nullptr) {
875+ TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
876+ return;
877+ }
878+ if (callback == nullptr) {
879+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
880+ return;
881+ }
817 KillProcessesByBundleNameInner(env, callback, bundleName, clearPageStack, etsAppIndex);882 KillProcessesByBundleNameInner(env, callback, bundleName, clearPageStack, etsAppIndex);
818}883}
819 884 
@@ -825,6 +890,10 @@ void EtsAppManager::KillProcessesByBundleNameInner(ani_env *env, ani_object call
825 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");890 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
826 return;891 return;
827 }892 }
893+ if (callback == nullptr) {
894+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
895+ return;
896+ }
828 auto abilityManager = GetAbilityManagerInstance();897 auto abilityManager = GetAbilityManagerInstance();
829 if (abilityManager == nullptr) {898 if (abilityManager == nullptr) {
830 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");899 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");
@@ -835,7 +904,7 @@ void EtsAppManager::KillProcessesByBundleNameInner(ani_env *env, ani_object call
835 return;904 return;
836 }905 }
837 std::string bundleName;906 std::string bundleName;
838- if (!AppExecFwk::GetStdString(env, etsBundleName, bundleName)) {907+ if (!AppExecFwk::GetStdString(env, etsBundleName, bundleName) || bundleName.empty()) {
839 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString Failed");908 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString Failed");
840 AppExecFwk::AsyncCallback(env, callback,909 AppExecFwk::AsyncCallback(env, callback,
841 AbilityRuntime::EtsErrorUtil::CreateInvalidParamError(910 AbilityRuntime::EtsErrorUtil::CreateInvalidParamError(
@@ -871,6 +940,10 @@ void EtsAppManager::NativeKillProcessWithAccountSync(ani_env *env, ani_string an
871 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");940 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
872 return;941 return;
873 }942 }
943+ if (callback == nullptr) {
944+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
945+ return;
946+ }
874 ani_ref undefined = nullptr;947 ani_ref undefined = nullptr;
875 env->GetUndefined(&undefined);948 env->GetUndefined(&undefined);
876 KillProcessWithAccountInner(env, callback, aniBundleName, aniAccountId,949 KillProcessWithAccountInner(env, callback, aniBundleName, aniAccountId,
@@ -880,6 +953,14 @@ void EtsAppManager::NativeKillProcessWithAccountSync(ani_env *env, ani_string an
880void EtsAppManager::NativeKillProcessWithAccount(ani_env *env, ani_object callback, ani_string aniBundleName,953void EtsAppManager::NativeKillProcessWithAccount(ani_env *env, ani_object callback, ani_string aniBundleName,
881 ani_int aniAccountId, ani_boolean clearPageStack, ani_object aniAppIndex)954 ani_int aniAccountId, ani_boolean clearPageStack, ani_object aniAppIndex)
882{955{
956+ if (env == nullptr) {
957+ TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
958+ return;
959+ }
960+ if (callback == nullptr) {
961+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
962+ return;
963+ }
883 KillProcessWithAccountInner(env, callback, aniBundleName, aniAccountId,964 KillProcessWithAccountInner(env, callback, aniBundleName, aniAccountId,
884 clearPageStack, aniAppIndex);965 clearPageStack, aniAppIndex);
885}966}
@@ -892,6 +973,10 @@ void EtsAppManager::KillProcessWithAccountInner(ani_env *env, ani_object callbac
892 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");973 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
893 return;974 return;
894 }975 }
976+ if (callback == nullptr) {
977+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
978+ return;
979+ }
895 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();980 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
896 if (appMgr == nullptr || appMgr->GetAmsMgr() == nullptr) {981 if (appMgr == nullptr || appMgr->GetAmsMgr() == nullptr) {
897 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");982 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");
@@ -901,7 +986,7 @@ void EtsAppManager::KillProcessWithAccountInner(ani_env *env, ani_object callbac
901 return;986 return;
902 }987 }
903 std::string bundleName;988 std::string bundleName;
904- if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName)) {989+ if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {
905 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString Failed");990 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString Failed");
906 AppExecFwk::AsyncCallback(env, callback,991 AppExecFwk::AsyncCallback(env, callback,
907 AbilityRuntime::EtsErrorUtil::CreateInvalidParamError(992 AbilityRuntime::EtsErrorUtil::CreateInvalidParamError(
@@ -938,6 +1023,10 @@ void EtsAppManager::NativeGetProcessMemoryByPid(ani_env *env, ani_int aniPid, an
938 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1023 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
939 return;1024 return;
940 }1025 }
1026+ if (callback == nullptr) {
1027+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1028+ return;
1029+ }
941 TAG_LOGD(AAFwkTag::APPMGR, "NativeGetProcessMemoryByPid pid:%{public}d", aniPid);1030 TAG_LOGD(AAFwkTag::APPMGR, "NativeGetProcessMemoryByPid pid:%{public}d", aniPid);
942 1031 
943 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();1032 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
@@ -966,6 +1055,10 @@ void EtsAppManager::GetRunningProcessInformationByBundleType(
966 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1055 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
967 return;1056 return;
968 }1057 }
1058+ if (callback == nullptr) {
1059+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1060+ return;
1061+ }
969 ani_object emptyArray = CreateEmptyAniArray(env);1062 ani_object emptyArray = CreateEmptyAniArray(env);
970 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();1063 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
971 if (appMgr == nullptr) {1064 if (appMgr == nullptr) {
@@ -1012,6 +1105,10 @@ void EtsAppManager::NativeIsSharedBundleRunning(ani_env *env, ani_string aniBund
1012 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1105 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1013 return;1106 return;
1014 }1107 }
1108+ if (callback == nullptr) {
1109+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1110+ return;
1111+ }
1015 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();1112 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
1016 if (appMgr == nullptr) {1113 if (appMgr == nullptr) {
1017 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");1114 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");
@@ -1095,6 +1192,10 @@ void EtsAppManager::NativeKillProcessesInBatch(ani_env *env, ani_object pids, an
1095 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1192 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1096 return;1193 return;
1097 }1194 }
1195+ if (callback == nullptr) {
1196+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1197+ return;
1198+ }
1098 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();1199 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
1099 if (appMgr == nullptr || appMgr->GetAmsMgr() == nullptr) {1200 if (appMgr == nullptr || appMgr->GetAmsMgr() == nullptr) {
1100 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");1201 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");
@@ -1126,6 +1227,10 @@ void EtsAppManager::NativeIsAppRunning(ani_env *env, ani_object callback, ani_st
1126 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1227 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1127 return;1228 return;
1128 }1229 }
1230+ if (callback == nullptr) {
1231+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1232+ return;
1233+ }
1129 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();1234 sptr<AppExecFwk::IAppMgr> appMgr = GetAppManagerInstance();
1130 if (appMgr == nullptr) {1235 if (appMgr == nullptr) {
1131 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");1236 TAG_LOGE(AAFwkTag::APPMGR, "appManager null ptr");
@@ -1181,6 +1286,10 @@ void EtsAppManager::NativeSetKeepAliveForBundle(ani_env *env, ani_string aniBund
1181 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1286 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1182 return;1287 return;
1183 }1288 }
1289+ if (callback == nullptr) {
1290+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1291+ return;
1292+ }
1184 auto abilityManager = GetAbilityManagerInstance();1293 auto abilityManager = GetAbilityManagerInstance();
1185 if (abilityManager == nullptr) {1294 if (abilityManager == nullptr) {
1186 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");1295 TAG_LOGE(AAFwkTag::APPMGR, "abilityManager null ptr");
@@ -1212,6 +1321,10 @@ void EtsAppManager::NativeGetKeepAliveBundles(ani_env *env, ani_object callback,
1212 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1321 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1213 return;1322 return;
1214 }1323 }
1324+ if (callback == nullptr) {
1325+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1326+ return;
1327+ }
1215 ani_object emptyArray = CreateEmptyAniArray(env);1328 ani_object emptyArray = CreateEmptyAniArray(env);
1216 auto abilityManager = GetAbilityManagerInstance();1329 auto abilityManager = GetAbilityManagerInstance();
1217 if (abilityManager == nullptr) {1330 if (abilityManager == nullptr) {
@@ -1323,10 +1436,10 @@ void EtsAppManager::OnOnAbilityFirstFrameState(
1323 }1436 }
1324 std::string strType;1437 std::string strType;
1325 if (!OHOS::AppExecFwk::GetStdString(env, type, strType)1438 if (!OHOS::AppExecFwk::GetStdString(env, type, strType)
1326- && strType != ON_OFF_TYPE_ABILITY_FIRST_FRAME_STATE) {1439+ || strType != ON_OFF_TYPE_ABILITY_FIRST_FRAME_STATE) {
1327 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString failed");1440 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString failed");
1328 AbilityRuntime::EtsErrorUtil::ThrowInvalidParamError(env,1441 AbilityRuntime::EtsErrorUtil::ThrowInvalidParamError(env,
1329- "Parse param observer failed, must be a AbilityFirstFrameStateObserver.");1442+ "Parse param type failed, must be abilityFirstFrameState.");
1330 return;1443 return;
1331 }1444 }
1332 ani_status status = ANI_OK;1445 ani_status status = ANI_OK;
@@ -1416,17 +1529,17 @@ void EtsAppManager::OnOffAbilityFirstFrameState(ani_env *env, ani_string type, a
1416 }1529 }
1417 ani_vm *aniVM = nullptr;1530 ani_vm *aniVM = nullptr;
1418 if (env->GetVM(&aniVM) != ANI_OK) {1531 if (env->GetVM(&aniVM) != ANI_OK) {
1419- TAG_LOGE(AAFwkTag::UI_EXT, "get aniVM failed");1532+ TAG_LOGE(AAFwkTag::APPMGR, "get aniVM failed");
1420 EtsErrorUtil::ThrowError(env, EtsErrorUtil::CreateErrorByNativeErr(env, static_cast<int32_t>(1533 EtsErrorUtil::ThrowError(env, EtsErrorUtil::CreateErrorByNativeErr(env, static_cast<int32_t>(
1421 AbilityErrorCode::ERROR_CODE_INNER), "", GetInnerErrorMsg(AbilityInnerErrorMsg::OPERATION_FAILED)));1534 AbilityErrorCode::ERROR_CODE_INNER), "", GetInnerErrorMsg(AbilityInnerErrorMsg::OPERATION_FAILED)));
1422 return;1535 return;
1423 }1536 }
1424 std::string strType;1537 std::string strType;
1425 if (!OHOS::AppExecFwk::GetStdString(env, type, strType)1538 if (!OHOS::AppExecFwk::GetStdString(env, type, strType)
1426- && strType != ON_OFF_TYPE_ABILITY_FIRST_FRAME_STATE) {1539+ || strType != ON_OFF_TYPE_ABILITY_FIRST_FRAME_STATE) {
1427 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString failed");1540 TAG_LOGE(AAFwkTag::APPMGR, "GetStdString failed");
1428 AbilityRuntime::EtsErrorUtil::ThrowInvalidParamError(env,1541 AbilityRuntime::EtsErrorUtil::ThrowInvalidParamError(env,
1429- "Parse param observer failed, must be a AbilityFirstFrameStateObserver.");1542+ "Parse param type failed, must be abilityFirstFrameState.");
1430 return;1543 return;
1431 }1544 }
1432 ani_status status = ANI_OK;1545 ani_status status = ANI_OK;
@@ -1525,6 +1638,10 @@ void EtsAppManager::ClearUpApplicationData(ani_env *env, ani_string aniBundleNam
1525 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1638 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1526 return;1639 return;
1527 }1640 }
1641+ if (callback == nullptr) {
1642+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1643+ return;
1644+ }
1528 std::string bundleName;1645 std::string bundleName;
1529 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {1646 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {
1530 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");1647 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");
@@ -1562,6 +1679,10 @@ void EtsAppManager::GetKeepAliveAppServiceExtensions(ani_env *env, ani_object ca
1562 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1679 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1563 return;1680 return;
1564 }1681 }
1682+ if (callback == nullptr) {
A
Aafwk_helper8月25日

🤖 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: }


likedislike
1683+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1684+ return;
1685+ }
1565 ani_object emptyArray = CreateEmptyAniArray(env);1686 ani_object emptyArray = CreateEmptyAniArray(env);
1566 int32_t innerErrCode = static_cast<int32_t>(ERR_OK);1687 int32_t innerErrCode = static_cast<int32_t>(ERR_OK);
1567 auto infoList = std::make_shared<std::vector<AbilityRuntime::KeepAliveInfo>>();1688 auto infoList = std::make_shared<std::vector<AbilityRuntime::KeepAliveInfo>>();
@@ -1610,6 +1731,10 @@ void EtsAppManager::SetKeepAliveForAppServiceExtension(ani_env *env, ani_string
1610 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1731 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1611 return;1732 return;
1612 }1733 }
1734+ if (callback == nullptr) {
1735+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1736+ return;
1737+ }
1613 std::string bundleName;1738 std::string bundleName;
1614 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {1739 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {
1615 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");1740 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");
@@ -1657,6 +1782,10 @@ void EtsAppManager::ClearUpAppData(ani_env *env, ani_object callback, ani_string
1657 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1782 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1658 return;1783 return;
1659 }1784 }
1785+ if (callback == nullptr) {
1786+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1787+ return;
1788+ }
1660 std::string bundleName;1789 std::string bundleName;
1661 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {1790 if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {
1662 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");1791 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");
@@ -1704,6 +1833,10 @@ void EtsAppManager::TerminateMission(ani_env *env, ani_int missionId, ani_object
1704 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1833 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1705 return;1834 return;
1706 }1835 }
1836+ if (callback == nullptr) {
A
Aafwk_helper8月25日

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟡 异步API TerminateMission在callback为空时静默返回,未向前端抛出错误

位置: L1712-L1715 | 严重程度: Medium

❓ 问题描述

TerminateMission是一个异步API,接受callback参数用于通知执行结果。当callback为nullptr时,代码仅打印日志并return,未通过ani环境向前端抛出错误异常。这导致JS侧调用方无法得知操作状态,形成静默失败。同文件中OnOffAbilityFirstFrameState等函数在参数无效时会调用ThrowInvalidParamError抛出错误,此处应保持一致的错误处理策略。

💡 修复建议

修改建议:当callback为空时,应通过EtsErrorUtil::ThrowInvalidParamError向前端抛出参数错误异常,与同文件中其他异步API的错误处理模式保持一致。

1712: if (callback == nullptr) { 1713: TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr"); 1714: AbilityRuntime::EtsErrorUtil::ThrowInvalidParamError(env, "Parse param callback failed, must be a AsyncCallback."); 1715: return; 1716: }


likedislike
1837+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1838+ return;
1839+ }
1707 TAG_LOGD(AAFwkTag::APPMGR, "missionId:%{public}d", missionId);1840 TAG_LOGD(AAFwkTag::APPMGR, "missionId:%{public}d", missionId);
1708 auto amsClient = AAFwk::AbilityManagerClient::GetInstance();1841 auto amsClient = AAFwk::AbilityManagerClient::GetInstance();
1709 if (amsClient == nullptr) {1842 if (amsClient == nullptr) {
@@ -1732,8 +1865,12 @@ void EtsAppManager::IsApplicationRunning(ani_env *env, ani_string aniBundleName,
1732 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");1865 TAG_LOGE(AAFwkTag::APPMGR, "env null ptr");
1733 return;1866 return;
1734 }1867 }
1868+ if (callback == nullptr) {
1869+ TAG_LOGE(AAFwkTag::APPMGR, "callback null ptr");
1870+ return;
1871+ }
1735 std::string bundleName;1872 std::string bundleName;
1736- if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName)) {1873+ if (!AppExecFwk::GetStdString(env, aniBundleName, bundleName) || bundleName.empty()) {
1737 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");1874 TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed");
1738 AppExecFwk::AsyncCallback(env, callback,1875 AppExecFwk::AsyncCallback(env, callback,
1739 AbilityRuntime::EtsErrorUtil::CreateInvalidParamError(1876 AbilityRuntime::EtsErrorUtil::CreateInvalidParamError(
@@ -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 }
@@ -1014,7 +1014,13 @@ void AppRunningManager::TerminateAbility(const sptr<IRemoteObject> &token, bool
1014 appRecord->TerminateAbility(token, false);1014 appRecord->TerminateAbility(token, false);
1015 }1015 }
1016#endif //SUPPORT_SCREEN1016#endif //SUPPORT_SCREEN
1017- auto isLauncherApp = appRecord->GetApplicationInfo()->isLauncherApp;1017+ auto appInfo = appRecord->GetApplicationInfo();
A
Aafwk_helper8月25日

🤖 AI 代码检视意见(回复本评论可解决检视意见,点击被检视代码行左侧的小头像可收起检视意见)


🟡 GetApplicationInfo返回空时直接return,可能中断TerminateAbility后续清理流程

位置: L1017-L1022 | 严重程度: Medium

❓ 问题描述

修复正确地增加了对GetApplicationInfo()返回值的空指针检查,防止了崩溃。但在TerminateAbility函数上下文中,当appInfo为空时直接return会导致后续的isKeepAliveApp判断和清理逻辑被完全跳过,可能造成应用记录状态不一致(如Ability已被TerminateAbility调用终止,但应用级别的清理逻辑未执行)。应考虑在空指针情况下是否需要执行降级的清理逻辑或至少记录足够的状态信息。

💡 修复建议

修改建议:在appInfo为空时,除打印日志外,应考虑继续执行不依赖appInfo的后续清理逻辑,或在日志中记录appRecord的关键信息以便排查为何ApplicationInfo为空。

1017: auto appInfo = appRecord->GetApplicationInfo(); 1018: if (appInfo == nullptr) { 1019: TAG_LOGE(AAFwkTag::APPMGR, "null applicationInfo, appRecord uid:%{public}d", appRecord->GetUid()); 1020: return; 1021: } 1022: auto isLauncherApp = appInfo->isLauncherApp;


likedislike
1018+ if (appInfo == nullptr) {
1019+ TAG_LOGE(AAFwkTag::APPMGR, "null applicationInfo, bundle:%{public}s recordId:%{public}d",
1020+ appRecord->GetBundleName().c_str(), appRecord->GetRecordId());
1021+ return;
1022+ }
1023+ auto isLauncherApp = appInfo->isLauncherApp;
1018 auto isKeepAliveApp = appRecord->IsKeepAliveApp();1024 auto isKeepAliveApp = appRecord->IsKeepAliveApp();
1019 TAG_LOGI(AAFwkTag::PROCESSMGR, "term isLast:%{public}d,%{public}d alive:%{public}d",1025 TAG_LOGI(AAFwkTag::PROCESSMGR, "term isLast:%{public}d,%{public}d alive:%{public}d",
1020 isLastAbility, isLastAgentAbility, isKeepAliveApp);1026 isLastAbility, isLastAgentAbility, isKeepAliveApp);