diff --git a/OHBM/build-profile.json5 b/OHBM/build-profile.json5 index 278e3201fd9f13803681bdccd77c54fb06ceb37a..1b02a4eac717c16da94816d8b9392ca0e3088b2f 100644 --- a/OHBM/build-profile.json5 +++ b/OHBM/build-profile.json5 @@ -20,8 +20,9 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", - "runtimeOS": "HarmonyOS", + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, + "runtimeOS": "OpenHarmony", "buildOption": { "strictMode": { "caseSensitiveCheck": true, diff --git a/OHBM/entry/src/main/ets/models/BasicInfoItemData.ets b/OHBM/entry/src/main/ets/models/BasicInfoItemData.ets new file mode 100644 index 0000000000000000000000000000000000000000..04ed4d74e005f71faa141b432d7730261e0f584b --- /dev/null +++ b/OHBM/entry/src/main/ets/models/BasicInfoItemData.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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. + */ +/** + * List item data entity. + */ + +export default class BasicInfoItemData { + name: string = '' + value: string = '' + + constructor(name: string, value: string) { + this.name = name; + this.value = value; + } +} \ No newline at end of file diff --git a/OHBM/entry/src/main/ets/pages/BasicInfo.ets b/OHBM/entry/src/main/ets/pages/BasicInfo.ets index 80bf79ec64893b76e0f56ec327314179b7c74603..6cc29a999b99ee2774f47300e068330d15806161 100644 --- a/OHBM/entry/src/main/ets/pages/BasicInfo.ets +++ b/OHBM/entry/src/main/ets/pages/BasicInfo.ets @@ -19,30 +19,29 @@ import { sensor } from '@kit.SensorServiceKit'; import { camera } from '@kit.CameraKit'; import { common } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; +import { inputDevice } from '@kit.InputKit'; +import Item from '../models/BasicInfoItemData'; +import BasicInfoArray from '../views/BasicInfoAarry'; +import { display } from '@kit.ArkUI'; -class Item { - name: string = '' - value: string = '' - - constructor(name: string, value: string) { - this.name = name; - this.value = value; - } -} @Entry @Component struct BasicInfo { - @State deviceInfoArray: Item[] = [] - @State batteryInfoArray: Item[] = [] - @State sensorInfoArray: Item[] = [] - @State cameraInfoArray: Item[] = [] + @State deviceInfoArray: Item[] = []; + @State batteryInfoArray: Item[] = []; + @State sensorInfoArray: Item[] = []; + @State cameraInfoArray: Item[] = []; + @State inputDevicesArray: Item[] = []; + @State displaysArray: Item[] = []; aboutToAppear(): void { this.getDeviceInfo(); this.getCameraInfo(); this.getBatteryInfo(); this.getSensorInfo(); + this.getInputDevices(); + this.getDisplays(); } build() { @@ -54,101 +53,17 @@ struct BasicInfo { .margin(16) Scroll() { Column() { - Text('设备信息') - .fontSize(24) - .width('100%') - .backgroundColor('#CCCCCC') - .padding(12) - List() { - ForEach(this.deviceInfoArray, (item: Item) => { - ListItem() { - Row() { - Text(item.name) - .fontSize(18) - Text(item.value) - .fontSize(18) - } - .margin({ top: 4, bottom: 4 }) - .justifyContent(FlexAlign.SpaceBetween) - .width('100%') - } - }) - } - .divider({ strokeWidth: 1, color: '#CCCCCC' }) - .width('90%') - - Text('相机') - .fontSize(24) - .width('100%') - .backgroundColor('#CCCCCC') - .padding(12) - List() { - ForEach(this.cameraInfoArray, (item: Item) => { - ListItem() { - Row() { - Text(item.name) - .fontSize(18) - Text(item.value) - .fontSize(18) - } - .margin({ top: 4, bottom: 4 }) - .justifyContent(FlexAlign.SpaceBetween) - .width('100%') - } - }) - } - .divider({ strokeWidth: 1, color: '#CCCCCC' }) - .width('90%') - - Text('电量信息') - .fontSize(24) - .width('100%') - .backgroundColor('#CCCCCC') - .padding(12) - List() { - ForEach(this.batteryInfoArray, (item: Item) => { - ListItem() { - Row() { - Text(item.name) - .fontSize(18) - Text(item.value) - .fontSize(18) - } - .margin({ top: 4, bottom: 4 }) - .justifyContent(FlexAlign.SpaceBetween) - .width('100%') - } - }) - } - .divider({ strokeWidth: 1, color: '#CCCCCC' }) - .width('90%') - - Text('传感器') - .fontSize(24) - .width('100%') - .backgroundColor('#CCCCCC') - .padding(12) - List() { - ForEach(this.sensorInfoArray, (item: Item) => { - ListItem() { - Row() { - Text(item.name) - .fontSize(18) - Text(item.value) - .fontSize(18) - } - .margin({ top: 4, bottom: 4 }) - .justifyContent(FlexAlign.SpaceBetween) - .width('100%') - } - }) - } - .divider({ strokeWidth: 1, color: '#CCCCCC' }) - .width('90%') + BasicInfoArray({title:'设备信息',infoArray:this.deviceInfoArray}) + BasicInfoArray({title:'相机',infoArray:this.cameraInfoArray}) + BasicInfoArray({title:'屏幕',infoArray:this.displaysArray}) + BasicInfoArray({title:'电量信息',infoArray:this.batteryInfoArray}) + BasicInfoArray({title:'输入设备',infoArray:this.inputDevicesArray}) + BasicInfoArray({title:'传感器',infoArray:this.sensorInfoArray}) } } .scrollBar(BarState.Off) .height('100%') + .align(Alignment.Top) }.margin({ bottom: 48 }) } @@ -196,7 +111,7 @@ struct BasicInfo { cameras = cameraManager.getSupportedCameras(); for (let index = 0; index < cameras.length; index++) { let element = cameras[index]; - this.cameraInfoArray.push(new Item('ID', element.cameraId)); + this.cameraInfoArray.push(new Item('#[ID]', element.cameraId)); this.cameraInfoArray.push(new Item('位置', `${element.cameraPosition}(0-相机位置未指定,1-后置相机,2-前置相机)`)); this.cameraInfoArray.push(new Item('类型', @@ -269,6 +184,78 @@ struct BasicInfo { return cameraManager; } + getInputDevices() { + try { + inputDevice.getDeviceList().then((ids: Array) => { + for (let index = 0; index < ids.length; index++) { + try { + inputDevice.getDeviceInfo(ids[index].valueOf(), (error: Error, deviceData: inputDevice.InputDeviceData) => { + if (error) { + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + this.inputDevicesArray.push(new Item('#[ID]', deviceData.id.toString())); + this.inputDevicesArray.push(new Item('name', deviceData.name.toString())); + for (let index = 0; index < deviceData.sources.length; index++) { + this.inputDevicesArray.push(new Item('sources', deviceData.sources[index].toString())); + } + for (let index = 0; index < deviceData.axisRanges.length; index++) { + this.inputDevicesArray.push(new Item('axisRanges source', deviceData.axisRanges[index].source.toString())); + this.inputDevicesArray.push(new Item('axisRanges axis', deviceData.axisRanges[index].axis.toString())); + this.inputDevicesArray.push(new Item('axisRanges max', deviceData.axisRanges[index].max.toString())); + this.inputDevicesArray.push(new Item('axisRanges min', deviceData.axisRanges[index].min.toString())); + this.inputDevicesArray.push(new Item('axisRanges fuzz', deviceData.axisRanges[index].fuzz.toString())); + this.inputDevicesArray.push(new Item('axisRanges flat', deviceData.axisRanges[index].flat.toString())); + this.inputDevicesArray.push(new Item('axisRanges resolution', deviceData.axisRanges[index].resolution.toString())); + } + this.inputDevicesArray.push(new Item('bus', deviceData.bus.toString())); + this.inputDevicesArray.push(new Item('product', deviceData.product.toString())); + this.inputDevicesArray.push(new Item('vendor', deviceData.vendor.toString())); + this.inputDevicesArray.push(new Item('version', deviceData.version.toString())); + this.inputDevicesArray.push(new Item('phys', deviceData.phys.toString())); + this.inputDevicesArray.push(new Item('uniq', deviceData.uniq.toString())); + }); + } catch (error) { + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); + } + } + }); + } catch (error) { + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); + } + + } + + getDisplays(){ + let promise: Promise> = display.getAllDisplays(); + promise.then((data: Array) => { + for (let index = 0; index < data.length; index++) { + let element = data[index]; + this.displaysArray.push(new Item('#[ID]', element.id.toString())); + this.displaysArray.push(new Item('name', element.name.toString())); + this.displaysArray.push(new Item('alive', element.alive.toString())); + this.displaysArray.push(new Item('state', element.state.toString())); + this.displaysArray.push(new Item('refreshRate', element.refreshRate.toString())); + this.displaysArray.push(new Item('rotation', element.rotation.toString())); + this.displaysArray.push(new Item('width', element.width.toString())); + this.displaysArray.push(new Item('height', element.height.toString())); + this.displaysArray.push(new Item('availableWidth', element.availableWidth.toString())); + this.displaysArray.push(new Item('availableHeight', element.availableHeight.toString())); + this.displaysArray.push(new Item('densityDPI', element.densityDPI.toString())); + this.displaysArray.push(new Item('orientation', element.orientation.toString())); + this.displaysArray.push(new Item('densityPixels', element.densityPixels.toString())); + this.displaysArray.push(new Item('scaledDensity', element.scaledDensity.toString())); + this.displaysArray.push(new Item('xDPI', element.xDPI.toString())); + this.displaysArray.push(new Item('yDPI', element.yDPI.toString())); + this.displaysArray.push(new Item('colorSpaces', JSON.stringify(element.colorSpaces))); + this.displaysArray.push(new Item('hdrFormats', JSON.stringify(element.hdrFormats))); + } + console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)); + }).catch((err: BusinessError) => { + console.error(`Failed to obtain all the display objects. Code: ${err.code}, message: ${err.message}`); + }); + + } getBatteryInfo() { this.batteryInfoArray = [] this.batteryInfoArray.push(new Item('batterySOC', batteryInfo.batterySOC.toString())); diff --git a/OHBM/entry/src/main/ets/views/BasicInfoAarry.ets b/OHBM/entry/src/main/ets/views/BasicInfoAarry.ets new file mode 100644 index 0000000000000000000000000000000000000000..48db0a0937cdd5fe63db0c2451515e60eba983f8 --- /dev/null +++ b/OHBM/entry/src/main/ets/views/BasicInfoAarry.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 ItemData from '../models/BasicInfoItemData'; + +/** + * List item information component. + */ +@Component +export default struct BasicInfoArray { + @State title: string = ''; + @State infoArray: ItemData[] = []; + @State isFold: boolean = false; + + aboutToAppear() { + } + + build() { + Column() { + Row() { + Text(this.title) + .fontSize(24) + .padding(12) + Image($r('app.media.chevron_down')) + .width(36) + .height(36) + .rotate({ angle: this.isFold ? 0 : 180 }) + } + .justifyContent(FlexAlign.SpaceBetween) + .backgroundColor('#CCCCCC') + .width('100%') + .borderWidth(1) + .onClick(() => { + this.isFold = !this.isFold; + }) + + if (!this.isFold) { + List() { + ForEach(this.infoArray, (item: ItemData, index: number) => { + ListItem() { + Row() { + Text(item.name) + .fontSize(18) + Text(item.value) + .fontSize(18) + } + .margin({ top: 4, bottom: 4 }) + .justifyContent(FlexAlign.SpaceBetween) + .width('100%') + }.backgroundColor(index % 2 === 0 ? '#FFFFFF' : '#EEEEEE') + }) + } + .transition(TransitionEffect.OPACITY.animation({ duration: 1000, curve: Curve.Ease })) + .divider({ strokeWidth: 1, color: '#CCCCCC' }) + .width('90%') + } + } + } +} \ No newline at end of file diff --git a/OHBM/entry/src/main/module.json5 b/OHBM/entry/src/main/module.json5 index 18c8d1e2f07ad15d2fa56e708e6ec679eb437e72..af4efdf9542b478fdcdb33af25332b13b654a79f 100644 --- a/OHBM/entry/src/main/module.json5 +++ b/OHBM/entry/src/main/module.json5 @@ -20,9 +20,8 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "default", + "tablet" ], "deliveryWithInstall": true, "installationFree": false, @@ -32,7 +31,7 @@ "name": "EntryAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", - "icon": "$media:layered_image", + "icon": "$media:startIcon", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", @@ -60,7 +59,7 @@ "name": "ohos.extension.backup", "resource": "$profile:backup_config" } - ], + ] } ], "requestPermissions": [ diff --git a/OHBM/entry/src/main/resources/base/element/string.json b/OHBM/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..c678248bcbfa7ee3cbf4b343cdc498cba99d8030 100644 --- a/OHBM/entry/src/main/resources/base/element/string.json +++ b/OHBM/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "OHBM" } ] } \ No newline at end of file diff --git a/OHBM/entry/src/main/resources/base/media/chevron_down.png b/OHBM/entry/src/main/resources/base/media/chevron_down.png new file mode 100644 index 0000000000000000000000000000000000000000..e6d58ca9bc4ffdcfd6ea29e46a23382d52b5c0e4 Binary files /dev/null and b/OHBM/entry/src/main/resources/base/media/chevron_down.png differ diff --git a/OHBM/entry/src/main/resources/base/media/startIcon.png b/OHBM/entry/src/main/resources/base/media/startIcon.png index 205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b..ce6c0513a7ccbcf71ff5a955440463aa7a05e9e8 100644 Binary files a/OHBM/entry/src/main/resources/base/media/startIcon.png and b/OHBM/entry/src/main/resources/base/media/startIcon.png differ diff --git a/OHBM/entry/src/main/resources/base/media/startIcon1.png b/OHBM/entry/src/main/resources/base/media/startIcon1.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/OHBM/entry/src/main/resources/base/media/startIcon1.png differ diff --git a/OHBM/entry/src/main/resources/en_US/element/string.json b/OHBM/entry/src/main/resources/en_US/element/string.json index f94595515a99e0c828807e243494f57f09251930..c678248bcbfa7ee3cbf4b343cdc498cba99d8030 100644 --- a/OHBM/entry/src/main/resources/en_US/element/string.json +++ b/OHBM/entry/src/main/resources/en_US/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "OHBM" } ] } \ No newline at end of file diff --git a/OHBM/entry/src/main/resources/zh_CN/element/string.json b/OHBM/entry/src/main/resources/zh_CN/element/string.json index 597ecf95e61d7e30367c22fe2f8638008361b044..889dde09004b117c7780261efa2a5bfe4d655d10 100644 --- a/OHBM/entry/src/main/resources/zh_CN/element/string.json +++ b/OHBM/entry/src/main/resources/zh_CN/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "开鸿测评" } ] } \ No newline at end of file diff --git a/OHBM/entry/src/ohosTest/module.json5 b/OHBM/entry/src/ohosTest/module.json5 index ee9fbe0fc791b13b7993a65cb2b810a0f6b0fcdc..61b3568a11a7de7a4d155cd36a2f927b7d15bff1 100644 --- a/OHBM/entry/src/ohosTest/module.json5 +++ b/OHBM/entry/src/ohosTest/module.json5 @@ -18,9 +18,8 @@ "name": "entry_test", "type": "feature", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "default", + "tablet" ], "deliveryWithInstall": true, "installationFree": false