diff --git a/Security/SecurityComponent/.gitignore b/Security/SecurityComponent/.gitignore index 08d606210b3993e8f1f4535767bb3459b7b1d208..6efa5f5bcfa976d4c7f8b4ff3f614a4e05b80c34 100644 --- a/Security/SecurityComponent/.gitignore +++ b/Security/SecurityComponent/.gitignore @@ -10,4 +10,3 @@ /.clang-tidy **/.test /.appanalyzer -/oh-package-lock.json5 \ No newline at end of file diff --git a/Security/SecurityComponent/AppScope/resources/base/media/background.png b/Security/SecurityComponent/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Security/SecurityComponent/AppScope/resources/base/media/background.png differ diff --git a/Security/SecurityComponent/AppScope/resources/base/media/foreground.png b/Security/SecurityComponent/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/Security/SecurityComponent/AppScope/resources/base/media/foreground.png differ diff --git a/Security/SecurityComponent/AppScope/resources/base/media/layered_image.json b/Security/SecurityComponent/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Security/SecurityComponent/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Security/SecurityComponent/README.md b/Security/SecurityComponent/README_zh.md similarity index 49% rename from Security/SecurityComponent/README.md rename to Security/SecurityComponent/README_zh.md index b3740757200fdbf3dec7b907f05e9ea91af4eb88..9cb0fee76f4653c7ec577235e30e26d2d4bfa4b0 100644 --- a/Security/SecurityComponent/README.md +++ b/Security/SecurityComponent/README_zh.md @@ -1,4 +1,4 @@ -# 安全控件类型的UI控件(仅对系统应用开放) +# 安全控件类型的UI控件 ### 介绍 @@ -6,16 +6,14 @@ ### 效果预览 -| 主页 | Location | Paste | **Save** | -|:-----------------------------------:| :--------------------------------------------: |:---------------------------------------:| :------------------------------------: | -| ![main](screenshots/main.jpeg) | ![location](screenshots/location.jpeg) | ![paste](screenshots/paste.jpeg) | ![save](screenshots/save.jpeg) | +| 主页 | Paste | **Save** | +|:-----------------------------------:|:---------------------------------------:| :------------------------------------: | +| ![main](screenshots/main.jpeg) | ![paste](screenshots/paste.jpeg) | ![save](screenshots/save.jpeg) | 使用说明 -1. 在主界面,点击“Location”按钮,进入“Location”界面,点击“当前位置”按钮,成功获取当前定位信息,并通过提示框显示。 +1. 在主界面,点击“Paste”按钮,进入“Paste”界面,在文本输入框输入文字,全选剪切文字,点击“粘贴”按钮,获取剪贴板内容并显示在输入框中。 -2. 在主界面,点击“Paste”按钮,进入“Paste”界面,在文本输入框输入文字,全选剪切文字,点击“粘贴”按钮,获取剪贴板内容并显示在输入框中。 - -3. 在主界面,点击“Save”按钮,进入“Save”界面,点击“下载”按钮,将当前页面中的图片保存到本地的图库中。 +2. 在主界面,点击“Save”按钮,进入“Save”界面,点击“下载”按钮,将当前页面中的图片保存到本地的图库中。 ### 工程目录 @@ -29,7 +27,6 @@ SecurityComponent │ │ │ └──Index.ets // 首页 │ │ └──securitycomponent // 组件文件 │ │ └──page -│ │ ├──Location.ets // 位置服务安全控件界面 │ │ ├──Paste.ets // 剪贴板安全控件界面 │ │ └──Save.ets // 媒体库安全控件界面 | ├──resources // 资源文件目录 @@ -39,20 +36,16 @@ SecurityComponent ### 具体实现 -* 本示例分为Location安全控件模块,剪贴板安全控件模块,媒体库安全控件模块。 +* 本示例分为剪贴板安全控件模块,媒体库安全控件模块。 - * Location安全控件模块 - - * 使用LocationButton组件开发获取定位信息功能,在其点击回调onclick事件中调用geoLocationManager.getCurrentLocation()得到当前定位信息经纬度。 - * 接口参考:[@ohos.geoLocationManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-location-kit/js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation) * 剪贴板安全控件模块 * 使用PasteButton组件开发获取剪贴板信息功能,在其点击回调onclick事件中调用pasteboard.getSystemPasteboard().getData()将文本复制到剪贴板中,使用pasteData.getPrimaryText()得到剪贴板内容。 - * 接口参考:[@ohos.pasteboard](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-pasteboard.md) + * 接口参考:[@ohos.pasteboard](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-pasteboard.md) * 媒体库安全控件模块 * 使用SaveButton组件开发保存图片到媒体库功能,在其点击回调onclick事件中调用photoAccessHelper.getPhotoAccessHelper()得到媒体库图片管理器helper, helper.createAsset()得到保存到媒体库图片的uri,使用resourceManager.getMediaContent()得到存放在Resources/base/media文件下的test.jpg图片内容,调用fs.open()和fs.write()将图片内容通过得到的uri写到媒体库中,最后fs.close()关闭文件。 - * 接口参考:[@ohos.file.photoAccessHelper](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) + * 接口参考:[@ohos.file.photoAccessHelper-f](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/arkts-apis-photoAccessHelper-f.md),[@ohos.file.photoAccessHelper-PhotoAccessHelper](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/arkts-apis-photoAccessHelper-PhotoAccessHelper.md),[@ohos.file.fs](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) ### 相关权限 @@ -65,9 +58,8 @@ SecurityComponent ### 约束与限制 1. 本示例仅支持标准系统上运行,支持设备:RK3568,GPS定位功能仅支持部分机型。 -2. 本示例为Stage模型,支持API14版本SDK,版本号:(5.0.2.58)。 -4. 本示例已支持使DevEco Studio 5.0.1 Release (构建版本:5.0.5.306,构建 2024年12月6日)编译运行。 -5. 本示例需要使用系统权限的系统接口,需要使用Full SDK编译。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/link?target=https%3A%2F%2Fdocs.openharmony.cn%2Fpages%2Fv3.2%2Fzh-cn%2Fapplication-dev%2Fquick-start%2Ffull-sdk-switch-guide.md%2F)。 +2. 本示例为Stage模型,支持API20版本SDK,版本号:(6.0.0.38)。 +3. 本示例已支持使DevEco Studio 6.0.0 Release(构建版本:6.0.0.868)编译运行。 ### 下载 @@ -77,6 +69,6 @@ SecurityComponent git init git config core.sparsecheckout true echo code/DocsSample/Security/SecurityComponent/ > .git/info/sparse-checkout -git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git remote add origin https://gitcode.com/openharmony/applications_app_samples.git git pull origin master -``` \ No newline at end of file +``` diff --git a/Security/SecurityComponent/build-profile.json5 b/Security/SecurityComponent/build-profile.json5 index 5df1a662714175c2ccf9433cbcfde118fce7021b..15bf2b78481e9332cb1a08d1575e39a50912eef9 100644 --- a/Security/SecurityComponent/build-profile.json5 +++ b/Security/SecurityComponent/build-profile.json5 @@ -21,9 +21,9 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 14, - "compatibleSdkVersion": 14, - "runtimeOS": "OpenHarmony", + "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", "buildOption": { "strictMode": { "caseSensitiveCheck": true, @@ -55,4 +55,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/Security/SecurityComponent/code-linter.json5 b/Security/SecurityComponent/code-linter.json5 index 28586467ee7a761c737d8654a73aed6fddbc3c71..ed05653cca31b61d64cf6471529eaf50d4f70709 100644 --- a/Security/SecurityComponent/code-linter.json5 +++ b/Security/SecurityComponent/code-linter.json5 @@ -31,5 +31,17 @@ "plugin:@typescript-eslint/recommended" ], "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" } } \ No newline at end of file diff --git a/Security/SecurityComponent/entry/.gitignore b/Security/SecurityComponent/entry/.gitignore index eadab4e1522296628f32a70228b2c758ecab4759..e2713a2779c5a3e0eb879efe6115455592caeea5 100644 --- a/Security/SecurityComponent/entry/.gitignore +++ b/Security/SecurityComponent/entry/.gitignore @@ -3,5 +3,4 @@ /.preview /build /.cxx -/.test -/oh-package-lock.json5 \ No newline at end of file +/.test \ No newline at end of file diff --git a/Security/SecurityComponent/entry/build-profile.json5 b/Security/SecurityComponent/entry/build-profile.json5 index e7569e3056e27af38e9991b7ea73ec10f3ba8a05..6bf0d132e6f78049e712446c63f2633b2d1613d3 100644 --- a/Security/SecurityComponent/entry/build-profile.json5 +++ b/Security/SecurityComponent/entry/build-profile.json5 @@ -16,6 +16,11 @@ { "apiType": "stageMode", "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + } }, "buildOptionSet": [ { diff --git a/Security/SecurityComponent/entry/hvigorfile.ts b/Security/SecurityComponent/entry/hvigorfile.ts index a3d28cb60475cede46d0aa36973096d5544dbcd1..cfa8a00f74f409d9647f55cdf270ab6aec69fe41 100644 --- a/Security/SecurityComponent/entry/hvigorfile.ts +++ b/Security/SecurityComponent/entry/hvigorfile.ts @@ -17,5 +17,5 @@ import { hapTasks } from '@ohos/hvigor-ohos-plugin'; export default { system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ -} + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/Security/SecurityComponent/entry/src/main/ets/entryability/EntryAbility.ets b/Security/SecurityComponent/entry/src/main/ets/entryability/EntryAbility.ets index 0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd..98182799de1294d4c21194646a0c30eff08aea33 100644 --- a/Security/SecurityComponent/entry/src/main/ets/entryability/EntryAbility.ets +++ b/Security/SecurityComponent/entry/src/main/ets/entryability/EntryAbility.ets @@ -12,45 +12,51 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; +const DOMAIN = 0x0000; + export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } onDestroy(): void { - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); } onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err) => { if (err.code) { - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); return; } - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); }); } onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); } onForeground(): void { // Ability has brought to foreground - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); } onBackground(): void { // Ability has back to background - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); } -} +} \ No newline at end of file diff --git a/Security/SecurityComponent/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/Security/SecurityComponent/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index b1e212947256c5533c7b06285a597c94f840a6e3..0a97e21bd7a15599af76a806695860ff1eb0ebfe 100644 --- a/Security/SecurityComponent/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/Security/SecurityComponent/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -16,12 +16,16 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; +const DOMAIN = 0x0000; + export default class EntryBackupAbility extends BackupExtensionAbility { async onBackup() { - hilog.info(0x0000, 'testTag', 'onBackup ok'); + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); } async onRestore(bundleVersion: BundleVersion) { - hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); } } \ No newline at end of file diff --git a/Security/SecurityComponent/entry/src/main/ets/pages/Index.ets b/Security/SecurityComponent/entry/src/main/ets/pages/Index.ets index 4c49d15c873fc6762290ac20f0f77c347c6b5a38..eef62ec3a7302057f58b07e88a1df92ebdc66d3c 100644 --- a/Security/SecurityComponent/entry/src/main/ets/pages/Index.ets +++ b/Security/SecurityComponent/entry/src/main/ets/pages/Index.ets @@ -13,8 +13,6 @@ * limitations under the License. */ -import router from '@ohos.router'; - @Entry @Component struct Index { @@ -22,7 +20,7 @@ struct Index { @State text: string = ''; openPage(pageName: string) { - router.pushUrl({ + this.getUIContext().getRouter().pushUrl({ url: 'securitycomponent/pages/' + pageName, }); } diff --git a/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Paste.ets b/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Paste.ets index cf4cc106b455a939be998cb4180a4c3b5b036a96..caa056f6d0d9e5e0b3a514e8008234b12bc8e386 100644 --- a/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Paste.ets +++ b/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Paste.ets @@ -24,7 +24,10 @@ struct Index { build() { Row() { Column({ space: 10 }) { - TextInput({ placeholder: '请输入验证码', text: this.message }) + TextInput({ placeholder: $r('app.string.input_verify_code'), text: this.message }) + .onChange((val: string) => { + this.message = val; + }) PasteButton() .padding({top: 12, bottom: 12, left: 24, right: 24}) .onClick((event: ClickEvent, result: PasteButtonOnClickResult) => { @@ -34,7 +37,6 @@ struct Index { console.error(`Failed to get paste data. Code is ${err.code}, message is ${err.message}`); return; } - // 剪贴板内容为 '123456'。 this.message = pasteData.getPrimaryText(); }); } diff --git a/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Save.ets b/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Save.ets index 3b2ae887646abb0c571689618170fd1744ea422d..4a132865c971b30daebf8166833ee18d5db62239 100644 --- a/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Save.ets +++ b/Security/SecurityComponent/entry/src/main/ets/securitycomponent/pages/Save.ets @@ -27,14 +27,14 @@ async function savePhotoToGallery(context: common.UIAbilityContext) { let uri = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpg'); // 使用uri打开文件,可以持续写入内容,写入过程不受时间限制。 let file = await fileIo.open(uri, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); - // $r('app.media.startIcon')需要替换为开发者所需的图像资源文件。 - context.resourceManager.getMediaContent($r('app.media.startIcon').id, 0) + // $r('app.media.test')需要替换为开发者所需的图像资源文件。 + context.resourceManager.getMediaContent($r('app.media.test').id, 0) .then(async value => { let media = value.buffer; // 写到媒体库文件中。 await fileIo.write(file.fd, media); await fileIo.close(file.fd); - promptAction.openToast({ message: '已保存至相册!' }); + promptAction.openToast({ message: $r('app.string.saved_in_photo') }); }); } catch (error) { const err: BusinessError = error as BusinessError; @@ -48,10 +48,10 @@ struct Index { build() { Row() { Column({ space: 10 }) { - // $r('app.media.startIcon')需要替换为开发者所需的图像资源文件。 - Image($r('app.media.startIcon')) - .height(50) - .width(50) + // $r('app.media.test')需要替换为开发者所需的图像资源文件。 + Image($r('app.media.test')) + .height(400) + .width('100%') SaveButton() .padding({top: 12, bottom: 12, left: 24, right: 24}) @@ -61,7 +61,7 @@ struct Index { // 免去权限申请和权限请求等环节,获得临时授权,保存对应图片。 savePhotoToGallery(context); } else { - promptAction.openToast({ message: '设置权限失败!' }); + promptAction.openToast({ message: $r('app.string.set_permission_failed') }); } }) } diff --git a/Security/SecurityComponent/entry/src/main/module.json5 b/Security/SecurityComponent/entry/src/main/module.json5 index 4144486d1af4c03b0d767cce1cda86fc0d697f91..fad7ec42333e8ddfcb67c497f2cea5a251ae6cbc 100644 --- a/Security/SecurityComponent/entry/src/main/module.json5 +++ b/Security/SecurityComponent/entry/src/main/module.json5 @@ -20,8 +20,9 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "default", - "tablet" + "phone", + "tablet", + "2in1" ], "deliveryWithInstall": true, "installationFree": false, @@ -42,7 +43,7 @@ "entity.system.home" ], "actions": [ - "action.system.home" + "ohos.want.action.home" ] } ] @@ -59,7 +60,7 @@ "name": "ohos.extension.backup", "resource": "$profile:backup_config" } - ] + ], } ] } diff --git a/Security/SecurityComponent/entry/src/main/resources/base/element/float.json b/Security/SecurityComponent/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/Security/SecurityComponent/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/Security/SecurityComponent/entry/src/main/resources/base/element/string.json b/Security/SecurityComponent/entry/src/main/resources/base/element/string.json index 160359841be7cabf65747992508b79d76ef84e9d..d046b74cce06bf5159cc23802730153eeedcb5b0 100644 --- a/Security/SecurityComponent/entry/src/main/resources/base/element/string.json +++ b/Security/SecurityComponent/entry/src/main/resources/base/element/string.json @@ -12,10 +12,6 @@ "name": "EntryAbility_label", "value": "SecurityComponent" }, - { - "name": "get_location_failed", - "value": "获取位置信息失败!" - }, { "name": "input_verify_code", "value": "请输入验证码" diff --git a/Security/SecurityComponent/entry/src/main/resources/base/media/background.png b/Security/SecurityComponent/entry/src/main/resources/base/media/background.png index f939c9fa8cc8914832e602198745f592a0dfa34d..923f2b3f27e915d6871871deea0420eb45ce102f 100644 Binary files a/Security/SecurityComponent/entry/src/main/resources/base/media/background.png and b/Security/SecurityComponent/entry/src/main/resources/base/media/background.png differ diff --git a/Security/SecurityComponent/entry/src/main/resources/base/media/foreground.png b/Security/SecurityComponent/entry/src/main/resources/base/media/foreground.png index 4483ddad1f079e1089d685bd204ee1cfe1d01902..97014d3e10e5ff511409c378cd4255713aecd85f 100644 Binary files a/Security/SecurityComponent/entry/src/main/resources/base/media/foreground.png and b/Security/SecurityComponent/entry/src/main/resources/base/media/foreground.png differ diff --git a/Security/SecurityComponent/entry/src/main/resources/dark/element/color.json b/Security/SecurityComponent/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/Security/SecurityComponent/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/Security/SecurityComponent/entry/src/ohosTest/ets/test/Ability.test.ets b/Security/SecurityComponent/entry/src/ohosTest/ets/test/Ability.test.ets index b7e9f1b20ef9385d3b2dee79c239df97236ca669..4b5b24a467e260de55ed31353d10b41611f5b153 100644 --- a/Security/SecurityComponent/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/Security/SecurityComponent/entry/src/ohosTest/ets/test/Ability.test.ets @@ -21,10 +21,10 @@ import Logger from '../utils/Logger'; const BUNDLE = 'SecurityComponent_'; const DELAY_TIME = 1000; let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); -let manage = abilityDelegator.getAppContext().resourceManager; +let resourceManager = abilityDelegator.getAppContext().resourceManager; -async function getResourceString(resource: Resource): Promise { - let text = await manage.getStringValue(resource); +async function getResourceString(resId: number): Promise { + let text = await resourceManager.getStringValue(resId); return text; } @@ -49,34 +49,6 @@ export default function abilityTest() { } Logger.info(BUNDLE + 'StartAbility_001 end'); }) - /** - * 获取定位信息 - */ - it(BUNDLE + 'GetLocation_001', 0, async (done: Function) => { - Logger.info(BUNDLE + 'GetLocation_001 begin'); - await driver.delayMs(DELAY_TIME); - // 点击Location - await driver.assertComponentExist(ON.id('Location')); - let location = await driver.findComponent(ON.id('Location')); - await location.click(); - await driver.delayMs(DELAY_TIME); - // 点击LocationButton获取定位信息 - await driver.assertComponentExist(ON.type('LocationButton')); - let locationButton = await driver.findComponent(ON.type('LocationButton')); - await locationButton.click(); - await driver.delayMs(DELAY_TIME); - // 点击允许 - let str = await getResourceString($r('app.string.admit')); - await driver.assertComponentExist(ON.text(str)); - let button = await driver.findComponent(ON.text(str)); - await button.click(); - await driver.delayMs(DELAY_TIME * 5); - // 返回 - await driver.pressBack(); - await driver.delayMs(DELAY_TIME); - Logger.info(BUNDLE + 'GetLocation_001 end'); - done(); - }) /** * 获取剪贴板内容 @@ -96,13 +68,13 @@ export default function abilityTest() { await textInput.longClick(); await driver.delayMs(DELAY_TIME); // 点击全选按钮 - let str = await getResourceString($r('app.string.select_all')); + let str = await getResourceString($r('app.string.select_all').id); await driver.assertComponentExist(ON.text(str)); let selectButton = await driver.findComponent(ON.text(str)); await selectButton.click(); await driver.delayMs(DELAY_TIME); // 点击剪切选项 - str = await getResourceString($r('app.string.cut')); + str = await getResourceString($r('app.string.cut').id); await driver.assertComponentExist(ON.text(str)); let cutButton = await driver.findComponent(ON.text(str)); await cutButton.click(); @@ -133,13 +105,12 @@ export default function abilityTest() { let save = await driver.findComponent(ON.id('Save')); await save.click(); await driver.delayMs(DELAY_TIME); - // 点击LocationButton获取定位信息 await driver.assertComponentExist(ON.type('SaveButton')); let saveButton = await driver.findComponent(ON.type('SaveButton')); await saveButton.click(); await driver.delayMs(DELAY_TIME); // 点击允许 - let str = await getResourceString($r('app.string.admit')); + let str = await getResourceString($r('app.string.admit').id); await driver.assertComponentExist(ON.text(str)); let Button = await driver.findComponent(ON.text(str)); await Button.click(); diff --git a/Security/SecurityComponent/entry/src/ohosTest/module.json5 b/Security/SecurityComponent/entry/src/ohosTest/module.json5 index 924e61edf7b81c0583debc543425a2cb893c913b..6b9889e8ccb62f93825d6b26fa53db8e97a974c0 100644 --- a/Security/SecurityComponent/entry/src/ohosTest/module.json5 +++ b/Security/SecurityComponent/entry/src/ohosTest/module.json5 @@ -18,10 +18,11 @@ "name": "entry_test", "type": "feature", "deviceTypes": [ - "default", - "tablet" + "phone", + "tablet", + "2in1" ], "deliveryWithInstall": true, - "installationFree": false, + "installationFree": false } -} \ No newline at end of file +} diff --git a/Security/SecurityComponent/hvigor/hvigor-config.json5 b/Security/SecurityComponent/hvigor/hvigor-config.json5 index 43beb743cbd25c3507b1cf8a744bf8197b3bf2fb..b8fea3f097bd68b0bc4d87de986d2cb7732c1d9b 100644 --- a/Security/SecurityComponent/hvigor/hvigor-config.json5 +++ b/Security/SecurityComponent/hvigor/hvigor-config.json5 @@ -14,15 +14,16 @@ */ { - "modelVersion": "5.0.0", + "modelVersion": "6.0.0", "dependencies": { }, "execution": { - // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ }, "logging": { // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ diff --git a/Security/SecurityComponent/hvigorfile.ts b/Security/SecurityComponent/hvigorfile.ts index 4beb74fe5b573059b972acf9312d33ea1703c016..4cfc811670f43a9427793854a1ff54dc587007c8 100644 --- a/Security/SecurityComponent/hvigorfile.ts +++ b/Security/SecurityComponent/hvigorfile.ts @@ -17,5 +17,5 @@ import { appTasks } from '@ohos/hvigor-ohos-plugin'; export default { system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ - plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ } diff --git a/Security/SecurityComponent/oh-package-lock.json5 b/Security/SecurityComponent/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..64e1988d696a2aa1c1db6d5c2635793808ad44a3 --- /dev/null +++ b/Security/SecurityComponent/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.24": "@ohos/hypium@1.0.24" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.24": { + "name": "@ohos/hypium", + "version": "1.0.24", + "integrity": "sha512-3dCqc+BAR5LqEGG2Vtzi8O3r7ci/3fYU+FWjwvUobbfko7DUnXGOccaror0yYuUhJfXzFK0aZNMGSnXaTwEnbw==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.24.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/Security/SecurityComponent/oh-package.json5 b/Security/SecurityComponent/oh-package.json5 index 93f097993a458e967d6d5239ea0580e79b5d6998..69cb43cba3addcee1840403c67405134a2a9102c 100644 --- a/Security/SecurityComponent/oh-package.json5 +++ b/Security/SecurityComponent/oh-package.json5 @@ -14,12 +14,12 @@ */ { - "modelVersion": "5.0.0", + "modelVersion": "6.0.0", "description": "Please describe the basic information.", "dependencies": { }, "devDependencies": { - "@ohos/hypium": "1.0.19", + "@ohos/hypium": "1.0.24", "@ohos/hamock": "1.0.0" } } diff --git a/Security/SecurityComponent/ohosTest.md b/Security/SecurityComponent/ohosTest.md index f1dd06475c698ea844712e308d4a349edcb0cf42..1e6f22989c9956b384707fa3951a15bd7be4b6ee 100644 --- a/Security/SecurityComponent/ohosTest.md +++ b/Security/SecurityComponent/ohosTest.md @@ -5,7 +5,6 @@ | 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | | -------------- | ------------------------------------------------------------ | ------------------ | ---------------------------- | -------- | -------- | | 拉起应用 | 设备正常运行 | | 成功拉起应用 | 是 | Pass | -| 获取定位信息 | 成功拉起应用,点击”Location“按钮后,成功进入“Location”界面 | 点击“当前位置”按钮 | 提示框显示获取位置信息失败 | 是 | Pass | | 剪切输入框内容 | 成功拉起应用,点击”Paste“按钮后,成功进入“Paste”界面,拉起输入法,输入文本后长按输入框,点击“全选”按钮 | 点击“剪切”按钮 | 文本被剪切,输入框清除文本 | 是 | Pass | | 获取剪贴板内容 | 成功拉起应用,点击”Paste“按钮后,成功进入“Paste”界面,成功得到输入文本 | 点击“粘贴”按钮 | 剪切的文本信息出现在文本框中 | 是 | Pass | | 保存图片 | 成功拉起应用,点击”SaveButton“按钮后,成功进入“SaveButton”界面 | 点击“下载”按钮 | 弹出提示框,文件保存成功 | 是 | Pass | \ No newline at end of file diff --git a/Security/SecurityComponent/screenshots/location.jpeg b/Security/SecurityComponent/screenshots/location.jpeg deleted file mode 100644 index 914eaa22f8a651b13f44ba47e9b12fd7eacbc490..0000000000000000000000000000000000000000 Binary files a/Security/SecurityComponent/screenshots/location.jpeg and /dev/null differ diff --git a/Security/SecurityComponent/screenshots/main.jpeg b/Security/SecurityComponent/screenshots/main.jpeg index ba804573ab5b80fa80ab6f8cfe4b988b8f33f397..7105e749c1209e3460347fef23d676ff850713d9 100644 Binary files a/Security/SecurityComponent/screenshots/main.jpeg and b/Security/SecurityComponent/screenshots/main.jpeg differ