diff --git a/Telephony/eTSRadioTech/README_zh.md b/Telephony/eTSRadioTech/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..b25b7d45aab35dc297a42183865dfd65748ecdeb --- /dev/null +++ b/Telephony/eTSRadioTech/README_zh.md @@ -0,0 +1,18 @@ +# 电话服务-网络搜索 + +### 简介 + +本示例通过eTS来展示电话服务中网络搜索功能,包含无线接入技术、网络状态、选网模式、ISO国家码、信号强度信息列表及Radio是否打开。 + +### 使用说明 + +1、点击"SIM1 status",弹出面板显示卡1的无线接入技术、注册网络信号强度信息列表、选网模式、ISO国家码, + 再次点击面板消失, 点击"SIM2 status"显示同理。 + +2、"NetworkState"显示网络状态相关信息。 + +3、"IsRadioOn"显示Radio是否打开,true为打开,false为关闭。 + +### 约束与限制 + +本示例仅支持在标准系统上运行。 \ No newline at end of file diff --git a/Telephony/eTSRadioTech/build.gradle b/Telephony/eTSRadioTech/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..f1b1a556a0c09953268d32e7da54b1e1ba664bac --- /dev/null +++ b/Telephony/eTSRadioTech/build.gradle @@ -0,0 +1,34 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 8 + supportSystem "standard" +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:3.0.5.2' + classpath 'com.huawei.ohos:decctest:1.2.7.2' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/Telephony/eTSRadioTech/entry/build.gradle b/Telephony/eTSRadioTech/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..cef7b37de8f320938458ca42edde1462669836d2 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'com.huawei.ohos.hap' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 8 + defaultConfig { + compatibleSdkVersion 7 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13.1' +} diff --git a/Telephony/eTSRadioTech/entry/src/main/config.json b/Telephony/eTSRadioTech/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..3c5232ad91568ccf1a480bc035b66d52a0ae64ca --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/config.json @@ -0,0 +1,67 @@ +{ + "app": { + "bundleName": "ohos.samples.etsradiotech", + "vendor": "samples", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.etsradiotech", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/app.ets b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf28e58b36cf11db491d3f00768ef2c9e41d05cf --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/common/infoView.ets b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/common/infoView.ets new file mode 100644 index 0000000000000000000000000000000000000000..b046c7e25e5ae54d6c3c372590810e4375a22594 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/common/infoView.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 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 { RadioStatus } from '../model/radioStatus' + +@Component +export struct InfoView { + @Link show: boolean + @Link slotId: number + @Link title: string + @State simArray: Array = [] + @State radioStatus: RadioStatus = new RadioStatus() + + aboutToAppear() { + this.getSimSpn(0) + this.getSimSpn(1) + } + + getSimSpn(slotId) { + let self = this + this.radioStatus.getSimSpn(slotId, (result) => { + let title = slotId === 0 ? 'SIM1 status' : 'SIM2 status' + self.simArray.push({ slotId: slotId, title: title, value: result }) + }) + } + + build() { + Column() { + ForEach(this.simArray, item => { + Row() { + Column() { + Text(item.title) + .width('100%') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10 }) + Text(item.value) + .width('100%') + .fontSize(20) + .margin({ bottom: 10 }) + } + .layoutWeight(1) + + Image($r('app.media.right_arrow')) + .width('3%') + .height('3%') + .margin({ right: 10 }) + } + .width('100%') + .onClick(() => { + console.log(`PanelView()`) + this.show = !this.show + this.slotId = item.slotId + this.title = item.title + }) + + }, item => JSON.stringify(item)) + } + .width('100%') + .padding({ left: 20, right: 20 }) + } +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/common/panelView.ets b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/common/panelView.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a307064baa92bdb9eef794c46c8716b138da629 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/common/panelView.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 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 { RadioStatus } from '../model/radioStatus' + +@Component +export struct PanelView { + @Link show: boolean + private slotId: number + private title: string + @State statusArray: Array = [] + @State radioStatus: RadioStatus = new RadioStatus() + + aboutToAppear() { + let self = this + this.radioStatus.getRadioTech(this.slotId, (result) => { + self.statusArray.push({ title: 'RadioTech', value: result }) + }) + this.radioStatus.getSignalInformation(this.slotId, (result) => { + self.statusArray.push({ title: 'SignalInformation', value: result }) + }) + this.radioStatus.getNetworkSelectionMode(this.slotId, (result) => { + self.statusArray.push({ title: 'NetworkSelectionMode', value: result }) + }) + this.radioStatus.getISOCountryCodeForNetwork(this.slotId, (result) => { + self.statusArray.push({ title: 'ISOCountryCodeForNetwork', value: result }) + }) + } + + build() { + Panel(this.show) { + Column() { + Text(this.title) + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 10 }) + Divider() + ForEach(this.statusArray, item => { + Column() { + Text(item.title) + .fontSize(20) + .fontColor(Color.Grey) + .margin({ top: 10 }) + Text(item.value) + .fontSize(20) + } + }, item => JSON.stringify(item) + ) + } + } + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .halfHeight(500) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + .onClick(() => { + this.show = !this.show + }) + } +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/model/radioStatus.ets b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/model/radioStatus.ets new file mode 100644 index 0000000000000000000000000000000000000000..b06132bb7d6bd491671542e78dc14d9b63689887 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/model/radioStatus.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2021 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 sim from '@ohos.telephony.sim' +import radio from '@ohos.telephony.radio' + +const TAG = '[RadioStatus]' + +export class RadioStatus { + constructor() { + } + + getSimSpn(slotId, callback) { + sim.getSimSpn(slotId, (err, data) => { + console.log(`${TAG} SimSpn callback: err->${(err)}, data->${data}`) + this.setCallback(callback, data) + }) + } + + getRadioTech(slotId, callback) { + radio.getRadioTech(slotId, (err, data) => { + console.log(`${TAG} RadioTech callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`) + callback(JSON.stringify(data)) + }) + } + + getSignalInformation(slotId, callback) { + radio.getSignalInformation(slotId, (err, data) => { + console.log(`${TAG} SignalInformation callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`) + callback(JSON.stringify(data)) + }) + } + + getNetworkSelectionMode(slotId, callback) { + radio.getNetworkSelectionMode(slotId, (err, data) => { + console.log(`${TAG} NetworkSelectionMode callback: err->${err}, data->${data}`) + this.setCallback(callback, data) + }) + } + + getISOCountryCodeForNetwork(slotId, callback) { + radio.getISOCountryCodeForNetwork(slotId, (err, data) => { + console.log(`${TAG} ISOCountryCode callback: err->${err}, data->${data}`) + if (data == '') { + callback('not available') + } else { + callback(data) + } + }) + } + + getNetworkState(callback) { + radio.getNetworkState((err, data) => { + console.log(`${TAG} NetworkState callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`) + let networkState: string = `longOperatorName:${JSON.stringify(data.longOperatorName)}\n` + + `shortOperatorName:${JSON.stringify(data.shortOperatorName)}\n` + + `plmnNumeric:${JSON.stringify(data.plmnNumeric)}\n` + + `isRoaming:${JSON.stringify(data.isRoaming)}\n` + + `regState:${JSON.stringify(data.regState)}\n` + + `nsaState:${JSON.stringify(data.nsaState)}\n` + + `isCaActive:${JSON.stringify(data.isCaActive)}\n` + + `isEmergency:${JSON.stringify(data.isEmergency)}\n` + callback(networkState) + }) + } + + getRadioOn(callback) { + radio.isRadioOn((err, data) => { + console.log(`${TAG} IsRadioOn callback: err->${err}, data->${data}`) + this.setCallback(callback, data) + }) + } + + setCallback(callback, data) { + if (typeof (JSON.stringify(data)) == `undefined`) { + callback('not available') + } else { + callback(data) + } + } +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/pages/index.ets b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..66fe629044d4795faff33143f14ef825c1786de2 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 { InfoView } from '../common/infoView' +import { PanelView } from '../common/panelView' +import { RadioStatus } from '../model/radioStatus' + +@Entry +@Component +struct Index { + @State show: boolean = false + @State slotId: number = 0 + @State title: string = 'SIM1 status' + @State networkArray: Array = [] + @State radioStatus: RadioStatus = new RadioStatus() + + aboutToAppear() { + let self = this + this.radioStatus.getNetworkState((result) => { + self.networkArray.push({ title: 'NetworkState', value: result }) + }) + this.radioStatus.getRadioOn((result) => { + self.networkArray.push({ title: 'IsRadioOn', value: result }) + }) + } + + build() { + Stack() { + Column() { + Text($r('app.string.entry_MainAbility')) + .width('100%') + .height(50) + .backgroundColor('#0D9FFB') + .fontColor(Color.White) + .fontSize(20) + .padding({ left: 20 }) + + Scroll() { + Column() { + InfoView({ show: $show, slotId: $slotId, title: $title }) + Divider().color(Color.Grey) + ForEach(this.networkArray, item => { + Column() { + Text(item.title) + .width('100%') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ top: 10 }) + Text(item.value) + .width('100%') + .fontSize(20) + .margin({ bottom: 10 }) + } + .margin({ left: 20, right: 20 }) + }, item => JSON.stringify(item)) + } + } + .layoutWeight(1) + } + + PanelView({ show: $show, slotId: this.slotId, title: this.title }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/resources/base/element/string.json b/Telephony/eTSRadioTech/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e1477edbbdf0963948af69e0e43cd9d33e96fac7 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "eTSRadioTech" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/resources/base/media/icon.png b/Telephony/eTSRadioTech/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/Telephony/eTSRadioTech/entry/src/main/resources/base/media/icon.png differ diff --git a/Telephony/eTSRadioTech/entry/src/main/resources/base/media/right_arrow.png b/Telephony/eTSRadioTech/entry/src/main/resources/base/media/right_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..d55dc201e9145911bf112a487264bb2a2c518ebd Binary files /dev/null and b/Telephony/eTSRadioTech/entry/src/main/resources/base/media/right_arrow.png differ diff --git a/Telephony/eTSRadioTech/entry/src/main/resources/en/element/string.json b/Telephony/eTSRadioTech/entry/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e1477edbbdf0963948af69e0e43cd9d33e96fac7 --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/resources/en/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "eTSRadioTech" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/entry/src/main/resources/zh/element/string.json b/Telephony/eTSRadioTech/entry/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..7f7984366b9302fd9506c02b0b3126022f4a950b --- /dev/null +++ b/Telephony/eTSRadioTech/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "网络搜索" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/Telephony/eTSRadioTech/screenshots/devices/main.png b/Telephony/eTSRadioTech/screenshots/devices/main.png new file mode 100644 index 0000000000000000000000000000000000000000..9246a677b8a8654b664fe28d51b775a422653b61 Binary files /dev/null and b/Telephony/eTSRadioTech/screenshots/devices/main.png differ diff --git a/Telephony/eTSRadioTech/screenshots/devices/panel.png b/Telephony/eTSRadioTech/screenshots/devices/panel.png new file mode 100644 index 0000000000000000000000000000000000000000..e09fdd21c7385429951e1f947dbc76059b856a97 Binary files /dev/null and b/Telephony/eTSRadioTech/screenshots/devices/panel.png differ diff --git a/Telephony/eTSRadioTech/settings.gradle b/Telephony/eTSRadioTech/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/Telephony/eTSRadioTech/settings.gradle @@ -0,0 +1 @@ +include ':entry'