update callui and mobiledatasettings

Signed-off-by: 18518779689 <litingting84@huawei.com>
This commit is contained in:
18518779689 2023-03-20 17:28:42 +08:00
parent d93d186314
commit 1c43d0f258
23 changed files with 384 additions and 272 deletions

View File

@ -7,7 +7,6 @@ const TAG = "MyAbilityStage";
export default class MyAbilityStage extends AbilityStage {
onCreate() {
globalThis.deviceTypeInfo = deviceInfo.deviceType;
notification.enableNotification({
bundle: "com.ohos.callui"
}, true, (err, data) => {

View File

@ -1,13 +1,16 @@
import Ability from '@ohos.app.ability.UIAbility'
import LogUtils from '../common/utils/LogUtils'
import CallManager from '../model/CallManager'
import GlobalThisHelper from '../common/utils/GlobalThisHelper'
import Constants from '../common/utils/Constants'
const TAG = "MainAbility";
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
LogUtils.i(TAG, "onCreate")
globalThis.abilityWant = want;
globalThis.calluiAbilityContext = this.context;
GlobalThisHelper.set<any>(Constants.GLOBALTHIS_ABILITY_WANT, want);
GlobalThisHelper.set<any>(Constants.GLOBALTHIS_CONTEXT, this.context);
}
onWindowStageCreate(windowStage) {
@ -40,7 +43,6 @@ export default class MainAbility extends Ability {
onDestroy() {
LogUtils.i(TAG, "onDestroy")
globalThis.callManager.clearTimer();
globalThis.callManager.unsubscribe();
CallManager.getInstance()?.clearTimer();
}
};

View File

@ -17,17 +17,17 @@
* @file: call manager service
*/
import PA from '@ohos.ability.particleAbility';
import TelephonyCall from './TelephonyApi';
import commonEvent from '@ohos.commonEvent';
import LogUtils from "../common/utils/LogUtils"
import LogUtils from "../common/utils/LogUtils";
import CallManager from '../model/CallManager'
let subscriber;
const TAG = "CallManagerService";
const CALL_BUNDLE_NAME = 'com.ohos.callui';
const ABILITY_NAME = 'com.ohos.callui.MainAbility';
const CALL_STATUS_INCOMING = 4;
const CALL_STATUS_WAITING = 5
const CALL_STATUS_WAITING = 5;
const CALL_STATUS_DIALING = 2;
const CALL_STATUS_DISCONNECTED = 6;
const CALL_STATUS_DISCONNECTING = 7;
@ -140,6 +140,16 @@ export default class CallManagerService {
}
}
/**
* service disconnected
*
* @return void
*/
public onDisconnected(): void {
this.callData.callState = CALL_STATUS_DISCONNECTED;
this.publishData(this.callData);
}
/**
* start ability
*
@ -184,18 +194,7 @@ export default class CallManagerService {
* @param { Object } callData - Object
*/
publishData(callData) {
if (globalThis.callManager !== undefined) {
globalThis.callManager.update(callData);
} else {
commonEvent.publish('callui.event.callDetailsChange', {
bundleName: 'com.ohos.callui',
isOrdered: false,
subscriberPermissions: ["ohos.permission.GET_TELEPHONY_STATE"],
data: JSON.stringify(callData)
}, (res) => {
LogUtils.i(TAG, "publishData commonEvent.publish callback res: callui.event.callDetailsChange");
});
}
CallManager.getInstance().update(callData);
}
/**

View File

@ -27,7 +27,12 @@ export default class ServiceAbility extends ServiceExtension {
callData.isEcc = want.parameters?.isEcc;
callData.conferenceState = want.parameters?.conferenceState;
this.callManagerService.getCallData(callData);
return new Stub("ServiceAbility");
return new Stub('ServiceAbility');
}
onDisconnect(): void {
LogUtils.i(TAG, 'onDisconnect callUI service');
this.callManagerService.onDisconnected();
}
onRequest(want: Want, startId: number) {

View File

@ -19,8 +19,9 @@
import CallStateConst from '../constant/CallStateConst';
import CallServiceProxy from '../../model/CallServiceProxy';
import app from '@system.app';
import LogUtils from '../utils/LogUtils';
import GlobalThisHelper from '../utils/GlobalThisHelper'
import Constants from '../utils/Constants'
const TAG = "CallList";
@ -80,7 +81,6 @@ export default struct CallList {
* @return {number} - callState
*/
private callState() {
LogUtils.i(TAG, "callState : " + this.callData.callState)
return this.callData.callState;
}
@ -93,7 +93,7 @@ export default struct CallList {
LogUtils.i(TAG, "onHangUp : " + callId);
this.mCallServiceProxy.hangUpCall(callId);
if (this.callList.length === 1) {
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.terminateSelf().then((data) => {
LogUtils.i(TAG, "onHangUp terminateSelfCallBack");
});
}

View File

@ -199,11 +199,13 @@ export default struct ContactCard {
if (this.isShowTime()) {
Row() {
Image($r("app.media.ic_public_phone_HD"))
.margin({right:4})
.width(12)
.height(12)
.opacity(0.6)
if (this.callData.callType === 1) {
Image($r("app.media.ic_public_phone_HD"))
.margin({ right: 4 })
.width(12)
.height(12)
.opacity(0.6)
}
Text(this.callTimeList[0]?.callTime)
.fontSize(14)

View File

@ -18,10 +18,11 @@ import FuncBtn from './FuncBtn';
import CallStateConst from '../constant/CallStateConst';
import CallServiceProxy from '../../model/CallServiceProxy';
import Clone from '../utils/Clone';
import ConferenceConst from '../constant/ConferenceConst';
import BtnGroupConfig from '../configs/BtnGroupConfig';
import LogUtils from '../utils/LogUtils';
import screenLock from '@ohos.screenLock'
import screenLock from '@ohos.screenLock';
import GlobalThisHelper from '../utils/GlobalThisHelper';
import Constants from '../utils/Constants';
const TAG = 'FuncBtnGroup';
const textMap =
@ -205,7 +206,7 @@ export default struct FuncBtnGroup {
}
startContactAbility(pageFlag) {
globalThis.calluiAbilityContext?.startAbility({
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.startAbility({
bundleName: 'com.ohos.contacts',
abilityName: 'com.ohos.contacts.MainAbility',
parameters: {

View File

@ -22,6 +22,8 @@ import sms from '@ohos.telephony.sms';
import resourceManager from '@ohos.resourceManager';
import prompt from '@system.prompt';
import LogUtils from '../utils/LogUtils';
import GlobalThisHelper from '../utils/GlobalThisHelper';
import Constants from '../utils/Constants';
const TAG = "IncomingCom";
const SMS_REJECTION = `${ImagePathConst.BASE_URL}ic_public_message.svg`;
@ -83,10 +85,10 @@ export default struct IncomingCom {
* @param obj
*/
private sendMessage(obj) {
let slotId = 0
let slotId = this.callData.accountId
let destinationHost = this.callData.accountNumber
let contactName = this.callData.contactName
globalThis.calluiAbilityContext?.resourceManager.getString(obj.msg.id, (err, typeName) => {
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString(obj.msg.id, (err, typeName) => {
LogUtils.i(TAG, "sendMessage");
sms.sendMessage({
slotId: slotId,
@ -97,7 +99,7 @@ export default struct IncomingCom {
return;
}
if (sendResult.result === SEND_SMS_SUCCESS) {
globalThis.calluiAbilityContext?.resourceManager.getString($r("app.string.SMS_Sent")
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString($r("app.string.SMS_Sent")
.id, (err, typeName) => {
if (err) {
return;
@ -108,7 +110,7 @@ export default struct IncomingCom {
});
})
} else {
globalThis.calluiAbilityContext?.resourceManager.getString($r("app.string.message_Failed").id, (err, typeName) => {
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString($r("app.string.message_Failed").id, (err, typeName) => {
if (err) {
return;
}

View File

@ -20,6 +20,10 @@ export class Constants {
public APP_KEY_CALLDATAMANGER_MANAGER: string = "CallDataManager";
public CALL_BUNDLE_NAME = 'com.ohos.callui';
public CALL_ABILITY_NAME = 'com.ohos.callui.MainAbility';
public GLOBALTHIS_CALLMANAGER = 'callManager';
public GLOBALTHIS_ABILITY_WANT = 'abilityWant';
public GLOBALTHIS_CONTEXT = 'calluiAbilityContext';
public GLOBALTHIS_APPINACTIVE_STATE = 'appInactiveState';
}
let mConstants = new Constants();

View File

@ -0,0 +1,35 @@
import LogUtils from '../utils/LogUtils'
const TAG = "GlobalThisHelper"
export default class GlobalThisHelper {
private static registerKeys = [
"calluiAbilityContext",
"callManager",
"aaa",
'abilityWant',
'appInactiveState'
];
public static set<T>(key: string, value: T) : T {
const element = GlobalThisHelper.registerKeys.find((ele) => ele === key);
if (element === undefined) {
LogUtils.i(TAG, "Cant't find register key: " + JSON.stringify(key))
return undefined;
}
if (!globalThis[key]) {
globalThis[key] = value;
}
LogUtils.i(TAG, "GlobalThisHelper.set succeed, key:" + JSON.stringify(key));
return globalThis[key];
}
public static get<T>(key: string): T{
if (!globalThis[key]) {
LogUtils.i(TAG, "the key is not exist, key" + JSON.stringify(key));
return undefined;
}
return (globalThis[key] as T);
}
}

View File

@ -1,26 +0,0 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LogUtils from './LogUtils'
const TAG = "SingleInstanceHelper";
export default function createOrGet<T>(objectClass: { new(): T }, storageKey: string): T {
if (!globalThis[storageKey]) {
globalThis[storageKey] = new objectClass();
LogUtils.i(TAG, "Create key of: " + JSON.stringify(storageKey));
}
return globalThis[storageKey];
}

View File

@ -21,11 +21,10 @@ import CallStateConst from '../common/constant/CallStateConst';
import ContactManager from './ContactManager';
import NotificationManager from '../model/NotificationManager';
import LogUtils from '../common/utils/LogUtils';
import getSingleInstance from '../common/utils/SingleInstanceHelper'
import GlobalThisHelper from '../common/utils/GlobalThisHelper';
import Constants from '../common/utils/Constants';
const TAG = "CallDataManager";
const CALL_DATA_MANAGER_KEY = 'AppStorage_CallDataManager';
/**
* class CallDataManager
*/
@ -37,9 +36,13 @@ export default class CallDataManager {
private mCallStateManager: CallStateManager ;
private NotificationManager;
private contactManager;
private static sCallDataManager: CallDataManager;
public static getInstance():CallDataManager {
return getSingleInstance(CallDataManager, CALL_DATA_MANAGER_KEY);
public static getInstance(): CallDataManager {
if (!CallDataManager.sCallDataManager) {
CallDataManager.sCallDataManager = new CallDataManager();
}
return CallDataManager.sCallDataManager;
}
/**
@ -71,7 +74,7 @@ export default class CallDataManager {
...callData
});
if (oldCallState != callState) {
AppStorage.Get<NotificationManager>('notificationManager').sendCapsuleNotification(callData, globalThis.appInactiveState);
AppStorage.Get<NotificationManager>('notificationManager').sendCapsuleNotification(callData, GlobalThisHelper.get<boolean>(Constants.GLOBALTHIS_APPINACTIVE_STATE));
}
} else {
this.addCallList({
@ -80,7 +83,9 @@ export default class CallDataManager {
// use setTimeout to avoid block ui show
setTimeout(() => {
this.contactManager.getContactInfo(callData)
if (this.contactManager != undefined) {
this.contactManager.getContactInfo(callData)
}
}, 0);
}
@ -101,7 +106,7 @@ export default class CallDataManager {
this.NotificationManager.cancelNotification();
AppStorage.Get<NotificationManager>('notificationManager').sendCapsuleNotification(callData, true);
AppStorage.Delete("CallTimeList");
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.terminateSelf().then((data) => {
LogUtils.i(TAG, "calluiAbility terminateSelf");
});
} else {

View File

@ -19,16 +19,15 @@
import CallDataManager from './CallDataManager';
import CallUtils from '../common/utils/CallUtils';
import Utils from '../common/utils/utils';
import commonEvent from '@ohos.commonEvent';
import CallServiceProxy from './CallServiceProxy';
import LogUtils from '../common/utils/LogUtils'
import call from '@ohos.telephony.call';
import CallStateConst from '../common/constant/CallStateConst';
import GlobalThisHelper from '../common/utils/GlobalThisHelper'
import Constants from '../common/utils/Constants'
const TAG = "CallManager";
let subscriber;
const TIMING = 1000;
const events = ['callui.event.callDetailsChange'];
/**
* class CallManager
@ -45,18 +44,27 @@ export default class CallManager {
private diffSeconds
private mTimeMeter
constructor(ctx) {
public static getInstance(): CallManager {
if (GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CALLMANAGER) === undefined) {
GlobalThisHelper.set<any>(Constants.GLOBALTHIS_CALLMANAGER, new CallManager());
}
return GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CALLMANAGER);
}
private constructor() {
this.mCallServiceProxy = CallServiceProxy.getInstance();
this.mUtils = Utils.getInstance();
this.timer = null;
this.mCallDataManager = CallDataManager.getInstance();
}
init(ctx) {
this.callData = ctx.callData;
this.timer = null;
this.ctx = ctx;
this.callTimeList = ctx.callTimeList;
this.mCallDataManager = CallDataManager.getInstance();
this.mCallDataManager.init(ctx.callData, ctx.callList, ctx.callTimeList);
this.mCallDataManager?.init(ctx.callData, ctx.callList, ctx.callTimeList);
this.openTimer();
this.sendNotificationHandle = (arg) => arg;
this.registerSubscriber();
this.initCallData();
}
@ -64,9 +72,11 @@ export default class CallManager {
* init CallData
*/
private initCallData() {
if (globalThis.abilityWant && globalThis.abilityWant.parameters && ('callState' in globalThis.abilityWant.parameters)) {
this.callData = this.getCallDataFromWant(globalThis.abilityWant.parameters);
this.update(this.callData);
if (!GlobalThisHelper.get<any>(Constants.GLOBALTHIS_ABILITY_WANT)
&& GlobalThisHelper.get<any>(Constants.GLOBALTHIS_ABILITY_WANT)?.parameters
&& ('callState' in GlobalThisHelper.get<any>(Constants.GLOBALTHIS_ABILITY_WANT)?.parameters)) {
let callData = this.getCallDataFromWant(GlobalThisHelper.get<any>(Constants.GLOBALTHIS_ABILITY_WANT).parameters);
this.update(callData);
LogUtils.i(TAG, "initCallData featureAbility.getWant :")
} else {
this.mCallServiceProxy.publish({
@ -92,51 +102,22 @@ export default class CallManager {
videoState: parameters.videoState});
}
/**
* Registered subscribers
*/
private async registerSubscriber() {
subscriber = await new Promise((resolve) => {
commonEvent.createSubscriber({
events,
publisherPermission: "ohos.permission.GET_TELEPHONY_STATE"
},
(err, data) => {
resolve(data);
}
);
});
commonEvent.subscribe(subscriber, (err, res) => {
if (err.code === 0) {
const callData = JSON.parse(res.data);
LogUtils.i(TAG, "commonEvent subscribe : %s" + JSON.stringify(subscriber))
if (callData) {
this.update(callData);
}
} else {
LogUtils.i(TAG, "commonEvent.subscribe err : %s" + JSON.stringify(err))
}
});
}
/**
* unsubscribe
*/
private unsubscribe() {
commonEvent.unsubscribe(subscriber, (err) => {
if (err.code !== 0) {
LogUtils.i(TAG, "commonEvent.unsubscribe err: %s" + JSON.stringify(err))
}
});
}
/**
* update callData callBack
*
* @param { Object } callData -Object
*/
async update(callData) {
LogUtils.i(TAG, "update calldata:")
if (this.callData != undefined && this.callData.callId === callData.callId) {
const { callState } = this.callData;
if (callState === 6) {
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.terminateSelf().then((data) => {
LogUtils.i(TAG, "calluiAbility terminateSelf because service disconnected");
});
return;
}
}
this.callData = callData;
this.mCallDataManager.update(callData);
call.formatPhoneNumber(callData.accountNumber, (err, data) => {

View File

@ -25,12 +25,10 @@
import commonEvent from '@ohos.commonEvent';
import call from '@ohos.telephony.call';
import getSingleInstance from '../common/utils/SingleInstanceHelper'
import LogUtils from '../common/utils/LogUtils';
const TAG = "CallServiceProxy";
const prefixLog = 'callUI app:@ohos.telephony.call:';
const CALL_SERVICE_PROXY_KEY = 'AppStorage_CallServiceProxy'
/**
* dial call
@ -41,8 +39,13 @@ const CALL_SERVICE_PROXY_KEY = 'AppStorage_CallServiceProxy'
* @return { Object } promise object
*/
export default class CallServiceProxy {
private static sCallServiceProxy: CallServiceProxy;
public static getInstance(): CallServiceProxy {
return getSingleInstance(CallServiceProxy, CALL_SERVICE_PROXY_KEY);
if (!CallServiceProxy.sCallServiceProxy) {
CallServiceProxy.sCallServiceProxy = new CallServiceProxy();
}
return CallServiceProxy.sCallServiceProxy;
}
/**
@ -144,24 +147,6 @@ export default class CallServiceProxy {
});
});
/**
* audio channel switch
*
* @param {number} device - device type
*
* @return {Promise} promise object
*/
public setAudioDevice = (device = 1) => new Promise((resolve, reject) => {
call.setAudioDevice(device).then((res) => {
LogUtils.i(TAG, prefixLog + "then:setAudioDevice : %s" + JSON.stringify(device))
resolve(res);
}).catch((err) => {
reject(err);
LogUtils.i(TAG, prefixLog + "catch:setAudioDevice : %s" + JSON.stringify(err))
});
});
/**
* set call mute
*/

View File

@ -19,6 +19,9 @@
import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import LogUtils from '../common/utils/LogUtils';
import CallManager from '../model/CallManager';
import GlobalThisHelper from '../common/utils/GlobalThisHelper';
import Constants from '../common/utils/Constants';
const TAG = "ContactManager";
const DBbaseUri = 'datashare:///com.ohos.contactsdataability';
@ -42,13 +45,13 @@ export default class ContactManager {
const predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo('detail_info', callData.accountNumber);
predicates.equalTo('is_deleted', 0);
const dataAbilityHelper = await dataShare.createDataShareHelper(globalThis.calluiAbilityContext, DBbaseUri);
const dataAbilityHelper = await dataShare.createDataShareHelper(GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT), DBbaseUri);
const resSet = await dataAbilityHelper.query(DBUri, predicates, columns);
LogUtils.i(TAG, "getContactInfo resSet : " + JSON.stringify(resSet.rowCount))
if (resSet.rowCount > 0) {
resSet.goToFirstRow();
callData.contactName = resSet.getString(resSet.getColumnIndex('display_name'));
globalThis.callManager.update(callData);
CallManager.getInstance().update(callData);
}
} catch (err) {
LogUtils.i(TAG, "getContactInfo catch err : %s" + JSON.stringify(err))

View File

@ -23,7 +23,7 @@ import commonEvent from '@ohos.commonEvent';
import callStateConst from '../common/constant/CallStateConst';
import LogUtils from '../common/utils/LogUtils';
import Constants from '../common/utils/Constants';
import resourceManager from '@ohos.resourceManager';
import GlobalThisHelper from '../common/utils/GlobalThisHelper';
const TAG = "NotificationManager";
const ID = 0;
@ -71,7 +71,7 @@ export default class NotificationManager {
const {START_ABILITY, SEND_COMMON_EVENT} = wantAgent.OperationType;
const wantAgentObj = await this.getWantAgent(callData, START_ABILITY);
let titleName = ' ';
let expandedName = ' '
let expandedName = ' ';
if (contactName) {
titleName = contactName;
expandedName = accountNumber;
@ -87,11 +87,11 @@ export default class NotificationManager {
callId, btnType: key
};
const wantAgentObj = await this.getWantAgent(data, SEND_COMMON_EVENT);
globalThis.calluiAbilityContext?.resourceManager.getString(textMap[key].id, (error, value) => {
GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString(textMap[key].id, (error, value) => {
if (error != null) {
LogUtils.i(TAG, "sendNotification getResourceManager getString err")
LogUtils.i(TAG, "sendNotification getResourceManager getString err");
} else {
LogUtils.i(TAG, "sendNotification getResourceManager getString value" + value)
LogUtils.i(TAG, "sendNotification getResourceManager getString value" + value);
notificationRequest.actionButtons.push({
title: value,
wantAgent: wantAgentObj

View File

@ -29,6 +29,7 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
import Constants from '../common/utils/Constants';
import CallDataManager from '../model/CallDataManager';
import MultiContactCard from '../common/components/MultiContactCard';
import GlobalThisHelper from '../common/utils/GlobalThisHelper';
const TAG = "Index";
@ -72,7 +73,7 @@ struct Index {
LogUtils.i(TAG, "aboutToAppear")
byTrace.startTrace('aboutToAppear', 0);
this.notificationManager = new NotificationManager();
globalThis.callManager = new CallManager(this)
CallManager.getInstance()?.init(this);
AppStorage.SetOrCreate<NotificationManager>('notificationManager', this.notificationManager);
this.mCallDataManager = CallDataManager.getInstance();
byTrace.finishTrace('aboutToAppear', 0);
@ -85,21 +86,21 @@ struct Index {
}
onPageShow() {
LogUtils.i(TAG, "onPageShow")
LogUtils.i(TAG, "onPageShow");
byTrace.startTrace('onPageShow', 1);
globalThis.appInactiveState = false;
GlobalThisHelper.set<boolean>(Constants.GLOBALTHIS_APPINACTIVE_STATE, false);
this.stopBackgroundRunning();
this.notificationManager.cancelNotification();
this.notificationManager.sendCapsuleNotification(this.callData, false);
this.notificationManager?.cancelNotification();
this.notificationManager?.sendCapsuleNotification(this.callData, false);
byTrace.finishTrace('onPageShow', 1);
LogUtils.i(TAG, "onPageShow end")
LogUtils.i(TAG, "onPageShow end");
}
onPageHide() {
LogUtils.i(TAG, "onPageHide")
globalThis.appInactiveState = true;
LogUtils.i(TAG, "onPageHide");
GlobalThisHelper.set<boolean>(Constants.GLOBALTHIS_APPINACTIVE_STATE, true);
this.updateNotification();
LogUtils.i(TAG, "onPageHide end")
LogUtils.i(TAG, "onPageHide end");
}
updateNotification() {
@ -108,14 +109,14 @@ struct Index {
if (this.mCallDataManager.hasAliveCall()) {
this.startBackgroundRunning();
}
this.notificationManager.sendNotification(this.callData);
this.notificationManager.sendCapsuleNotification(this.callData, true);
this.notificationManager?.sendNotification(this.callData);
this.notificationManager?.sendCapsuleNotification(this.callData, true);
}
}
aboutToDisappear() {
LogUtils.i(TAG, "aboutToDisappear")
LogUtils.i(TAG, "aboutToDisappear");
this.stopBackgroundRunning();
this.updateNotification();
this.smListener.off('change', this.isBreakpointSM);
@ -124,10 +125,10 @@ struct Index {
}
private stopBackgroundRunning() {
backgroundTaskManager.stopBackgroundRunning(globalThis.calluiAbilityContext).then(() => {
LogUtils.i(TAG, "stopBackgroundRunning succeeded")
backgroundTaskManager.stopBackgroundRunning(GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT)).then(() => {
LogUtils.i(TAG, "stopBackgroundRunning succeeded");
}).catch((err) => {
LogUtils.i(TAG, "stopBackgroundRunning failed")
LogUtils.i(TAG, "stopBackgroundRunning failed");
});
}
@ -142,7 +143,7 @@ struct Index {
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(globalThis.calluiAbilityContext,
backgroundTaskManager.startBackgroundRunning(GlobalThisHelper.get<any>(Constants.GLOBALTHIS_CONTEXT),
backgroundTaskManager.BackgroundMode.VOIP, wantAgentObj).then(() => {
LogUtils.i(TAG, "startBackgroundRunning succeeded")
}).catch((err) => {

View File

@ -15,6 +15,10 @@
{
"name": "divider_calllist",
"value": "#14FFFFFF"
},
{
"name": "button_active",
"value": "#007DFF"
}
]
}

View File

@ -49,14 +49,13 @@ export default struct HeadComponent {
Text($r('app.string.mobile_data'))
.fontSize(20)
.lineHeight(33)
.fontFamily('HarmonyHeiTi-Bold')
.fontWeight(FontWeight.Medium)
.fontColor($r('app.color.font_color_182431'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.textAlign(TextAlign.Start)
.margin({ top: 13, bottom: 15 });
.margin({ top: 15, bottom: 15 });
}
.width("100%")
.padding({ left: 12 })

View File

@ -15,7 +15,16 @@
import publiccontent from '../publiccontent'
import router from '@system.router';
import call from '@ohos.telephony.call';
import { enableCellularDataRoaming, disableCellularDataRoaming } from '../../../model/mobileDataStatus';
import {
enableCellularDataRoamingCardOne,
enableCellularDataRoamingCardTwo,
disableCellularDataRoamingCardOne,
disableCellularDataRoamingCardTwo,
enableImsSwitchCardOne,
enableImsSwitchCardTwo,
disableImsSwitchCardOne,
disableImsSwitchCardTwo
} from '../../../model/mobileDataStatus';
import { setCache } from '../../utils/KvManager';
import LogUtils from '../../utils/LogUtils'
@ -26,8 +35,8 @@ export default struct listItem {
@Prop isCard: boolean;
@Prop isBtn: boolean;
@Prop isDisabled: boolean;
@Prop LastOne: boolean;
@Prop Controlswitch: boolean;
@Prop cardType: number;
@Link controlSwitch: boolean;
@State title: any = '';
@State describe: any = '';
@Prop isSupport: boolean;
@ -37,7 +46,7 @@ export default struct listItem {
dialogTitle: string = '';
radio_state_enable5g = 'RADIO_STATE_ENABLE5G';
recordTypeDialog: CustomDialogController = new CustomDialogController({
builder: dataRomingDialog({ isCon: this.isCon, isMsg: $Controlswitch }),
builder: dataRomingDialog({ isCon: this.isCon, isMsg: $controlSwitch, cardType: this.cardType }),
alignment: DialogAlignment.Bottom,
autoCancel: false,
offset: { dx: 0, dy: -10 }
@ -71,7 +80,7 @@ export default struct listItem {
.fontSize(16)
.fontWeight(FontWeight.Medium)
.fontColor('#000')
.opacity(this.Controlswitch ? 0.9 : 0.6)
.opacity(this.controlSwitch ? 0.9 : 0.6)
.visibility(this.isSupport ? Visibility.None : Visibility.Visible)
.letterSpacing(1)
.lineHeight(22)
@ -91,7 +100,7 @@ export default struct listItem {
.margin({ right: 26 })
.onClick(() => {
LogUtils.i(TAG, "onclick clickHandle")
this.clickHandle()
this.clickHandle();
})
.enabled(this.isDisabled)
@ -99,29 +108,26 @@ export default struct listItem {
.width(16)
.height(18)
.visibility(!this.isBtn ? Visibility.Visible : Visibility.None)
Toggle({ type: ToggleType.Switch, isOn: this.Controlswitch })
Toggle({ type: ToggleType.Switch, isOn: this.controlSwitch })
.width(36)
.height(20)
.enabled(this.isDisabled)
.onChange((isOn: boolean) => {
this.Controlswitch = !this.Controlswitch;
if (this.isCon == 1) {
this.controlSwitch = !this.controlSwitch;
LogUtils.i(TAG, 'onclick cardType is :' + JSON.stringify(this.cardType) + 'switcher is:' + JSON.stringify(this.isCon) + "Switch status:" + this.controlSwitch);
if (this.isCon === 1) {
setCache(this.radio_state_enable5g, isOn);
}
if (this.Controlswitch && this.isCon == 0) {
if (this.controlSwitch && this.isCon === 0) {
this.dialogTitle = this.title;
this.recordTypeDialog.open();
} else if (this.Controlswitch == false && this.isCon == 0) {
disableCellularDataRoaming().then((data) => {
LogUtils.i(TAG, "disableCellularDataRoamingthen" + JSON.stringify(data))
}).catch((error) => {
LogUtils.i(TAG, "disableCellularDataRoamingcatch" + JSON.stringify(error))
});
} else if (this.controlSwitch == false && this.isCon === 0) {
this.cardType === 0 ? disableCellularDataRoamingCardOne() : disableCellularDataRoamingCardTwo();
}
if (this.isCon == 22 && this.Controlswitch) {
call.enableImsSwitch(0);
} else if (this.isCon == 22 && this.Controlswitch == false) {
call.disableImsSwitch(0);
if (this.isCon === 22 && this.controlSwitch) {
this.cardType === 0 ? enableImsSwitchCardOne() : enableImsSwitchCardTwo();
} else if (this.isCon === 22 && this.controlSwitch === false) {
this.cardType === 0 ? disableImsSwitchCardOne() : disableImsSwitchCardTwo();
}
})
.visibility(this.isBtn ? Visibility.Visible : Visibility.None)
@ -146,6 +152,7 @@ struct dataRomingDialog {
controller: CustomDialogController;
isCon: number;
@Link isMsg: boolean;
cardType: number;
build() {
Column() {
@ -175,6 +182,7 @@ struct dataRomingDialog {
.fontColor($r('sys.color.ohos_id_color_text_primary_activated'))
.fontSize(16)
.onClick(() => {
LogUtils.i(TAG, "dataRomingDialog onclick cancel");
this.controller.close();
this.isMsg = false;
})
@ -187,13 +195,10 @@ struct dataRomingDialog {
.fontColor($r('sys.color.ohos_id_color_text_primary_activated'))
.fontSize(16)
.onClick(() => {
LogUtils.i(TAG, "dataRomingDialog onclick confim toggletype: " + JSON.stringify(this.isCon) + " for cardtype:" + JSON.stringify(this.cardType));
this.controller.close();
this.isMsg = true;
enableCellularDataRoaming().then((data) => {
LogUtils.i(TAG, "enableCellularDataRoamingthen" + JSON.stringify(data))
}).catch((error) => {
LogUtils.i(TAG, "enableCellularDataRoamingcatch" + JSON.stringify(error))
});
this.cardType == 0 ? enableCellularDataRoamingCardOne() : enableCellularDataRoamingCardTwo();
})
}
.margin({ top: 18 })

View File

@ -27,7 +27,11 @@ const TAG = "getCellularDataRomingEnabledApi"
*
* @return {Promise}
*/
export function isCellularDataRoamingEnabled(slotId = 0) {
export function isCellularDataRoamingEnabledCardOne(slotId = 0) {
return telephonyData.isCellularDataRoamingEnabled(slotId);
}
export function isCellularDataRoamingEnabledCardTwo(slotId = 1) {
return telephonyData.isCellularDataRoamingEnabled(slotId);
}

View File

@ -14,7 +14,8 @@
*/
import telephonyData from '@ohos.telephony.data';
import radio from '@ohos.telephony.radio';
import LogUtils from '../common/utils/LogUtils'
import LogUtils from '../common/utils/LogUtils';
import call from '@ohos.telephony.call';
const TAG = "mobileDataStatus"
@ -23,9 +24,9 @@ const TAG = "mobileDataStatus"
*
* @return {Promise} promise object
*/
export function getCellularDataState() {
if (telephonyData.getCellularDataState) {
return telephonyData.getCellularDataState();
export function isCellularDataEnabled() {
if (telephonyData.isCellularDataEnabled()) {
return telephonyData.isCellularDataEnabled();
}
}
@ -84,8 +85,42 @@ export function getCellularDataRoaming(slotId = 0) {
*
* @return {Promise}
*/
export function enableCellularDataRoaming(slotId = 0) {
return telephonyData.enableCellularDataRoaming(slotId);
export function enableCellularDataRoamingCardOne(slotId = 0) {
return new Promise((resolve, reject) => {
try {
telephonyData.enableCellularDataRoaming(slotId, (error, value) => {
if (error) {
LogUtils.i(TAG, "enableCellularDataRoaming card one error :" + JSON.stringify(error));
reject(error);
} else {
LogUtils.i(TAG, "enableCellularDataRoaming card one success : then" + JSON.stringify(value));
resolve(value);
}
});
} catch (error) {
LogUtils.i(TAG, "enableCellularDataRoaming card one catch: " + JSON.stringify(error));
reject(error);
}
});
}
export function enableCellularDataRoamingCardTwo(slotId = 1) {
return new Promise((resolve, reject) => {
try {
telephonyData.enableCellularDataRoaming(slotId, (error, value) => {
if (error) {
LogUtils.i(TAG, "enableCellularDataRoaming card two error :" + JSON.stringify(error));
reject(error);
} else {
LogUtils.i(TAG, "enableCellularDataRoaming card two success :then" + JSON.stringify(value));
resolve(value);
}
});
} catch (error) {
LogUtils.i(TAG, "enableCellularDataRoaming card two catch: " + JSON.stringify(error));
reject(error);
}
});
}
/**
@ -93,6 +128,75 @@ export function enableCellularDataRoaming(slotId = 0) {
*
* @return {Promise}
*/
export function disableCellularDataRoaming(slotId = 0) {
return telephonyData.disableCellularDataRoaming(slotId);
}
export function disableCellularDataRoamingCardOne(slotId = 0) {
return new Promise((resolve, reject) => {
try {
telephonyData.disableCellularDataRoaming(slotId, (error, value) => {
if (error) {
LogUtils.i(TAG, "disableCellularDataRoaming card one error : " + JSON.stringify(error));
reject(error);
} else {
LogUtils.i(TAG, "disableCellularDataRoaming card one success : then" + JSON.stringify(value));
resolve(value);
}
});
} catch (error) {
LogUtils.i(TAG, "disableCellularDataRoaming card one catch:" + JSON.stringify(error));
reject(error);
}
});
}
export function disableCellularDataRoamingCardTwo(slotId = 1) {
return new Promise((resolve, reject) => {
try {
telephonyData.disableCellularDataRoaming(slotId, (error, value) => {
if (error) {
LogUtils.i(TAG, "disableCellularDataRoaming card two error :" + JSON.stringify(error));
reject(error);
} else {
LogUtils.i(TAG, "disableCellularDataRoaming card two success :then" + JSON.stringify(value));
resolve(value);
}
});
} catch (error) {
LogUtils.i(TAG, "disableCellularDataRoaming card two catch:" + JSON.stringify(error));
reject(error);
}
});
}
export function enableImsSwitchCardOne() {
call.enableImsSwitch(0).then((data) => {
AppStorage.SetOrCreate("imsOne", true);
LogUtils.i(TAG, "enableImsSwitch card one : success then " + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "enableImsSwitch card one : catch" + JSON.stringify(error));
});
}
export function enableImsSwitchCardTwo() {
call.enableImsSwitch(1).then((data) => {
LogUtils.i(TAG, "enableImsSwitch card two : success then " + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "enableImsSwitch card two : catch" + JSON.stringify(error));
});
}
export function disableImsSwitchCardOne() {
call.disableImsSwitch(0).then((data) => {
AppStorage.SetOrCreate("imsOne", false);
LogUtils.i(TAG, "disableImsSwitch card one : success then " + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "disableImsSwitch card one : catch" + JSON.stringify(error));
});
}
export function disableImsSwitchCardTwo() {
call.disableImsSwitch(1).then((data) => {
LogUtils.i(TAG, "disableImsSwitch card two : success then " + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "disableImsSwitch card two : catch" + JSON.stringify(error));
});
}

View File

@ -19,11 +19,12 @@
import publiccontent from '../common/components/publiccontent';
import item from '../common/components/listItem/listItem';
import call from '@ohos.telephony.call';
import { registerSimStateChange, getMaxSimCount } from '../model/registerSimStateApi'
import { registerSimStateChange, getMaxSimCount } from '../model/registerSimStateApi';
import { getSimStateCardOne, getSimStateCardTwo } from '../common/model/getSimStateApi';
import { getSimCardOnePhoneNumber, getSimCardTwoPhoneNumber } from '../common/model/getSimTelephoneNumberApi';
import {
isCellularDataRoamingEnabled,
isCellularDataRoamingEnabledCardOne,
isCellularDataRoamingEnabledCardTwo,
enableCellularDataRoaming,
disableCellularDataRoaming,
getSupportNetwork
@ -31,17 +32,16 @@ import {
import { setPreferredNetwork } from '../common/model/setPreferredNetworkApi';
import { getPreferredNetwork } from '../common/model/getPreferredNetworkModeApi';
import {
getCellularDataState,
isCellularDataEnabled,
enableCellularData,
disableCellularData,
getOperatorName
} from '../model/mobileDataStatus';
import { MOBILE_DATA_STATUS } from '../common/constant/moblieDataConst';
import HeadComponent from '../common/components/headComponent'
import { SubHeader } from '../common/components/subHeader'
import LogUtils from '../common/utils/LogUtils'
import HeadComponent from '../common/components/headComponent';
import { SubHeader } from '../common/components/subHeader';
import LogUtils from '../common/utils/LogUtils';
const TAG = "Index"
const TAG = "Index";
@Entry
@Component
@ -61,7 +61,8 @@ struct Index {
// Mobile data switch
@State isDataEnable: boolean = true;
// Data roaming switch
@State DataRoamSwitch: boolean = false;
@State dataRoamSwitchCardOne: boolean = false;
@State dataRoamSwitchCardTwo: boolean = false;
// HD call switch
@State volteSwitch: boolean = false;
// Card I status
@ -74,11 +75,13 @@ struct Index {
setCache_cun_name = 'DISTRIBUTEDDATA_CUN_NAME';
setCache_wl_name = 'SETCACHE_WL_NAME';
@State enable5g: boolean = false;
@State enableISM: boolean = false;
@StorageLink("imsOne")enableISM: boolean = false;
@State enableISM2: boolean = false;
@State TelephoneNumber: string = '';
@State TelephoneNumber2?: string = '';
@State ceshi: boolean = false;
@State cardOne: number = 0;
@State cardTwo: number = 1;
/**
* Get network mode
@ -119,6 +122,7 @@ struct Index {
this.simStateStatusCardOne = false;
}
}).catch((err) => {
this.simStateStatusCardOne = false;
LogUtils.i(TAG, 'getSimStateData Card1 :console.error() ' + JSON.stringify(err.message));
});
}
@ -128,7 +132,7 @@ struct Index {
*/
getSimStateDataCardTwo() {
getSimStateCardTwo().then((res: any) => {
LogUtils.i(TAG, "getSimState Card2 :success " + JSON.stringify(res));
LogUtils.i(TAG, "getSimState Card2 :success then" + JSON.stringify(res));
const simState = {
SIM_STATE_UNKNOWN: 0,
SIM_STATE_NOT_PRESENT: 1,
@ -143,6 +147,7 @@ struct Index {
this.simStateStatusCardTwo = false;
}
}).catch((err) => {
this.simStateStatusCardTwo = false;
LogUtils.i(TAG, 'getSimState Card2 :console.error() ' + JSON.stringify(err.message));
});
}
@ -155,7 +160,7 @@ struct Index {
this.isSupport = false;
}
}).catch((err) => {
})
});
}
/**
@ -164,7 +169,7 @@ struct Index {
getSimCardOnePhoneNumber() {
getSimCardOnePhoneNumber().then((res) => {
LogUtils.i(TAG, "getSimTelephoneNumber card1 other success" + JSON.stringify(res));
this.TelephoneNumber = res
this.TelephoneNumber = res;
}).catch((err) => {
LogUtils.i(TAG, "getSimTelephoneNumber card1 other catch" + JSON.stringify(err));
});
@ -186,30 +191,11 @@ struct Index {
* Get mobile data on or off
*/
getCellularDataState() {
getCellularDataState().then((data) => {
if (data == MOBILE_DATA_STATUS.DATA_STATE_CONNECTED) {
/**
* Gets the status of the mobile data
*/
enableCellularData().then((data) => {
LogUtils.i(TAG, "enableCellularData success" + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "enableCellularData catch" + JSON.stringify(error));
});
this.isDataEnable = true;
} else if (data == MOBILE_DATA_STATUS.DATA_STATE_DISCONNECTED || data == MOBILE_DATA_STATUS.DATA_STATE_UNKNOWN) {
this.isDataEnable = false;
/**
* Gets the status of the disableCellularData
*/
disableCellularData().then((data) => {
LogUtils.i(TAG, "disableCellularData success" + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "disableCellularData error" + JSON.stringify(error));
});
}
isCellularDataEnabled().then((data) => {
LogUtils.i(TAG, "isCellularDataEnabled success: isON:" + JSON.stringify(data));
this.isDataEnable = data;
}).catch((error) => {
LogUtils.i(TAG, "disableCellularData catch" + JSON.stringify(error));
LogUtils.i(TAG, "isCellularDataEnabled error catch" + JSON.stringify(error));
});
}
@ -223,6 +209,10 @@ struct Index {
this.getSimCardOnePhoneNumber();
this.getSimCardTwoPhoneNumber();
this.getCellularDataState();
this.isImsSwitchEnabled(0);
if (getMaxSimCount() === 2) {
this.isImsSwitchEnabled(1);
}
})
}
@ -230,15 +220,17 @@ struct Index {
call.isImsSwitchEnabled(slotId).then((res: any) => {
if (slotId) {
this.enableISM2 = res;
LogUtils.i(TAG, "isImsSwitchEnable enable 1:" + JSON.stringify(this.enableISM2));
} else {
this.enableISM = res;
LogUtils.i(TAG, "isImsSwitchEnable enable 0:" + JSON.stringify(this.enableISM));
}
})
});
}
aboutToAppear() {
LogUtils.i(TAG, "aboutToAppear")
if (getMaxSimCount() == 2) {
if (getMaxSimCount() === 2) {
this.addRegisterSimStateChange(1);
this.isImsSwitchEnabled(1);
this.getSimStateDataCardTwo();
@ -260,6 +252,10 @@ struct Index {
this.getCellularDataState();
}
onPageShow() {
this.isImsSwitchEnabled(0);
}
/**
* Set network mode
*/
@ -269,25 +265,22 @@ struct Index {
}
getCellularDataRoamingEnabled() {
isCellularDataRoamingEnabled().then((res) => {
if (!res) {
this.DataRoamSwitch = false;
disableCellularDataRoaming().then((data) => {
LogUtils.i(TAG, "disableCellularDataRoaming success: then" + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "disableCellularDataRoaming error" + JSON.stringify(error));
});
} else {
this.DataRoamSwitch = true;
enableCellularDataRoaming().then((data) => {
LogUtils.i(TAG, "enableCellularDataRoaming success: then" + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "enableCellularDataRoaming error" + JSON.stringify(error));
});
}
isCellularDataRoamingEnabledCardOne().then((res) => {
LogUtils.i(TAG,"getCellularDataRoamingEnabled card one success then:" + JSON.stringify(res));
this.dataRoamSwitchCardOne = res;
}).catch((err) => {
LogUtils.i(TAG, "enableCellularDataRoaming catch:" + JSON.stringify(err));
this.dataRoamSwitchCardOne = false;
LogUtils.i(TAG, "enableCellularDataRoaming card one catch:" + JSON.stringify(err));
});
if (getMaxSimCount() === 2) {
isCellularDataRoamingEnabledCardTwo().then((res) => {
LogUtils.i(TAG,"getCellularDataRoamingEnabled card two success then:" + JSON.stringify(res));
this.dataRoamSwitchCardTwo = res;
}).catch((err) => {
this.dataRoamSwitchCardTwo = false;
LogUtils.i(TAG, "enableCellularDataRoaming card two catch:" + JSON.stringify(err));
});
}
}
build() {
@ -331,27 +324,26 @@ struct Index {
}
.margin({ top: 2, right: 26 })
}
.opacity(this.simStateStatusCardOne ? 1 : 0.4)
.alignItems(HorizontalAlign.Start)
Toggle({ type: ToggleType.Switch, isOn: this.isDataEnable })
.width(36)
.height(20)
.enabled(this.simStateStatusCardOne)
.opacity(this.simStateStatusCardOne ? 1 : 0.4)
.enabled(this.simStateStatusCardOne || this.simStateStatusCardTwo)
.onChange((isOn: boolean) => {
this.isDataEnable = !this.isDataEnable
this.isDataEnable = !this.isDataEnable;
LogUtils.i(TAG, "mobile data switch changes enable:" + JSON.stringify(this.isDataEnable));
if (this.isDataEnable == false) {
disableCellularData().then((data) => {
LogUtils.i(TAG, "disableCellularData: then" + JSON.stringify(data))
LogUtils.i(TAG, "disableCellularData: success then" + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "disableCellularData: catch" + JSON.stringify(error))
LogUtils.i(TAG, "disableCellularData: error catch" + JSON.stringify(error));
});
} else {
enableCellularData().then((data) => {
LogUtils.i(TAG, "enableCellularData: then" + JSON.stringify(data))
LogUtils.i(TAG, "enableCellularData: success then" + JSON.stringify(data));
}).catch((error) => {
LogUtils.i(TAG, "enableCellularData: catch" + JSON.stringify(error))
LogUtils.i(TAG, "enableCellularData: error catch" + JSON.stringify(error));
});
}
})
@ -366,6 +358,7 @@ struct Index {
.width("100%")
.borderRadius(24)
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.opacity((this.simStateStatusCardOne || this.simStateStatusCardTwo) ? 1 : 0.4)
SubHeader({
titleContent: $r('app.string.mobile_data_card1'),
@ -375,8 +368,8 @@ struct Index {
Column() {
item({
isBtn: this.moisBtn,
LastOne: this.moislastone,
Controlswitch: this.DataRoamSwitch,
cardType: this.cardOne,
controlSwitch: $dataRoamSwitchCardOne,
title: $r('app.string.mobile_data_dataRoaming'),
describe: $r('app.string.mobile_data_enableDataWhileRoaming'),
isDisabled: this.simStateStatusCardOne,
@ -384,6 +377,7 @@ struct Index {
isSupport: false,
isCon: 0,
})
Divider()
.strokeWidth(0.5)
.color("#E3E3E3")
@ -392,8 +386,8 @@ struct Index {
item({
isBtn: this.gqBtn,
LastOne: this.moislastone,
Controlswitch: this.enableISM,
cardType: this.cardOne,
controlSwitch: $enableISM,
title: $r('app.string.mobile_data_volte'),
describe: $r('app.string.mobile_data_confirmation_function'),
isDisabled: this.simStateStatusCardOne,
@ -411,17 +405,19 @@ struct Index {
.width("100%")
.borderRadius(24)
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.opacity(this.simStateStatusCardOne ? 1 : 0.4)
SubHeader({
titleContent: $r('app.string.mobile_data_card2'),
subTitleContent: this.TelephoneNumber2
});
})
.visibility(getMaxSimCount() === 2 ? Visibility.Visible : Visibility.Hidden)
Column() {
item({
isBtn: this.moisBtn,
LastOne: this.moislastone,
Controlswitch: this.mobileDataDisabled2,
cardType: this.cardTwo,
controlSwitch: $mobileDataDisabled2,
title: $r('app.string.mobile_data_dataRoaming'),
describe: $r('app.string.mobile_data_enableDataWhileRoaming'),
isDisabled: this.simStateStatusCardTwo,
@ -436,8 +432,8 @@ struct Index {
.margin({ right: '2%' })
item({
isBtn: this.gqBtn,
LastOne: this.moislastone,
Controlswitch: this.enableISM2,
cardType: this.cardTwo,
controlSwitch: $enableISM2,
title: $r('app.string.mobile_data_volte'),
describe: $r('app.string.mobile_data_confirmation_function'),
isDisabled: this.simStateStatusCardTwo,
@ -461,6 +457,8 @@ struct Index {
.width("100%")
.borderRadius(24)
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.opacity(this.simStateStatusCardTwo ? 1 : 0.4)
.visibility(getMaxSimCount() === 2 ? Visibility.Visible : Visibility.Hidden)
}
.alignItems(HorizontalAlign.Start)
}