From 43a69cd52b1399e8dbcc688f8a305fa49503922f Mon Sep 17 00:00:00 2001 From: zhangxingxia Date: Tue, 15 Mar 2022 09:05:43 +0800 Subject: [PATCH] add permission for xts Signed-off-by: zhangxingxia --- .../signature/openharmony_sx.p7b | Bin 3437 -> 3544 bytes .../src/main/config.json | 126 +++++++++++------- .../main/js/default/test/filemanager.test.js | 23 ++-- 3 files changed, 90 insertions(+), 59 deletions(-) diff --git a/storage/storagefilemanagerjstest/signature/openharmony_sx.p7b b/storage/storagefilemanagerjstest/signature/openharmony_sx.p7b index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..1fa42c55eceafebe1aad98c326e0210953e7d232 100644 GIT binary patch delta 1083 zcmaizZ)oFm9L8G)6pffY_=3+9bG;FhSU!Lg2q4$Aj`;b*l7h32iS#XDy6L8?cf}I zeD+ay*LvXDimphGf*f>TJow`5c|4U!uHhJ-Tt*DjU6I`pI+HXi3jBng{}3O$y9DoaZ|86Q#8cS0YHxh~vo7@WxZyvX?#P0r`3 zp3ikT|Aci3lM@_|6lzpi5E$CaQeu}baRkdiv_z8{munc}Dxo)fnkM(rou<+A84*?q zHD4y6Bhqxrt5|78k}`^OR|HjE7Tk4C3GnenX}mIhKKHDuFS zy~&g{87p}e5sHK=542vFF9<9_sOq3$94C$-ygUh^*sSrSAXpW=-Rjjc`2@ZLs;e*~ z`6$*c5G|TAokV(zt)oh{@AI`$k!cuNk83*_tyD?@I;pcjtk&vAzOQnqW9|%_iZFoU z)S5YSN+ramX3L$1F@1X`IZhW`-yUju!;rTK!O6Bfxjx7ZQ)a$YRwWL43`q`{B9}-J zkfR6zQWAt-U0{8fbtO;`Fe^c^!?@)%j2zd>k(4Unr3|VAB2i#8Lg&<02OG7MMla=9 z(ufw=IH=}5tL-KQ$dX>BID}Y5(aW8<*)T>>PlF_7G_y9(ySyO`a4*9bbgD)qc(*j- zYuTVjHeH)GvVL~NI9hzVA6b9KcOA<%yNc`vDV`y=kDCMafz0Ky+{B~iBEweeAp{bzye`Ms< zqhBNI^Rt^^5_)MGTO2I@`|GCH7h_`#U?@N_6vx);Ab#?M3lS8FES=fBaphTlDZU`{uFhrMpMf`=3AY&{cS- KyH}ocxBdomYid{k delta 992 zcmY+DO^D-U7{|Ar&a5L-g%t)?4>NWTg7cO1Ytn&ree*F%I+L_%lYWFAnxtvdHci@m z^ljqGKo5hU2tzNjh^~hfPr9&P1VPrDuqZ5p?o9+mFS?+IJqdP3cEscR`#-;j_wf85 zz4ZHwN60kZU0Qzim^pqDk6e!4p2p=lszf6Z^m!z{wA?&qBKkrs8dWSG(WIb*h zw%gLjx@iw}XSN%;v05Mr0;tIjfGiF=EG3qTvJ}qViF|y-_b9YsaU>h^qLiu{8qb9k zoYU}v^>CjPTu2CYvLXmH1@olXqskl(Xn;x-fphtWC8sKeI%xIPWX9r36eQvKG($ln zROpJY4-8Z7Q340j|5^sel%>+qev6)qA|=c}@idy8M^6)p!`X8MOt?ceg`4WYFth#O*1(vwp%rA)lS;}n17DI{<3K4n{fPoFX@@p_ z%Ne`FTs6>(>|~&QXk<(hUx4`Mq4AXjebcZ z170!@yh6otQcV9atYP_FE8{v^E_AQYZpQZFgJ6ECW>-_rj&yb!yLPX+xO;h#K&Fu! zv-ej<&;7p_v#as#BNWM^86=s)QkabFT-0Pah9+X`@N`xC1ifE>9R2*xMsshicI&3} z)2FBEpC?~`_5=3T+sLy^&&(_M?e*9~G)5y-bloYC*H+g4_{K{O#;L~x?<9AnHc`f?#r7zMN{CSf&0~O4{JaF1Cc{Z AlmGw# diff --git a/storage/storagefilemanagerjstest/src/main/config.json b/storage/storagefilemanagerjstest/src/main/config.json index ff67126de..4063ca213 100644 --- a/storage/storagefilemanagerjstest/src/main/config.json +++ b/storage/storagefilemanagerjstest/src/main/config.json @@ -1,61 +1,85 @@ { "app": { - "bundleName": "ohos.acts.storage.filemanager", - "vendor": "example", - "version": { - "code": 1000000, - "name": "1.0.0" - }, "apiVersion": { - "compatible": 4, - "target": 5 - } + "compatible": 6, + "target": 7 + }, + "vendor": "example", + "bundleName": "ohos.acts.storage.filemanager", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": { + "default": { + "debug": true + } }, - "deviceConfig": {}, "module": { - "package": "ohos.acts.storage.filemanager", - "name": ".MyApplication", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry", - "installationFree": true - }, - "abilities": [ - { - "skills": [ + "abilities": [ { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] + "iconId": 16777218, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "icon": "$media:icon", + "name": "ohos.acts.storage.filemanager.MainAbility", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "homeAbility": true, + "launchType": "standard" } - ], - "name": "ohos.acts.storage.filemanager.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "$string:app_name", - "type": "page", - "launchType": "standard", - "visible": true - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false + ], + "deviceType": [ + "phone", + "tablet", + "tv", + "wearable" + ], + "reqPermissions": [ + { + "name" : "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason" : "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name" : "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", + "reason" : "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" + }, + { + "name" : "ohos.permission.READ_MEDIA", + "reason" : "use ohos.permission.READ_MEDIA" } - } - ] + ], + "mainAbility": "ohos.acts.storage.filemanager.MainAbility", + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "ohos.acts.storage.filemanager", + "name": ".MyApplication", + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] } } \ No newline at end of file diff --git a/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js b/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js index e2ad87d59..4bb19a519 100644 --- a/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js +++ b/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js @@ -14,12 +14,9 @@ */ import filemanager from '@ohos.filemanager'; -import { - describe, - it, - expect -} -from 'deccjsunit/index' +import {describe,it,expect,beforeAll}from 'deccjsunit/index'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import bundle from '@ohos.bundle'; // getRoot() interface, when the parameter is "local", the returned data and the data contrast, return the same data is correct const ROOTFILE = [ @@ -36,8 +33,19 @@ let AUDIO_ROOT = ""; let IMAGE_ALBUM = ""; let LOG_ = "FMS_XTS_TEXT: "; let LENGTH = 0; +let tokenID = null; describe("filemanager_test", function () { + beforeAll(async function (){ + let appInfo = await bundle.getApplicationInfo('ohos.acts.storage.filemanager', 0, 100); + tokenID = appInfo.accessTokenId; + let atManager = abilityAccessCtrl.createAtManager(); + let result = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.READ_MEDIA",1); + console.log("tokenID:" + tokenID + "-result:" + result); + let result1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA"); + console.log("tokenID:" + tokenID + "-result:" + result1); + }); + /** * @tc.number SUB_DF_FILEMANAGER_GET_ROOT_0000 * @tc.name filemanager_test_get_root_async_000 @@ -172,7 +180,7 @@ describe("filemanager_test", function () { "name":1 } } - await filemanager.getRoot(options) + await filemanager.getRoot(options); } catch (error) { console.log("filemanager_test_get_root_async_004 has failed for " + error); expect(error.message == "GetRoot func get dev para fails").assertTrue(); @@ -194,7 +202,6 @@ describe("filemanager_test", function () { let path = IMAGE_ROOT; let fileInfos = await filemanager.listFile(path, "image"); expect(Array.isArray(fileInfos)).assertTrue(); - console.log(JSON.stringify(fileInfos)) for (let i = 0; i < fileInfos.length; i++) { if (fileInfos[i].name == "image") { console.log(JSON.stringify(fileInfos[i])) -- GitLab