!95 1.通话设置界面和通话应用支持飞行模式适配; 2.支持来电振动和接近光功能

Merge pull request !95 from 高冰清/master
This commit is contained in:
openharmony_ci 2023-05-23 06:24:19 +00:00 committed by Gitee
commit b5d03f539a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
27 changed files with 994 additions and 43 deletions

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* 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
@ -21,6 +21,7 @@ import TelephonyCall from './TelephonyApi';
import commonEvent from '@ohos.commonEvent';
import LogUtils from "../common/utils/LogUtils";
import CallManager from '../model/CallManager'
import VibrationAndProximityUtils from '../common/utils/VibrationAndProximityUtils';
let subscriber;
const TAG = "CallManagerService";
@ -31,7 +32,7 @@ const CALL_STATUS_WAITING = 5;
const CALL_STATUS_DIALING = 2;
const CALL_STATUS_DISCONNECTED = 6;
const CALL_STATUS_DISCONNECTING = 7;
const events = ['callui.event.callEvent', 'callui.event.click'];
const events = ['callui.event.callEvent', 'callui.event.click', 'usual.event.SCREEN_OFF'];
/**
* class CallManagerService
@ -59,6 +60,8 @@ export default class CallManagerService {
this.addRegisterListener();
this.addSubscriber();
this.context = context;
// voice
VibrationAndProximityUtils.addVoiceObserver();
}
/**
@ -88,6 +91,10 @@ export default class CallManagerService {
const {callId,btnType} = res.parameters
this.btnclickAgent(callId, btnType)
}
if (res.event === events[2]) {
VibrationAndProximityUtils.stopVibration();
}
} else {
LogUtils.i(TAG, "addSubscriber commonEvent.subscribe failed err :" + JSON.stringify(err))
}
@ -147,9 +154,19 @@ export default class CallManagerService {
if (this.callList.length > 1) {
this.publishData(callData);
}
if (callState === CALL_STATUS_DIALING) {
// add Proximity Listener
VibrationAndProximityUtils.addProximityListener();
}
} else if (callState !== CALL_STATUS_DISCONNECTING) {
this.publishData(callData);
}
if (callState === CALL_STATUS_INCOMING || callState === CALL_STATUS_WAITING) {
// incoming, vibration
VibrationAndProximityUtils.startVibration();
} else {
VibrationAndProximityUtils.stopVibration();
}
}
/**

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* 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
@ -24,7 +24,7 @@ import prompt from '@system.prompt';
import LogUtils from '../utils/LogUtils';
import DefaultCallData from '../struct/TypeUtils';
import CallListStruct from '../struct/CallListStruct'
import VibrationAndProximityUtils from '../utils/VibrationAndProximityUtils';
const TAG = "IncomingCom";
const SMS_REJECTION = `${ImagePathConst.BASE_URL}ic_public_message.svg`;
@ -219,6 +219,8 @@ export default struct IncomingCom {
} else {
this.mCallServiceProxy.acceptCall(this.callData.callId);
}
VibrationAndProximityUtils.addProximityListener();
VibrationAndProximityUtils.stopVibration();
}
build() {

View File

@ -0,0 +1,158 @@
/**
* 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.
*/
/**
* Message/AirplaneMode utils
*/
const SETTING_AIRPLANE_MODE_URI = 'datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true';
const QUERY_AIRPLANE_MODE_KEY = 'airplane_mode';
const TAG = 'AirplaneMode';
import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import LogUtils from './LogUtils';
let dataShareHelper;
/**
* add AirPlaneMode Listener.
*/
export function addAirPlaneModeListener(callback) {
LogUtils.i(TAG, 'addAirPlaneModeListener');
try {
dataShare.createDataShareHelper(globalThis.calluiAbilityContext, SETTING_AIRPLANE_MODE_URI, (err, data) => {
if (err != undefined) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
return;
}
dataShareHelper = data;
try {
dataShareHelper.on('dataChange', SETTING_AIRPLANE_MODE_URI, () => {
LogUtils.i(TAG, 'addAirPlaneModeListener dataChange');
queryAirPlaneMode(callback);
});
queryAirPlaneMode(callback);
LogUtils.i(TAG, 'addAirPlaneModeListener success');
} catch (err) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
});
} catch (err) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* remove AirPlaneMode Listener.
*/
export function removeAirPlaneModeListener() {
LogUtils.i(TAG, 'removeAirPlaneModeListener');
if (!dataShareHelper) {
LogUtils.e(TAG, 'removeAirPlaneModeListener dataShareHelper null');
return;
}
try {
dataShareHelper.off('dataChange', SETTING_AIRPLANE_MODE_URI, () => {
LogUtils.i(TAG, 'removeAirPlaneModeListener dataChange');
});
} catch (err) {
LogUtils.e(TAG, 'removeAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* turnOn AirPlaneMode.
*/
export function turnOnAirPlaneMode() {
LogUtils.i(TAG, 'turnOnAirPlaneMode');
if (!dataShareHelper) {
LogUtils.e(TAG, 'turnOnAirPlaneMode dataShareHelper null');
return;
}
let valueBucket = {
'KEYWORD': QUERY_AIRPLANE_MODE_KEY,
'VALUE': true
};
try {
let da = new dataSharePredicates.DataSharePredicates();
dataShareHelper.update(SETTING_AIRPLANE_MODE_URI, da, valueBucket, (err, data) => {
if (err != undefined) {
LogUtils.e(TAG, 'turnOnAirPlaneMode update error: err: ' + err);
return;
}
LogUtils.i(TAG, 'turnOnAirPlaneMode update succeed');
});
} catch (err) {
LogUtils.e(TAG, 'turnOnAirPlaneMode error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* turnOff AirPlaneMode.
*/
export function turnOffAirPlaneMode() {
LogUtils.i(TAG, 'turnOffAirPlaneMode');
if (!dataShareHelper) {
LogUtils.e(TAG, 'turnOffAirPlaneMode dataShareHelper null');
return;
}
let valueBucket = {
'KEYWORD': QUERY_AIRPLANE_MODE_KEY,
'VALUE': false
};
try {
let da = new dataSharePredicates.DataSharePredicates();
dataShareHelper.update(SETTING_AIRPLANE_MODE_URI, da, valueBucket, (err, data) => {
if (err != undefined) {
LogUtils.e(TAG, 'turnOffAirPlaneMode update error: code: ' + err.code + ', message:' + err.message);
return;
}
LogUtils.i(TAG, 'turnOffAirPlaneMode update succeed');
});
} catch (err) {
LogUtils.e(TAG, 'turnOffAirPlaneMode error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* query AirPlaneMode.
*/
export function queryAirPlaneMode(callback) {
LogUtils.i(TAG, 'queryAirPlaneMode');
if (!dataShareHelper) {
LogUtils.e(TAG, 'queryAirPlaneMode dataShareHelper null');
return;
}
let condition = new dataSharePredicates.DataSharePredicates();
try {
// ID, KEYWORD, VALUE
dataShareHelper.query(SETTING_AIRPLANE_MODE_URI, condition, null).then((data) => {
LogUtils.i(TAG, 'queryAirPlaneMode query succeed');
let hasNext = data.goToFirstRow();
while (hasNext) {
if (data.getString(data.getColumnIndex('KEYWORD')) == QUERY_AIRPLANE_MODE_KEY) {
LogUtils.i(TAG, 'queryAirPlaneMode query succeed return key');
callback(data.getLong(data.getColumnIndex('VALUE')));
return;
}
hasNext = data.goToNextRow();
}
callback(-1);
}).catch((err) => {
LogUtils.e(TAG, 'queryAirPlaneMode query in error: err: ' + JSON.stringify(err));
});
} catch (err) {
LogUtils.e(TAG, 'queryAirPlaneMode query out error: code: ' + err.code + ', message: ' + err.message);
}
}

View File

@ -0,0 +1,181 @@
/**
* 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.
*/
/**
* Vibration And Proximity 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 audio from '@ohos.multimedia.audio';
import LogUtils from './LogUtils';
import power from '@ohos.power';
import sensor from '@ohos.sensor';
import vibrator from '@ohos.vibrator';
const TAG = 'VibrationAndProximityUtils';
const PROXIMITY_INTERVAL = 10000000;
const VIBRATION_DURATION = 100 * 1000;
/**
* Vibration And Proximity tool class
*/
export class VibrationAndProximityUtils {
startVibrationFlag = false;
addProximityListenerFlag = false;
recordDistance = -1;
/**
* add Proximity Listener
*/
public addProximityListener() {
try {
if (this.addProximityListenerFlag) {
LogUtils.e(TAG, 'addProximityListener return');
return;
}
this.addProximityListenerFlag = true;
let that = this
sensor.on(sensor.SensorId.PROXIMITY, function (data) {
if (data) {
if (that.recordDistance != data.distance) {
if (data.distance == 0) {
that.suspendScreen();
} else {
that.wakeupScreen();
}
}
that.recordDistance = data.distance;
}
}, { interval: PROXIMITY_INTERVAL });
} catch (err) {
LogUtils.e(TAG, 'addProximityListener sensor On fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
}
/**
* remove Proximity Listener Vibration
*/
removeProximityListener() {
try {
if (!this.addProximityListenerFlag) {
LogUtils.e(TAG, 'removeProximityListener return');
return;
}
this.addProximityListenerFlag = false;
sensor.off(sensor.SensorId.PROXIMITY, function () {
LogUtils.i(TAG, 'removeProximityListener ');
})
} catch (err) {
LogUtils.e(TAG, 'removeProximityListener sensor off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
}
/**
* suspend Screen
*/
public suspendScreen() {
try {
power.suspend();
LogUtils.i(TAG, 'suspendScreen suspend');
} catch(err) {
LogUtils.e(TAG, 'suspendScreen suspend failed, err: ' + err);
}
}
/**
* wakeup Screen
*/
public wakeupScreen() {
try {
power.wakeup('wakeup_call');
LogUtils.i(TAG, 'wakeupScreen wakeup');
} catch(err) {
LogUtils.e(TAG, 'wakeupScreen wakeup failed, err: ' + err);
}
}
/**
* start Vibration
*/
public startVibration() {
try {
if (this.startVibrationFlag) {
LogUtils.e(TAG, 'startVibration return');
return;
}
let that = this;
vibrator.startVibration({
type: 'time',
duration: VIBRATION_DURATION,
}, {
usage: 'ring'
}, (error) => {
if (error) {
LogUtils.e(TAG, 'startVibration fail, error.code: ' + error.code + ', error.message: ' + error.message);
} else {
that.startVibrationFlag = true;
LogUtils.i(TAG, 'startVibration Callback returned to indicate a successful vibration.');
}
});
} catch (err) {
LogUtils.e(TAG, 'startVibration errCode: ' + err.code + ' ,msg: ' + err.message);
}
}
/**
* stop Vibration
*/
public stopVibration() {
if (!this.startVibrationFlag) {
LogUtils.e(TAG, 'stopVibration return');
return;
}
try {
let that = this;
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
LogUtils.e(TAG, 'stopVibration error.code: ' + error.code + ', error.message: ' + error.message);
return;
}
that.startVibrationFlag = false;
LogUtils.i(TAG, 'stopVibration Callback returned to indicate successful.');
})
} catch (err) {
LogUtils.e(TAG, 'stopVibration errCode: ' + err.code + ' ,msg: ' + err.message);
}
}
/**
* add Voice Observe
*/
addVoiceObserver() {
audio.getAudioManager().on('volumeChange', () => {
LogUtils.i(TAG, 'addVoiceObserver volumeChange');
this.stopVibration();
});
}
}
let mVibrationAndProximityUtils = new VibrationAndProximityUtils();
export default mVibrationAndProximityUtils as VibrationAndProximityUtils;

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* 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
@ -24,6 +24,7 @@ import LogUtils from '../common/utils/LogUtils';
import CallTimeListStruct from '../common/struct/CallTimeListStruct';
import CallListStruct from '../common/struct/CallListStruct';
import DefaultCallData from '../common/struct/TypeUtils';
import VibrationAndProximityUtils from '../common/utils/VibrationAndProximityUtils';
const TAG = "CallDataManager";
/**
@ -130,13 +131,9 @@ export default class CallDataManager {
if (callState === CallStateConst.CALL_STATUS_DISCONNECTED) {
if (this.callList.length === 1) {
this.NotificationManager.cancelNotification();
AppStorage.Get<NotificationManager>('notificationManager').sendCapsuleNotification(callData, true);
AppStorage.Delete("CallTimeList");
this.clearData();
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
LogUtils.i(TAG, "calluiAbility terminateSelf");
});
if (!AppStorage.Get('AirplaneMode')) {
this.clearCall(callData);
}
} else {
this.removeCallById(callId);
const activeCallData = this.callList.find((v) => v.callState === CallStateConst.CALL_STATUS_ACTIVE);
@ -153,6 +150,19 @@ export default class CallDataManager {
}
}
public clearCall(callData) {
this.NotificationManager.cancelNotification();
AppStorage.Get<NotificationManager>('notificationManager').sendCapsuleNotification(callData, true);
AppStorage.Delete("CallTimeList");
this.clearData();
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
LogUtils.i(TAG, "calluiAbility terminateSelf");
});
// remove Proximity Listener
VibrationAndProximityUtils.removeProximityListener();
VibrationAndProximityUtils.stopVibration();
}
sendNotification(callData) {
if (globalThis.appInactiveState && callData) {
AppStorage.Get<NotificationManager>('notificationManager')?.sendNotification(callData);

View File

@ -110,7 +110,7 @@ export default class CallManager {
LogUtils.i(TAG, "update calldata:")
if (this.callData != undefined && this.callData.callId === callData.callId) {
const { callState } = this.callData;
if (callState === 6 && this.callList.length === 1) {
if (callState === 6 && this.callList.length === 1 && !AppStorage.Get('AirplaneMode')) {
globalThis.calluiAbilityContext?.terminateSelf().then((data) => {
LogUtils.i(TAG, "calluiAbility terminateSelf because service disconnected");
});

View File

@ -0,0 +1,90 @@
/**
* 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.
*/
/**
* The confirm dialog box is displayed at the bottom.
*/
@CustomDialog
export default struct ConfirmDialogEx {
@StorageLink('curBp') curBp: string = 'md'
controller: CustomDialogController;
cancel: () => void;
confirm: () => void;
title: string | Resource;
cancelText: string | Resource;
confirmText: string | Resource;
build() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Text(this.title)
.fontSize(18)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.maxLines(2)
}
.margin({ bottom: 10, top: 10 })
Row() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Text(this.cancelText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(18)
}
.layoutWeight(1)
.height(35)
.onClick(() => {
this.controller.close();
this.cancel();
})
Line().width(1).height(25).backgroundColor($r('sys.color.ohos_id_color_list_separator'))
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Text(this.confirmText).fontColor($r('sys.color.ohos_id_color_text_primary_activated')).fontSize(18)
}
.layoutWeight(1)
.height(35)
.onClick(() => {
this.controller.close();
this.confirm();
})
}
.height('30vp')
}
.width('90%')
.height($r('app.float.ConfirmDialogEx_height'))
.borderRadius(20)
.padding({
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
right: $r('sys.float.ohos_id_notification_margin_start'),
left: $r('sys.float.ohos_id_notification_margin_end')
})
.margin({ left: 12, right: 12, bottom: this.curBp === 'sm' ? 16 : 0 })
}
}

View File

@ -0,0 +1,35 @@
/**
* 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.
*/
import deviceInfo from '@ohos.deviceInfo';
export default class EnvironmentProp {
private static readonly DEVICE_TYPE = deviceInfo.deviceType;
constructor() {
}
/**
* Querying the Device Type
*
* default: phone
*/
static getDeviceType(): string {
return this.DEVICE_TYPE;
}
static isTablet(): boolean {
let deviceType = EnvironmentProp.getDeviceType();
return deviceType === 'tablet';
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* 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
@ -13,6 +13,9 @@
* limitations under the License.
*/
import { addAirPlaneModeListener, removeAirPlaneModeListener, turnOffAirPlaneMode } from '../common/utils/AirplaneMode';
import ConfirmDialogEx from './dialog/ConfirmDialogEx';
import EnvironmentProp from './dialog/EnvironmentProp';
import mediaQuery from '@ohos.mediaquery';
import wantAgent from '@ohos.wantAgent';
import ContactCard from '../common/components/ContactCard';
@ -33,6 +36,7 @@ import DefaultCallData from '../common/struct/TypeUtils'
import CallListStruct from '../common/struct/CallListStruct'
import CallTimeListStruct from '../common/struct/CallTimeListStruct'
const AIRPLANE_MODE = 1;
const TAG = "Index";
/**
@ -53,6 +57,31 @@ struct Index {
private smListener: mediaQuery.MediaQueryListener;
private mdListener: mediaQuery.MediaQueryListener;
private lgListener: mediaQuery.MediaQueryListener;
private isNeedCallAgain: boolean = false;
airplaneModeDialogController: CustomDialogController = new CustomDialogController({
//Components shared by the TIP for creating or updating a contact by mistake and the TIP for deleting a contact
builder: ConfirmDialogEx({
cancel: () => {
this.airplaneModeDialogController.close();
LogUtils.i(TAG, 'dial airplaneModeDialogController cancel');
this.mCallDataManager.clearCall(this.callData);
},
confirm: () => {
LogUtils.i(TAG, 'dial airplaneModeDialogController confirm');
this.airplaneModeDialogController.close();
this.isNeedCallAgain = true;
turnOffAirPlaneMode();
},
title: $r('app.string.turn_off_airplane_and_calls'),
cancelText: $r('app.string.cancel'),
confirmText: $r('app.string.shutDown')
}),
autoCancel: false,
alignment: (EnvironmentProp.isTablet() ? DialogAlignment.Center : DialogAlignment.Bottom),
offset: { dx: 0, dy: -16 }
});
isBreakpointSM = (mediaQueryResult) => {
if (mediaQueryResult.matches) {
this.curBp = 'sm'
@ -86,6 +115,7 @@ struct Index {
this.mdListener.on("change", this.isBreakpointMD);
this.lgListener = mediaQuery.matchMediaSync('(840vp<width)');
this.lgListener.on("change", this.isBreakpointLG);
this.initAirPlaneMode();
}
onPageShow() {
@ -99,6 +129,25 @@ struct Index {
LogUtils.i(TAG, "onPageShow end");
}
initAirPlaneMode() {
LogUtils.i(TAG, 'initAirPlaneMode');
try {
addAirPlaneModeListener((data) => {
LogUtils.i(TAG, 'initAirPlaneMode callback');
if (data == AIRPLANE_MODE) {
this.airplaneModeDialogController.open();
AppStorage.SetOrCreate('AirplaneMode', true);
} else if (this.isNeedCallAgain) {
this.isNeedCallAgain = false;
AppStorage.SetOrCreate('AirplaneMode', false);
this.mCallDataManager.clearCall(this.callData);
}
});
} catch(err) {
LogUtils.e(TAG, `initAirPlaneMode err = ${JSON.stringify(err)}`);
}
}
onPageHide() {
LogUtils.i(TAG, "onPageHide");
if (!this.mHangup) {
@ -125,6 +174,7 @@ struct Index {
this.smListener.off('change', this.isBreakpointSM);
this.mdListener.off('change', this.isBreakpointMD);
this.lgListener.off('change', this.isBreakpointLG);
removeAirPlaneModeListener();
}
onBackPress() {

View File

@ -93,7 +93,27 @@
},
{
"name": "ohos.permission.ANSWER_CALL",
"reason": "$string:ANSWER_CALL"
"reason": "$string:ANSWER_CALL"
},
{
"name": "ohos.permission.VIBRATE",
"reason": "$string:VIBRATE"
},
{
"name": "ohos.permission.SET_TELEPHONY_STATE",
"reason": "$string:SET_TELEPHONY_STATE"
},
{
"name": "ohos.permission.ACCELEROMETER",
"reason": "$string:ACCELEROMETER"
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "$string:MANAGE_SECURE_SETTINGS"
},
{
"name": "ohos.permission.PLACE_CALL",
"reason": "$string:PLACE_CALL"
}
]
}

View File

@ -109,6 +109,26 @@
{
"name": "ohos.permission.ANSWER_CALL",
"reason": "$string:ANSWER_CALL"
},
{
"name": "ohos.permission.VIBRATE",
"reason": "$string:VIBRATE"
},
{
"name": "ohos.permission.SET_TELEPHONY_STATE",
"reason": "$string:SET_TELEPHONY_STATE"
},
{
"name": "ohos.permission.ACCELEROMETER",
"reason": "$string:ACCELEROMETER"
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "$string:MANAGE_SECURE_SETTINGS"
},
{
"name": "ohos.permission.PLACE_CALL",
"reason": "$string:PLACE_CALL"
}
]
}

View File

@ -0,0 +1,8 @@
{
"float": [
{
"name": "ConfirmDialogEx_height",
"value": "109vp"
}
]
}

View File

@ -243,6 +243,30 @@
{
"name": "ANSWER_CALL",
"value": "Answer call"
},
{
"name": "turn_off_airplane_and_calls",
"value": "Do you want to turn off airplane mode and make phone calls?"
},
{
"name": "VIBRATE",
"value": "vibrate"
},
{
"name": "SET_TELEPHONY_STATE",
"value": "set telephony state"
},
{
"name": "ACCELEROMETER",
"value": "accelerometer"
},
{
"name": "MANAGE_SECURE_SETTINGS",
"value": "manage secure settings"
},
{
"name": "PLACE_CALL",
"value": "place call"
}
]
}

View File

@ -247,6 +247,30 @@
{
"name": "ANSWER_CALL",
"value": "接听电话"
},
{
"name": "turn_off_airplane_and_calls",
"value": "是否关闭飞行模式以拨打电话?"
},
{
"name": "VIBRATE",
"value": "振动"
},
{
"name": "SET_TELEPHONY_STATE",
"value": "设置电话状态"
},
{
"name": "ACCELEROMETER",
"value": "加速度计"
},
{
"name": "MANAGE_SECURE_SETTINGS",
"value": "管理安全设置"
},
{
"name": "PLACE_CALL",
"value": "拨打电话"
}
]
}

View File

@ -0,0 +1,103 @@
/**
* 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.
*/
/**
* Message/AirplaneMode utils
*/
const SETTING_AIRPLANE_MODE_URI = 'datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true';
const QUERY_AIRPLANE_MODE_KEY = 'airplane_mode';
const TAG = 'AirplaneMode';
import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import LogUtils from './LogUtils';
let dataShareHelper;
/**
* add AirPlaneMode Listener.
*/
export function addAirPlaneModeListener(callback) {
LogUtils.i(TAG, 'addAirPlaneModeListener');
try {
dataShare.createDataShareHelper(globalThis.settingsAbilityContext, SETTING_AIRPLANE_MODE_URI, (err, data) => {
if (err != undefined) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
return;
}
dataShareHelper = data;
try {
dataShareHelper.on('dataChange', SETTING_AIRPLANE_MODE_URI, () => {
LogUtils.i(TAG, 'addAirPlaneModeListener dataChange');
queryAirPlaneMode(callback);
});
queryAirPlaneMode(callback);
} catch (err) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
});
} catch (err) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* remove AirPlaneMode Listener.
*/
export function removeAirPlaneModeListener() {
LogUtils.i(TAG, 'removeAirPlaneModeListener');
if (!dataShareHelper) {
LogUtils.e(TAG, 'removeAirPlaneModeListener dataShareHelper null');
return;
}
try {
dataShareHelper.off('dataChange', SETTING_AIRPLANE_MODE_URI, () => {
LogUtils.i(TAG, 'removeAirPlaneModeListener dataChange');
});
} catch (err) {
LogUtils.e(TAG, 'removeAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* query AirPlaneMode.
*/
export function queryAirPlaneMode(callback) {
LogUtils.i(TAG, 'queryAirPlaneMode');
if (!dataShareHelper) {
LogUtils.e(TAG, 'queryAirPlaneMode dataShareHelper null');
return;
}
let condition = new dataSharePredicates.DataSharePredicates();
try {
// ID, KEYWORD, VALUE
dataShareHelper.query(SETTING_AIRPLANE_MODE_URI, condition, null).then((data) => {
LogUtils.i(TAG, 'queryAirPlaneMode query succeed');
let hasNext = data.goToFirstRow();
while (hasNext) {
if (data.getString(data.getColumnIndex('KEYWORD')) == QUERY_AIRPLANE_MODE_KEY) {
LogUtils.i(TAG, 'queryAirPlaneMode query succeed return key');
callback(data.getLong(data.getColumnIndex('VALUE')));
return;
}
hasNext = data.goToNextRow();
}
callback(-1);
}).catch((err) => {
LogUtils.e(TAG, 'queryAirPlaneMode query in error: err: ' + JSON.stringify(err));
});
} catch (err) {
LogUtils.e(TAG, 'queryAirPlaneMode query out error: code: ' + err.code + ', message: ' + err.message);
}
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* 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
@ -16,6 +16,7 @@
/**
* @file: Mobile Network Home page
*/
import { addAirPlaneModeListener, removeAirPlaneModeListener, queryAirPlaneMode } from '../common/utils/AirplaneMode';
import publiccontent from '../common/components/publiccontent';
import item from '../common/components/listItem/listItem';
import call from '@ohos.telephony.call';
@ -57,6 +58,8 @@ struct Index {
@State mobileDataDisabled2: boolean = false;
// Mobile data switch
@State isDataEnable: boolean = true;
// Mobile AirPlane Mode
@State isAirPlaneMode: boolean = false;
// Data roaming switch
@State dataRoamSwitchCardOne: boolean = false;
@State dataRoamSwitchCardTwo: boolean = false;
@ -195,6 +198,32 @@ struct Index {
});
}
// init AirPlane Mode
initAirPlaneMode() {
LogUtils.i(TAG, 'initAirPlaneMode');
try {
addAirPlaneModeListener((data) => {
LogUtils.i(TAG, 'initAirPlaneMode callback');
this.isAirPlaneMode = data == 1 ? true : false;
});
} catch(err) {
LogUtils.e(TAG,`initAirPlaneMode err = ${JSON.stringify(err)}`);
}
}
// query AirPlane Mode
getAirPlaneMode() {
LogUtils.i(TAG, 'getAirPlaneMode');
try {
queryAirPlaneMode((data) => {
LogUtils.i(TAG, 'getAirPlaneMode callback');
this.isAirPlaneMode = data == 1 ? true : false;
});
} catch(err) {
LogUtils.e(TAG,`getAirPlaneMode err = ${JSON.stringify(err)}`);
}
}
addRegisterSimStateChange(slotId) {
registerSimStateChange(slotId, async () => {
this.getCellularDataRoamingEnabled();
@ -235,6 +264,7 @@ struct Index {
aboutToAppear() {
LogUtils.i(TAG, "aboutToAppear")
this.initAirPlaneMode();
if (getMaxSimCount() === 2) {
this.addRegisterSimStateChange(1);
this.isImsSwitchEnabled(1);
@ -259,6 +289,11 @@ struct Index {
onPageShow() {
this.isImsSwitchEnabled(0);
this.getAirPlaneMode();
}
onPageHide() {
removeAirPlaneModeListener();
}
/**
@ -333,7 +368,7 @@ struct Index {
Toggle({ type: ToggleType.Switch, isOn: this.isDataEnable })
.width(36)
.height(20)
.enabled(this.simStateStatusCardOne || this.simStateStatusCardTwo)
.enabled((this.simStateStatusCardOne || this.simStateStatusCardTwo) && !this.isAirPlaneMode)
.onChange((isOn: boolean) => {
this.isDataEnable = !this.isDataEnable;
LogUtils.i(TAG, "mobile data switch changes enable:" + JSON.stringify(this.isDataEnable));
@ -362,7 +397,7 @@ struct Index {
.width("100%")
.borderRadius(16)
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.opacity((this.simStateStatusCardOne || this.simStateStatusCardTwo) ? 1 : 0.4)
.opacity((this.simStateStatusCardOne || this.simStateStatusCardTwo) && !this.isAirPlaneMode ? 1 : 0.4)
SubHeader({
titleContent: $r('app.string.mobile_data_card1'),
@ -376,7 +411,7 @@ struct Index {
controlSwitch: $dataRoamSwitchCardOne,
title: $r('app.string.mobile_data_dataRoaming'),
describe: $r('app.string.mobile_data_enableDataWhileRoaming'),
isDisabled: this.simStateStatusCardOne,
isDisabled: this.simStateStatusCardOne && !this.isAirPlaneMode,
isCard: true,
isSupport: false,
isCon: 0,
@ -394,7 +429,7 @@ struct Index {
controlSwitch: $enableISM,
title: $r('app.string.mobile_data_volte'),
describe: $r('app.string.mobile_data_confirmation_function'),
isDisabled: this.simStateStatusCardOne,
isDisabled: this.simStateStatusCardOne && !this.isAirPlaneMode,
isSupport: false,
isCard: true,
isCon: 22,
@ -409,7 +444,7 @@ struct Index {
.width("100%")
.borderRadius(16)
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.opacity(this.simStateStatusCardOne ? 1 : 0.4)
.opacity(this.simStateStatusCardOne && !this.isAirPlaneMode ? 1 : 0.4)
SubHeader({
titleContent: $r('app.string.mobile_data_card2'),
@ -424,7 +459,7 @@ struct Index {
controlSwitch: $mobileDataDisabled2,
title: $r('app.string.mobile_data_dataRoaming'),
describe: $r('app.string.mobile_data_enableDataWhileRoaming'),
isDisabled: this.simStateStatusCardTwo,
isDisabled: this.simStateStatusCardTwo && !this.isAirPlaneMode,
isSupport: false,
isCard: true,
isCon: 0,
@ -440,7 +475,7 @@ struct Index {
controlSwitch: $enableISM2,
title: $r('app.string.mobile_data_volte'),
describe: $r('app.string.mobile_data_confirmation_function'),
isDisabled: this.simStateStatusCardTwo,
isDisabled: this.simStateStatusCardTwo && !this.isAirPlaneMode,
isSupport: false,
isCard: true,
isCon: 22,
@ -461,7 +496,7 @@ struct Index {
.width("100%")
.borderRadius(16)
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.opacity(this.simStateStatusCardTwo ? 1 : 0.4)
.opacity(this.simStateStatusCardTwo && !this.isAirPlaneMode ? 1 : 0.4)
.visibility(getMaxSimCount() === 2 ? Visibility.Visible : Visibility.Hidden)
}
.alignItems(HorizontalAlign.Start)

View File

@ -42,6 +42,10 @@
{
"name": "ohos.permission.GET_TELEPHONY_STATE",
"reason": "$string:GET_TELEPHONY_STATE"
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "$string:MANAGE_SECURE_SETTINGS"
}
]
}

View File

@ -57,6 +57,10 @@
{
"name": "ohos.permission.GET_TELEPHONY_STATE",
"reason": "$string:GET_TELEPHONY_STATE"
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "$string:MANAGE_SECURE_SETTINGS"
}
]
}

View File

@ -163,6 +163,10 @@
{
"name": "mobile_empty_string",
"value": " "
},
{
"name": "MANAGE_SECURE_SETTINGS",
"value": "manage secure settings"
}
]
}

View File

@ -163,6 +163,10 @@
{
"name": "mobile_empty_string",
"value": " "
},
{
"name": "MANAGE_SECURE_SETTINGS",
"value": "管理安全设置"
}
]
}

View File

@ -60,6 +60,7 @@ export default struct eSimSet {
@Link isCardChange2: boolean;
@Link defaultSetString: Resource;
@StorageLink("operatorName") @Watch('updateOperatorName') operatorRes: OperaNameStruct = new OperaNameStruct();
@Link isAirPlaneMode: boolean;
timer = null;
SIM_CARD_DEFAULT = 'sim_card_management_card_default_call';
SIM_CARD_INFO = 'sim_card_management_storage_card_info';
@ -454,7 +455,7 @@ export default struct eSimSet {
}
Column() {
Text(this.list[0].name)
Text(this.isAirPlaneMode ? $r('app.string.sim_no_service') : this.list[0].name)
.fontSize('16vp')
.margin({
bottom: 2
@ -477,7 +478,7 @@ export default struct eSimSet {
.fontWeight(FontWeight.Regular)
}
.margin({ left: 16 })
.opacity(this.list[0].isOpened ? 1 : 0.4)
.opacity((this.list[0].isOpened && !this.isAirPlaneMode) ? 1 : 0.4)
Image($r('app.media.redact'))
.width('15vp')
@ -485,14 +486,15 @@ export default struct eSimSet {
.onClick(() => {
this.edit(this.list[0])
})
.margin({ left: 20 })
.enabled(this.list[0].isOpened)
.margin({ left: 20 })
.enabled(this.list[0].isOpened && !this.isAirPlaneMode)
}
Row() {
Toggle({ type: ToggleType.Switch, isOn: this.list[0].isOpened })
.width(36)
.height(20)
.enabled(!this.isAirPlaneMode)
.onChange((isOn: boolean) => {
LogUtils.i(TAG, "onclick toggle card one")
this.getDefaultVoiceSlotId();
@ -545,8 +547,8 @@ export default struct eSimSet {
})
}
}
.opacity(this.list[0].isOpened ? 1 : 0.6)
.enabled(this.list[0].disabled)
.opacity(this.list[0].isOpened && !this.isAirPlaneMode ? 1 : 0.6)
.enabled(this.list[0].disabled && !this.isAirPlaneMode)
.padding({
left: 12,
right: 12,
@ -578,7 +580,7 @@ export default struct eSimSet {
}
Column() {
Text(this.list[1].name)
Text(this.isAirPlaneMode ? $r('app.string.sim_no_service') : this.list[1].name)
.fontSize('16vp')
.margin({ bottom: 2 })
.fontFamily("HarmonyHeiTi")
@ -599,7 +601,7 @@ export default struct eSimSet {
.fontWeight(FontWeight.Regular)
}
.margin({ left: 16 })
.opacity(this.list[1].isOpened ? 1 : 0.4)
.opacity((this.list[1].isOpened && !this.isAirPlaneMode) ? 1 : 0.4)
Image($r('app.media.redact'))
.width('12vp')
@ -608,13 +610,14 @@ export default struct eSimSet {
this.edit(this.list[1]);
})
.margin({ left: 4 })
.enabled(this.list[1].isOpened)
.enabled(this.list[1].isOpened && !this.isAirPlaneMode)
}
Row() {
Toggle({ type: ToggleType.Switch, isOn: this.list[1].isOpened })
.width(36)
.height(20)
.enabled(!this.isAirPlaneMode)
.onChange((isOn: boolean) => {
LogUtils.i(TAG, "onclick toggle card two")
this.getDefaultVoiceSlotId();
@ -668,8 +671,8 @@ export default struct eSimSet {
}
}
.height(104)
.opacity(this.list[1].isOpened ? 1 : 0.6)
.enabled(this.list[1].disabled)
.opacity(this.list[1].isOpened && !this.isAirPlaneMode ? 1 : 0.6)
.enabled(this.list[1].disabled && !this.isAirPlaneMode)
.padding({
left: 12,
right: 12,

View File

@ -0,0 +1,103 @@
/**
* 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.
*/
/**
* Message/AirplaneMode utils
*/
const SETTING_AIRPLANE_MODE_URI = 'datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true';
const QUERY_AIRPLANE_MODE_KEY = 'airplane_mode';
const TAG = 'AirplaneMode';
import dataShare from '@ohos.data.dataShare';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import LogUtils from './LogUtils';
let dataShareHelper;
/**
* add AirPlaneMode Listener.
*/
export function addAirPlaneModeListener(callback) {
LogUtils.i(TAG, 'addAirPlaneModeListener');
try {
dataShare.createDataShareHelper(globalThis.simCardAbilityContext, SETTING_AIRPLANE_MODE_URI, (err, data) => {
if (err != undefined) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
return;
}
dataShareHelper = data;
try {
dataShareHelper.on('dataChange', SETTING_AIRPLANE_MODE_URI, () => {
LogUtils.i(TAG, 'addAirPlaneModeListener dataChange');
queryAirPlaneMode(callback);
});
queryAirPlaneMode(callback);
} catch (err) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
});
} catch (err) {
LogUtils.e(TAG, 'addAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* remove AirPlaneMode Listener.
*/
export function removeAirPlaneModeListener() {
LogUtils.i(TAG, 'removeAirPlaneModeListener');
if (!dataShareHelper) {
LogUtils.e(TAG, 'removeAirPlaneModeListener dataShareHelper null');
return;
}
try {
dataShareHelper.off('dataChange', SETTING_AIRPLANE_MODE_URI, () => {
LogUtils.i(TAG, 'removeAirPlaneModeListener dataChange');
});
} catch (err) {
LogUtils.e(TAG, 'removeAirPlaneModeListener error: code: ' + err.code + ', message: ' + err.message);
}
}
/**
* query AirPlaneMode.
*/
export function queryAirPlaneMode(callback) {
LogUtils.i(TAG, 'queryAirPlaneMode ');
if (!dataShareHelper) {
LogUtils.e(TAG, 'queryAirPlaneMode dataShareHelper null');
return;
}
let condition = new dataSharePredicates.DataSharePredicates();
try {
// ID, KEYWORD, VALUE
dataShareHelper.query(SETTING_AIRPLANE_MODE_URI, condition, null).then((data) => {
LogUtils.i(TAG, 'queryAirPlaneMode query succeed');
let hasNext = data.goToFirstRow();
while (hasNext) {
if (data.getString(data.getColumnIndex('KEYWORD')) == QUERY_AIRPLANE_MODE_KEY) {
LogUtils.i(TAG, 'queryAirPlaneMode query succeed return key');
callback(data.getLong(data.getColumnIndex('VALUE')));
return;
}
hasNext = data.goToNextRow();
}
callback(-1);
}).catch((err) => {
LogUtils.e(TAG, 'queryAirPlaneMode query in error: err: ' + JSON.stringify(err));
});
} catch (err) {
LogUtils.e(TAG, 'queryAirPlaneMode query out error: code: ' + err.code + ', message: ' + err.message);
}
}

View File

@ -14,6 +14,7 @@
*/
/**
SIM_CARD_INFO */
import { addAirPlaneModeListener, removeAirPlaneModeListener, queryAirPlaneMode } from '../common/utils/AirplaneMode';
import HeadComponent from '../common/components/headComponent'
import CardInfomation from '../common/components/cardInfomation'
import SetFlowLimit from '../common/components/dialog/setFlowLimit'
@ -76,6 +77,8 @@ struct Index {
@State defaultSet: Resource = $r('app.string.not_set');
@State simActive: boolean = false;
@StorageLink("operatorName") @Watch('updateInfo') operatorInfo: OperaNameStruct = new OperaNameStruct();
// Mobile AirPlane Mode
@State isAirPlaneMode: boolean = false;
SIM_CARD_STOP = 'sim_card_management_card_stop_boolean';
SIM_CARD_Change = 'sim_card_management_card_change_boolean';
SIM_CARD_DEFAULT = 'sim_card_management_card_default_call';
@ -103,6 +106,32 @@ struct Index {
this.defaultDialCard.open();
};
// init AirPlane Mode
initAirPlaneMode() {
LogUtils.i(TAG, 'initAirPlaneMode');
try {
addAirPlaneModeListener((data) => {
LogUtils.i(TAG, 'initAirPlaneMode callback');
this.isAirPlaneMode = data == 1 ? true : false;
});
} catch(err) {
LogUtils.e(TAG,`initAirPlaneMode err = ${JSON.stringify(err)}`);
}
}
// query AirPlane Mode
getAirPlaneMode() {
LogUtils.i(TAG, 'getAirPlaneMode');
try {
queryAirPlaneMode((data) => {
LogUtils.i(TAG, 'getAirPlaneMode callback');
this.isAirPlaneMode = data == 1 ? true : false;
});
} catch(err) {
LogUtils.e(TAG,`getAirPlaneMode err = ${JSON.stringify(err)}`);
}
}
/**
* Get the customized mobile phone number set by the user
*/
@ -183,6 +212,7 @@ struct Index {
aboutToAppear() {
LogUtils.i(TAG, "aboutToAppear:");
this.initAirPlaneMode();
SubscriberManager.registerSubscriber();
if (getMaxSimCount() >= 2) {
@ -214,6 +244,7 @@ struct Index {
onPageShow() {
LogUtils.i(TAG, "onPageShow start ");
this.getAirPlaneMode();
this.updateInfo();
LogUtils.i(TAG, "onPageShow end ")
}
@ -230,6 +261,10 @@ struct Index {
SubscriberManager.unsubscribe();
}
onPageHide() {
removeAirPlaneModeListener();
}
build() {
GridRow({ columns: { sm: 4, md: 8, lg: 12 }, gutter: { x: 12 } }) {
GridCol({ span: { sm: 4, md: 8, lg: 8 }, offset: { sm: 0, md: 1, lg: 2 } }) {
@ -250,6 +285,7 @@ struct Index {
isCardChange: $defaultDataChange,
isCardChange2: $isShow,
defaultSetString: $defaultSet,
isAirPlaneMode: $isAirPlaneMode,
})
Column() {
@ -261,15 +297,15 @@ struct Index {
Column() {
Text($r('app.string.default_mobile_data')).fontSize('16vp').fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Medium).maxLines(1)
}
.opacity(this.isStop ? 1 : 0.4)
.opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4)
.opacity(this.isStop && !this.isAirPlaneMode ? 1 : 0.4)
.opacity((this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode) ? 1 : 0.4)
.align(Alignment.Center)
Row() {
DefaultCard({ cardName: $r('app.string.card_1'),
cardTextBackgrounColor: this.defaultDataChange ? "#0A59F7" : "#FFFFFF",
cardTextColor: this.defaultDataChange ? "#FFFFFF" : "#0A59F7" })
.opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4)
.opacity((this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode) ? 1 : 0.4)
.onClick(() => {
LogUtils.i(TAG, "onclick defaultcard card one")
this.setDefaultDataSlotId(0);
@ -280,14 +316,14 @@ struct Index {
DefaultCard({ cardName: $r('app.string.card_2'),
cardTextBackgrounColor: this.defaultDataChange ? "#FFFFFF" : "#0A59F7",
cardTextColor: this.defaultDataChange ? "#0A59F7" : "#FFFFFF" })
.opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4)
.opacity((this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode) ? 1 : 0.4)
.onClick(() => {
LogUtils.i(TAG, "onclick defaultcard card two")
this.setDefaultDataSlotId(1);
this.defaultDataChange = !this.defaultDataChange;
})
}
.enabled((this.list[0].isOpened && this.list[1].isOpened))
.enabled(this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode)
.margin({ right: 1 })
.width(148)
.height(40)
@ -328,10 +364,10 @@ struct Index {
.fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Regular)
Image($r('app.media.next_icon')).height(20).width(12)
}
.opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4)
.opacity((this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode) ? 1 : 0.4)
}
.opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.6)
.enabled((this.list[0].isOpened && this.list[1].isOpened))
.opacity((this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode) ? 1 : 0.6)
.enabled((this.list[0].isOpened && this.list[1].isOpened && !this.isAirPlaneMode))
.onClick(() => {
this.defaultCard();
})

View File

@ -42,6 +42,10 @@
{
"name": "ohos.permission.GET_TELEPHONY_STATE",
"reason": "$string:GET_TELEPHONY_STATE"
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "$string:MANAGE_SECURE_SETTINGS"
}
]
}

View File

@ -57,6 +57,10 @@
{
"name": "ohos.permission.GET_TELEPHONY_STATE",
"reason": "$string:GET_TELEPHONY_STATE"
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "$string:MANAGE_SECURE_SETTINGS"
}
]
}

View File

@ -239,6 +239,10 @@
{
"name": "GET_TELEPHONY_STATE",
"value": "获取卡的状态"
},
{
"name": "MANAGE_SECURE_SETTINGS",
"value": "管理安全设置"
}
]
}

View File

@ -239,6 +239,10 @@
{
"name": "GET_TELEPHONY_STATE",
"value": "get telephony state"
},
{
"name": "MANAGE_SECURE_SETTINGS",
"value": "manage secure settings"
}
]
}