mirror of
https://gitee.com/openharmony/applications_call
synced 2024-11-27 00:20:46 +00:00
!126 【新需求】获取当前SIM卡网络制式并显示列表,提供手动设置移动网络制式的操作
Merge pull request !126 from gbluo/OpenHarmony-5.0.1-Release
This commit is contained in:
commit
fd1d75bf57
@ -13,15 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import LogUtils from '../utils/LogUtils'
|
||||
import { Router } from '@ohos.arkui.UIContext';
|
||||
import router from '@ohos.router';
|
||||
|
||||
const TAG = 'HeadComponent'
|
||||
const TAG = "HeadComponent"
|
||||
|
||||
/**
|
||||
* head custom component
|
||||
*/
|
||||
@Component
|
||||
export default struct HeadComponent {
|
||||
@State isTouch: boolean = false;
|
||||
@State isTouch?: boolean = false;
|
||||
title: Resource = $r('app.string.mobile_data');
|
||||
isTerminateSelf: boolean = true
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
@ -29,14 +33,18 @@ export default struct HeadComponent {
|
||||
Image($r('app.media.ic_back'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
.fillColor($r("sys.color.ohos_id_color_primary"))
|
||||
}
|
||||
.margin({ right: 16 })
|
||||
.backgroundColor(this.isTouch ? $r('app.color.color_E3E3E3_grey') : $r('app.color.color_00000000_transparent'))
|
||||
.onClick(() => {
|
||||
globalThis.settingsAbilityContext?.terminateSelf().then((data) => {
|
||||
LogUtils.i(TAG, 'terminateSelfCallBack');
|
||||
});
|
||||
if (this.isTerminateSelf) {
|
||||
globalThis.settingsAbilityContext?.terminateSelf().then((data) => {
|
||||
LogUtils.i(TAG, "terminateSelfCallBack");
|
||||
});
|
||||
} else {
|
||||
router.back()
|
||||
}
|
||||
})
|
||||
.onTouch((event: TouchEvent) => {
|
||||
if (event.type === TouchType.Down) {
|
||||
@ -47,7 +55,7 @@ export default struct HeadComponent {
|
||||
}
|
||||
});
|
||||
|
||||
Text($r('app.string.mobile_data'))
|
||||
Text(this.title)
|
||||
.fontSize(20)
|
||||
.fontFamily('HarmonyHeiTi-Bold')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
@ -57,7 +65,7 @@ export default struct HeadComponent {
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({ top: 15, bottom: 15 });
|
||||
}
|
||||
.width('100%')
|
||||
.width("100%")
|
||||
.padding({ left: 12 })
|
||||
.height(56)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
|
@ -0,0 +1,42 @@
|
||||
@Preview
|
||||
@Component
|
||||
export default struct NetworkStandItem {
|
||||
@Link networkMode: number;
|
||||
title: ResourceStr = '';
|
||||
thisNetworkMode: number = 5
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text(this.title)
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.opacity(this.networkMode == this.thisNetworkMode ? 0.9 : 0.6)
|
||||
.letterSpacing(1)
|
||||
.lineHeight(22)
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
.width('100%')
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.margin({ right: 26 })
|
||||
|
||||
Image(this.networkMode == this.thisNetworkMode ? $r('app.media.ic_redio_check') : '')
|
||||
.width(24)
|
||||
.height(24)
|
||||
}
|
||||
}
|
||||
}
|
||||
.height(50)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.borderRadius(16)
|
||||
.margin({ top: 5, left: 10, right: 10, bottom: 5 })
|
||||
.padding({ left: 10, right: 10 })
|
||||
.onClick(() => {
|
||||
this.networkMode = this.thisNetworkMode
|
||||
})
|
||||
}
|
||||
}
|
@ -39,8 +39,9 @@ import {
|
||||
import HeadComponent from '../common/components/headComponent';
|
||||
import { SubHeader } from '../common/components/subHeader';
|
||||
import LogUtils from '../common/utils/LogUtils';
|
||||
import router from '@ohos.router';
|
||||
|
||||
const TAG = 'Index';
|
||||
const TAG = "Index";
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -69,17 +70,21 @@ struct Index {
|
||||
@State simStateStatusCardOne: boolean = true;
|
||||
// Card 2 status
|
||||
@State simStateStatusCardTwo: boolean = false;
|
||||
@State controlSwitchWLMS: boolean = false;
|
||||
@State ControlswitchWLMS: boolean = false;
|
||||
@State slotId: number = 0;
|
||||
@State dialogTitle: Resource = publiccontent.strings.preferredNetworkMode;
|
||||
setCache_cun_name = 'DISTRIBUTEDDATA_CUN_NAME';
|
||||
setCache_wl_name = 'SETCACHE_WL_NAME';
|
||||
@State enable5g: boolean = false;
|
||||
@StorageLink('imsOne')enableISM: boolean = false;
|
||||
@StorageLink("imsOne")enableISM: boolean = false;
|
||||
@State enableISM2: boolean = false;
|
||||
@State mTelephoneNumber: string = '';
|
||||
@State mTelephoneNumber2?: string = '';
|
||||
@State TelephoneNumber: string = '';
|
||||
@State TelephoneNumber2?: string = '';
|
||||
@State ceshi: boolean = false;
|
||||
@State cardOne: number = 0;
|
||||
@State cardTwo: number = 1;
|
||||
@State controllerMobileNetworkIsOn: boolean = false;
|
||||
childComponentTitle:Resource=$r('app.string.mobile_data')
|
||||
|
||||
/**
|
||||
* Get network mode
|
||||
@ -104,7 +109,7 @@ struct Index {
|
||||
*/
|
||||
getSimStateDataCardOne() {
|
||||
getSimStateCardOne().then((res: number) => {
|
||||
LogUtils.i(TAG, 'getSimStateData Card1 :success ' + JSON.stringify(res))
|
||||
LogUtils.i(TAG, "getSimStateData Card1 :success " + JSON.stringify(res))
|
||||
const simState = {
|
||||
SIM_STATE_UNKNOWN: 0,
|
||||
SIM_STATE_NOT_PRESENT: 1,
|
||||
@ -129,7 +134,7 @@ struct Index {
|
||||
*/
|
||||
getSimStateDataCardTwo() {
|
||||
getSimStateCardTwo().then((res: number) => {
|
||||
LogUtils.i(TAG, 'getSimState Card2 :success then' + JSON.stringify(res));
|
||||
LogUtils.i(TAG, "getSimState Card2 :success then" + JSON.stringify(res));
|
||||
const simState = {
|
||||
SIM_STATE_UNKNOWN: 0,
|
||||
SIM_STATE_NOT_PRESENT: 1,
|
||||
@ -165,10 +170,10 @@ struct Index {
|
||||
*/
|
||||
getSimCardOnePhoneNumber() {
|
||||
getSimCardOnePhoneNumber().then((res) => {
|
||||
LogUtils.i(TAG, 'getSimTelephoneNumber card1 other success' + JSON.stringify(res));
|
||||
this.mTelephoneNumber = res;
|
||||
LogUtils.i(TAG, "getSimTelephoneNumber card1 other success" + JSON.stringify(res));
|
||||
this.TelephoneNumber = res;
|
||||
}).catch((err) => {
|
||||
LogUtils.i(TAG, 'getSimTelephoneNumber card1 other catch' + JSON.stringify(err));
|
||||
LogUtils.i(TAG, "getSimTelephoneNumber card1 other catch" + JSON.stringify(err));
|
||||
});
|
||||
}
|
||||
|
||||
@ -177,10 +182,10 @@ struct Index {
|
||||
*/
|
||||
getSimCardTwoPhoneNumber() {
|
||||
getSimCardTwoPhoneNumber().then((res) => {
|
||||
LogUtils.i(TAG, 'getSimTelephoneNumber card2 other success' + JSON.stringify(res));
|
||||
this.mTelephoneNumber2 = res;
|
||||
LogUtils.i(TAG, "getSimTelephoneNumber card2 other success" + JSON.stringify(res));
|
||||
this.TelephoneNumber2 = res;
|
||||
}).catch((err) => {
|
||||
LogUtils.i(TAG, 'getSimTelephoneNumber card2 other catch' + JSON.stringify(err));
|
||||
LogUtils.i(TAG, "getSimTelephoneNumber card2 other catch" + JSON.stringify(err));
|
||||
});
|
||||
}
|
||||
|
||||
@ -189,10 +194,10 @@ struct Index {
|
||||
*/
|
||||
getCellularDataState() {
|
||||
isCellularDataEnabled().then((data) => {
|
||||
LogUtils.i(TAG, 'isCellularDataEnabled success: isON:' + JSON.stringify(data));
|
||||
LogUtils.i(TAG, "isCellularDataEnabled success: isON:" + JSON.stringify(data));
|
||||
this.isDataEnable = data;
|
||||
}).catch((error) => {
|
||||
LogUtils.i(TAG, 'isCellularDataEnabled error catch' + JSON.stringify(error));
|
||||
LogUtils.i(TAG, "isCellularDataEnabled error catch" + JSON.stringify(error));
|
||||
});
|
||||
}
|
||||
|
||||
@ -204,8 +209,8 @@ struct Index {
|
||||
LogUtils.i(TAG, 'initAirPlaneMode callback');
|
||||
this.isAirPlaneMode = data == 1 ? true : false;
|
||||
});
|
||||
} catch (err) {
|
||||
LogUtils.e(TAG, `initAirPlaneMode err = ${JSON.stringify(err)}`);
|
||||
} catch(err) {
|
||||
LogUtils.e(TAG,`initAirPlaneMode err = ${JSON.stringify(err)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,8 +222,8 @@ struct Index {
|
||||
LogUtils.i(TAG, 'getAirPlaneMode callback');
|
||||
this.isAirPlaneMode = data == 1 ? true : false;
|
||||
});
|
||||
} catch (err) {
|
||||
LogUtils.e(TAG, `getAirPlaneMode err = ${JSON.stringify(err)}`);
|
||||
} catch(err) {
|
||||
LogUtils.e(TAG,`getAirPlaneMode err = ${JSON.stringify(err)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,25 +248,25 @@ struct Index {
|
||||
call.isImsSwitchEnabled(slotId).then((res: boolean) => {
|
||||
if (slotId) {
|
||||
this.enableISM2 = res;
|
||||
LogUtils.i(TAG, 'isImsSwitchEnable enable 1:' + JSON.stringify(this.enableISM2));
|
||||
LogUtils.i(TAG, "isImsSwitchEnable enable 1:" + JSON.stringify(this.enableISM2));
|
||||
} else {
|
||||
this.enableISM = res;
|
||||
LogUtils.i(TAG, 'isImsSwitchEnable enable 0:' + JSON.stringify(this.enableISM));
|
||||
LogUtils.i(TAG, "isImsSwitchEnable enable 0:" + JSON.stringify(this.enableISM));
|
||||
}
|
||||
}).catch((err) => {
|
||||
if (slotId) {
|
||||
this.enableISM2 = true;
|
||||
LogUtils.i(TAG, 'isImsSwitchEnable err 1:' + JSON.stringify(this.enableISM2));
|
||||
LogUtils.i(TAG, "isImsSwitchEnable err 1:" + JSON.stringify(this.enableISM2));
|
||||
} else {
|
||||
this.enableISM = true;
|
||||
LogUtils.i(TAG, 'isImsSwitchEnable err 0:' + JSON.stringify(this.enableISM));
|
||||
LogUtils.i(TAG, "isImsSwitchEnable err 0:" + JSON.stringify(this.enableISM));
|
||||
}
|
||||
LogUtils.i(TAG, 'isImsSwitchEnabled card catch:' + JSON.stringify(err));
|
||||
LogUtils.i(TAG, "isImsSwitchEnabled card catch:" + JSON.stringify(err));
|
||||
});
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
LogUtils.i(TAG, 'aboutToAppear')
|
||||
LogUtils.i(TAG, "aboutToAppear")
|
||||
this.initAirPlaneMode();
|
||||
if (getMaxSimCount() === 2) {
|
||||
this.addRegisterSimStateChange(1);
|
||||
@ -299,35 +304,50 @@ struct Index {
|
||||
*/
|
||||
radioChange(slotId, v) {
|
||||
const res = setPreferredNetwork(slotId, v);
|
||||
LogUtils.i(TAG, 'radioChange res:' + JSON.stringify(res));
|
||||
LogUtils.i(TAG, "radioChange res:" + JSON.stringify(res));
|
||||
}
|
||||
|
||||
getCellularDataRoamingEnabled() {
|
||||
isCellularDataRoamingEnabledCardOne().then((res) => {
|
||||
LogUtils.i(TAG,'getCellularDataRoamingEnabled card one success then:' + JSON.stringify(res));
|
||||
LogUtils.i(TAG,"getCellularDataRoamingEnabled card one success then:" + JSON.stringify(res));
|
||||
this.dataRoamSwitchCardOne = res;
|
||||
}).catch((err) => {
|
||||
this.dataRoamSwitchCardOne = false;
|
||||
LogUtils.i(TAG, 'enableCellularDataRoaming card one catch:' + JSON.stringify(err));
|
||||
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));
|
||||
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));
|
||||
LogUtils.i(TAG, "enableCellularDataRoaming card two catch:" + JSON.stringify(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
clickHandle(click:number) {
|
||||
switch (click) {
|
||||
case 0:
|
||||
router.pushUrl({
|
||||
url: 'pages/networkStand'
|
||||
})
|
||||
break
|
||||
case 1:
|
||||
router.pushUrl({
|
||||
url: 'pages/apnSettings'
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
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 } }) {
|
||||
Column() {
|
||||
Column() {
|
||||
|
||||
HeadComponent();
|
||||
HeadComponent({isTouch:true,title:this.childComponentTitle});
|
||||
|
||||
Stack({ alignContent: Alignment.TopStart }) {
|
||||
Scroll(this.scroller) {
|
||||
@ -369,18 +389,18 @@ struct Index {
|
||||
.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));
|
||||
LogUtils.i(TAG, "mobile data switch changes enable:" + JSON.stringify(this.isDataEnable));
|
||||
if (this.isDataEnable == false) {
|
||||
disableCellularData().then((data) => {
|
||||
LogUtils.i(TAG, 'disableCellularData: success then' + JSON.stringify(data));
|
||||
LogUtils.i(TAG, "disableCellularData: success then" + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
LogUtils.i(TAG, 'disableCellularData: error catch' + JSON.stringify(error));
|
||||
LogUtils.i(TAG, "disableCellularData: error catch" + JSON.stringify(error));
|
||||
});
|
||||
} else {
|
||||
enableCellularData().then((data) => {
|
||||
LogUtils.i(TAG, 'enableCellularData: success then' + JSON.stringify(data));
|
||||
LogUtils.i(TAG, "enableCellularData: success then" + JSON.stringify(data));
|
||||
}).catch((error) => {
|
||||
LogUtils.i(TAG, 'enableCellularData: error catch' + JSON.stringify(error));
|
||||
LogUtils.i(TAG, "enableCellularData: error catch" + JSON.stringify(error));
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -392,14 +412,14 @@ struct Index {
|
||||
bottom: 4
|
||||
})
|
||||
.height(90)
|
||||
.width('100%')
|
||||
.width("100%")
|
||||
.borderRadius(16)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
|
||||
.opacity((this.simStateStatusCardOne || this.simStateStatusCardTwo) && !this.isAirPlaneMode ? 1 : 0.4)
|
||||
|
||||
SubHeader({
|
||||
titleContent: $r('app.string.mobile_data_card1'),
|
||||
subTitleContent: this.mTelephoneNumber
|
||||
subTitleContent: this.TelephoneNumber
|
||||
});
|
||||
|
||||
Column() {
|
||||
@ -417,7 +437,7 @@ struct Index {
|
||||
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.color("#E3E3E3")
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ right: '2%' })
|
||||
|
||||
@ -432,6 +452,51 @@ struct Index {
|
||||
isCard: true,
|
||||
isCon: 22,
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color("#E3E3E3")
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ right: '2%' })
|
||||
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text( $r('app.string.network_standard'))
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.opacity((this.simStateStatusCardOne && !this.controllerMobileNetworkIsOn) ? 0.9 : 0.6)
|
||||
.letterSpacing(1)
|
||||
.lineHeight(22)
|
||||
.textAlign(TextAlign.Start)
|
||||
Text( $r('app.string.network_standard_select'))
|
||||
.margin({ top: 2 })
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
|
||||
.opacity(0.6)
|
||||
.lineHeight(19)
|
||||
.letterSpacing(1)
|
||||
}
|
||||
.width('100%')
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.margin({ right: 26 })
|
||||
Image($r('app.media.next_icon'))
|
||||
.width(10)
|
||||
.height(15)
|
||||
.margin({ right: 10 })
|
||||
.enabled(this.simStateStatusCardOne && !this.controllerMobileNetworkIsOn)
|
||||
|
||||
}.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
|
||||
.opacity((this.simStateStatusCardOne && !this.controllerMobileNetworkIsOn) ? 1 : 0.4)
|
||||
.margin({ top: 8, bottom: this.isSupport ? 5 : 11 })
|
||||
.onClick(() => {
|
||||
if ((this.simStateStatusCardOne && !this.controllerMobileNetworkIsOn)) {
|
||||
this.clickHandle(0)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
.padding({
|
||||
left: 12,
|
||||
@ -439,14 +504,14 @@ struct Index {
|
||||
top: 4,
|
||||
bottom: 4
|
||||
})
|
||||
.width('100%')
|
||||
.width("100%")
|
||||
.borderRadius(16)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
|
||||
.opacity(this.simStateStatusCardOne && !this.isAirPlaneMode ? 1 : 0.4)
|
||||
|
||||
SubHeader({
|
||||
titleContent: $r('app.string.mobile_data_card2'),
|
||||
subTitleContent: this.mTelephoneNumber2
|
||||
subTitleContent: this.TelephoneNumber2
|
||||
})
|
||||
.visibility(getMaxSimCount() === 2 ? Visibility.Visible : Visibility.Hidden)
|
||||
|
||||
@ -464,7 +529,7 @@ struct Index {
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.color("#E3E3E3")
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ right: '2%' })
|
||||
item({
|
||||
@ -491,10 +556,10 @@ struct Index {
|
||||
top: 4,
|
||||
bottom: 4
|
||||
})
|
||||
.width('100%')
|
||||
.width("100%")
|
||||
.borderRadius(16)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.opacity(this.simStateStatusCardTwo && !this.isAirPlaneMode ? 1 : 0.4)
|
||||
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
|
||||
.opacity(this.simStateStatusCardTwo && !this.isAirPlaneMode ? 1 : 0.4)
|
||||
.visibility(getMaxSimCount() === 2 ? Visibility.Visible : Visibility.Hidden)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
@ -513,6 +578,6 @@ struct Index {
|
||||
.padding({ left: 12, right: 12 })
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
|
||||
}
|
||||
}
|
134
mobiledatasettings/src/main/ets/pages/networkStand.ets
Normal file
134
mobiledatasettings/src/main/ets/pages/networkStand.ets
Normal file
@ -0,0 +1,134 @@
|
||||
import NetworkStandItem from '../common/components/networkStandItem';
|
||||
import radio from '@ohos.telephony.radio';
|
||||
import HeadComponent from '../common/components/headComponent';
|
||||
import LogUtils from '../common/utils/LogUtils';
|
||||
|
||||
const TAG = 'NetworkStand';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct NetworkStand {
|
||||
@State @Watch('networkModeChanged') networkMode: number = 5
|
||||
@State slotId: number = 0;
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.getPreferredNetwork(this.slotId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get network mode
|
||||
*
|
||||
* @param {Object} slotId - call slotId
|
||||
*/
|
||||
async getPreferredNetwork(slotId) {
|
||||
|
||||
radio.getPreferredNetwork(slotId, (err, data: radio.PreferredNetworkMode) => {
|
||||
if (err) {
|
||||
LogUtils.e(TAG, 'getPreferredNetwork error, callback: data->' + JSON.stringify(err))
|
||||
return;
|
||||
}
|
||||
|
||||
this.networkMode = data
|
||||
LogUtils.i(TAG, 'getPreferredNetwork success, callback: data-> ' + JSON.stringify(data))
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
networkModeChanged() {
|
||||
LogUtils.i(TAG, 'networkMode Changed data-> ' + JSON.stringify(this.networkMode))
|
||||
try {
|
||||
radio.setPreferredNetwork(this.slotId, this.networkMode).then(() => {
|
||||
LogUtils.i(TAG, 'set 0 Preferred Network-> ' + JSON.stringify(this.networkMode) + ' success')
|
||||
}).catch((err) => {
|
||||
LogUtils.i(TAG, 'set 0 Preferred Network-> ' + JSON.stringify(this.networkMode) + ' failed' + JSON.stringify(err))
|
||||
});
|
||||
} catch (err) {
|
||||
LogUtils.i(TAG, 'set 0 Preferred Network-> ' + JSON.stringify(this.networkMode) + ' failed tryCatch ' + JSON.stringify(err))
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
Column() {
|
||||
HeadComponent({ title: $r('app.string.network_standard_select'), isTerminateSelf: false });
|
||||
Column() {
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_fiveAuto'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM//34
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ left: '2%', right: '2%' })
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_fourAuto'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM //5
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ left: '2%', right: '2%' })
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_threeAuto'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM//6
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ left: '2%', right: '2%' })
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_only_5g'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR//31
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ left: '2%', right: '2%' })
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_only_4g'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE//3
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ left: '2%', right: '2%' })
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_only_3g'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA//2
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ left: '2%', right: '2%' })
|
||||
NetworkStandItem({
|
||||
networkMode: $networkMode,
|
||||
title: $r('app.string.mobile_data_2g'),
|
||||
thisNetworkMode: radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_GSM//1
|
||||
})
|
||||
}
|
||||
.padding({
|
||||
left: 4,
|
||||
right: 4,
|
||||
top: 4,
|
||||
bottom: 4
|
||||
})
|
||||
.width('90%')
|
||||
.borderRadius(16)
|
||||
.backgroundColor(Color.White)
|
||||
}.height('100%')
|
||||
.width('100%')
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
}
|
||||
}
|
@ -62,15 +62,15 @@
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_fiveAuto",
|
||||
"value": "5G/4G/3G/2G Auto Select"
|
||||
"value": "5G Network First"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_fourAuto",
|
||||
"value": "4G/3G/2G Auto Select"
|
||||
"value": "4G Network First"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_threeAuto",
|
||||
"value": "3G/2G Auto Select"
|
||||
"value": "3G Network First"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_twoOnly",
|
||||
@ -128,6 +128,18 @@
|
||||
"name": "mobile_data_3g",
|
||||
"value": "3G/2G automatic selection"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_only_5g",
|
||||
"value": "5G only"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_only_4g",
|
||||
"value": "4G only"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_only_3g",
|
||||
"value": "3G only"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_2g",
|
||||
"value": "2G only"
|
||||
@ -167,6 +179,14 @@
|
||||
{
|
||||
"name": "MANAGE_SECURE_SETTINGS",
|
||||
"value": "manage secure settings"
|
||||
},
|
||||
{
|
||||
"name": "network_standard",
|
||||
"value": "Network Standard"
|
||||
},
|
||||
{
|
||||
"name": "network_standard_select",
|
||||
"value": "Select The Network Type"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
@ -1,5 +1,6 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/index"
|
||||
"pages/index",
|
||||
"pages/networkStand"
|
||||
]
|
||||
}
|
||||
|
@ -62,15 +62,15 @@
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_fiveAuto",
|
||||
"value": "5G/4G/3G/2G 自动选择"
|
||||
"value": "5G网络优先"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_fourAuto",
|
||||
"value": "4G/3G/2G 自动选择"
|
||||
"value": "4G网络优先"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_threeAuto",
|
||||
"value": "3G/2G 自动选择"
|
||||
"value": "3G网络优先"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_twoOnly",
|
||||
@ -128,9 +128,21 @@
|
||||
"name": "mobile_data_3g",
|
||||
"value": "3G/2G 自动选择"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_only_5g",
|
||||
"value": "仅使用5G网络"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_only_4g",
|
||||
"value": "仅使用4G网络"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_only_3g",
|
||||
"value": "仅使用3G网络"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_2g",
|
||||
"value": "仅 2G"
|
||||
"value": "仅使用2G网络"
|
||||
},
|
||||
{
|
||||
"name": "mobile_data_tips",
|
||||
@ -167,6 +179,14 @@
|
||||
{
|
||||
"name": "MANAGE_SECURE_SETTINGS",
|
||||
"value": "管理安全设置"
|
||||
},
|
||||
{
|
||||
"name": "network_standard",
|
||||
"value": "网络制式"
|
||||
},
|
||||
{
|
||||
"name": "network_standard_select",
|
||||
"value": "网络类型选择"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user