优化power、button2键,不亮屏不响应。
authorSnickerSun <snickersun@163.com>
Thu, 14 Dec 2023 13:52:13 +0000 (21:52 +0800)
committerSnickerSun <snickersun@163.com>
Thu, 14 Dec 2023 13:52:13 +0000 (21:52 +0800)
code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp

index ede223e..976e9bd 100755 (executable)
@@ -91,16 +91,20 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event)
         if (longPressFlag == 0 && pressFlag == 1) { // 短按电源键
 
 
-          if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片
+            if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片
                 // 音量+
                 CallVolumeDipSwitchControl(1);
-          }else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘
-                PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
-                NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM);
+            }else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘
+                if(mcu_pms_is_screen_on()){ //只有亮屏的时候才做界面切换
+                    PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
+                    NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM);
+                }
             } else {
-                PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
                 if (!MainViewSample::GetInstance()->IsMainView()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面
-                    NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+                    if(mcu_pms_is_screen_on()){ //只有亮屏的时候才做界面切换
+                        PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
+                        NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+                    }
                 } else {
                     //power键要进入休眠
                     if(mcu_pms_is_screen_on()){
@@ -117,14 +121,18 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event)
                 // 音量-
                 CallVolumeDipSwitchControl(0);
             } else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘
-                PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
-                NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM);
+               if(mcu_pms_is_screen_on()){ //只有亮屏的时候才做界面切换
+                    PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
+                    NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM);
+               }
             } else {
-                PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
-                if (!MainViewSample::GetInstance()->IsMainView()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面
-                    NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
-                } else {
-                    NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TRANSITION_ZOOM);
+                if(mcu_pms_is_screen_on()){ //只有亮屏的时候才做界面切换
+                   PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面
+                    if (!MainViewSample::GetInstance()->IsMainView()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面
+                        NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE);
+                    } else {
+                        NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TRANSITION_ZOOM);
+                    }
                 }
             }
         }