Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fcd6433c
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fcd6433c
编写于
10月 20, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5984 【master】【xts】fixbug getPermission
Merge pull request !5984 from yangbo/1020_xts
上级
44049724
ff52f30c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
13 deletion
+52
-13
multimedia/medialibrary/common.js
multimedia/medialibrary/common.js
+16
-4
multimedia/userfilemgr/common.js
multimedia/userfilemgr/common.js
+36
-9
未找到文件。
multimedia/medialibrary/common.js
浏览文件 @
fcd6433c
...
...
@@ -211,13 +211,25 @@ const getPermission = async function (name) {
let
appInfo
=
await
bundle
.
getApplicationInfo
(
name
,
0
,
100
);
let
tokenID
=
appInfo
.
accessTokenId
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
result1
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.MEDIA_LOCATION
"
,
1
);
let
result2
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_MEDIA
"
,
1
);
let
result3
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_MEDIA
"
,
1
);
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.MEDIA_LOCATION
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission MEDIA_LOCATION failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_MEDIA
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission READ_MEDIA failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_MEDIA
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission WRITE_MEDIA failed
'
)
}
let
isGranted1
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.MEDIA_LOCATION
"
);
let
isGranted2
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.READ_MEDIA
"
);
let
isGranted3
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.WRITE_MEDIA
"
);
if
(
!
(
result1
==
0
&&
result2
==
0
&&
result3
==
0
)
||
!
(
isGranted1
==
0
&&
isGranted2
==
0
&&
isGranted3
==
0
))
{
if
(
!
(
isGranted1
==
0
&&
isGranted2
==
0
&&
isGranted3
==
0
))
{
console
.
info
(
'
getPermission failed
'
)
}
console
.
info
(
'
getPermission end
'
)
...
...
multimedia/userfilemgr/common.js
浏览文件 @
fcd6433c
...
...
@@ -138,13 +138,41 @@ const getPermission = async function (name = 'ohos.acts.multimedia.userfilemgr')
let
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.multimedia.userfilemgr
'
,
0
,
100
);
let
tokenID
=
appInfo
.
accessTokenId
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
result1
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.MEDIA_LOCATION
"
,
1
);
let
resultReadImageVideo
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_IMAGEVIDEO
"
,
1
);
let
resultReadAudio
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_AUDIO
"
,
1
);
let
resultReadDocument
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_DOCUMENT
"
,
1
);
let
resultWriteImageVideo
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_IMAGEVIDEO
"
,
1
);
let
resultWriteAudio
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_AUDIO
"
,
1
);
let
resultWriteDocument
=
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_DOCUMENT
"
,
1
);
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.MEDIA_LOCATION
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission MEDIA_LOCATION failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_IMAGEVIDEO
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission READ_IMAGEVIDEO failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_AUDIO
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission READ_AUDIO failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.READ_DOCUMENT
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission READ_DOCUMENT failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_IMAGEVIDEO
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission WRITE_IMAGEVIDEO failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_AUDIO
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission WRITE_AUDIO failed
'
)
}
try
{
await
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.WRITE_DOCUMENT
"
,
1
);
}
catch
(
error
)
{
console
.
info
(
'
getPermission WRITE_DOCUMENT failed
'
)
}
let
isGranted1
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.MEDIA_LOCATION
"
);
let
isGrantedReadImageVideo
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.READ_IMAGEVIDEO
"
);
let
isGrantedReadAudio
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.READ_AUDIO
"
);
...
...
@@ -152,8 +180,7 @@ const getPermission = async function (name = 'ohos.acts.multimedia.userfilemgr')
let
isGrantedWriteImageVideo
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.WRITE_IMAGEVIDEO
"
);
let
isGrantedWriteAudio
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.WRITE_AUDIO
"
);
let
isGrantedWriteDocument
=
await
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.WRITE_DOCUMENT
"
);
if
(
result1
!=
0
||
isGranted1
!=
0
||
!
(
resultReadImageVideo
==
0
&&
resultReadAudio
==
0
&&
resultReadDocument
==
0
)
||
!
(
resultWriteImageVideo
==
0
&&
resultWriteAudio
==
0
&&
resultWriteDocument
==
0
)
||
if
(
isGranted1
!=
0
||
!
(
isGrantedReadImageVideo
==
0
&&
isGrantedReadAudio
==
0
&&
isGrantedReadDocument
==
0
)
||
!
(
isGrantedWriteImageVideo
==
0
&&
isGrantedWriteAudio
==
0
&&
isGrantedWriteDocument
==
0
))
{
console
.
info
(
'
getPermission failed
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录