|
@@ -288,41 +288,48 @@ export default class EntryAbility extends UIAbility {
|
|
|
|
|
|
|
|
|
|
|
|
|
getHiCarStatus(){
|
|
getHiCarStatus(){
|
|
|
- if (!this.awareness){
|
|
|
|
|
- this.awareness=canIUse("SystemCapability.CarService.DistributedEngine")?smartMobilityCommon.getSmartMobilityAwareness():undefined;
|
|
|
|
|
- }
|
|
|
|
|
- console.log('enter getHiCarStatus,awareness:'+JSON.stringify(this.awareness));
|
|
|
|
|
- if(this.awareness){
|
|
|
|
|
- // this.awareness = smartMobilityCommon.getSmartMobilityAwareness();
|
|
|
|
|
- console.log('enter awareness');
|
|
|
|
|
- // 业务类型
|
|
|
|
|
- let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.HICAR];
|
|
|
|
|
- // 获取出行业务连接状态
|
|
|
|
|
- let info = this.awareness.getSmartMobilityStatus(types[0]);
|
|
|
|
|
-
|
|
|
|
|
- hilog.info(0x0000, 'getHiCarStatus info: ', JSON.stringify(info));
|
|
|
|
|
- if(info&&info.status==1){
|
|
|
|
|
- AppStorage.setOrCreate('isHiCarStatus', true);
|
|
|
|
|
- }else{
|
|
|
|
|
- AppStorage.setOrCreate('isHiCarStatus', false);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!this.awareness){
|
|
|
|
|
+ this.awareness=canIUse("SystemCapability.CarService.DistributedEngine")?smartMobilityCommon.getSmartMobilityAwareness():undefined;
|
|
|
}
|
|
}
|
|
|
|
|
+ console.log('enter getHiCarStatus,awareness:'+JSON.stringify(this.awareness));
|
|
|
|
|
+ if(this.awareness){
|
|
|
|
|
|
|
|
- // 出行连接状态回调函数
|
|
|
|
|
- const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
|
|
|
|
|
- hilog.info(0x0000, 'getHiCarStatus Received smart mobility info: ', JSON.stringify(info));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ console.log('enter awareness');
|
|
|
|
|
+ // 业务类型
|
|
|
|
|
+ let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.HICAR];
|
|
|
|
|
+ // 获取出行业务连接状态
|
|
|
|
|
+ let info = this.awareness.getSmartMobilityStatus(types[0]);
|
|
|
|
|
+
|
|
|
|
|
+ hilog.info(0x0000, 'getHiCarStatus info: ', JSON.stringify(info));
|
|
|
if(info&&info.status==1){
|
|
if(info&&info.status==1){
|
|
|
AppStorage.setOrCreate('isHiCarStatus', true);
|
|
AppStorage.setOrCreate('isHiCarStatus', true);
|
|
|
}else{
|
|
}else{
|
|
|
AppStorage.setOrCreate('isHiCarStatus', false);
|
|
AppStorage.setOrCreate('isHiCarStatus', false);
|
|
|
}
|
|
}
|
|
|
- this.sendChangeEvent()
|
|
|
|
|
- };
|
|
|
|
|
- // 注册智慧出行连接状态的监听
|
|
|
|
|
- this.awareness.on('smartMobilityStatus', types, callBack);
|
|
|
|
|
- }else{
|
|
|
|
|
- AppStorage.setOrCreate('isHiCarStatus', false);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ // 出行连接状态回调函数
|
|
|
|
|
+ const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
|
|
|
|
|
+ hilog.info(0x0000, 'getHiCarStatus Received smart mobility info: ', JSON.stringify(info));
|
|
|
|
|
+ if(info&&info.status==1){
|
|
|
|
|
+ AppStorage.setOrCreate('isHiCarStatus', true);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ AppStorage.setOrCreate('isHiCarStatus', false);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.sendChangeEvent()
|
|
|
|
|
+ };
|
|
|
|
|
+ // 注册智慧出行连接状态的监听
|
|
|
|
|
+ this.awareness.on('smartMobilityStatus', types, callBack);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ AppStorage.setOrCreate('isHiCarStatus', false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (error) {
|
|
|
|
|
+ console.error(`Failed to getHiCarStatus: ${error.code}, message: ${error.message}`);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|