Browse Source

hicar onDestroy 的try catch处理

onecold 11 months ago
parent
commit
284fb334bb

+ 14 - 9
entry/src/main/ets/entryability/EntryAbility.ets

@@ -172,17 +172,22 @@ export default class EntryAbility extends UIAbility {
     }
 
     onDestroy() {
+        try {
         hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
-        if(this.awareness){
-            let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.CAR_HOP];
-            // 出行连接状态回调函数
-            const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
-                hilog.info(0x0000, 'Received smart mobility info: ', JSON.stringify(info));
-            };
-            // 解注册智慧出行连接状态的监听 示例2
-            this.awareness.off('smartMobilityStatus', types, callBack);
-        }
+            if(this.awareness){
+                let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.CAR_HOP];
+                // 出行连接状态回调函数
+                const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
+                    hilog.info(0x0000, 'Received smart mobility info: ', JSON.stringify(info));
+                };
+                // 解注册智慧出行连接状态的监听 示例2
+                this.awareness.off('smartMobilityStatus', types, callBack);
+            }
+        }catch (error) {
+            console.error(`Failed to getHiCarStatus: ${error.code}, message: ${error.message}`);
+
         }
+    }
 
 
     onWindowStageCreate(windowStage: window.WindowStage) {

+ 2 - 3
entry/src/main/ets/view/LocalMusic.ets

@@ -4927,7 +4927,6 @@ export struct LocalMusic {
               .margin({ right: 5, left: 12 })
               .onClick(async () => {
                 if (PreferencesUtil.getStringSync('COVER_API',  '') === '') {
-                  this.isShowMoreView  = false;
                   this.showTipsDialog();
                   return; // Return empty string when no API is configured
                 }
@@ -9127,9 +9126,9 @@ export struct LocalMusic {
             // }else{
             //   this.isShowEdit = false
             // }
-
+            this.isShowMoreView  = false;
             this.isShowPlay = false
-            this.mType = 3
+            this.mType = 4
 
 
             // router.pushUrl({