增加循环震动 #753 1012/6
authorhcj <1224667075@qq.com>
Wed, 25 Sep 2024 12:36:16 +0000 (20:36 +0800)
committerhcj <1224667075@qq.com>
Wed, 25 Sep 2024 12:36:16 +0000 (20:36 +0800)
code/sdk/application/wearable/fd230app/nativeui/callerlog/src/CallerLogModel.cpp

index 13cfe6e..35a0c5e 100644 (file)
@@ -37,6 +37,9 @@ static PhoneCallInfo callInfo{};
 static int g_retNum{0}; // 电话个数
 static int g_volumeLocal{0}; // 错误码返回
 osTimerId_t g_startCounting = nullptr; // 定时器
+//
+osTimerId_t g_shake = nullptr; // 循环震动定时器
+
 static constexpr uint64_t MS_ONE_SECONDS = 1000;
 static PhoneCallInfo callList[MULTI_CALL_MAX_NUME]{};
 // 电话优先级标志位
@@ -88,6 +91,19 @@ static void SetPriorityNumber()
     return;
 }
 
+
+static void DisshakeTimer()
+{
+    if (g_shake != nullptr) {
+        osStatus_t ret = osTimerDelete(g_shake);
+        if (ret != osOK) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret);
+            return;
+        }
+        g_shake = nullptr;
+    }
+}
+
 /* 关闭定时器 */
 static void DisableCallingTimer()
 {
@@ -116,15 +132,14 @@ void StatusReset(void)
     CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::callleisure);
     NotificationManager::GetInstance()->SetWatchCallStatus(false);
     CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourcePhone);
-
-    PhoneServiceScreenCtr(false);
+    DisshakeTimer();
 
     // If the call is handling in the notification, the slice is not switched
     if (!CallerLogModel::GetInstance()->GetNotifyFlag())
     {
+        PhoneServiceScreenCtr(false);
         if(NativeAbility::GetInstance().GetCurSliceId() == VIEW_INCOMING_CALL)
         {
-            //NativeAbility::GetInstance().ChangeSlice(NativeAbility::GetInstance().GetPreSliceId());
             NativeAbility::GetInstance().Back_CountSlice_make_phone();
         }
        
@@ -154,11 +169,22 @@ static void CallTimerCallbackProc(int data)
         SetText(CallerLogModel::GetInstance()->DisplayCallDuration().c_str());
 }
 
+static void snakeCallback(int data)
+{
+    if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
+    {
+        ui_api_vibrate_once_func();
+    }
+}
+
+
 static void CallTimerCallback(int data)
 {
     GraphicService::GetInstance()->PostGraphicEvent(std::bind(CallTimerCallbackProc, data));
 }
 
+
+
 /* 开启定时器 */
 static void InitCallingTimer()
 {
@@ -187,6 +213,35 @@ static void InitCallingTimer()
     }
 }
 
+static void InitshakeTimer()
+{
+    if (g_shake != nullptr) {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer already exists!!");
+        return;
+    }
+    g_shake = osTimerNew((osTimerFunc_t)snakeCallback, osTimerPeriodic, nullptr, nullptr);
+    if (g_shake == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer osTimerNew failed!!");
+        return;
+    }
+    int tick = osMs2Tick(MS_ONE_SECONDS);
+    osStatus_t retTimer = osTimerStart(g_shake, tick);
+    if (retTimer != osOK) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::CallerTimer osTimerStart failed, ret = %lx!!", retTimer);
+        if (g_shake != nullptr) {
+            retTimer = osTimerDelete(g_shake);
+            if (retTimer != osOK) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallerLogModel::osTimerDelete failed, ret = %lx!!", retTimer);
+                return;
+            }
+            g_shake = nullptr;
+        }
+        return;
+    }
+}
+
+
+
 /* 判断是否有电话,判断优先级 */
 bool FindCallListInfoAndSetPriorityNumber()
 {
@@ -518,7 +573,7 @@ void CAT1_ChangeStatusScreendisplay(int lastStatus)
 {
     // If the call is handling in the notification, the slice is not switched
     if (lastStatus != OPERATE_PHONE_ACTIVE) {
-        NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID,
+                NativeAbility::GetInstance().ChangeSlice(VIEW_INCOMING_CALL, TransitionType::TRANSITION_INVALID,
             PRIORITY_ONE);
     }
 }
@@ -562,6 +617,8 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall)
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[UsingPhoneChangeStatusCallback] operate:%d, callNUm:%d, call flow:%d",
         phoneCall->operate, GetCurrCallNum(), IsCompleteCallFlow());
 
+    DisshakeTimer();
+
     if (phoneCall->operate == OPERATE_WATCH_FINISH && GetCurrCallNum() == 0) {
         g_callOperate = OPERATE_WATCH_FINISH;
         WatchFinishHandle();
@@ -582,7 +639,10 @@ void UsingPhoneChangeStatusCallback(const PhoneCallInfo *phoneCall)
         case OPERATE_INCOMING:
             // 显示电话呼入
             {
-               IncomingHandle();
+                InitshakeTimer();
+
+                IncomingHandle();
+
             }
             break;
         case OPERATE_WAITING: