diff --git a/interfaces/native/vibrator/src/vibrator_agent.cpp b/interfaces/native/vibrator/src/vibrator_agent.cpp old mode 100755 new mode 100644 index a491e487f57c1f1d6d2eaa67ad97b141095d4864..0188420748369b3956a0845b4e758d1412d50c00 --- a/interfaces/native/vibrator/src/vibrator_agent.cpp +++ b/interfaces/native/vibrator/src/vibrator_agent.cpp @@ -38,11 +38,11 @@ int32_t DisableLooping() int32_t StartVibrator(const char *effectId) { - if (effectId == NULL) { + if (effectId == nullptr) { HiLog::Error(LABEL, "%{public}s effectId is null", __func__); return OHOS::Sensors::ERROR; } - bool isLooping = (g_loopingFlag == 1) ? true : false; + bool isLooping = g_loopingFlag == 1; auto &client = VibratorServiceClient::GetInstance(); int32_t ret = client.Vibrate(DEFAULT_VIBRATOR_ID, effectId, isLooping); if (ret != OHOS::ERR_OK) { @@ -69,6 +69,11 @@ int32_t StartVibratorOnce(uint32_t duration) int32_t StopVibrator(const char *mode) { + if (mode == nullptr) { + HiLog::Error(LABEL, "%{public}s mode is null", __func__); + return OHOS::Sensors::ERROR; + } + if (strcmp(mode, "time") != 0 && strcmp(mode, "preset") != 0) { HiLog::Error(LABEL, "%{public}s mode is invalid, mode is %{public}s", __func__, mode); return OHOS::Sensors::ERROR; @@ -80,4 +85,4 @@ int32_t StopVibrator(const char *mode) return OHOS::Sensors::ERROR; } return OHOS::Sensors::SUCCESS; -} \ No newline at end of file +}