mirror of
https://github.com/openharmony/applications_call.git
synced 2026-07-01 20:24:03 -04:00
TicketNo:#IBGXAD Description:支持自定义专网接入点APN设置 是 否完成编程规范自检:Y 是否编程且验证通过:Y 影响的设备与平台范围:5.0 团队:中科鸿略
Signed-off-by: miaojunxiang <miaojx@superred.com.cn>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
@Preview
|
||||
@Component
|
||||
export default struct ApnInfoItem {
|
||||
@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
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
export const apnProtocoloption: string[] = ['IPv4', 'IPv6', 'IPv4/IPv6']
|
||||
|
||||
export const bearingSystemType: string[] = ['无', 'LTE', 'HSPAP', 'HSPA', 'HSUPA', 'HSDPA', 'UMTS', 'EDGE', 'GPRS', 'eHRPD', 'EVDO_B', 'EVDO_A', 'EVDO_O', '1xRTT', 'IS95B', 'IS95A']
|
||||
|
||||
export class ApnDetailDataConst {
|
||||
static readonly PROFILE_ID = 'profile_id'
|
||||
static readonly PROFILE_NAME = 'profile_name'
|
||||
static readonly APN = 'apn'
|
||||
static readonly PROXY_IP_ADDRESS = 'proxy_ip_address'
|
||||
static readonly APNPORT = 'apnPort'
|
||||
static readonly AUTH_USER = 'auth_user'
|
||||
static readonly AUTH_PWD = 'auth_pwd'
|
||||
static readonly SERVER = 'server'
|
||||
static readonly HOME_URL = 'home_url'
|
||||
static readonly MMS_IP_ADDRESS = 'mms_ip_address'
|
||||
static readonly MMSPORT = 'mmsPort'
|
||||
static readonly MCC = 'mcc'
|
||||
static readonly MNC = 'mnc'
|
||||
static readonly MCCMNC = 'mccmnc'
|
||||
static readonly AUTH_TYPE = 'auth_type'
|
||||
static readonly APN_TYPES = 'apn_types'
|
||||
static readonly APN_PROTOCOL = 'apn_protocol'
|
||||
static readonly APN_ROAM_PROTOCOL = 'apn_roam_protocol'
|
||||
static readonly IS_ROAMING_APN = 'is_roaming_apn'
|
||||
static readonly BEARING_SYSTEM_TYPE = 'bearing_system_type'
|
||||
static readonly MVNO_TYPE = 'mvno_type'
|
||||
static readonly MVNO_MATCH_DATA = 'mvno_match_data'
|
||||
static readonly EDITED = 'edited'
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
export class ApnInfo {
|
||||
profile_id: number = 0
|
||||
profile_name: string = ''
|
||||
mcc: string = ''
|
||||
mnc: string = ''
|
||||
mccmnc: string = ''
|
||||
apn: string = ''
|
||||
auth_type: number = 0
|
||||
auth_user: string = ''
|
||||
auth_pwd: string = ''
|
||||
apn_types: string = 'default'
|
||||
is_roaming_apn: number = 1
|
||||
apn_protocol: string = ''
|
||||
apn_roam_protocol: string = ''
|
||||
home_url: string = ''
|
||||
mms_ip_address: string = ''
|
||||
proxy_ip_address: string = ''
|
||||
bearing_system_type: number = 0
|
||||
mvno_type: string = ''
|
||||
mvno_match_data: string = ''
|
||||
edited: number = 0
|
||||
server: string = ''
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@Observed
|
||||
export class ApnItemInfo{
|
||||
id: string
|
||||
key: Resource
|
||||
value: string | number
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import preferences from '@ohos.data.preferences'
|
||||
|
||||
export class PreferenceUtil {
|
||||
static getStore() {
|
||||
const context = AppStorage.get<Context>('abilityContext')
|
||||
return preferences.getPreferencesSync(context, {
|
||||
name: 'preference_apn'
|
||||
})
|
||||
}
|
||||
|
||||
static put(key: string, value: preferences.ValueType) {
|
||||
const store = PreferenceUtil.getStore()
|
||||
store.putSync(key, value)
|
||||
store.flush()
|
||||
}
|
||||
|
||||
static get(key: string, defaultValue: preferences.ValueType) {
|
||||
const store = PreferenceUtil.getStore()
|
||||
return store.getSync(key, defaultValue)
|
||||
}
|
||||
|
||||
static delete(key: string) {
|
||||
const store = PreferenceUtil.getStore()
|
||||
store.deleteSync(key)
|
||||
store.flush()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
import dataShare from '@ohos.data.dataShare'
|
||||
import common from '@ohos.app.ability.common'
|
||||
import { ApnInfo } from '../common/constant/apnInfo'
|
||||
import { ValuesBucket } from '@ohos.data.ValuesBucket'
|
||||
import { BusinessError } from '@ohos.base'
|
||||
import dataSharePredicates from '@ohos.data.dataSharePredicates'
|
||||
import DataShareResultSet from '@ohos.data.DataShareResultSet'
|
||||
import { ApnItemInfo } from '../common/constant/apnItemInfo'
|
||||
import { ApnDetailDataConst } from '../common/constant/apnData'
|
||||
|
||||
|
||||
export class ApnDataStorage {
|
||||
private xmlUri: string = 'datashare:///com.ohos.pdpprofileability/net/pdp_profile/preferapn'
|
||||
private dbUri: string = 'datashare:///com.ohos.pdpprofileability/net/pdp_profile'
|
||||
private dataShareHelper: dataShare.DataShareHelper | undefined = undefined;
|
||||
private xmlShareHelper: dataShare.DataShareHelper | undefined = undefined;
|
||||
private content:Context= undefined
|
||||
|
||||
public async initData(context: Context) {
|
||||
this.content = context
|
||||
if (this.dataShareHelper == null || this.dataShareHelper == undefined) {
|
||||
this.dataShareHelper = await this.createDBHelper(context)
|
||||
}
|
||||
if (this.xmlShareHelper == null || this.xmlShareHelper == undefined) {
|
||||
this.xmlShareHelper = await this.createXmlHelper(context)
|
||||
}
|
||||
}
|
||||
|
||||
async createXmlHelper(context: Context): Promise<dataShare.DataShareHelper> {
|
||||
return await dataShare.createDataShareHelper(context, this.xmlUri)
|
||||
}
|
||||
|
||||
async createDBHelper(context: Context): Promise<dataShare.DataShareHelper> {
|
||||
return await dataShare.createDataShareHelper(context, this.dbUri)
|
||||
}
|
||||
|
||||
|
||||
public async updateXmlPeofileID(simID: number, profileID: number): Promise<boolean> {
|
||||
let success: boolean = false
|
||||
let xmlData = new dataSharePredicates.DataSharePredicates();
|
||||
let data: ValuesBucket = {
|
||||
'sim_id': 1,
|
||||
'profile_id': profileID,
|
||||
}
|
||||
this.xmlShareHelper.update(this.xmlUri, xmlData, data).then(insertData => {
|
||||
success = true
|
||||
}).catch((err: BusinessError) => {
|
||||
success = false
|
||||
})
|
||||
return success
|
||||
}
|
||||
|
||||
ResourceToString(resource: Resource): string {
|
||||
return this.content.resourceManager.getStringSync(resource)
|
||||
}
|
||||
|
||||
public async dataDelete(profileID: number): Promise<boolean> {
|
||||
let success: boolean = false
|
||||
let da = new dataSharePredicates.DataSharePredicates();
|
||||
da.equalTo('profile_id', Number(profileID));
|
||||
await this.dataShareHelper.delete(this.dbUri, da).then(data => {
|
||||
success = true
|
||||
}).catch((err: BusinessError) => {
|
||||
success = false
|
||||
})
|
||||
return success
|
||||
}
|
||||
|
||||
|
||||
public async dataInsert(apnInfo: ApnInfo): Promise<boolean> {
|
||||
let success: boolean = false
|
||||
let data = this.getValuesBucket(apnInfo)
|
||||
await this.dataShareHelper.insert(this.dbUri, data).then(insertData => {
|
||||
success = true
|
||||
}).catch((err: BusinessError) => {
|
||||
success = false
|
||||
})
|
||||
return success
|
||||
}
|
||||
|
||||
|
||||
public async dataUpdate(apnInfo: ApnInfo): Promise<boolean> {
|
||||
let success: boolean = false
|
||||
let data = this.getValuesBucket(apnInfo)
|
||||
let conditionData = new dataSharePredicates.DataSharePredicates();
|
||||
conditionData.equalTo('profile_id', Number(apnInfo.profile_id));
|
||||
await this.dataShareHelper.update(this.dbUri, conditionData, data).then(insertData => {
|
||||
success = true
|
||||
}).catch((err: BusinessError) => {
|
||||
success = false
|
||||
})
|
||||
return success
|
||||
}
|
||||
|
||||
|
||||
getValuesBucket(apnInfo: ApnInfo): ValuesBucket {
|
||||
let data: ValuesBucket = {
|
||||
'profile_name': apnInfo.profile_name,
|
||||
'apn': apnInfo.apn,
|
||||
'proxy_ip_address': apnInfo.proxy_ip_address,
|
||||
'auth_user': apnInfo.auth_user,
|
||||
'auth_pwd': apnInfo.auth_pwd,
|
||||
'home_url': apnInfo.home_url,
|
||||
'mms_ip_address': apnInfo.mms_ip_address,
|
||||
'mcc': apnInfo.mcc,
|
||||
'mnc': apnInfo.mnc,
|
||||
'mccmnc': apnInfo.mcc + apnInfo.mnc,
|
||||
'auth_type': Number(apnInfo.auth_type),
|
||||
'apn_types': apnInfo.apn_types,
|
||||
'apn_protocol': apnInfo.apn_protocol,
|
||||
'apn_roam_protocol': apnInfo.apn_roam_protocol,
|
||||
'is_roaming_apn': 1,
|
||||
'bearing_system_type': Number(apnInfo.bearing_system_type),
|
||||
'edited': 1,
|
||||
'server': apnInfo.server,
|
||||
'mvno_type': apnInfo.mvno_type,
|
||||
'mvno_match_data': apnInfo.mvno_match_data
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
public listToApnInfo(list: Array<ApnItemInfo>, edited: number, profileID: number): ApnInfo {
|
||||
let apnInfo = new ApnInfo()
|
||||
if (edited === 1) {
|
||||
apnInfo.profile_id = profileID
|
||||
}
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let apnItemInfo = list[i]
|
||||
if (apnItemInfo.value.toString() === this.ResourceToString($r('app.string.apn_not_configured')) ||
|
||||
apnItemInfo.value.toString() === this.ResourceToString($r('app.string.apn_null'))) {
|
||||
apnItemInfo.value = ''
|
||||
}
|
||||
switch (apnItemInfo.id) {
|
||||
case ApnDetailDataConst.PROFILE_NAME:
|
||||
apnInfo.profile_name = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.APN:
|
||||
apnInfo.apn = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.PROXY_IP_ADDRESS:
|
||||
if (apnItemInfo.value.toString() == '') {
|
||||
apnInfo.proxy_ip_address = ''
|
||||
} else {
|
||||
apnInfo.proxy_ip_address = apnItemInfo.value.toString()
|
||||
}
|
||||
break
|
||||
case ApnDetailDataConst.APNPORT:
|
||||
if (apnItemInfo.value.toString() == '') {
|
||||
apnInfo.proxy_ip_address = apnInfo.proxy_ip_address
|
||||
} else {
|
||||
apnInfo.proxy_ip_address = apnInfo.proxy_ip_address + ':' + apnItemInfo.value.toString()
|
||||
}
|
||||
break
|
||||
case ApnDetailDataConst.AUTH_USER:
|
||||
apnInfo.auth_user = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.AUTH_PWD:
|
||||
apnInfo.auth_pwd = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.SERVER:
|
||||
apnInfo.server = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.HOME_URL:
|
||||
apnInfo.home_url = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.MMS_IP_ADDRESS:
|
||||
if (apnItemInfo.value.toString() == '') {
|
||||
apnInfo.mms_ip_address = ''
|
||||
} else {
|
||||
apnInfo.mms_ip_address = apnItemInfo.value.toString()
|
||||
}
|
||||
break
|
||||
case ApnDetailDataConst.MMSPORT:
|
||||
if (apnItemInfo.value.toString() == '') {
|
||||
apnInfo.mms_ip_address = apnInfo.mms_ip_address
|
||||
} else {
|
||||
apnInfo.mms_ip_address = apnInfo.mms_ip_address + ':' + apnItemInfo.value.toString()
|
||||
}
|
||||
break
|
||||
|
||||
case ApnDetailDataConst.MCC:
|
||||
apnInfo.mcc = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.MNC:
|
||||
apnInfo.mnc = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.AUTH_TYPE:
|
||||
apnInfo.auth_type = Number(apnItemInfo.value)
|
||||
break
|
||||
case ApnDetailDataConst.APN_TYPES:
|
||||
apnInfo.apn_types = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.APN_PROTOCOL :
|
||||
apnInfo.apn_protocol = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.APN_ROAM_PROTOCOL:
|
||||
apnInfo.apn_roam_protocol = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.BEARING_SYSTEM_TYPE:
|
||||
apnInfo.bearing_system_type = Number(apnItemInfo.value)
|
||||
break
|
||||
case ApnDetailDataConst.MVNO_TYPE:
|
||||
apnInfo.mvno_type = apnItemInfo.value.toString()
|
||||
break
|
||||
case ApnDetailDataConst.MVNO_MATCH_DATA:
|
||||
apnInfo.mvno_match_data = apnItemInfo.value.toString()
|
||||
break
|
||||
|
||||
}
|
||||
}
|
||||
return apnInfo
|
||||
}
|
||||
|
||||
|
||||
public async queryApnList(mccmnc: string): Promise<DataShareResultSet> {
|
||||
let resultSet: DataShareResultSet = null
|
||||
let columns = ['*'];
|
||||
let da = new dataSharePredicates.DataSharePredicates();
|
||||
da.equalTo('mccmnc', mccmnc)
|
||||
.and()
|
||||
.beginWrap()
|
||||
.beginWrap()
|
||||
.beginWrap()
|
||||
.like('apn_types', '%default%')
|
||||
.or()
|
||||
.like('apn_types', '%mms%')
|
||||
.endWrap()
|
||||
.and()
|
||||
.equalTo('edited', 0)
|
||||
.endWrap()
|
||||
.or()
|
||||
.equalTo('edited', 1)
|
||||
.endWrap()
|
||||
try {
|
||||
if (this.dataShareHelper != undefined) {
|
||||
await (this.dataShareHelper as dataShare.DataShareHelper).query(this.dbUri, da, columns)
|
||||
.then((dataShareResultSet: DataShareResultSet) => {
|
||||
resultSet = dataShareResultSet
|
||||
})
|
||||
.catch((err: BusinessError) => {
|
||||
resultSet = null
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
let message = (err as BusinessError).message;
|
||||
resultSet = null
|
||||
}
|
||||
return resultSet
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,641 @@
|
||||
import { ApnInfo } from '../common/constant/apnInfo';
|
||||
import router from '@ohos.router';
|
||||
import { ApnDataStorage } from '../model/apnDataStorage';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import sim from '@ohos.telephony.sim';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
import { ApnItemInfo } from '../common/constant/apnItemInfo';
|
||||
import { ApnDetailDataConst } from '../common/constant/apnData';
|
||||
|
||||
|
||||
export class ApnProxy {
|
||||
proxy: string = ''
|
||||
port: string = ''
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@Component
|
||||
struct EditDialog {
|
||||
@Link textValue: Resource
|
||||
@Link inputValue: string
|
||||
@State value: string = ''
|
||||
controller?: CustomDialogController
|
||||
cancel: () => void = () => {
|
||||
}
|
||||
confirm: () => void = () => {
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(this.textValue).fontSize(20).margin({ top: 10, bottom: 10 })
|
||||
TextInput({ placeholder: this.inputValue, text: this.inputValue })
|
||||
.height(60)
|
||||
.width('90%')
|
||||
.showUnderline(false)
|
||||
.borderRadius(0)
|
||||
.onChange((value: string) => {
|
||||
this.value = value
|
||||
})
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button($r('app.string.apn_cancel')).onClick(() => {
|
||||
if (this.controller != undefined) {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
}
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
Button($r('app.string.ok'))
|
||||
.onClick(() => {
|
||||
if (this.controller != undefined) {
|
||||
this.inputValue = this.value
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
}
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
}.margin({ bottom: 10 })
|
||||
}.backgroundColor(Color.White)
|
||||
.width('100%')
|
||||
.borderRadius(10)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CustomDialog
|
||||
@Component
|
||||
struct SingleSelectDialog {
|
||||
@Link textValue: Resource
|
||||
@Link inputValue: string
|
||||
@Link selectList: string[]
|
||||
tmpValue: string = this.inputValue
|
||||
controller?: CustomDialogController
|
||||
cancel: () => void = () => {
|
||||
}
|
||||
confirm: () => void = () => {
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(this.textValue).fontSize(20).margin({ top: 10, bottom: 10 })
|
||||
List() {
|
||||
ForEach(this.selectList, (item: string) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Text(item)
|
||||
Radio({ value: item, group: 'radioGroup' })
|
||||
.checked(this.inputValue == item)
|
||||
.onChange((isChecked: boolean) => {
|
||||
if (isChecked) {
|
||||
this.tmpValue = item
|
||||
} else {
|
||||
this.tmpValue = this.inputValue
|
||||
}
|
||||
})
|
||||
}.width('95%')
|
||||
.margin({ left: 20, right: 20 })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button($r('app.string.apn_cancel'))
|
||||
.onClick(() => {
|
||||
if (this.controller != undefined) {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
}
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
Button($r('app.string.ok'))
|
||||
.onClick(() => {
|
||||
if (this.controller != undefined) {
|
||||
this.inputValue = this.tmpValue
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
}
|
||||
})
|
||||
.backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
}.margin({ bottom: 10 })
|
||||
}
|
||||
.backgroundColor(Color.White)
|
||||
.width('100%')
|
||||
.borderRadius(10)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CustomDialog
|
||||
@Component
|
||||
struct MultipleSelectDialog {
|
||||
@Link textValue: Resource
|
||||
@Link inputValue: string
|
||||
@Link selectList: string[]
|
||||
tmpList: string[] = []
|
||||
controller?: CustomDialogController
|
||||
cancel: () => void = () => {
|
||||
}
|
||||
confirm: () => void = () => {
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text(this.textValue).fontSize(20).margin({ top: 10, bottom: 10 })
|
||||
List() {
|
||||
ForEach(this.selectList, (item: string) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Text(item)
|
||||
Checkbox({ name: item, group: 'checkboxGroup' })
|
||||
.select(this.inputValue === item)
|
||||
.selectedColor(Color.Blue)
|
||||
.onChange((isChecked: boolean) => {
|
||||
if (isChecked) {
|
||||
this.tmpList.push(item)
|
||||
} else {
|
||||
let index = this.tmpList.indexOf(item)
|
||||
this.tmpList.slice(index, 1)
|
||||
}
|
||||
})
|
||||
}.width('95%')
|
||||
.margin({ left: 20, right: 20 })
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
})
|
||||
|
||||
}.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button($r('app.string.apn_cancel'))
|
||||
.onClick(() => {
|
||||
if (this.controller != undefined) {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
}
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
Button($r('app.string.ok'))
|
||||
.onClick(() => {
|
||||
if (this.controller != undefined) {
|
||||
if (this.tmpList.length > 0) {
|
||||
this.inputValue = this.tmpList.join(',');
|
||||
}
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
}
|
||||
})
|
||||
.backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
}.margin({ bottom: 10 })
|
||||
}.backgroundColor(Color.White)
|
||||
.width('100%')
|
||||
.height('50%')
|
||||
.borderRadius(10)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ApnDetail {
|
||||
|
||||
private storage: ApnDataStorage = new ApnDataStorage()
|
||||
@State name: string = ''
|
||||
@State textValue: Resource | null = null
|
||||
@State inputValue: string = ''
|
||||
@State list: Array<ApnItemInfo> = []
|
||||
@State apnInfo: ApnInfo = router.getParams() as ApnInfo
|
||||
@State selectList: string[] = []
|
||||
@State title: string = ''
|
||||
@State edited: number = 0 //0不可编辑 1 可编辑 2 新增
|
||||
@State profileID: number = 0
|
||||
@StorageLink('ApnStatus') apnStatus: boolean = false;
|
||||
dialogController: CustomDialogController | null = new CustomDialogController({
|
||||
builder: EditDialog({
|
||||
cancel: () => {
|
||||
this.onCancel()
|
||||
},
|
||||
confirm: () => {
|
||||
this.onAccept()
|
||||
},
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue
|
||||
}),
|
||||
cancel: this.exitApp,
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Center,
|
||||
offset: { dx: 0, dy: -20 },
|
||||
gridCount: 4,
|
||||
customStyle: false,
|
||||
cornerRadius: 10,
|
||||
})
|
||||
singleSelectDialogController: CustomDialogController | null = new CustomDialogController({
|
||||
builder: SingleSelectDialog({
|
||||
cancel: () => {
|
||||
this.onCancel()
|
||||
},
|
||||
confirm: () => {
|
||||
this.onAccept()
|
||||
},
|
||||
selectList: $selectList,
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue
|
||||
}),
|
||||
cancel: this.exitApp,
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Center,
|
||||
offset: { dx: 0, dy: -20 },
|
||||
gridCount: 4,
|
||||
customStyle: false,
|
||||
cornerRadius: 10,
|
||||
})
|
||||
multipleSelectDialogController: CustomDialogController | null = new CustomDialogController({
|
||||
builder: MultipleSelectDialog({
|
||||
cancel: () => {
|
||||
this.onCancel()
|
||||
},
|
||||
confirm: () => {
|
||||
this.onAccept()
|
||||
},
|
||||
selectList: $selectList,
|
||||
textValue: $textValue,
|
||||
inputValue: $inputValue
|
||||
}),
|
||||
cancel: this.exitApp,
|
||||
autoCancel: true,
|
||||
alignment: DialogAlignment.Center,
|
||||
offset: { dx: 0, dy: -20 },
|
||||
gridCount: 4,
|
||||
customStyle: false,
|
||||
cornerRadius: 10,
|
||||
})
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.storage.initData(getContext() as common.UIAbilityContext)
|
||||
this.getDataList()
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
this.dialogController = null
|
||||
this.singleSelectDialogController = null
|
||||
this.multipleSelectDialogController = null
|
||||
}
|
||||
|
||||
onCancel() {
|
||||
}
|
||||
|
||||
onAccept() {
|
||||
for (let i = 0; i < this.list.length; i++) {
|
||||
if (this.list[i].key.id == this.textValue.id) {
|
||||
let apnInfo = new ApnItemInfo()
|
||||
apnInfo.id = this.list[i].id
|
||||
apnInfo.key = this.textValue
|
||||
apnInfo.value = this.inputValue
|
||||
this.list[i] = apnInfo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exitApp() {
|
||||
console.info('Click the callback in the blank area')
|
||||
}
|
||||
|
||||
getProxyPort(pp: string[]): ApnProxy {
|
||||
let length = pp.length
|
||||
let resproxy: string = ''
|
||||
let resport: string = ''
|
||||
pp.forEach((value, index) => {
|
||||
if (index < length - 1) {
|
||||
if (resproxy === '') {
|
||||
resproxy += value
|
||||
} else {
|
||||
resproxy += ':' + value
|
||||
}
|
||||
} else {
|
||||
resport = value
|
||||
}
|
||||
})
|
||||
let res: ApnProxy = {
|
||||
proxy: resproxy,
|
||||
port: resport
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
getDataList() {
|
||||
let simOpKey: string = sim.getSimOperatorNumericSync(0);
|
||||
if (this.apnInfo) {
|
||||
this.title = this.apnInfo.profile_name
|
||||
this.edited = this.apnInfo.edited
|
||||
this.profileID = this.apnInfo.profile_id
|
||||
} else {
|
||||
this.edited = 2
|
||||
this.apnInfo = new ApnInfo()
|
||||
}
|
||||
|
||||
//名称
|
||||
let name: ApnItemInfo = new ApnItemInfo()
|
||||
name.id = ApnDetailDataConst.PROFILE_NAME
|
||||
name.key = $r('app.string.apn_name')
|
||||
name.value = this.isNoConfig(this.apnInfo.profile_name)
|
||||
this.list.push(name)
|
||||
//apn
|
||||
let apn: ApnItemInfo = new ApnItemInfo()
|
||||
apn.id = ApnDetailDataConst.APN
|
||||
apn.key = $r('app.string.apn_apn')
|
||||
apn.value = this.isNoConfig(this.apnInfo.apn)
|
||||
this.list.push(apn)
|
||||
//代理
|
||||
let apnProxy: ApnItemInfo = new ApnItemInfo()
|
||||
apnProxy.id = ApnDetailDataConst.PROXY_IP_ADDRESS
|
||||
apnProxy.key = $r('app.string.apn_proxy')
|
||||
|
||||
//代理端口
|
||||
let apnPort: ApnItemInfo = new ApnItemInfo()
|
||||
apnPort.id = ApnDetailDataConst.APNPORT
|
||||
apnPort.key = $r('app.string.apn_port')
|
||||
let proxyIPAddressList = this.apnInfo.proxy_ip_address.split(':');
|
||||
if (proxyIPAddressList.length >= 2) {
|
||||
let obj = this.getProxyPort(proxyIPAddressList)
|
||||
apnProxy.value = obj.proxy
|
||||
apnPort.value = obj.port
|
||||
} else {
|
||||
apnProxy.value = this.isNoConfig(this.apnInfo.proxy_ip_address)
|
||||
apnPort.value = this.ResourceToString($r('app.string.apn_not_configured'))
|
||||
}
|
||||
this.list.push(apnProxy)
|
||||
this.list.push(apnPort)
|
||||
|
||||
//用户名
|
||||
let authName: ApnItemInfo = new ApnItemInfo()
|
||||
authName.id = ApnDetailDataConst.AUTH_USER
|
||||
authName.key = $r('app.string.apn_auth_user')
|
||||
authName.value = this.isNoConfig(this.apnInfo.auth_user)
|
||||
this.list.push(authName)
|
||||
//密码
|
||||
let authPwd: ApnItemInfo = new ApnItemInfo()
|
||||
authPwd.id = ApnDetailDataConst.AUTH_PWD
|
||||
authPwd.key = $r('app.string.apn_auth_pwd')
|
||||
authPwd.value = this.isNoConfig(this.apnInfo.auth_pwd)
|
||||
this.list.push(authPwd)
|
||||
//服务器
|
||||
let server: ApnItemInfo = new ApnItemInfo()
|
||||
server.id = ApnDetailDataConst.SERVER
|
||||
server.key = $r('app.string.apn_server')
|
||||
server.value = this.isNoConfig(this.apnInfo.server)
|
||||
this.list.push(server)
|
||||
//mmsc
|
||||
let mmsc: ApnItemInfo = new ApnItemInfo()
|
||||
mmsc.id = ApnDetailDataConst.HOME_URL
|
||||
mmsc.key = $r('app.string.apn_mmsc')
|
||||
mmsc.value = this.isNoConfig(this.apnInfo.home_url)
|
||||
this.list.push(mmsc)
|
||||
//彩信代理
|
||||
let mmsProxy: ApnItemInfo = new ApnItemInfo()
|
||||
mmsProxy.id = ApnDetailDataConst.MMS_IP_ADDRESS
|
||||
mmsProxy.key = $r('app.string.apn_mms_proxy')
|
||||
//彩信端口
|
||||
let mmsPort: ApnItemInfo = new ApnItemInfo()
|
||||
mmsPort.id = ApnDetailDataConst.MMSPORT
|
||||
mmsPort.key = $r('app.string.apn_mms_port')
|
||||
|
||||
let mmsProxyIPAddressList = this.apnInfo.mms_ip_address.split(':');
|
||||
if (mmsProxyIPAddressList.length >= 2) {
|
||||
let obj = this.getProxyPort(mmsProxyIPAddressList)
|
||||
mmsProxy.value = obj.proxy
|
||||
mmsPort.value = obj.port
|
||||
} else {
|
||||
mmsProxy.value = this.isNoConfig(this.apnInfo.mms_ip_address)
|
||||
mmsPort.value = this.ResourceToString($r('app.string.apn_not_configured'))
|
||||
}
|
||||
this.list.push(mmsProxy)
|
||||
this.list.push(mmsPort)
|
||||
|
||||
//mcc
|
||||
let mcc: ApnItemInfo = new ApnItemInfo()
|
||||
mcc.id = ApnDetailDataConst.MCC
|
||||
mcc.key = $r('app.string.apn_mcc')
|
||||
mcc.value = (this.apnInfo.mcc === '' ? simOpKey.substring(0, 3) : this.apnInfo.mcc)
|
||||
this.list.push(mcc)
|
||||
//mnc
|
||||
let mnc: ApnItemInfo = new ApnItemInfo()
|
||||
mnc.id = ApnDetailDataConst.MNC
|
||||
mnc.key = $r('app.string.apn_mnc')
|
||||
mnc.value = (this.apnInfo.mnc === '' ? simOpKey.substring(3, 5) : this.apnInfo.mnc)
|
||||
this.list.push(mnc)
|
||||
//身份验证类型
|
||||
let authType: ApnItemInfo = new ApnItemInfo()
|
||||
authType.id = ApnDetailDataConst.AUTH_TYPE
|
||||
authType.key = $r('app.string.apn_auth_type')
|
||||
authType.value = this.isNullDefaultTxt(this.apnInfo.auth_type)
|
||||
this.list.push(authType)
|
||||
//APN类型
|
||||
let apnType: ApnItemInfo = new ApnItemInfo()
|
||||
apnType.id = ApnDetailDataConst.APN_TYPES
|
||||
apnType.key = $r('app.string.apn_apn_types')
|
||||
apnType.value = (this.apnInfo.apn_types === '' ? 'default' : this.apnInfo.apn_types)
|
||||
this.list.push(apnType)
|
||||
//APN协议
|
||||
let apnProtocol: ApnItemInfo = new ApnItemInfo()
|
||||
apnProtocol.id = ApnDetailDataConst.APN_PROTOCOL
|
||||
apnProtocol.key = $r('app.string.apn_apn_protocol')
|
||||
apnProtocol.value = (this.apnInfo.apn_protocol === '' ? 'IPv4' : this.apnInfo.apn_protocol)
|
||||
this.list.push(apnProtocol)
|
||||
//APN漫游协议
|
||||
let apnRoamProtocol: ApnItemInfo = new ApnItemInfo()
|
||||
apnRoamProtocol.id = ApnDetailDataConst.APN_ROAM_PROTOCOL
|
||||
apnRoamProtocol.key = $r('app.string.apn_apn_roam_protocol')
|
||||
apnRoamProtocol.value = (this.apnInfo.apn_roam_protocol === '' ? 'IPv4' : this.apnInfo.apn_roam_protocol)
|
||||
this.list.push(apnRoamProtocol)
|
||||
//APN承载系统
|
||||
let apnBearingSystemType: ApnItemInfo = new ApnItemInfo()
|
||||
apnBearingSystemType.id = ApnDetailDataConst.BEARING_SYSTEM_TYPE
|
||||
apnBearingSystemType.key = $r('app.string.apn_bearing_system_type')
|
||||
apnBearingSystemType.value = this.isNullDefaultTxt(this.apnInfo.bearing_system_type)
|
||||
this.list.push(apnBearingSystemType)
|
||||
//mvno类型
|
||||
let mvnoType: ApnItemInfo = new ApnItemInfo()
|
||||
mvnoType.id = ApnDetailDataConst.MVNO_TYPE
|
||||
mvnoType.key = $r('app.string.apn_mvno_type')
|
||||
mvnoType.value = this.isNullDefaultTxt(this.apnInfo.mvno_type)
|
||||
this.list.push(mvnoType)
|
||||
//mvno值
|
||||
let mvnoData: ApnItemInfo = new ApnItemInfo()
|
||||
mvnoData.id = ApnDetailDataConst.MVNO_MATCH_DATA
|
||||
mvnoData.key = $r('app.string.apn_mvno_match_data')
|
||||
mvnoData.value = this.isNullDefaultTxt(this.apnInfo.mvno_match_data)
|
||||
this.list.push(mvnoData)
|
||||
}
|
||||
|
||||
isNullDefaultTxt(value: string | number): string {
|
||||
return (value === '' || value === 0) ? this.ResourceToString($r('app.string.apn_null')) : value.toString()
|
||||
}
|
||||
|
||||
isNoConfig(value: string | number): string {
|
||||
return (value === '' || value === 0) ? this.ResourceToString($r('app.string.apn_not_configured')) : value.toString()
|
||||
}
|
||||
|
||||
ResourceToString(resource: Resource): string {
|
||||
return getContext(this).resourceManager.getStringSync(resource)
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Row() {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Image($r('app.media.ic_back'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
}
|
||||
.margin({ right: 10 })
|
||||
.backgroundColor($r('app.color.color_00000000_transparent'))
|
||||
.onClick(() => {
|
||||
router.back()
|
||||
})
|
||||
|
||||
Text(this.title === '' ? $r('app.string.apn_add') : this.title)
|
||||
.fontSize(20)
|
||||
.fontFamily('HarmonyHeiTi-Bold')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({ top: 15, bottom: 15 });
|
||||
}
|
||||
|
||||
Image($r('app.media.ic_apn_save'))
|
||||
.width(28)
|
||||
.height(28)
|
||||
.visibility(this.edited === 0 ? Visibility.None : Visibility.Visible)
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
.onClick((event: ClickEvent) => {
|
||||
let name = this.list[0].value
|
||||
if (name === '' || name === this.ResourceToString($r('app.string.apn_not_configured'))) {
|
||||
promptAction.showToast({
|
||||
message: this.ResourceToString($r('app.string.apn_tips_name_null')),
|
||||
duration: 2000
|
||||
});
|
||||
return
|
||||
}
|
||||
let apn = this.list[1].value
|
||||
if (apn === '' || apn === this.ResourceToString($r('app.string.apn_not_configured'))) {
|
||||
promptAction.showToast({
|
||||
message: this.ResourceToString($r('app.string.apn_tips_apn_null')),
|
||||
duration: 2000
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.edited == 2) { //新增
|
||||
this.storage.dataInsert(this.storage.listToApnInfo(this.list, 2, this.profileID))
|
||||
.then((success) => {
|
||||
if (success) {
|
||||
AppStorage.setOrCreate<boolean>('ApnStatus',!this.apnStatus)
|
||||
router.back()
|
||||
}
|
||||
})
|
||||
} else { //编辑
|
||||
this.storage.dataUpdate(this.storage.listToApnInfo(this.list, 1, this.profileID))
|
||||
.then((success) => {
|
||||
if (success) {
|
||||
AppStorage.setOrCreate<boolean>('ApnStatus',!this.apnStatus)
|
||||
router.back()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.width('100%')
|
||||
.padding({ left: 12, right: 12 })
|
||||
.height(56)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.align(Alignment.Start)
|
||||
|
||||
List() {
|
||||
ForEach(this.list, (item: ApnItemInfo) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Text(item.key)
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor(this.edited == 0 ? '#666666' : $r('sys.color.ohos_id_color_text_primary'))
|
||||
.letterSpacing(1)
|
||||
.lineHeight(22)
|
||||
.textAlign(TextAlign.Start)
|
||||
|
||||
Text(item.value.toString())
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor(this.edited == 0 ? '#666666' : $r('sys.color.ohos_id_color_text_primary'))
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
.height(50)
|
||||
.width('96%')
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.borderRadius(10)
|
||||
.backgroundColor(Color.White)
|
||||
.margin({ top: 5, left: 10, right: 10, bottom: 5 })
|
||||
.padding({ left: 10, right: 10 })
|
||||
|
||||
}
|
||||
.enabled(this.edited == 0 ? false : true)
|
||||
.onClick((event: ClickEvent) => {
|
||||
this.textValue = item.key
|
||||
this.inputValue = (item.value.toString() === this.ResourceToString($r('app.string.apn_not_configured'))) ? '' : item.value.toString()
|
||||
if (item.id == 'auth_type') {
|
||||
this.selectList = [this.ResourceToString($r('app.string.apn_null')), 'PAP', 'CHAP', 'PAP/CHAP']
|
||||
if (this.singleSelectDialogController != null){
|
||||
this.singleSelectDialogController.open()
|
||||
}
|
||||
} else if (item.id == 'apn_protocol') {
|
||||
this.selectList = ['IPv4', 'IPv6', 'IPv4/IPv6']
|
||||
if (this.singleSelectDialogController != null){
|
||||
this.singleSelectDialogController.open()
|
||||
}
|
||||
} else if (item.id == 'apn_roam_protocol') {
|
||||
this.selectList = ['IPv4', 'IPv6', 'IPv4/IPv6']
|
||||
if (this.singleSelectDialogController != null){
|
||||
this.singleSelectDialogController.open()
|
||||
}
|
||||
} else if (item.id == 'bearing_system_type') {
|
||||
this.selectList = [this.ResourceToString($r('app.string.apn_null')), 'LTE', 'HSPAP', 'HSPA', 'HSUPA', 'HSDPA', 'UMTS', 'EDGE', 'GPRS', 'eHRPD', 'EVDO_B', 'EVDO_A', 'EVDO_O', '1xRTT', 'IS95B', 'IS95A']
|
||||
if (this.multipleSelectDialogController != null){
|
||||
this.multipleSelectDialogController.open()
|
||||
}
|
||||
} else if (item.id == 'mvno_type') {
|
||||
this.selectList = [this.ResourceToString($r('app.string.apn_null')), 'SPN', 'IMSI', 'GID']
|
||||
if (this.singleSelectDialogController != null){
|
||||
this.singleSelectDialogController.open()
|
||||
}
|
||||
} else {
|
||||
this.dialogController.open()
|
||||
}
|
||||
})
|
||||
})
|
||||
}.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
||||
Row() {
|
||||
Image($r('app.media.ic_apn_delete')).width(25).height(25).onClick((even: ClickEvent) => {
|
||||
this.storage.dataDelete(this.profileID)
|
||||
.then((success) => {
|
||||
if (success) {
|
||||
AppStorage.setOrCreate<boolean>('ApnStatus',!this.apnStatus)
|
||||
router.back()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(40)
|
||||
.backgroundColor(Color.White)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.visibility(this.edited === 1 ? Visibility.Visible : Visibility.None)
|
||||
}.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import router from '@ohos.router';
|
||||
import sim from '@ohos.telephony.sim';
|
||||
import { ApnInfo } from '../common/constant/apnInfo';
|
||||
import { PreferenceUtil } from '../common/utils/PreferenceUtil';
|
||||
import { ApnDataStorage } from '../model/apnDataStorage';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { ApnDetailDataConst } from '../common/constant/apnData';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct ApnList {
|
||||
private storage: ApnDataStorage = new ApnDataStorage()
|
||||
@State apnList: ApnInfo[] = []
|
||||
@State mccmnc: string = ''
|
||||
@State selectedApn: number = -1
|
||||
private cardTpye: number = 0
|
||||
@StorageLink('ApnStatus') @Watch('queryApnList') apnStatus: boolean = false;
|
||||
|
||||
async aboutToAppear() {
|
||||
this.storage.initData(getContext() as common.UIAbilityContext).then(() => {
|
||||
this.queryApnList()
|
||||
})
|
||||
this.mccmnc = sim.getSimOperatorNumericSync(this.cardTpye)
|
||||
this.selectedApn = Number(PreferenceUtil.get('select_apn_common_' + this.mccmnc, -1))
|
||||
|
||||
}
|
||||
|
||||
onPageShow(): void {
|
||||
this.queryApnList()
|
||||
}
|
||||
|
||||
queryApnList() {
|
||||
this.apnList = []
|
||||
this.storage.queryApnList(this.mccmnc).then((resultSet) => {
|
||||
if (resultSet == null){
|
||||
return
|
||||
}
|
||||
|
||||
while (resultSet.goToNextRow()) {
|
||||
let info: ApnInfo = new ApnInfo()
|
||||
info.profile_id = resultSet.getLong(resultSet.getColumnIndex(ApnDetailDataConst.PROFILE_ID));
|
||||
info.profile_name = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.PROFILE_NAME));
|
||||
info.mcc = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.MCC));
|
||||
info.mnc = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.MNC));
|
||||
info.mccmnc = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.MCCMNC));
|
||||
info.apn = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.APN));
|
||||
info.auth_type = resultSet.getLong(resultSet.getColumnIndex(ApnDetailDataConst.AUTH_TYPE));
|
||||
info.auth_user = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.AUTH_USER));
|
||||
info.auth_pwd = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.AUTH_PWD));
|
||||
info.apn_types = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.APN_TYPES));
|
||||
info.is_roaming_apn = resultSet.getLong(resultSet.getColumnIndex(ApnDetailDataConst.IS_ROAMING_APN));
|
||||
info.apn_protocol = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.APN_PROTOCOL));
|
||||
info.apn_roam_protocol = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.APN_ROAM_PROTOCOL));
|
||||
info.home_url = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.HOME_URL));
|
||||
info.mms_ip_address = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.MMS_IP_ADDRESS));
|
||||
info.proxy_ip_address = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.PROXY_IP_ADDRESS));
|
||||
info.bearing_system_type = resultSet.getLong(resultSet.getColumnIndex(ApnDetailDataConst.BEARING_SYSTEM_TYPE));
|
||||
info.mvno_type = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.MVNO_TYPE));
|
||||
info.mvno_match_data = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.MVNO_MATCH_DATA));
|
||||
info.edited = resultSet.getLong(resultSet.getColumnIndex(ApnDetailDataConst.EDITED));
|
||||
info.server = resultSet.getString(resultSet.getColumnIndex(ApnDetailDataConst.SERVER));
|
||||
this.apnList.push(info)
|
||||
let id = PreferenceUtil.get('select_apn_common_' + this.mccmnc, -1)
|
||||
if (id == -1) {
|
||||
PreferenceUtil.put('select_apn_common_' + this.mccmnc, resultSet.getLong(resultSet.getColumnIndex('profile_id')))
|
||||
}
|
||||
this.selectedApn = Number(PreferenceUtil.get('select_apn_common_' + this.mccmnc, -1))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Row() {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Image($r('app.media.ic_back'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
}
|
||||
.margin({ right: 16 })
|
||||
.backgroundColor($r('app.color.color_00000000_transparent'))
|
||||
.onClick(() => {
|
||||
router.back()
|
||||
})
|
||||
|
||||
Text($r('app.string.apn_title'))
|
||||
.fontSize(20)
|
||||
.fontFamily('HarmonyHeiTi-Bold')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({ top: 15, bottom: 15 });
|
||||
}
|
||||
|
||||
Image($r('app.media.ic_add'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.fillColor($r('sys.color.ohos_id_color_primary'))
|
||||
.onClick((event: ClickEvent) => {
|
||||
router.pushUrl({
|
||||
url: 'pages/apnDetail'
|
||||
})
|
||||
})
|
||||
}
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.width('100%')
|
||||
.padding({ left: 12, right: 12 })
|
||||
.height(56)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.align(Alignment.Start)
|
||||
|
||||
Column() {
|
||||
List() {
|
||||
ForEach(this.apnList, (item: ApnInfo) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Row() {
|
||||
Image($r('app.media.ic_redio_check'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.margin({ right: 10 })
|
||||
.visibility(item.profile_id === this.selectedApn ? Visibility.Visible : Visibility.Hidden)
|
||||
Column() {
|
||||
Text(item.profile_name)
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary'))
|
||||
.letterSpacing(1)
|
||||
.lineHeight(22)
|
||||
.textAlign(TextAlign.Start)
|
||||
Text(item.apn)
|
||||
.fontFamily('HarmonyHeiTi')
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#666666')
|
||||
.letterSpacing(1)
|
||||
.lineHeight(22)
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
.justifyContent(FlexAlign.Start)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
|
||||
Navigator({ target: 'pages/apnDetail', type: NavigationType.Push }) {
|
||||
Image($r('app.media.ic_about_apn'))
|
||||
.padding(10)
|
||||
.width(40)
|
||||
.height(40)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.borderRadius(100)
|
||||
}.params(item)
|
||||
|
||||
}
|
||||
.height(80)
|
||||
.width('96%')
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
.borderRadius(15)
|
||||
.backgroundColor(Color.White)
|
||||
.margin({ top: 5, left: 10, right: 10, bottom: 5 })
|
||||
.padding({ left: 10, right: 10 })
|
||||
}.width('100%')
|
||||
.margin({ bottom: '1px' })
|
||||
.height(60)
|
||||
.onClick((event: ClickEvent) => {
|
||||
if (this.selectedApn != item.profile_id) {
|
||||
this.storage.initData(getContext() as common.UIAbilityContext).then(() => {
|
||||
this.storage.updateXmlPeofileID(this.cardTpye, item.profile_id)
|
||||
.then((success) => {
|
||||
PreferenceUtil.put('select_apn_common_' + this.mccmnc, item.profile_id)
|
||||
this.selectedApn = item.profile_id
|
||||
if (success) {
|
||||
router.back()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}.layoutWeight(1)
|
||||
.width('100%')
|
||||
}
|
||||
.backgroundColor($r('sys.color.ohos_id_color_sub_background'))
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
@@ -332,6 +332,11 @@ struct Index {
|
||||
url: 'pages/networkStand'
|
||||
})
|
||||
break
|
||||
case 1:
|
||||
router.pushUrl({
|
||||
url: 'pages/apnList'
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +498,51 @@ struct Index {
|
||||
this.clickHandle(0)
|
||||
}
|
||||
})
|
||||
Divider()
|
||||
.strokeWidth(0.5)
|
||||
.color('#E3E3E3')
|
||||
.lineCap(LineCapStyle.Round)
|
||||
.margin({ right: '2%' })
|
||||
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Column() {
|
||||
Text($r('app.string.access_point_name'))
|
||||
.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.isAirPlaneMode) ? 0.9 : 0.6)
|
||||
.letterSpacing(1)
|
||||
.lineHeight(22)
|
||||
.textAlign(TextAlign.Start)
|
||||
Text($r('app.string.apn_stttings'))
|
||||
.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)
|
||||
}.justifyContent(FlexAlign.Center)
|
||||
.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.isAirPlaneMode)
|
||||
|
||||
}.backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
|
||||
.opacity((this.simStateStatusCardOne && !this.isAirPlaneMode) ? 1 : 0.4)
|
||||
.margin({ top: 8, bottom: this.isSupport ? 5 : 11 })
|
||||
.onClick(() => {
|
||||
if ((this.simStateStatusCardOne && !this.isAirPlaneMode)) {
|
||||
this.clickHandle(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
.padding({
|
||||
left: 12,
|
||||
|
||||
@@ -187,6 +187,123 @@
|
||||
{
|
||||
"name": "network_standard_select",
|
||||
"value": "Select The Network Type"
|
||||
},
|
||||
{
|
||||
"name": "apn_title",
|
||||
"value": "APN Settings"
|
||||
},
|
||||
{
|
||||
"name": "apn_name",
|
||||
"value": "Name"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn",
|
||||
"value": "APN"
|
||||
},
|
||||
{
|
||||
"name": "apn_proxy",
|
||||
"value": "Proxy"
|
||||
},
|
||||
{
|
||||
"name": "apn_port",
|
||||
"value": "Port"
|
||||
},
|
||||
{
|
||||
"name": "apn_auth_user",
|
||||
"value": "User Name"
|
||||
},
|
||||
{
|
||||
"name": "apn_auth_pwd",
|
||||
"value": "Auth Password"
|
||||
},
|
||||
{
|
||||
"name": "apn_server",
|
||||
"value": "Server"
|
||||
},
|
||||
{
|
||||
"name": "apn_mmsc",
|
||||
"value": "MMSC"
|
||||
},
|
||||
{
|
||||
"name": "apn_mms_proxy",
|
||||
"value": "MMS Proxy"
|
||||
},
|
||||
{
|
||||
"name": "apn_mms_port",
|
||||
"value": "MMS Port"
|
||||
},
|
||||
{
|
||||
"name": "apn_mcc",
|
||||
"value": "MCC"
|
||||
},
|
||||
{
|
||||
"name": "apn_mnc",
|
||||
"value": "MNC"
|
||||
},
|
||||
{
|
||||
"name": "apn_auth_type",
|
||||
"value": "Auth Type"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn_types",
|
||||
"value": "APN Typs"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn_protocol",
|
||||
"value": "APN Protocol"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn_roam_protocol",
|
||||
"value": "APN Roam Protocol"
|
||||
},
|
||||
{
|
||||
"name": "apn_bearing_system_type",
|
||||
"value": "Bearing System Type"
|
||||
},
|
||||
{
|
||||
"name": "apn_mvno_type",
|
||||
"value": "MVNO Type"
|
||||
},
|
||||
{
|
||||
"name": "apn_mvno_match_data",
|
||||
"value": "MVNO Data"
|
||||
},
|
||||
{
|
||||
"name": "apn_add",
|
||||
"value": "Add APN"
|
||||
},
|
||||
{
|
||||
"name": "ok",
|
||||
"value": "ok"
|
||||
},
|
||||
{
|
||||
"name": "apn_cancel",
|
||||
"value": "cancel"
|
||||
},
|
||||
{
|
||||
"name": "apn_not_configured",
|
||||
"value": "Not Configured"
|
||||
},
|
||||
{
|
||||
"name": "apn_null",
|
||||
"value": "null"
|
||||
},
|
||||
{
|
||||
"name": "apn_tips_name_null",
|
||||
"value": "name is not null"
|
||||
},
|
||||
{
|
||||
"name": "apn_tips_apn_null",
|
||||
"value": "APN is not null"
|
||||
},
|
||||
{
|
||||
"name": "access_point_name",
|
||||
"value": "Access Point Name"
|
||||
},
|
||||
{
|
||||
"name": "apn_stttings",
|
||||
"value": "APN Settings"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="26px" height="26px" viewBox="0 0 26 26" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>编组 14</title>
|
||||
<g id="主页面" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Setting__首页下备份" transform="translate(-47.000000, -210.000000)">
|
||||
<g id="编组-13" transform="translate(24.000000, 80.000000)">
|
||||
<g id="编组-10" transform="translate(4.000000, 60.000000)">
|
||||
<g id="编组-14" transform="translate(19.500000, 71.000000)">
|
||||
<rect id="矩形" x="0.5" y="4.54747351e-13" width="24" height="24"></rect>
|
||||
<path d="M12.6,7.4 C13.5664983,7.4 14.35,8.18350169 14.35,9.15 L14.35,10.4 L14.349,10.4 L14.349,20.4 L14.5,20.4 C15.3284271,20.4 16,21.0715729 16,21.9 C16,22.7284271 15.3284271,23.4 14.5,23.4 L10.5,23.4 C9.67157288,23.4 9,22.7284271 9,21.9 C9,21.0715729 9.67157288,20.4 10.5,20.4 L10.849,20.4 L10.849,10.4 L10.5,10.4 C9.67157288,10.4 9,9.72842712 9,8.9 C9,8.07157288 9.67157288,7.4 10.5,7.4 L12.6,7.4 Z M12.05,4.54747351e-13 C13.5686875,4.54747351e-13 14.8,1.2313125 14.8,2.75 C14.8,4.2686875 13.5686875,5.5 12.05,5.5 C10.5313125,5.5 9.3,4.2686875 9.3,2.75 C9.3,1.2313125 10.5313125,4.54747351e-13 12.05,4.54747351e-13 Z" id="形状结合" fill-opacity="0.599213287" fill="#182431" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1728961349531" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4263" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M863.328262 481.340895l-317.344013 0.099772L545.984249 162.816826c0-17.664722-14.336138-32.00086-32.00086-32.00086s-31.99914 14.336138-31.99914 32.00086l0 318.400215-322.368714-0.17718c-0.032684 0-0.063647 0-0.096331 0-17.632039 0-31.935493 14.239806-32.00086 31.904529-0.096331 17.664722 14.208843 32.031824 31.871845 32.095471l322.59234 0.17718 0 319.167424c0 17.695686 14.336138 32.00086 31.99914 32.00086s32.00086-14.303454 32.00086-32.00086L545.982529 545.440667l317.087703-0.099772c0.063647 0 0.096331 0 0.127295 0 17.632039 0 31.935493-14.239806 32.00086-31.904529S880.960301 481.404542 863.328262 481.340895z" fill="#575B66" p-id="4264"></path></svg>
|
||||
|
After Width: | Height: | Size: 991 B |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1729151144401" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5277" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M839.7 409.6c-22.6 0-41 18.3-41 41v409.6c0 22.6-18.4 41-41 41H266.2c-22.6 0-41-18.4-41-41V450.6c0-22.6-18.3-41-41-41s-41 18.3-41 41v409.6c0 67.8 55.1 122.9 122.9 122.9h491.5c67.8 0 122.9-55.1 122.9-122.9V450.6c0.1-22.7-18.2-41-40.8-41zM942.1 225.3H757.8v-81.9c0-56.5-46-102.4-102.4-102.4H368.6c-56.5 0-102.4 45.9-102.4 102.4v81.9H81.9c-22.5 0-41 18.4-41 41 0 22.5 18.4 41 41 41H942c22.5 0 41-18.4 41-41s-18.4-41-40.9-41z m-593.9 0v-81.9c0-11.3 9.2-20.5 20.5-20.5h286.7c11.3 0 20.5 9.2 20.5 20.5v81.9H348.2z" p-id="5278"></path><path d="M450.6 737.3V491.5c0-22.5-18.4-41-41-41s-41 18.4-41 41v245.8c0 22.5 18.4 41 41 41s41-18.5 41-41zM655.4 737.3V491.5c0-22.5-18.4-41-41-41-22.5 0-41 18.4-41 41v245.8c0 22.5 18.4 41 41 41 22.5-0.1 41-18.5 41-41z" p-id="5279"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1729130725682" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4254" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M840.021333 267.690667a42.666667 42.666667 0 0 1 1.621334 60.330666l-384 405.333334a42.666667 42.666667 0 0 1-61.141334 0.853333l-213.333333-213.333333a42.666667 42.666667 0 1 1 60.330667-60.373334l182.357333 182.314667 353.834667-373.504a42.666667 42.666667 0 0 1 60.330666-1.621333z" p-id="4255"></path></svg>
|
||||
|
After Width: | Height: | Size: 644 B |
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/index",
|
||||
"pages/networkStand"
|
||||
"pages/networkStand",
|
||||
"pages/apnList",
|
||||
"pages/apnDetail"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -187,6 +187,122 @@
|
||||
{
|
||||
"name": "network_standard_select",
|
||||
"value": "网络类型选择"
|
||||
},
|
||||
{
|
||||
"name": "apn_title",
|
||||
"value": "APN 设置"
|
||||
},
|
||||
{
|
||||
"name": "apn_name",
|
||||
"value": "名称"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn",
|
||||
"value": "APN"
|
||||
},
|
||||
{
|
||||
"name": "apn_proxy",
|
||||
"value": "代理"
|
||||
},
|
||||
{
|
||||
"name": "apn_port",
|
||||
"value": "端口"
|
||||
},
|
||||
{
|
||||
"name": "apn_auth_user",
|
||||
"value": "用户名"
|
||||
},
|
||||
{
|
||||
"name": "apn_auth_pwd",
|
||||
"value": "密码"
|
||||
},
|
||||
{
|
||||
"name": "apn_server",
|
||||
"value": "服务器"
|
||||
},
|
||||
{
|
||||
"name": "apn_mmsc",
|
||||
"value": "MMSC"
|
||||
},
|
||||
{
|
||||
"name": "apn_mms_proxy",
|
||||
"value": "彩信代理"
|
||||
},
|
||||
{
|
||||
"name": "apn_mms_port",
|
||||
"value": "彩信端口"
|
||||
},
|
||||
{
|
||||
"name": "apn_mcc",
|
||||
"value": "MCC"
|
||||
},
|
||||
{
|
||||
"name": "apn_mnc",
|
||||
"value": "MNC"
|
||||
},
|
||||
{
|
||||
"name": "apn_auth_type",
|
||||
"value": "身份验证类型"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn_types",
|
||||
"value": "APN类型"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn_protocol",
|
||||
"value": "APN协议"
|
||||
},
|
||||
{
|
||||
"name": "apn_apn_roam_protocol",
|
||||
"value": "APN漫游协议"
|
||||
},
|
||||
{
|
||||
"name": "apn_bearing_system_type",
|
||||
"value": "承载系统"
|
||||
},
|
||||
{
|
||||
"name": "apn_mvno_type",
|
||||
"value": "MVNO类型"
|
||||
},
|
||||
{
|
||||
"name": "apn_mvno_match_data",
|
||||
"value": "MVNO值"
|
||||
},
|
||||
{
|
||||
"name": "apn_add",
|
||||
"value": "新增APN"
|
||||
},
|
||||
{
|
||||
"name": "ok",
|
||||
"value": "确定"
|
||||
},
|
||||
{
|
||||
"name": "apn_cancel",
|
||||
"value": "取消"
|
||||
},
|
||||
{
|
||||
"name": "apn_not_configured",
|
||||
"value": "未设置"
|
||||
},
|
||||
{
|
||||
"name": "apn_null",
|
||||
"value": "无"
|
||||
},
|
||||
{
|
||||
"name": "apn_tips_name_null",
|
||||
"value": "名称不能为空"
|
||||
},
|
||||
{
|
||||
"name": "apn_tips_apn_null",
|
||||
"value": "APN不能为空"
|
||||
},
|
||||
{
|
||||
"name": "access_point_name",
|
||||
"value": "接入点名称(APN)"
|
||||
},
|
||||
{
|
||||
"name": "apn_stttings",
|
||||
"value": "设置APN"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user