mirror of
https://gitee.com/openharmony/applications_call
synced 2024-11-27 00:20:46 +00:00
simcard commit
Signed-off-by: 18518779689 <litingting84@huawei.com>
This commit is contained in:
parent
6a88eb5c5e
commit
67c1e6a2f5
@ -19,6 +19,7 @@
|
||||
import LogUtils from '../utils/LogUtils';
|
||||
import callStateConst from '../constant/CallStateConst';
|
||||
import Utils from '../utils/utils'
|
||||
import CallUtils from '../utils/CallUtils'
|
||||
|
||||
const TAG = "contactCard";
|
||||
|
||||
@ -34,6 +35,8 @@ export default struct ContactCard {
|
||||
@StorageLink("CallTimeList") callTimeList: any = [];
|
||||
@StorageLink("AccountNumber") accountNumber: string = '';
|
||||
@StorageLink("IsEmergencyPhoneNumber") isEmergencyPhoneNumber: boolean = false;
|
||||
@StorageLink("hasSimCard1") hasSimCard1: boolean = false;
|
||||
@StorageLink("hasSimCard2") hasSimCard2: boolean = false;
|
||||
private mUtils: Utils;
|
||||
private timer;
|
||||
private emergency = $r('app.string.emergency');
|
||||
@ -50,6 +53,10 @@ export default struct ContactCard {
|
||||
if (this.callData.callState === 3) {
|
||||
clearInterval(this.timer)
|
||||
}
|
||||
if (this.callData.callState === 4) {
|
||||
CallUtils.hasSimeCard(0);
|
||||
CallUtils.hasSimeCard(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +66,8 @@ export default struct ContactCard {
|
||||
*/
|
||||
private isShowCard() {
|
||||
return this.callList.length === 1 || (this.callList.length > 1 && this.callList.some((v) =>
|
||||
v.callState === callStateConst.CALL_STATUS_WAITING));
|
||||
v.callState === callStateConst.
|
||||
CALL_STATUS_WAITING));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,6 +88,10 @@ export default struct ContactCard {
|
||||
return this.callState() === callStateConst.CALL_STATUS_ACTIVE && this.callList.length === 1;
|
||||
}
|
||||
|
||||
private isShowSim() {
|
||||
return this.callState() === callStateConst.CALL_STATUS_INCOMING && this.hasSimCard1 && this.hasSimCard2;
|
||||
}
|
||||
|
||||
build() {
|
||||
GridRow({ columns: { sm: 4, md: 8, lg: 12 }, gutter: 24 }) {
|
||||
GridCol({ span: { sm: 4, md: 6, lg: 6 }, offset: { md: 1, lg: 3 } }) {
|
||||
@ -178,12 +190,28 @@ export default struct ContactCard {
|
||||
.fontColor('#FFFFFF')
|
||||
}
|
||||
|
||||
if (this.isShowSim()) {
|
||||
Image(this.callData.accountId == 1 ? $r("app.media.ic_public_phone_sim2") : $r("app.media.ic_public_phone_sim1"))
|
||||
.margin({ right: 4 })
|
||||
.width(12)
|
||||
.height(12)
|
||||
.opacity(0.6)
|
||||
}
|
||||
|
||||
if (this.isShowTime()) {
|
||||
Text(this.callTimeList[0]?.callTime)
|
||||
.fontSize(14)
|
||||
.height(19)
|
||||
.lineHeight(19)
|
||||
.fontColor('#FFFFFF')
|
||||
Row() {
|
||||
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)
|
||||
.height(19)
|
||||
.lineHeight(19)
|
||||
.fontColor('#FFFFFF')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
83
entry/src/main/ets/common/utils/CallUtils.ts
Normal file
83
entry/src/main/ets/common/utils/CallUtils.ts
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Call Util
|
||||
*
|
||||
* standard:
|
||||
* 1. define TAG, recommend class name.
|
||||
* 2. switch IS_DEBUG_ON as true, when debugging.
|
||||
* 3. msg should be short and valuable.
|
||||
* 4. choose appropriate function.
|
||||
* 5. the function execute many times can not print.
|
||||
* 6. uniqueness.
|
||||
*/
|
||||
import call from '@ohos.telephony.call';
|
||||
import sim from '@ohos.telephony.sim'
|
||||
import LogUtils from './LogUtils'
|
||||
|
||||
const TAG = "CallUtils"
|
||||
|
||||
/**
|
||||
* calllog package tool class
|
||||
*/
|
||||
export class CallUtils {
|
||||
/**
|
||||
* Judge whether there is a sim card.
|
||||
*
|
||||
* @param { accountId } accountId
|
||||
*
|
||||
* @return { boolean } - return success true fail false
|
||||
*/
|
||||
public hasSimeCard = (accountId) => new Promise((resolve, reject) => {
|
||||
sim.hasSimCard(accountId).then((res) => {
|
||||
resolve(res);
|
||||
if (accountId === 0) {
|
||||
AppStorage.SetOrCreate("hasSimCard1", res);
|
||||
} else if (accountId === 1) {
|
||||
AppStorage.SetOrCreate("hasSimCard2", res);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
LogUtils.i(TAG, "catch:hasSimeCard :" + JSON.stringify(err));
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Determine whether the call is an emergency call.
|
||||
*
|
||||
* @param { phoneNumber } phoneNumber-number
|
||||
*
|
||||
* @return { boolean } - return success true fail false
|
||||
*/
|
||||
public isEmergencyPhoneNumber = (phoneNumber) => new Promise((resolve, reject) => {
|
||||
call.isEmergencyPhoneNumber(phoneNumber, {
|
||||
slotId: 0
|
||||
}).then((res) => {
|
||||
resolve(res);
|
||||
AppStorage.SetOrCreate("IsEmergencyPhoneNumber", res)
|
||||
LogUtils.i(TAG, "then:isEmergencyPhoneNumber :" + JSON.stringify(res));
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
LogUtils.i(TAG, "catch:isEmergencyPhoneNumber :" + JSON.stringify(err));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let mCallUtil = new CallUtils();
|
||||
|
||||
export default mCallUtil as CallUtils;
|
||||
|
@ -17,6 +17,7 @@
|
||||
* @file: Call management
|
||||
*/
|
||||
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';
|
||||
@ -145,30 +146,10 @@ export default class CallManager {
|
||||
AppStorage.SetOrCreate("AccountNumber", data)
|
||||
}
|
||||
});
|
||||
this.isEmergencyPhoneNumber(callData.accountNumber)
|
||||
CallUtils.isEmergencyPhoneNumber(callData.accountNumber)
|
||||
LogUtils.i(TAG, "update :")
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the call is an emergency call.
|
||||
*
|
||||
* @param { phoneNumber } phoneNumber-number
|
||||
*
|
||||
* @return { boolean } - return success true fail false
|
||||
*/
|
||||
private isEmergencyPhoneNumber = (phoneNumber) => new Promise((resolve, reject) => {
|
||||
call.isEmergencyPhoneNumber(phoneNumber, {
|
||||
slotId: 0
|
||||
}).then((res) => {
|
||||
resolve(res);
|
||||
AppStorage.SetOrCreate("IsEmergencyPhoneNumber", res)
|
||||
LogUtils.i(TAG, "then:isEmergencyPhoneNumber : %s" + JSON.stringify(res))
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
LogUtils.i(TAG, "catch:isEmergencyPhoneNumber : %s" + JSON.stringify(err))
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* update call time list
|
||||
*/
|
||||
|
26
entry/src/main/resources/base/media/ic_public_phone_HD.svg
Normal file
26
entry/src/main/resources/base/media/ic_public_phone_HD.svg
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="12px"
|
||||
height="12x"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_contacts_HD</title>
|
||||
<g
|
||||
id="ic_contacts_HD"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<rect
|
||||
id="矩形"
|
||||
x="0"
|
||||
y="0"
|
||||
width="24"
|
||||
height="24"></rect>
|
||||
<path
|
||||
d="M18.6818182,1.5 C20.7905418,1.5 22.5,3.20945823 22.5,5.31818182 L22.5,18.6818182 C22.5,20.7905418 20.7905418,22.5 18.6818182,22.5 L5.31818182,22.5 C3.20945823,22.5 1.5,20.7905418 1.5,18.6818182 L1.5,5.31818182 C1.5,3.20945823 3.20945823,1.5 5.31818182,1.5 L18.6818182,1.5 Z M16.0940455,7.44490909 L13.2075,7.44490909 L13.2075,17.2270909 L16.0940455,17.2270909 L16.3578535,17.2199141 C17.0521027,17.181638 17.6724394,16.9902576 18.2188636,16.6457727 C18.8335909,16.2582273 19.3102273,15.6969545 19.6487727,14.9619545 C19.9873182,14.2269545 20.1565909,13.3471818 20.1565909,12.3226364 C20.1565909,11.307 19.9873182,10.4316818 19.6487727,9.69668182 C19.3102273,8.96168182 18.8335909,8.40263636 18.2188636,8.01954545 C17.6041364,7.63645455 16.8958636,7.44490909 16.0940455,7.44490909 L16.0940455,7.44490909 Z M6.20781818,7.44490909 L4.36363636,7.44490909 L4.36363636,17.2270909 L6.20781818,17.2270909 L6.20781818,12.9774545 L9.45518182,12.9774545 L9.45518182,17.2270909 L11.2993636,17.2270909 L11.2993636,7.44490909 L9.45518182,7.44490909 L9.45518182,11.3337273 L6.20781818,11.3337273 L6.20781818,7.44490909 Z M15.8802273,9.03518182 C16.6553182,9.03518182 17.2344091,9.31359091 17.6175,9.87040909 C18.0005909,10.4272273 18.1921364,11.2446364 18.1921364,12.3226364 C18.1921364,13.4095455 18.0028182,14.2314091 17.6241818,14.7882273 C17.2455455,15.3450455 16.6642273,15.6234545 15.8802273,15.6234545 L15.8802273,15.6234545 L15.0516818,15.6234545 L15.0516818,9.03518182 Z"
|
||||
id="形状结合"
|
||||
fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
27
entry/src/main/resources/base/media/ic_public_phone_sim1.svg
Normal file
27
entry/src/main/resources/base/media/ic_public_phone_sim1.svg
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px"
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>stat_sys_sim1</title>
|
||||
<g
|
||||
id="stat_sys_sim1"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<rect
|
||||
id="矩形"
|
||||
x="0"
|
||||
y="0"
|
||||
width="24"
|
||||
height="24"></rect>
|
||||
<path
|
||||
d="M15.014,1 L21,6.985 L21,19 C21,21.209139 19.209139,23 17,23 L7,23 C4.790861,23 3,21.209139 3,19 L3,5 C3,2.790861 4.790861,1 7,1 L15.014,1 Z M13.5,6 L11.7339623,6 L9.5,7.7704918 L9.5,10.3606557 L11.3566038,8.90163934 L11.3566038,18 L13.5,18 L13.5,6 Z"
|
||||
id="形状结合"
|
||||
fill="#FFFFFF"
|
||||
fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 919 B |
27
entry/src/main/resources/base/media/ic_public_phone_sim2.svg
Normal file
27
entry/src/main/resources/base/media/ic_public_phone_sim2.svg
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px"
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>stat_sys_sim2</title>
|
||||
<g
|
||||
id="stat_sys_sim2"
|
||||
stroke="none"
|
||||
stroke-width="1"
|
||||
fill="none"
|
||||
fill-rule="evenodd">
|
||||
<rect
|
||||
id="矩形"
|
||||
x="0"
|
||||
y="0"
|
||||
width="24"
|
||||
height="24"></rect>
|
||||
<path
|
||||
d="M15.014,1 L21,6.985 L21,19 C21,21.209139 19.209139,23 17,23 L7,23 C4.790861,23 3,21.209139 3,19 L3,5 C3,2.790861 4.790861,1 7,1 L15.014,1 Z M12.1389646,6 C10.4386921,6 9.40871935,7.01423846 9.04904632,9.04444125 L9.04904632,9.04444125 L10.9618529,10.090896 C11.0815492,9.40399827 11.2123394,8.90694664 11.3542234,8.6008917 C11.4955236,8.29483676 11.6811989,8.14180929 11.9100817,8.14180929 C12.0735695,8.14180929 12.1932659,8.21717244 12.2697548,8.36732346 C12.3456598,8.51804976 12.3841962,8.75449446 12.3841962,9.07608227 C12.3841962,9.50582482 12.3024523,9.93499209 12.1389646,10.3647346 C11.9754768,10.7944772 11.6590113,11.4388034 11.1907357,12.2977132 L11.1907357,12.2977132 L9,16.2764274 L9,18 L15,18 L15,15.9381562 L11.7792916,15.9381562 L13.1852861,13.2647778 C13.7954457,12.0940601 14.2175944,11.202934 14.4523161,10.5902488 C14.6864539,9.97871422 14.8038147,9.37695959 14.8038147,8.78613548 C14.8038147,7.93815619 14.5831063,7.26161369 14.1416894,6.75650798 C13.7002725,6.25197756 13.0323083,6 12.1389646,6 Z"
|
||||
id="形状结合"
|
||||
fill="#FFFFFF"
|
||||
fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue
Block a user