Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7a9b371b
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a9b371b
编写于
1月 14, 2023
作者:
L
lichenchen
提交者:
cclicn
2月 09, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
appaccount add changelogs
Signed-off-by:
N
lichenchen
<
lichenchen15@huawei.com
>
上级
3c4d1aeb
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
73 addition
and
13 deletion
+73
-13
zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-account_os_account.md
...ogs/OpenHarmony_3.2.10.3/changelogs-account_os_account.md
+62
-2
zh-cn/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md
.../changelogs/v3.1-Release/changelogs-account_os_account.md
+11
-11
未找到文件。
zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-account_os_account.md
浏览文件 @
7a9b371b
...
...
@@ -20,7 +20,6 @@
```
ts
import
account_osAccount
from
"
@ohos.account.osAccount
"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
accountMgr
=
account_osAccount
.
getAccountManager
();
let
domainInfo
=
{
...
...
@@ -31,6 +30,67 @@ try {
await
accountMgr
.
createOsAccountForDomain
(
account_osAccount
.
OsAccountType
.
NORMAL
,
domainInfo
);
await
accountMgr
.
createOsAccountForDomain
(
account_osAccount
.
OsAccountType
.
NORMAL
,
domainInfo
);
}
catch
(
err
)
{
expect
(
err
.
code
).
assertEqual
(
12300004
);
console
.
log
(
"
activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
// error.code = 12300004;
}
```
## cl.account_os_account.2 应用帐号getAllAccounts接口权限场景变更
应用使用getAllAccounts接口查询自己可访问的帐号列表时,不需要申请权限ohos.permission.GET_ALL_APP_ACCOUNTS。
**变更影响**
基于此后版本开发的应用,查询自己可访问的帐号列表时,无需申请权限。
**关键接口/组件变更**
-
AccountManager
-
getAllAccounts(callback: AsyncCallback
<
Array
<
AppAccountInfo
>>
): void;
-
getAllAccounts(): Promise
<
Array
<
AppAccountInfo
>>
;
**适配指导**
应用未申请ohos.permission.GET_ALL_APP_ACCOUNTS,查询自己可访问的帐号列表示例代码如下:
```
ts
import
account_appAccount
from
"
@ohos.account.appAccount
"
let
accountMgr
=
account_appAccount
.
createAppAccountManager
();
try
{
await
accountMgr
.
addAccount
(
"
accessibleAccount_promise_nopermission
"
);
var
data
=
await
accountMgr
.
getAllAccounts
();
if
(
data
[
0
].
name
==
"
accessibleAccount_promise_nopermission
"
)
{
console
.
log
(
"
getAllAccounts successfully
"
);
}
}
catch
(
err
)
{
console
.
log
(
"
getAllAccounts err:
"
+
JSON
.
stringify
(
err
));
}
```
## cl.account_os_account.3 应用帐号getAccountsByOwner接口权限场景变更
应用使用getAccountsByOwner接口查询可访问的指定应用的帐号列表时,不需要申请权限ohos.permission.GET_ALL_APP_ACCOUNTS。
**变更影响**
基于此后版本开发的应用,查询指定应用可访问的帐号列表时,无需申请权限。
**关键接口/组件变更**
-
AccountManager
-
getAccountsByOwner(owner: string, callback: AsyncCallback
<
Array
<
AppAccountInfo
>>
): void;
-
getAccountsByOwner(owner: string): Promise
<
Array
<
AppAccountInfo
>>
;
**适配指导**
应用未申请ohos.permission.GET_ALL_APP_ACCOUNTS,查询指定应用可访问的帐号列表示例代码如下:
```
ts
import
account_appAccount
from
"
@ohos.account.appAccount
"
let
accountMgr
=
account_appAccount
.
createAppAccountManager
();
try
{
var
ownerName
=
"
com.example.owner
"
;
var
data
=
await
accountMgr
.
getAllAccounts
(
ownerName
);
}
catch
(
err
)
{
console
.
log
(
"
getAllAccounts err:
"
+
JSON
.
stringify
(
err
));
}
```
\ No newline at end of file
zh-cn/release-notes/changelogs/v3.1-Release/changelogs-account_os_account.md
浏览文件 @
7a9b371b
...
...
@@ -33,25 +33,25 @@
**适配指导**
```
ts
import
account_osAccount
from
"
@ohos.account.osAccount
"
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
let
accountMgr
=
account_osAccount
.
getAccountManager
();
accountMgr
.
createOsAccount
(
'
account_test
'
,
account_osAccount
.
OsAccountType
.
GUEST
).
then
((
accountInfo
)
=>
{
expect
(
accountInfo
.
type
).
assertEqual
(
account_osAccount
.
OsAccountType
.
GUEST
);
accountMgr
.
createOsAccount
(
"
account_test
"
,
account_osAccount
.
OsAccountType
.
GUEST
).
then
((
accountInfo
)
=>
{
if
(
accountInfo
.
type
==
account_osAccount
.
OsAccountType
.
GUEST
)
{
console
.
log
(
"
createOsAccount successfully
"
);
}
accountMgr
.
activateOsAccount
(
accountInfo
.
localId
).
then
(()
=>
{
console
.
log
(
'
activateOsAccount successfully
'
);
console
.
log
(
"
activateOsAccount successfully
"
);
accountMgr
.
getOsAccountTypeFromProcess
().
then
((
accountType
)
=>
{
expect
(
accountType
).
assertEqual
(
account_osAccount
.
OsAccountType
.
GUEST
);
if
(
accountType
==
account_osAccount
.
OsAccountType
.
GUEST
)
{
console
.
log
(
"
getOsAccountTypeFromProcess successfully
"
);
}
}).
catch
((
err
)
=>
{
console
.
log
(
'
activateOsAccount err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
console
.
log
(
"
activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
activateOsAccount err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
console
.
log
(
"
activateOsAccount err:
"
+
JSON
.
stringify
(
err
));
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
createOsAccount err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
console
.
log
(
"
createOsAccount err:
"
+
JSON
.
stringify
(
err
));
});
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录