From 67d75130caf90af27c186dd404a9155ed1d86df1 Mon Sep 17 00:00:00 2001 From: youshugen Date: Sat, 31 Aug 2024 17:10:03 +0800 Subject: [PATCH] fix: alarming improve Signed-off-by: youshugen --- .../entry/src/main/ets/InjectNotice/InjectNoticeUtil.ts | 4 ++-- .../zidl/src/shutdown/takeover_shutdown_callback_stub.cpp | 4 ++++ utils/param/src/sysparam.cpp | 4 ++++ utils/shell/src/power_shell_command.cpp | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/power_dialog/entry/src/main/ets/InjectNotice/InjectNoticeUtil.ts b/power_dialog/entry/src/main/ets/InjectNotice/InjectNoticeUtil.ts index e59061d3..813a481b 100644 --- a/power_dialog/entry/src/main/ets/InjectNotice/InjectNoticeUtil.ts +++ b/power_dialog/entry/src/main/ets/InjectNotice/InjectNoticeUtil.ts @@ -28,7 +28,7 @@ const LABEL: string = 'inject notice'; const EVENT_NAME: string = 'event_inject_close_notice'; export const NOTICE_ID: number = 100; -export enum InjectNoticeStaus { +export enum InjectNoticeStatus { DEFAULT = 0, OPENING = 1, SERVER_CLOSE = 2, @@ -36,7 +36,7 @@ export enum InjectNoticeStaus { }; class InjectNoticeUtil { - status: InjectNoticeStaus = InjectNoticeStaus.DEFAULT; + status: InjectNoticeStatus = InjectNoticeStatus.DEFAULT; isInit: boolean = false; removalWantAgentObj: _WantAgent = null; removalWantAgentInfo: WantAgent.WantAgentInfo = { diff --git a/services/zidl/src/shutdown/takeover_shutdown_callback_stub.cpp b/services/zidl/src/shutdown/takeover_shutdown_callback_stub.cpp index 105cd62e..a5f4b8a0 100644 --- a/services/zidl/src/shutdown/takeover_shutdown_callback_stub.cpp +++ b/services/zidl/src/shutdown/takeover_shutdown_callback_stub.cpp @@ -28,8 +28,12 @@ int TakeOverShutdownCallbackStub::OnRemoteRequest( { POWER_HILOGD(FEATURE_SHUTDOWN, "cmd=%{public}d, flags=%{public}d", code, option.GetFlags()); const int32_t DFX_DELAY_S = 10; + const int32_t INVALID_ID = 0; int32_t id = HiviewDFX::XCollie::GetInstance().SetTimer( "PowerShutdownCallback", DFX_DELAY_S, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG); + if (id <= INVALID_ID) { + POWER_HILOGE(COMP_SVC, "SetTimer failed"); + } std::u16string descripter = TakeOverShutdownCallbackStub::GetDescriptor(); std::u16string remoteDescripter = data.ReadInterfaceToken(); if (descripter != remoteDescripter) { diff --git a/utils/param/src/sysparam.cpp b/utils/param/src/sysparam.cpp index 251df9f5..bc601206 100644 --- a/utils/param/src/sysparam.cpp +++ b/utils/param/src/sysparam.cpp @@ -45,6 +45,10 @@ int32_t SysParam::GetIntValue(const std::string& key, int32_t def) return def; } int32_t intValue = def; + if (!StrToInt(TrimStr(value), intValue)) { + POWER_HILOGW(COMP_UTILS, "StrToInt failed, return default def, value=%{public}s, def=%{public}d", value, def); + return def; + } StrToInt(TrimStr(value), intValue); return intValue; } diff --git a/utils/shell/src/power_shell_command.cpp b/utils/shell/src/power_shell_command.cpp index e056e704..45f441a0 100644 --- a/utils/shell/src/power_shell_command.cpp +++ b/utils/shell/src/power_shell_command.cpp @@ -180,6 +180,12 @@ ErrCode PowerShellCommand::RunAsForceTimeOutCommand() if (!IsDeveloperMode()) { return ERR_PERMISSION_DENIED; } + auto parameterCount = argList_.size(); + constexpr size_t MIN_PARAMETER_COUNT = 1; + if (parameterCount < MIN_PARAMETER_COUNT) { + resultReceiver_.append("too few arguments \n"); + return ERR_OK; + } bool enabled = argList_[0][0] - '0'; PowerMgrClient& client = PowerMgrClient::GetInstance(); client.SetForceTimingOut(enabled); -- Gitee