diff --git a/UI/JsDevice/README_zh.md b/UI/JsDevice/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..c0b866d0249dd933febe74b34ab4f460fdee1594 --- /dev/null +++ b/UI/JsDevice/README_zh.md @@ -0,0 +1,14 @@ +# 设备信息 + +### 简介 + +本示例通过deviceInfo、systemParameter和batteryInfo接口分别来查询设备信息、系统属性和电池和充电属性。 + +### 使用说明 + +分别点击对象的按钮框,查看对应的信息。 + +### 约束与限制 + +本示例仅支持在标准系统上运行。 + diff --git a/UI/JsDevice/build.gradle b/UI/JsDevice/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..6fac162cbb623b3b1d97cad7247172dc41cf91b9 --- /dev/null +++ b/UI/JsDevice/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' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.5.0' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/UI/JsDevice/entry/build.gradle b/UI/JsDevice/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..6b6a606b1b3e2af76d27a6fa8ad069e92ddbed68 --- /dev/null +++ b/UI/JsDevice/entry/build.gradle @@ -0,0 +1,17 @@ +apply plugin: 'com.huawei.ohos.hap' + +ohos { + compileSdkVersion 6 + defaultConfig { + compatibleSdkVersion 6 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + supportSystem "standard" +} diff --git a/UI/JsDevice/entry/src/main/config.json b/UI/JsDevice/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d9dcda86241ca0afa1c9515f97131a3ad4da141d --- /dev/null +++ b/UI/JsDevice/entry/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "ohos.samples.jsdevice", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.jsdevice", + "name": ".MyApplication", + "mainAbility": "ohos.samples.jsdevice.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": "ohos.samples.jsdevice.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index", + "pages/deviceInfo/deviceInfo", + "pages/systemProperties/systemProperties", + "pages/batteryProperties/batteryProperties" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/app.js b/UI/JsDevice/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..58d12b7b501fbf46db906a86187aaf18dfb1f677 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/app.js @@ -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"); + } +}; diff --git a/UI/JsDevice/entry/src/main/js/default/i18n/en-US.json b/UI/JsDevice/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..9ffbd740c1470946d472f6bfadc791969b297db3 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,44 @@ +{ + "strings": { + "deviceInfo": "DeviceInfo", + "systemProperties": "SystemProperties", + "batteryProperties": "BatteryProperties", + "back": "Back", + "serial": "serial", + "bootloaderVersion": "bootloaderVersion", + "securityPatchTag": "securityPatchTag", + "displayVersion": "displayVersion", + "osReleaseType": "osReleaseType", + "osFullName": "osFullName", + "majorVersion": "majorVersion", + "seniorVersion": "seniorVersion", + "featureVersion": "featureVersion", + "buildVersion": "buildVersion", + "sdkApiVersion": "sdkApiVersion", + "firstApiVersion": "firstApiVersion", + "versionId": "versionId", + "batterySOC": "batterySOC", + "chargingStatus": "chargingStatus", + "healthStatus": "healthStatus", + "pluggedType": "pluggedType", + "voltage": "voltage", + "technology": "technology", + "batteryTemperature": "batteryTemperature", + "none": "NONE", + "ac": "AC", + "usb": "USB", + "wireless": "WIRELESS", + "unknown": "UNKNOWN", + "good": "GOOD", + "overheat": "OVERHEAT", + "overVoltage": "OVER VOLTAGE", + "cold": "COLD", + "dead": "DEAD", + "enable": "ENABLE", + "disable": "DISABLE", + "full": "FULL", + "results": "results" + }, + "Files": { + } +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/i18n/zh-CN.json b/UI/JsDevice/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..ce20a8d877489d66fc7939412a8301b975e29f16 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,44 @@ +{ + "strings": { + "deviceInfo": "设备信息", + "systemProperties": "系统属性", + "batteryProperties": "电池属性", + "back": "返回", + "serial": "设备序列号", + "bootloaderVersion": "Bootloader版本号", + "securityPatchTag": "安全补丁级别", + "displayVersion": "产品版本", + "osReleaseType": "系统的发布类型", + "osFullName": "系统版本", + "majorVersion": "Major版本号", + "seniorVersion": "Senior版本号", + "featureVersion": "Feature版本号", + "buildVersion": "Build版本号", + "sdkApiVersion": "系统软件API版本", + "firstApiVersion": "首个版本系统软件API版本", + "versionId": "版本ID", + "batterySOC": "剩余电池容量", + "chargingStatus": "电池的充电状态", + "healthStatus": "电池的健康状态", + "pluggedType": "连接的充电器类型", + "voltage": "电池的电压", + "technology": "电池的技术型号", + "batteryTemperature": "电池的温度", + "none": "未知", + "ac": "交流充电器", + "usb": "USB", + "wireless": "无线充电器", + "unknown": "未知", + "good": "正常", + "overheat": "过热", + "overVoltage": "过压", + "cold": "低温", + "dead": "僵死状态", + "enable": "使能状态", + "disable": "停止状态", + "full": "已充满状态", + "results": "结果" + }, + "Files": { + } +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.css b/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.css new file mode 100644 index 0000000000000000000000000000000000000000..b48195d60c907a97141d30f54888c98a0a53956c --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.css @@ -0,0 +1,44 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + margin: 20px; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + width: 100%; + margin: 10px; + font-weight: bold; +} + +.info-text { + font-size: 32px; + width: 100%; + margin: 10px; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; + position: fixed; + bottom: 10px; + left: 25%; +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.hml b/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.hml new file mode 100644 index 0000000000000000000000000000000000000000..a24f80836c05c2fec6eeb1b8fb0e9d01c76f514b --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.hml @@ -0,0 +1,26 @@ + + +
+ {{ $t('strings.batteryProperties') }}: + {{ $t('strings.batterySOC') }}: {{ batterySOC }} + {{ $t('strings.chargingStatus') }}: {{ chargingStatus }} + {{ $t('strings.healthStatus') }}: {{ healthStatus }} + {{ $t('strings.pluggedType') }}: {{ pluggedType }} + {{ $t('strings.voltage') }}: {{ voltage }} + {{ $t('strings.technology') }}: {{ technology }} + {{ $t('strings.batteryTemperature') }}: {{ batteryTemperature }} + +
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.js b/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..6a37737276b0c1494c5097e09efa7b24825702ca --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/batteryProperties/batteryProperties.js @@ -0,0 +1,95 @@ +/* + * 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 router from '@system.router'; +import batteryInfo from '@ohos.batteryInfo'; + +export default { + data: { + batterySOC: '', + chargingStatus: '', + healthStatus: '', + pluggedType: '', + voltage: '', + technology: '', + batteryTemperature: '' + }, + onInit() { + this.batteryInfo(); + }, + batteryInfo() { + this.batterySOC = batteryInfo.batterySOC; + switch (batteryInfo.chargingStatus) { + case 0: + this.chargingStatus = this.$t('strings.none'); + break; + case 1: + this.chargingStatus = this.$t('strings.enable'); + break; + case 2: + this.chargingStatus = this.$t('strings.disable'); + break; + case 3: + this.chargingStatus = this.$t('strings.full'); + break; + default: + break; + } + switch (batteryInfo.healthStatus) { + case 0: + this.healthStatus = this.$t('strings.unknown'); + break; + case 1: + this.healthStatus = this.$t('strings.good'); + break; + case 2: + this.healthStatus = this.$t('strings.overheat'); + break; + case 3: + this.healthStatus = this.$t('strings.overVoltage'); + break; + case 4: + this.healthStatus = this.$t('strings.cold'); + break; + case 5: + this.healthStatus = this.$t('strings.dead'); + break; + default: + break; + } + switch (batteryInfo.pluggedType) { + case 0: + this.pluggedType = this.$t('strings.none'); + break; + case 1: + this.pluggedType = this.$t('strings.ac'); + break; + case 2: + this.pluggedType = this.$t('strings.usb'); + break; + case 3: + this.pluggedType = this.$t('strings.wireless'); + break; + default: + break; + } + this.voltage = batteryInfo.voltage; + this.technology = batteryInfo.technology; + this.batteryTemperature = batteryInfo.batteryTemperature; + }, + back() { + router.back(); + } +} diff --git a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.css b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.css new file mode 100644 index 0000000000000000000000000000000000000000..2592f3bb3f7e3bf4983df914b867e70a8dd1d178 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.css @@ -0,0 +1,44 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + margin: 20px; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + width: 100%; + margin: 10px; + font-weight: bold; +} + +.info-text { + font-size: 32px; + width: 100%; + margin: 10px; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; + position: fixed; + bottom: 10px; + left: 25%; +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml new file mode 100644 index 0000000000000000000000000000000000000000..48e4d4691a34430a91ea3e0130da8fc8ccfff2b2 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.hml @@ -0,0 +1,32 @@ + + +
+ {{ $t('strings.deviceInfo') }}: + {{ $t('strings.serial') }}: {{ serial }} + {{ $t('strings.bootloaderVersion') }}: {{ bootloaderVersion }} + {{ $t('strings.securityPatchTag') }}: {{ securityPatchTag }} + {{ $t('strings.displayVersion') }}: {{ displayVersion }} + {{ $t('strings.osReleaseType') }}: {{ osReleaseType }} + {{ $t('strings.osFullName') }}: {{ osFullName }} + {{ $t('strings.majorVersion') }}: {{ majorVersion }} + {{ $t('strings.seniorVersion') }}: {{ seniorVersion }} + {{ $t('strings.featureVersion') }}: {{ featureVersion }} + {{ $t('strings.buildVersion') }}: {{ buildVersion }} + {{ $t('strings.sdkApiVersion') }}: {{ sdkApiVersion }} + {{ $t('strings.firstApiVersion') }}: {{ firstApiVersion }} + {{ $t('strings.versionId') }}: {{ versionId }} + +
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js new file mode 100644 index 0000000000000000000000000000000000000000..97c3facd1cdae8d1ecf59790f278c0acad8713fa --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/deviceInfo/deviceInfo.js @@ -0,0 +1,58 @@ +/* + * 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 router from '@system.router' +import deviceInfo from '@ohos.deviceInfo'; + +export default { + data: { + serial: '', + bootloaderVersion: '', + abiList: '', + securityPatchTag: '', + displayVersion: '', + osReleaseType: '', + osFullName: '', + majorVersion: '', + seniorVersion: '', + featureVersion: '', + buildVersion: '', + sdkApiVersion: '', + firstApiVersion: '', + versionId: '', + data1: '' + }, + onInit() { + this.deviceInfo(); + }, + deviceInfo() { + this.serial = deviceInfo.serial; + this.bootloaderVersion = deviceInfo.bootloaderVersion; + this.securityPatchTag = deviceInfo.securityPatchTag; + this.displayVersion = deviceInfo.displayVersion; + this.osReleaseType = deviceInfo.osReleaseType; + this.osFullName = deviceInfo.osFullName; + this.majorVersion = deviceInfo.majorVersion; + this.seniorVersion = deviceInfo.seniorVersion; + this.featureVersion = deviceInfo.featureVersion; + this.buildVersion = deviceInfo.buildVersion; + this.sdkApiVersion = deviceInfo.sdkApiVersion; + this.firstApiVersion = deviceInfo.firstApiVersion; + this.versionId = deviceInfo.versionId; + }, + back() { + router.back(); + } +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/index/index.css b/UI/JsDevice/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..7585214453efef3b497c75f00076ce2d961cec9d --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,17 @@ +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; + margin: 10px; +} diff --git a/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml b/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..27fcdf5af8a4304de180d5adb0f3beece6ad92a1 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/index/index.js b/UI/JsDevice/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d57190a2f08cac7efe75e77630055520dfd7d4e7 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,19 @@ +import router from '@system.router' + +export default { + deviceInfo() { + router.push({ + uri: 'pages/deviceInfo/deviceInfo' + }) + }, + systemProperties() { + router.push({ + uri: 'pages/systemProperties/systemProperties' + }) + }, + batteryProperties() { + router.push({ + uri: 'pages/batteryProperties/batteryProperties' + }) + } +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css new file mode 100644 index 0000000000000000000000000000000000000000..8bcd85f78aa4c816b5e33102f624c53f7d8e3b9e --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.css @@ -0,0 +1,68 @@ +/* + * 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. + */ + +.container { + display: flex; + flex-direction: column; + align-items: center; + margin: 20px; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + width: 90%; + margin: 10px; + font-weight: bold; +} + +.info-text { + font-size: 32px; + width: 90%; + height: 400px; + background-color: #d6dcd4; + border-radius: 18px; + margin: 10px; + padding: 20px; +} +.button-row { + flex-direction: row; + align-items: center; + justify-content: center; +} + +.info-button { + width: 45%; + height: 80px; + font-size: 30px; + margin: 15px; +} + +.button-down { + width: 90%; + height: 80px; + font-size: 30px; + margin: 10px; +} + +.btn { + width: 50%; + height: 100px; + font-size: 40px; + position: fixed; + bottom: 10px; + left: 25%; +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml new file mode 100644 index 0000000000000000000000000000000000000000..ec8fc7f4ac388641e86456f5037f28560c616a57 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.hml @@ -0,0 +1,35 @@ + + +
+ {{ $t('strings.systemProperties') }}: + {{ $t('strings.results') }}: {{ results }} +
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
diff --git a/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..bf36c8ef9dcd35ea308c83d37ff5cff175e7d4f8 --- /dev/null +++ b/UI/JsDevice/entry/src/main/js/default/pages/systemProperties/systemProperties.js @@ -0,0 +1,129 @@ +/* + * 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 router from '@system.router' +import systemParameter from '@ohos.systemParameter'; + +let result = '' +export default { + data: { + results: '' + }, + setKey() { + try { + var promise = systemParameter.set("test.parameter.key", "testValue"); + promise.then(function (data) { + result = "setKey pass"; + console.log("set test.parameter.key success" + data); + }).catch(function (err) { + result = "set test.parameter.key error" + err.code; + console.log("set test.parameter.key error" + err.code); + }); + this.results = result; + } catch (e) { + this.results = "set unexpected error:" + e; + console.log("set unexpected error:" + e); + } + }, + getKey() { + try { + var promise = systemParameter.get("test.parameter.key", "default"); + promise.then(function (data) { + result = "getKey pass"; + console.log("get test.parameter.key success:" + JSON.stringify(data)); + }).catch(function (err) { + result = "get test.parameter.key error:" + err.code; + console.log("get test.parameter.key error:" + err.code); + }); + this.results = result; + } catch (e) { + this.results = "get unexpected error:" + e; + console.log("get unexpected error:" + e); + } + }, + setSync() { + try { + systemParameter.setSync("test.parameter.key", "testValue"); + this.results = "setSync pass"; + } catch (e) { + this.results = "setSync unexpected error:" + e; + console.log("setSync unexpected error:" + e); + } + }, + getSync() { + try { + var getSync = systemParameter.getSync("test.parameter.key", "default"); + console.log("getSync test.parameter.key value success:" + JSON.stringify(getSync)); + this.results = "getSync pass"; + } catch (e) { + this.results = "getSync unexpected error:" + e; + console.log("getSync unexpected error"); + } + }, + setASyncCallback() { + try { + systemParameter.set("test.parameter.key", "testValue", function (err, data) { + if (err = "undefined") { + result = "setASyncCallback pass" + console.log("set test.parameter.key value success:" + data); + } else { + result = "set test.parameter.key value err:" + err.code; + console.log("set test.parameter.key value err:" + err.code); + } + }); + this.results = result; + } catch (e) { + this.results = "set unexpected error:" + e; + console.log("set unexpected error:" + e); + } + }, + getAsyncCallback() { + try { + systemParameter.get("test.parameter.key", function (err, data) { + if (err == "undefined") { + result = "getAsyncCallback pass"; + console.log("get test.parameter.key value success:" + data); + } else { + result = "get test.parameter.key value err:" + err.code; + console.log("get test.parameter.key value err:" + err.code); + } + }); + this.results = result; + } catch (e) { + this.results = "getSync unexpected error:" + e; + console.log("getSync unexpected error:" + e); + } + }, + getDefAsyncCallback() { + try { + systemParameter.get("test.parameter.key", "default", function (err, data) { + if (err == "undefined") { + result = "getDefAsyncCallback pass"; + console.log("get test.parameter.key value success:" + data); + } else { + result = "get test.parameter.key value err:" + err.code; + console.log("get test.parameter.key value err:" + err.code); + } + }); + this.results = result; + } catch (e) { + this.results = "get test.parameter.key value err:" + e; + console.log("get test.parameter.key value err:" + e); + } + }, + back() { + router.back(); + } +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/resources/base/element/string.json b/UI/JsDevice/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..02a8fe6a6a3ac7b97d69399006caa95be295e090 --- /dev/null +++ b/UI/JsDevice/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "JsDevice" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/UI/JsDevice/entry/src/main/resources/base/media/icon.png b/UI/JsDevice/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/UI/JsDevice/entry/src/main/resources/base/media/icon.png differ diff --git a/UI/JsDevice/settings.gradle b/UI/JsDevice/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/UI/JsDevice/settings.gradle @@ -0,0 +1 @@ +include ':entry'