Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0e72c1b6
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看板
未验证
提交
0e72c1b6
编写于
8月 25, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22913 账号arkts告警整改挑单
Merge pull request !22913 from cc_ggboy/cherry-pick-1692868505
上级
8bea9a2b
24a2470f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
572 addition
and
371 deletion
+572
-371
zh-cn/application-dev/reference/apis/js-apis-osAccount.md
zh-cn/application-dev/reference/apis/js-apis-osAccount.md
+572
-371
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-osAccount.md
浏览文件 @
0e72c1b6
...
@@ -79,10 +79,10 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void
...
@@ -79,10 +79,10 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void
**示例:**
激活ID为100的系统帐号
**示例:**
激活ID为100的系统帐号
```
js
```
js
let
accountManager
=
account_osAccount
.
getAccountManager
()
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
accountManager
.
activateOsAccount
(
localId
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`activateOsAccount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`activateOsAccount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -130,12 +130,13 @@ activateOsAccount(localId: number): Promise<void>
...
@@ -130,12 +130,13 @@ activateOsAccount(localId: number): Promise<void>
**示例:**
激活ID为100的系统帐号
**示例:**
激活ID为100的系统帐号
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
activateOsAccount
(
localId
).
then
(()
=>
{
accountManager
.
activateOsAccount
(
localId
).
then
(()
=>
{
console
.
log
(
'
activateOsAccount successfully
'
);
console
.
log
(
'
activateOsAccount successfully
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
activateOsAccount failed, err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
activateOsAccount failed, err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -166,9 +167,10 @@ checkMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void
...
@@ -166,9 +167,10 @@ checkMultiOsAccountEnabled(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
checkMultiOsAccountEnabled
((
err
,
isEnabled
)
=>
{
accountManager
.
checkMultiOsAccountEnabled
((
err
:
BusinessError
,
isEnabled
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
}
else
{
...
@@ -203,11 +205,12 @@ checkMultiOsAccountEnabled(): Promise<boolean>
...
@@ -203,11 +205,12 @@ checkMultiOsAccountEnabled(): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
try
{
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
checkMultiOsAccountEnabled
().
then
((
isEnabled
)
=>
{
accountManager
.
checkMultiOsAccountEnabled
().
then
((
isEnabled
:
boolean
)
=>
{
console
.
log
(
'
checkMultiOsAccountEnabled successfully, isEnabled:
'
+
isEnabled
);
console
.
log
(
'
checkMultiOsAccountEnabled successfully, isEnabled:
'
+
isEnabled
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -243,10 +246,11 @@ checkOsAccountActivated(localId: number, callback: AsyncCallback<boolean>)
...
@@ -243,10 +246,11 @@ checkOsAccountActivated(localId: number, callback: AsyncCallback<boolean>)
**示例:**
判断ID为100的系统帐号是否处于激活状态
**示例:**
判断ID为100的系统帐号是否处于激活状态
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
checkOsAccountActivated
(
localId
,
(
err
,
isActivated
)
=>
{
accountManager
.
checkOsAccountActivated
(
localId
,
(
err
:
BusinessError
,
isActivated
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
checkOsAccountActivated failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountActivated failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -291,12 +295,13 @@ checkOsAccountActivated(localId: number): Promise<boolean>
...
@@ -291,12 +295,13 @@ checkOsAccountActivated(localId: number): Promise<boolean>
**示例:**
判断ID为100的系统帐号是否处于激活状态
**示例:**
判断ID为100的系统帐号是否处于激活状态
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
checkOsAccountActivated
(
localId
).
then
((
isActivated
)
=>
{
accountManager
.
checkOsAccountActivated
(
localId
).
then
((
isActivated
:
boolean
)
=>
{
console
.
log
(
'
checkOsAccountActivated successfully, isActivated:
'
+
isActivated
);
console
.
log
(
'
checkOsAccountActivated successfully, isActivated:
'
+
isActivated
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
checkOsAccountActivated failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountActivated failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -333,11 +338,12 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string, callback: A
...
@@ -333,11 +338,12 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string, callback: A
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
constraint
=
'
constraint.wifi
'
;
let
constraint
:
string
=
'
constraint.wifi
'
;
try
{
try
{
accountManager
.
checkOsAccountConstraintEnabled
(
localId
,
constraint
,
(
err
,
isEnabled
)
=>
{
accountManager
.
checkOsAccountConstraintEnabled
(
localId
,
constraint
,
(
err
:
BusinessError
,
isEnabled
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
checkOsAccountConstraintEnabled failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountConstraintEnabled failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -383,13 +389,14 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string): Promise<
...
@@ -383,13 +389,14 @@ checkOsAccountConstraintEnabled(localId: number, constraint: string): Promise<
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
constraint
=
'
constraint.wifi
'
;
let
constraint
:
string
=
'
constraint.wifi
'
;
try
{
try
{
accountManager
.
checkOsAccountConstraintEnabled
(
localId
,
constraint
).
then
((
isEnabled
)
=>
{
accountManager
.
checkOsAccountConstraintEnabled
(
localId
,
constraint
).
then
((
isEnabled
:
boolean
)
=>
{
console
.
log
(
'
checkOsAccountConstraintEnabled successfully, isEnabled:
'
+
isEnabled
);
console
.
log
(
'
checkOsAccountConstraintEnabled successfully, isEnabled:
'
+
isEnabled
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
checkOsAccountConstraintEnabled failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountConstraintEnabled failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -420,9 +427,10 @@ checkOsAccountTestable(callback: AsyncCallback<boolean>): void
...
@@ -420,9 +427,10 @@ checkOsAccountTestable(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
checkOsAccountTestable
((
err
,
isTestable
)
=>
{
accountManager
.
checkOsAccountTestable
((
err
:
BusinessError
,
isTestable
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
checkOsAccountTestable failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountTestable failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -457,11 +465,12 @@ checkOsAccountTestable(): Promise<boolean>
...
@@ -457,11 +465,12 @@ checkOsAccountTestable(): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
checkOsAccountTestable
().
then
((
isTestable
)
=>
{
accountManager
.
checkOsAccountTestable
().
then
((
isTestable
:
boolean
)
=>
{
console
.
log
(
'
checkOsAccountTestable successfully, isTestable:
'
+
isTestable
);
console
.
log
(
'
checkOsAccountTestable successfully, isTestable:
'
+
isTestable
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
checkOsAccountTestable failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountTestable failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -492,9 +501,10 @@ checkOsAccountVerified(callback: AsyncCallback<boolean>): void
...
@@ -492,9 +501,10 @@ checkOsAccountVerified(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
checkOsAccountVerified
((
err
,
isVerified
)
=>
{
accountManager
.
checkOsAccountVerified
((
err
:
BusinessError
,
isVerified
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -529,11 +539,12 @@ checkOsAccountVerified(): Promise<boolean>
...
@@ -529,11 +539,12 @@ checkOsAccountVerified(): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
checkOsAccountVerified
().
then
((
isVerified
)
=>
{
accountManager
.
checkOsAccountVerified
().
then
((
isVerified
:
boolean
)
=>
{
console
.
log
(
'
checkOsAccountVerified successfully, isVerified:
'
+
isVerified
);
console
.
log
(
'
checkOsAccountVerified successfully, isVerified:
'
+
isVerified
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -569,10 +580,11 @@ checkOsAccountVerified(localId: number, callback: AsyncCallback<boolean>):
...
@@ -569,10 +580,11 @@ checkOsAccountVerified(localId: number, callback: AsyncCallback<boolean>):
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
checkOsAccountVerified
(
localId
,
(
err
,
isVerified
)
=>
{
accountManager
.
checkOsAccountVerified
(
localId
,
(
err
:
BusinessError
,
isVerified
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -617,12 +629,13 @@ checkOsAccountVerified(localId: number): Promise<boolean>
...
@@ -617,12 +629,13 @@ checkOsAccountVerified(localId: number): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
checkOsAccountVerified
(
localId
).
then
((
isVerified
)
=>
{
accountManager
.
checkOsAccountVerified
(
localId
).
then
((
isVerified
:
boolean
)
=>
{
console
.
log
(
'
checkOsAccountVerified successfully, isVerified:
'
+
isVerified
);
console
.
log
(
'
checkOsAccountVerified successfully, isVerified:
'
+
isVerified
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -653,11 +666,12 @@ checkOsAccountVerified(): Promise<boolean>
...
@@ -653,11 +666,12 @@ checkOsAccountVerified(): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
checkOsAccountVerified
().
then
((
isVerified
)
=>
{
accountManager
.
checkOsAccountVerified
().
then
((
isVerified
:
boolean
)
=>
{
console
.
log
(
'
checkOsAccountVerified successfully, isVerified:
'
+
isVerified
);
console
.
log
(
'
checkOsAccountVerified successfully, isVerified:
'
+
isVerified
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
checkOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -696,11 +710,13 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void
...
@@ -696,11 +710,13 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountName
=
'
testAccountName
'
;
let
accountName
:
string
=
'
testAccountName
'
;
try
{
try
{
accountManager
.
createOsAccount
(
accountName
,
account_osAccount
.
OsAccountType
.
NORMAL
,
(
err
,
osAccountInfo
)
=>
{
accountManager
.
createOsAccount
(
accountName
,
account_osAccount
.
OsAccountType
.
NORMAL
,
accountManager
.
removeOsAccount
(
osAccountInfo
.
localId
,
(
err
)
=>
{
(
err
:
BusinessError
,
osAccountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
accountManager
.
removeOsAccount
(
osAccountInfo
.
localId
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
removeOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
removeOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -749,13 +765,15 @@ removeOsAccount(localId: number): Promise<void>
...
@@ -749,13 +765,15 @@ removeOsAccount(localId: number): Promise<void>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountName
=
'
testAccountName
'
;
let
accountName
:
string
=
'
testAccountName
'
;
try
{
try
{
accountManager
.
createOsAccount
(
accountName
,
account_osAccount
.
OsAccountType
.
NORMAL
,
(
err
,
osAccountInfo
)
=>
{
accountManager
.
createOsAccount
(
accountName
,
account_osAccount
.
OsAccountType
.
NORMAL
,
(
err
:
BusinessError
,
osAccountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
accountManager
.
removeOsAccount
(
osAccountInfo
.
localId
).
then
(()
=>
{
accountManager
.
removeOsAccount
(
osAccountInfo
.
localId
).
then
(()
=>
{
console
.
log
(
'
removeOsAccount successfully
'
);
console
.
log
(
'
removeOsAccount successfully
'
);
}).
catch
((
er
r
)
=>
{
}).
catch
((
err
:
BusinessErro
r
)
=>
{
console
.
log
(
'
removeOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
removeOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
});
});
...
@@ -797,11 +815,12 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl
...
@@ -797,11 +815,12 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl
**示例:**
给ID为100的系统帐号设置禁止使用Wi-Fi的约束
**示例:**
给ID为100的系统帐号设置禁止使用Wi-Fi的约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
constraint
=
'
constraint.wifi
'
;
let
constraint
:
string
=
'
constraint.wifi
'
;
try
{
try
{
accountManager
.
setOsAccountConstraints
(
localId
,
[
constraint
],
true
,
(
err
)
=>
{
accountManager
.
setOsAccountConstraints
(
localId
,
[
constraint
],
true
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
setOsAccountConstraints failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setOsAccountConstraints failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -851,12 +870,13 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl
...
@@ -851,12 +870,13 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl
**示例:**
删除ID为100的系统帐号的禁止使用Wi-Fi的约束
**示例:**
删除ID为100的系统帐号的禁止使用Wi-Fi的约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
setOsAccountConstraints
(
localId
,
[
'
constraint.location.set
'
],
false
).
then
(()
=>
{
accountManager
.
setOsAccountConstraints
(
localId
,
[
'
constraint.location.set
'
],
false
).
then
(()
=>
{
console
.
log
(
'
setOsAccountConstraints succsuccessfully
'
);
console
.
log
(
'
setOsAccountConstraints succsuccessfully
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
setOsAccountConstraints failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setOsAccountConstraints failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -896,11 +916,12 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback<
...
@@ -896,11 +916,12 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback<
**示例:**
将ID为100的系统帐号的帐号名设置成demoName
**示例:**
将ID为100的系统帐号的帐号名设置成demoName
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
name
=
'
demoName
'
;
let
name
:
string
=
'
demoName
'
;
try
{
try
{
accountManager
.
setOsAccountName
(
localId
,
name
,
(
err
)
=>
{
accountManager
.
setOsAccountName
(
localId
,
name
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
setOsAccountName failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setOsAccountName failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -949,13 +970,14 @@ setOsAccountName(localId: number, localName: string): Promise<void>
...
@@ -949,13 +970,14 @@ setOsAccountName(localId: number, localName: string): Promise<void>
**示例:**
将ID为100的系统帐号的帐号名设置成demoName
**示例:**
将ID为100的系统帐号的帐号名设置成demoName
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
name
=
'
testName
'
;
let
name
:
string
=
'
testName
'
;
try
{
try
{
accountManager
.
setOsAccountName
(
localId
,
name
).
then
(()
=>
{
accountManager
.
setOsAccountName
(
localId
,
name
).
then
(()
=>
{
console
.
log
(
'
setOsAccountName successfully
'
);
console
.
log
(
'
setOsAccountName successfully
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
setOsAccountName failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setOsAccountName failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -988,9 +1010,10 @@ getOsAccountCount(callback: AsyncCallback<number>): void
...
@@ -988,9 +1010,10 @@ getOsAccountCount(callback: AsyncCallback<number>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountCount
((
err
,
count
)
=>
{
accountManager
.
getOsAccountCount
((
err
:
BusinessError
,
count
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountCount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountCount failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -1027,11 +1050,12 @@ getOsAccountCount(): Promise<number>
...
@@ -1027,11 +1050,12 @@ getOsAccountCount(): Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountCount
().
then
((
count
)
=>
{
accountManager
.
getOsAccountCount
().
then
((
count
:
number
)
=>
{
console
.
log
(
'
getOsAccountCount successfully, count:
'
+
count
);
console
.
log
(
'
getOsAccountCount successfully, count:
'
+
count
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountCount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountCount failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1062,9 +1086,10 @@ getOsAccountLocalId(callback: AsyncCallback<number>): void
...
@@ -1062,9 +1086,10 @@ getOsAccountLocalId(callback: AsyncCallback<number>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountLocalId
((
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalId
((
err
:
BusinessError
,
localId
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountLocalId failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalId failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -1099,11 +1124,12 @@ getOsAccountLocalId(): Promise<number>
...
@@ -1099,11 +1124,12 @@ getOsAccountLocalId(): Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountLocalId
().
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalId
().
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalId successfully, localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalId successfully, localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalId failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalId failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1136,10 +1162,11 @@ getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback<number>): v
...
@@ -1136,10 +1162,11 @@ getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback<number>): v
**示例:**
查询值为12345678的uid所属的系统帐号的帐号ID
**示例:**
查询值为12345678的uid所属的系统帐号的帐号ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
uid
=
12345678
;
let
uid
:
number
=
12345678
;
try
{
try
{
accountManager
.
getOsAccountLocalIdForUid
(
uid
,
(
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdForUid
(
uid
,
(
err
:
BusinessError
,
localId
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountLocalIdForUid failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdForUid failed, error:
'
+
JSON
.
stringify
(
err
));
}
}
...
@@ -1180,12 +1207,13 @@ getOsAccountLocalIdForUid(uid: number): Promise<number>
...
@@ -1180,12 +1207,13 @@ getOsAccountLocalIdForUid(uid: number): Promise<number>
**示例:**
查询值为12345678的uid所属的系统帐号ID
**示例:**
查询值为12345678的uid所属的系统帐号ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
uid
=
12345678
;
let
uid
:
number
=
12345678
;
try
{
try
{
accountManager
.
getOsAccountLocalIdForUid
(
uid
).
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdForUid
(
uid
).
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdForUid successfully, localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdForUid successfully, localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdForUid failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdForUid failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1220,10 +1248,11 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallb
...
@@ -1220,10 +1248,11 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallb
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountLocalIdForDomain
(
domainInfo
,
(
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdForDomain
(
domainInfo
,
(
err
:
BusinessError
,
localId
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountLocalIdForDomain failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdForDomain failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -1267,12 +1296,13 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise<number&g
...
@@ -1267,12 +1296,13 @@ getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise<number&g
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
try
{
try
{
accountManager
.
getOsAccountLocalIdForDomain
(
domainInfo
).
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdForDomain
(
domainInfo
).
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdForDomain successfully, localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdForDomain successfully, localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdForDomain failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdForDomain failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1305,9 +1335,10 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void
...
@@ -1305,9 +1335,10 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
queryMaxOsAccountNumber
((
err
,
maxCnt
)
=>
{
accountManager
.
queryMaxOsAccountNumber
((
err
:
BusinessError
,
maxCnt
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
queryMaxOsAccountNumber failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryMaxOsAccountNumber failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -1344,11 +1375,12 @@ queryMaxOsAccountNumber(): Promise<number>
...
@@ -1344,11 +1375,12 @@ queryMaxOsAccountNumber(): Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
queryMaxOsAccountNumber
().
then
((
maxCnt
)
=>
{
accountManager
.
queryMaxOsAccountNumber
().
then
((
maxCnt
:
number
)
=>
{
console
.
log
(
'
queryMaxOsAccountNumber successfully, maxCnt:
'
+
maxCnt
);
console
.
log
(
'
queryMaxOsAccountNumber successfully, maxCnt:
'
+
maxCnt
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
queryMaxOsAccountNumber failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryMaxOsAccountNumber failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -1384,10 +1416,11 @@ getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<str
...
@@ -1384,10 +1416,11 @@ getOsAccountConstraints(localId: number, callback: AsyncCallback<Array<str
**示例:**
获取ID为100的系统帐号的全部约束
**示例:**
获取ID为100的系统帐号的全部约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
getOsAccountConstraints
(
localId
,
(
err
,
constraints
)
=>
{
accountManager
.
getOsAccountConstraints
(
localId
,
(
err
:
BusinessError
,
constraints
:
string
[]
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountConstraints failed, err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountConstraints failed, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -1432,12 +1465,13 @@ getOsAccountConstraints(localId: number): Promise<Array<string>>
...
@@ -1432,12 +1465,13 @@ getOsAccountConstraints(localId: number): Promise<Array<string>>
**示例:**
获取ID为100的系统帐号的全部约束
**示例:**
获取ID为100的系统帐号的全部约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
getOsAccountConstraints
(
localId
).
then
((
constraints
)
=>
{
accountManager
.
getOsAccountConstraints
(
localId
).
then
((
constraints
:
string
[]
)
=>
{
console
.
log
(
'
getOsAccountConstraints, constraints:
'
+
constraints
);
console
.
log
(
'
getOsAccountConstraints, constraints:
'
+
constraints
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountConstraints err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountConstraints err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1472,9 +1506,10 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>&
...
@@ -1472,9 +1506,10 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>&
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
queryAllCreatedOsAccounts
((
err
,
accountArr
)
=>
{
accountManager
.
queryAllCreatedOsAccounts
((
err
:
BusinessError
,
accountArr
:
account_osAccount
.
OsAccountInfo
[]
)
=>
{
console
.
log
(
'
queryAllCreatedOsAccounts err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryAllCreatedOsAccounts err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryAllCreatedOsAccounts accountArr:
'
+
JSON
.
stringify
(
accountArr
));
console
.
log
(
'
queryAllCreatedOsAccounts accountArr:
'
+
JSON
.
stringify
(
accountArr
));
});
});
...
@@ -1510,11 +1545,12 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>
...
@@ -1510,11 +1545,12 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
queryAllCreatedOsAccounts
().
then
((
accountArr
)
=>
{
accountManager
.
queryAllCreatedOsAccounts
().
then
((
accountArr
:
account_osAccount
.
OsAccountInfo
[]
)
=>
{
console
.
log
(
'
queryAllCreatedOsAccounts, accountArr:
'
+
JSON
.
stringify
(
accountArr
));
console
.
log
(
'
queryAllCreatedOsAccounts, accountArr:
'
+
JSON
.
stringify
(
accountArr
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
queryAllCreatedOsAccounts err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryAllCreatedOsAccounts err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1545,9 +1581,10 @@ getActivatedOsAccountLocalIds(callback: AsyncCallback<Array<number>>
...
@@ -1545,9 +1581,10 @@ getActivatedOsAccountLocalIds(callback: AsyncCallback<Array<number>>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getActivatedOsAccountLocalIds
((
err
,
idArray
)
=>
{
accountManager
.
getActivatedOsAccountLocalIds
((
err
:
BusinessError
,
idArray
:
number
[]
)
=>
{
console
.
log
(
'
getActivatedOsAccountLocalIds err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getActivatedOsAccountLocalIds err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getActivatedOsAccountLocalIds idArray length:
'
+
idArray
.
length
);
console
.
log
(
'
getActivatedOsAccountLocalIds idArray length:
'
+
idArray
.
length
);
for
(
let
i
=
0
;
i
<
idArray
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
idArray
.
length
;
i
++
)
{
...
@@ -1582,11 +1619,12 @@ getActivatedOsAccountLocalIds(): Promise<Array<number>>
...
@@ -1582,11 +1619,12 @@ getActivatedOsAccountLocalIds(): Promise<Array<number>>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getActivatedOsAccountLocalIds
().
then
((
idArray
)
=>
{
accountManager
.
getActivatedOsAccountLocalIds
().
then
((
idArray
:
number
[]
)
=>
{
console
.
log
(
'
getActivatedOsAccountLocalIds, idArray:
'
+
idArray
);
console
.
log
(
'
getActivatedOsAccountLocalIds, idArray:
'
+
idArray
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getActivatedOsAccountLocalIds err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getActivatedOsAccountLocalIds err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1627,9 +1665,11 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
...
@@ -1627,9 +1665,11 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
createOsAccount
(
'
testName
'
,
account_osAccount
.
OsAccountType
.
NORMAL
,
(
err
,
osAccountInfo
)
=>
{
accountManager
.
createOsAccount
(
'
testName
'
,
account_osAccount
.
OsAccountType
.
NORMAL
,
(
err
:
BusinessError
,
osAccountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
createOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
createOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
createOsAccount osAccountInfo:
'
+
JSON
.
stringify
(
osAccountInfo
));
console
.
log
(
'
createOsAccount osAccountInfo:
'
+
JSON
.
stringify
(
osAccountInfo
));
});
});
...
@@ -1676,11 +1716,13 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf
...
@@ -1676,11 +1716,13 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
createOsAccount
(
'
testAccountName
'
,
account_osAccount
.
OsAccountType
.
NORMAL
).
then
((
accountInfo
)
=>
{
accountManager
.
createOsAccount
(
'
testAccountName
'
,
account_osAccount
.
OsAccountType
.
NORMAL
).
then
(
(
accountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
createOsAccount, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
console
.
log
(
'
createOsAccount, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
createOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
createOsAccount err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1721,10 +1763,12 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
...
@@ -1721,10 +1763,12 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
try
{
try
{
accountManager
.
createOsAccountForDomain
(
account_osAccount
.
OsAccountType
.
NORMAL
,
domainInfo
,
(
err
,
osAccountInfo
)
=>
{
accountManager
.
createOsAccountForDomain
(
account_osAccount
.
OsAccountType
.
NORMAL
,
domainInfo
,
(
err
:
BusinessError
,
osAccountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
createOsAccountForDomain err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
createOsAccountForDomain err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
createOsAccountForDomain osAccountInfo:
'
+
JSON
.
stringify
(
osAccountInfo
));
console
.
log
(
'
createOsAccountForDomain osAccountInfo:
'
+
JSON
.
stringify
(
osAccountInfo
));
});
});
...
@@ -1771,12 +1815,14 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
...
@@ -1771,12 +1815,14 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
try
{
try
{
accountManager
.
createOsAccountForDomain
(
account_osAccount
.
OsAccountType
.
NORMAL
,
domainInfo
).
then
((
accountInfo
)
=>
{
accountManager
.
createOsAccountForDomain
(
account_osAccount
.
OsAccountType
.
NORMAL
,
domainInfo
).
then
(
(
accountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
createOsAccountForDomain, account info:
'
+
JSON
.
stringify
(
accountInfo
));
console
.
log
(
'
createOsAccountForDomain, account info:
'
+
JSON
.
stringify
(
accountInfo
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
createOsAccountForDomain err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
createOsAccountForDomain err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1809,9 +1855,10 @@ getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
...
@@ -1809,9 +1855,10 @@ getCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getCurrentOsAccount
((
err
,
cur
AccountInfo
)
=>
{
accountManager
.
getCurrentOsAccount
((
err
:
BusinessError
,
curAccountInfo
:
account_osAccount
.
Os
AccountInfo
)
=>
{
console
.
log
(
'
getCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getCurrentOsAccount curAccountInfo:
'
+
JSON
.
stringify
(
curAccountInfo
));
console
.
log
(
'
getCurrentOsAccount curAccountInfo:
'
+
JSON
.
stringify
(
curAccountInfo
));
});
});
...
@@ -1845,11 +1892,12 @@ getCurrentOsAccount(): Promise<OsAccountInfo>
...
@@ -1845,11 +1892,12 @@ getCurrentOsAccount(): Promise<OsAccountInfo>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getCurrentOsAccount
().
then
((
accountInfo
)
=>
{
accountManager
.
getCurrentOsAccount
().
then
((
accountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
getCurrentOsAccount, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
console
.
log
(
'
getCurrentOsAccount, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1887,10 +1935,11 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>
...
@@ -1887,10 +1935,11 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>
**示例:**
查询ID为100的系统帐号信息
**示例:**
查询ID为100的系统帐号信息
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
queryOsAccountById
(
localId
,
(
err
,
a
ccountInfo
)
=>
{
accountManager
.
queryOsAccountById
(
localId
,
(
err
:
BusinessError
,
accountInfo
:
account_osAccount
.
OsA
ccountInfo
)
=>
{
console
.
log
(
'
queryOsAccountById err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryOsAccountById err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryOsAccountById accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
console
.
log
(
'
queryOsAccountById accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
});
});
...
@@ -1934,12 +1983,13 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo>
...
@@ -1934,12 +1983,13 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo>
**示例:**
查询ID为100的系统帐号信息
**示例:**
查询ID为100的系统帐号信息
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
queryOsAccountById
(
localId
).
then
((
accountInfo
)
=>
{
accountManager
.
queryOsAccountById
(
localId
).
then
((
accountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
queryOsAccountById, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
console
.
log
(
'
queryOsAccountById, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
queryOsAccountById err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryOsAccountById err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1970,9 +2020,10 @@ getOsAccountType(callback: AsyncCallback<OsAccountType>): void
...
@@ -1970,9 +2020,10 @@ getOsAccountType(callback: AsyncCallback<OsAccountType>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountType
((
err
,
a
ccountType
)
=>
{
accountManager
.
getOsAccountType
((
err
:
BusinessError
,
accountType
:
account_osAccount
.
OsA
ccountType
)
=>
{
console
.
log
(
'
getOsAccountType err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountType err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountType accountType:
'
+
accountType
);
console
.
log
(
'
getOsAccountType accountType:
'
+
accountType
);
});
});
...
@@ -2004,11 +2055,12 @@ getOsAccountType(): Promise<OsAccountType>
...
@@ -2004,11 +2055,12 @@ getOsAccountType(): Promise<OsAccountType>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountType
().
then
((
accountType
)
=>
{
accountManager
.
getOsAccountType
().
then
((
accountType
:
account_osAccount
.
OsAccountType
)
=>
{
console
.
log
(
'
getOsAccountType, accountType:
'
+
accountType
);
console
.
log
(
'
getOsAccountType, accountType:
'
+
accountType
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountType err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountType err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2041,9 +2093,10 @@ queryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
...
@@ -2041,9 +2093,10 @@ queryDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
queryDistributedVirtualDeviceId
((
err
,
virtualID
)
=>
{
accountManager
.
queryDistributedVirtualDeviceId
((
err
:
BusinessError
,
virtualID
:
string
)
=>
{
console
.
log
(
'
queryDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryDistributedVirtualDeviceId virtualID:
'
+
virtualID
);
console
.
log
(
'
queryDistributedVirtualDeviceId virtualID:
'
+
virtualID
);
});
});
...
@@ -2077,11 +2130,12 @@ queryDistributedVirtualDeviceId(): Promise<string>
...
@@ -2077,11 +2130,12 @@ queryDistributedVirtualDeviceId(): Promise<string>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
queryDistributedVirtualDeviceId
().
then
((
virtualID
)
=>
{
accountManager
.
queryDistributedVirtualDeviceId
().
then
((
virtualID
:
string
)
=>
{
console
.
log
(
'
queryDistributedVirtualDeviceId, virtualID:
'
+
virtualID
);
console
.
log
(
'
queryDistributedVirtualDeviceId, virtualID:
'
+
virtualID
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
queryDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2119,10 +2173,11 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>)
...
@@ -2119,10 +2173,11 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>)
**示例:**
获取ID为100的系统帐号的头像
**示例:**
获取ID为100的系统帐号的头像
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
getOsAccountProfilePhoto
(
localId
,
(
err
,
photo
)
=>
{
accountManager
.
getOsAccountProfilePhoto
(
localId
,
(
err
:
BusinessError
,
photo
:
string
)
=>
{
console
.
log
(
'
getOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get photo:
'
+
photo
+
'
by localId:
'
+
localId
);
console
.
log
(
'
get photo:
'
+
photo
+
'
by localId:
'
+
localId
);
});
});
...
@@ -2166,12 +2221,13 @@ getOsAccountProfilePhoto(localId: number): Promise<string>
...
@@ -2166,12 +2221,13 @@ getOsAccountProfilePhoto(localId: number): Promise<string>
**示例:**
获取ID为100的系统帐号的头像
**示例:**
获取ID为100的系统帐号的头像
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
getOsAccountProfilePhoto
(
localId
).
then
((
photo
)
=>
{
accountManager
.
getOsAccountProfilePhoto
(
localId
).
then
((
photo
:
string
)
=>
{
console
.
log
(
'
getOsAccountProfilePhoto:
'
+
photo
);
console
.
log
(
'
getOsAccountProfilePhoto:
'
+
photo
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2211,14 +2267,15 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
...
@@ -2211,14 +2267,15 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
**示例:**
给ID为100的系统帐号设置头像
**示例:**
给ID为100的系统帐号设置头像
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
photo
=
'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA
'
+
let
photo
:
string
=
'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA
'
+
'
Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y
'
+
'
Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y
'
+
'
q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo
'
+
'
q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo
'
+
'
+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==
'
'
+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==
'
try
{
try
{
accountManager
.
setOsAccountProfilePhoto
(
localId
,
photo
,
(
err
)
=>
{
accountManager
.
setOsAccountProfilePhoto
(
localId
,
photo
,
(
err
:
BusinessError
)
=>
{
console
.
log
(
'
setOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2263,16 +2320,17 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void>
...
@@ -2263,16 +2320,17 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void>
**示例:**
给ID为100的系统帐号设置头像
**示例:**
给ID为100的系统帐号设置头像
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
photo
=
'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA
'
+
let
photo
:
string
=
'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA
'
+
'
Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y
'
+
'
Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y
'
+
'
q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo
'
+
'
q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo
'
+
'
+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==
'
'
+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg==
'
try
{
try
{
accountManager
.
setOsAccountProfilePhoto
(
localId
,
photo
).
then
(()
=>
{
accountManager
.
setOsAccountProfilePhoto
(
localId
,
photo
).
then
(()
=>
{
console
.
log
(
'
setOsAccountProfilePhoto success
'
);
console
.
log
(
'
setOsAccountProfilePhoto success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
setOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setOsAccountProfilePhoto err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2306,10 +2364,11 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback
...
@@ -2306,10 +2364,11 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback
**示例:**
查询与SN码12345关联的系统帐号的ID
**示例:**
查询与SN码12345关联的系统帐号的ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
serialNumber
=
12345
;
let
serialNumber
:
number
=
12345
;
try
{
try
{
accountManager
.
getOsAccountLocalIdForSerialNumber
(
serialNumber
,
(
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdForSerialNumber
(
serialNumber
,
(
err
:
BusinessError
,
localId
:
number
)
=>
{
console
.
log
(
'
ger localId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
ger localId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get localId:
'
+
localId
+
'
by serialNumber:
'
+
serialNumber
);
console
.
log
(
'
get localId:
'
+
localId
+
'
by serialNumber:
'
+
serialNumber
);
});
});
...
@@ -2349,12 +2408,13 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise<number>
...
@@ -2349,12 +2408,13 @@ getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise<number>
**示例:**
查询与SN码12345关联的系统帐号的ID
**示例:**
查询与SN码12345关联的系统帐号的ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
serialNumber
=
12345
;
let
serialNumber
:
number
=
12345
;
try
{
try
{
accountManager
.
getOsAccountLocalIdForSerialNumber
(
serialNumber
).
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdForSerialNumber
(
serialNumber
).
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdForSerialNumber localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdForSerialNumber localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdForSerialNumber err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdForSerialNumber err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2388,10 +2448,11 @@ getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback<n
...
@@ -2388,10 +2448,11 @@ getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback<n
**示例:**
获取ID为100的系统帐号关联的SN码
**示例:**
获取ID为100的系统帐号关联的SN码
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
getSerialNumberForOsAccountLocalId
(
localId
,
(
err
,
serialN
umber
)
=>
{
accountManager
.
getSerialNumberForOsAccountLocalId
(
localId
,
(
err
:
BusinessError
,
serialNumber
:
n
umber
)
=>
{
console
.
log
(
'
ger serialNumber err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
ger serialNumber err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get serialNumber:
'
+
serialNumber
+
'
by localId:
'
+
localId
);
console
.
log
(
'
get serialNumber:
'
+
serialNumber
+
'
by localId:
'
+
localId
);
});
});
...
@@ -2431,12 +2492,13 @@ getSerialNumberForOsAccountLocalId(localId: number): Promise<number>
...
@@ -2431,12 +2492,13 @@ getSerialNumberForOsAccountLocalId(localId: number): Promise<number>
**示例:**
获取ID为100的系统帐号关联的SN码
**示例:**
获取ID为100的系统帐号关联的SN码
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
try
{
try
{
accountManager
.
getSerialNumberForOsAccountLocalId
(
localId
).
then
((
serialNumber
)
=>
{
accountManager
.
getSerialNumberForOsAccountLocalId
(
localId
).
then
((
serialNumber
:
number
)
=>
{
console
.
log
(
'
getSerialNumberForOsAccountLocalId serialNumber:
'
+
serialNumber
);
console
.
log
(
'
getSerialNumberForOsAccountLocalId serialNumber:
'
+
serialNumber
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getSerialNumberForOsAccountLocalId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getSerialNumberForOsAccountLocalId err:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2475,7 +2537,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g
...
@@ -2475,7 +2537,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g
```
js
```
js
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
function
onCallback
(
receiveLocalId
){
function
onCallback
(
receiveLocalId
:
number
){
console
.
log
(
'
receive localId:
'
+
receiveLocalId
);
console
.
log
(
'
receive localId:
'
+
receiveLocalId
);
}
}
try
{
try
{
...
@@ -2553,10 +2615,11 @@ getBundleIdForUid(uid: number, callback: AsyncCallback<number>): void;
...
@@ -2553,10 +2615,11 @@ getBundleIdForUid(uid: number, callback: AsyncCallback<number>): void;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
testUid
=
1000000
;
let
testUid
:
number
=
1000000
;
try
{
try
{
accountManager
.
getBundleIdForUid
(
testUid
,
(
err
,
bundleId
)
=>
{
accountManager
.
getBundleIdForUid
(
testUid
,
(
err
:
BusinessError
,
bundleId
:
number
)
=>
{
console
.
info
(
'
getBundleIdForUid errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getBundleIdForUid errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getBundleIdForUid bundleId:
'
+
JSON
.
stringify
(
bundleId
));
console
.
info
(
'
getBundleIdForUid bundleId:
'
+
JSON
.
stringify
(
bundleId
));
});
});
...
@@ -2596,12 +2659,13 @@ getBundleIdForUid(uid: number): Promise<number>;
...
@@ -2596,12 +2659,13 @@ getBundleIdForUid(uid: number): Promise<number>;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
testUid
=
1000000
;
let
testUid
:
number
=
1000000
;
try
{
try
{
accountManager
.
getBundleIdForUid
(
testUid
).
then
((
result
)
=>
{
accountManager
.
getBundleIdForUid
(
testUid
).
then
((
result
:
number
)
=>
{
console
.
info
(
'
getBundleIdForUid bundleId:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
getBundleIdForUid bundleId:
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
'
getBundleIdForUid errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getBundleIdForUid errInfo:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2636,9 +2700,10 @@ isMainOsAccount(callback: AsyncCallback<boolean>): void;
...
@@ -2636,9 +2700,10 @@ isMainOsAccount(callback: AsyncCallback<boolean>): void;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
isMainOsAccount
((
err
,
result
)
=>
{
accountManager
.
isMainOsAccount
((
err
:
BusinessError
,
result
:
boolean
)
=>
{
console
.
info
(
'
isMainOsAccount errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
isMainOsAccount errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
isMainOsAccount result:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
isMainOsAccount result:
'
+
JSON
.
stringify
(
result
));
});
});
...
@@ -2673,11 +2738,12 @@ isMainOsAccount(): Promise<boolean>;
...
@@ -2673,11 +2738,12 @@ isMainOsAccount(): Promise<boolean>;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
isMainOsAccount
().
then
((
result
)
=>
{
accountManager
.
isMainOsAccount
().
then
((
result
:
boolean
)
=>
{
console
.
info
(
'
isMainOsAccount result:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
isMainOsAccount result:
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
'
isMainOsAccount errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
isMainOsAccount errInfo:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2715,9 +2781,11 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string, callback:
...
@@ -2715,9 +2781,11 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string, callback:
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountConstraintSourceTypes
(
100
,
'
constraint.wifi
'
,(
err
,
sourceTypeInfos
)
=>
{
accountManager
.
getOsAccountConstraintSourceTypes
(
100
,
'
constraint.wifi
'
,
(
err
:
BusinessError
,
sourceTypeInfos
:
account_osAccount
.
ConstraintSourceTypeInfo
[])
=>
{
console
.
info
(
'
getOsAccountConstraintSourceTypes errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getOsAccountConstraintSourceTypes errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getOsAccountConstraintSourceTypes sourceTypeInfos:
'
+
JSON
.
stringify
(
sourceTypeInfos
));
console
.
info
(
'
getOsAccountConstraintSourceTypes sourceTypeInfos:
'
+
JSON
.
stringify
(
sourceTypeInfos
));
});
});
...
@@ -2762,11 +2830,13 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise&
...
@@ -2762,11 +2830,13 @@ getOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise&
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
try
{
try
{
accountManager
.
getOsAccountConstraintSourceTypes
(
100
,
'
constraint.wifi
'
).
then
((
result
)
=>
{
accountManager
.
getOsAccountConstraintSourceTypes
(
100
,
'
constraint.wifi
'
).
then
(
(
result
:
account_osAccount
.
ConstraintSourceTypeInfo
[])
=>
{
console
.
info
(
'
getOsAccountConstraintSourceTypes sourceTypeInfos:
'
+
JSON
.
stringify
(
result
));
console
.
info
(
'
getOsAccountConstraintSourceTypes sourceTypeInfos:
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
'
getOsAccountConstraintSourceTypes errInfo:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getOsAccountConstraintSourceTypes errInfo:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -2795,8 +2865,9 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void
...
@@ -2795,8 +2865,9 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
isMultiOsAccountEnable
((
err
,
isEnabled
)
=>
{
accountManager
.
isMultiOsAccountEnable
((
err
:
BusinessError
,
isEnabled
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
isMultiOsAccountEnable failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isMultiOsAccountEnable failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -2826,10 +2897,11 @@ isMultiOsAccountEnable(): Promise<boolean>
...
@@ -2826,10 +2897,11 @@ isMultiOsAccountEnable(): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
isMultiOsAccountEnable
().
then
((
isEnabled
)
=>
{
accountManager
.
isMultiOsAccountEnable
().
then
((
isEnabled
:
boolean
)
=>
{
console
.
log
(
'
isMultiOsAccountEnable successfully, isEnabled:
'
+
isEnabled
);
console
.
log
(
'
isMultiOsAccountEnable successfully, isEnabled:
'
+
isEnabled
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
isMultiOsAccountEnable failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isMultiOsAccountEnable failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -2859,9 +2931,10 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi
...
@@ -2859,9 +2931,10 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi
**示例:**
判断ID为100的系统帐号是否处于激活状态
**示例:**
判断ID为100的系统帐号是否处于激活状态
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
isOsAccountActived
(
localId
,
(
err
,
isActived
)
=>
{
accountManager
.
isOsAccountActived
(
localId
,
(
err
:
BusinessError
,
isActived
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
isOsAccountActived failed, err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountActived failed, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -2899,11 +2972,12 @@ isOsAccountActived(localId: number): Promise<boolean>
...
@@ -2899,11 +2972,12 @@ isOsAccountActived(localId: number): Promise<boolean>
**示例:**
判断ID为100的系统帐号是否处于激活状态
**示例:**
判断ID为100的系统帐号是否处于激活状态
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
isOsAccountActived
(
localId
).
then
((
isActived
)
=>
{
accountManager
.
isOsAccountActived
(
localId
).
then
((
isActived
:
boolean
)
=>
{
console
.
log
(
'
isOsAccountActived successfully, isActived:
'
+
isActived
);
console
.
log
(
'
isOsAccountActived successfully, isActived:
'
+
isActived
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
isOsAccountActived failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountActived failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -2933,10 +3007,11 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
...
@@ -2933,10 +3007,11 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
constraint
=
'
constraint.wifi
'
;
let
constraint
:
string
=
'
constraint.wifi
'
;
accountManager
.
isOsAccountConstraintEnable
(
localId
,
constraint
,
(
err
,
isEnabled
)
=>
{
accountManager
.
isOsAccountConstraintEnable
(
localId
,
constraint
,
(
err
:
BusinessError
,
isEnabled
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
isOsAccountConstraintEnable failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountConstraintEnable failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -2975,12 +3050,13 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo
...
@@ -2975,12 +3050,13 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
**示例:**
判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
let
constraint
=
'
constraint.wifi
'
;
let
constraint
:
string
=
'
constraint.wifi
'
;
accountManager
.
isOsAccountConstraintEnable
(
localId
,
constraint
).
then
((
isEnabled
)
=>
{
accountManager
.
isOsAccountConstraintEnable
(
localId
,
constraint
).
then
((
isEnabled
:
boolean
)
=>
{
console
.
log
(
'
isOsAccountConstraintEnable successfully, isEnabled:
'
+
isEnabled
);
console
.
log
(
'
isOsAccountConstraintEnable successfully, isEnabled:
'
+
isEnabled
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
isOsAccountConstraintEnable err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountConstraintEnable err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3006,8 +3082,9 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void
...
@@ -3006,8 +3082,9 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
isTestOsAccount
((
err
,
isTestable
)
=>
{
accountManager
.
isTestOsAccount
((
err
:
BusinessError
,
isTestable
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
isTestOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isTestOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3037,10 +3114,11 @@ isTestOsAccount(): Promise<boolean>
...
@@ -3037,10 +3114,11 @@ isTestOsAccount(): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
isTestOsAccount
().
then
((
isTestable
)
=>
{
accountManager
.
isTestOsAccount
().
then
((
isTestable
:
boolean
)
=>
{
console
.
log
(
'
isTestOsAccount successfully, isTestable:
'
+
isTestable
);
console
.
log
(
'
isTestOsAccount successfully, isTestable:
'
+
isTestable
);
}).
catch
((
er
r
)
=>
{
}).
catch
((
err
:
BusinessErro
r
)
=>
{
console
.
log
(
'
isTestOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isTestOsAccount failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3068,8 +3146,9 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void
...
@@ -3068,8 +3146,9 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
isOsAccountVerified
((
err
,
isVerified
)
=>
{
accountManager
.
isOsAccountVerified
((
err
:
BusinessError
,
isVerified
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
isOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3102,9 +3181,10 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo
...
@@ -3102,9 +3181,10 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
isOsAccountVerified
(
localId
,
(
err
,
isVerified
)
=>
{
accountManager
.
isOsAccountVerified
(
localId
,
(
err
:
BusinessError
,
isVerified
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
isOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3142,10 +3222,11 @@ isOsAccountVerified(localId?: number): Promise<boolean>
...
@@ -3142,10 +3222,11 @@ isOsAccountVerified(localId?: number): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
isOsAccountVerified
(
localId
).
then
((
isVerified
)
=>
{
accountManager
.
isOsAccountVerified
(
localId
).
then
((
isVerified
:
boolean
)
=>
{
console
.
log
(
'
isOsAccountVerified successfully, isVerified:
'
+
isVerified
);
console
.
log
(
'
isOsAccountVerified successfully, isVerified:
'
+
isVerified
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
isOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isOsAccountVerified failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3173,8 +3254,9 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void
...
@@ -3173,8 +3254,9 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getCreatedOsAccountsCount
((
err
,
count
)
=>
{
accountManager
.
getCreatedOsAccountsCount
((
err
:
BusinessError
,
count
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getCreatedOsAccountsCount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getCreatedOsAccountsCount failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3206,10 +3288,11 @@ getCreatedOsAccountsCount(): Promise<number>
...
@@ -3206,10 +3288,11 @@ getCreatedOsAccountsCount(): Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getCreatedOsAccountsCount
().
then
((
count
)
=>
{
accountManager
.
getCreatedOsAccountsCount
().
then
((
count
:
number
)
=>
{
console
.
log
(
'
getCreatedOsAccountsCount successfully, count:
'
+
count
);
console
.
log
(
'
getCreatedOsAccountsCount successfully, count:
'
+
count
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getCreatedOsAccountsCount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getCreatedOsAccountsCount failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3235,8 +3318,9 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
...
@@ -3235,8 +3318,9 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getOsAccountLocalIdFromProcess
((
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdFromProcess
((
err
:
BusinessError
,
localId
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountLocalIdFromProcess failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdFromProcess failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3266,10 +3350,11 @@ getOsAccountLocalIdFromProcess(): Promise<number>
...
@@ -3266,10 +3350,11 @@ getOsAccountLocalIdFromProcess(): Promise<number>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getOsAccountLocalIdFromProcess
().
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdFromProcess
().
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdFromProcess successfully, localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdFromProcess successfully, localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdFromProcess failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdFromProcess failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3296,9 +3381,10 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>):
...
@@ -3296,9 +3381,10 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>):
**示例:**
查询值为12345678的uid所属的系统帐号ID
**示例:**
查询值为12345678的uid所属的系统帐号ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
uid
=
12345678
;
let
uid
:
number
=
12345678
;
accountManager
.
getOsAccountLocalIdFromUid
(
uid
,
(
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdFromUid
(
uid
,
(
err
:
BusinessError
,
localId
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountLocalIdFromUid failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdFromUid failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3334,11 +3420,12 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number>
...
@@ -3334,11 +3420,12 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number>
**示例:**
查询值为12345678的uid所属的系统帐号ID
**示例:**
查询值为12345678的uid所属的系统帐号ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
uid
=
12345678
;
let
uid
:
number
=
12345678
;
accountManager
.
getOsAccountLocalIdFromUid
(
uid
).
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdFromUid
(
uid
).
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdFromUid successfully, localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdFromUid successfully, localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdFromUid failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdFromUid failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3367,9 +3454,10 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
...
@@ -3367,9 +3454,10 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getOsAccountLocalIdFromDomain
(
domainInfo
,
(
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdFromDomain
(
domainInfo
,
(
err
:
BusinessError
,
localId
:
number
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
getOsAccountLocalIdFromDomain failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdFromDomain failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -3407,11 +3495,12 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number&
...
@@ -3407,11 +3495,12 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number&
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
let
domainInfo
=
{
domain
:
'
testDomain
'
,
accountName
:
'
testAccountName
'
};
accountManager
.
getOsAccountLocalIdFromDomain
(
domainInfo
).
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdFromDomain
(
domainInfo
).
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdFromDomain successfully, localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdFromDomain successfully, localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdFromDomain failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdFromDomain failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3440,9 +3529,10 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<
...
@@ -3440,9 +3529,10 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<
**示例:**
获取ID为100的系统帐号的全部约束
**示例:**
获取ID为100的系统帐号的全部约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
getOsAccountAllConstraints
(
localId
,
(
err
,
constraints
)
=>
{
accountManager
.
getOsAccountAllConstraints
(
localId
,
(
err
:
BusinessError
,
constraints
:
string
[]
)
=>
{
console
.
log
(
'
getOsAccountAllConstraints err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountAllConstraints err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountAllConstraints:
'
+
JSON
.
stringify
(
constraints
));
console
.
log
(
'
getOsAccountAllConstraints:
'
+
JSON
.
stringify
(
constraints
));
});
});
...
@@ -3477,11 +3567,12 @@ getOsAccountAllConstraints(localId: number): Promise<Array<string>>
...
@@ -3477,11 +3567,12 @@ getOsAccountAllConstraints(localId: number): Promise<Array<string>>
**示例:**
获取ID为100的系统帐号的全部约束
**示例:**
获取ID为100的系统帐号的全部约束
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
getOsAccountAllConstraints
(
localId
).
then
((
constraints
)
=>
{
accountManager
.
getOsAccountAllConstraints
(
localId
).
then
((
constraints
:
string
[]
)
=>
{
console
.
log
(
'
getOsAccountAllConstraints, constraints:
'
+
constraints
);
console
.
log
(
'
getOsAccountAllConstraints, constraints:
'
+
constraints
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountAllConstraints err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountAllConstraints err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3507,8 +3598,9 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>):
...
@@ -3507,8 +3598,9 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>):
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
queryActivatedOsAccountIds
((
err
,
idArray
)
=>
{
accountManager
.
queryActivatedOsAccountIds
((
err
:
BusinessError
,
idArray
:
number
[]
)
=>
{
console
.
log
(
'
queryActivatedOsAccountIds err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryActivatedOsAccountIds err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryActivatedOsAccountIds idArray length:
'
+
idArray
.
length
);
console
.
log
(
'
queryActivatedOsAccountIds idArray length:
'
+
idArray
.
length
);
for
(
let
i
=
0
;
i
<
idArray
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
idArray
.
length
;
i
++
)
{
...
@@ -3538,10 +3630,11 @@ queryActivatedOsAccountIds(): Promise<Array<number>>
...
@@ -3538,10 +3630,11 @@ queryActivatedOsAccountIds(): Promise<Array<number>>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
queryActivatedOsAccountIds
().
then
((
idArray
)
=>
{
accountManager
.
queryActivatedOsAccountIds
().
then
((
idArray
:
number
[]
)
=>
{
console
.
log
(
'
queryActivatedOsAccountIds, idArray:
'
+
idArray
);
console
.
log
(
'
queryActivatedOsAccountIds, idArray:
'
+
idArray
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
queryActivatedOsAccountIds err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryActivatedOsAccountIds err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3569,8 +3662,9 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
...
@@ -3569,8 +3662,9 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
queryCurrentOsAccount
((
err
,
cur
AccountInfo
)
=>
{
accountManager
.
queryCurrentOsAccount
((
err
:
BusinessError
,
curAccountInfo
:
account_osAccount
.
Os
AccountInfo
)
=>
{
console
.
log
(
'
queryCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryCurrentOsAccount curAccountInfo:
'
+
JSON
.
stringify
(
curAccountInfo
));
console
.
log
(
'
queryCurrentOsAccount curAccountInfo:
'
+
JSON
.
stringify
(
curAccountInfo
));
});
});
...
@@ -3599,10 +3693,11 @@ queryCurrentOsAccount(): Promise<OsAccountInfo>
...
@@ -3599,10 +3693,11 @@ queryCurrentOsAccount(): Promise<OsAccountInfo>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
queryCurrentOsAccount
().
then
((
accountInfo
)
=>
{
accountManager
.
queryCurrentOsAccount
().
then
((
accountInfo
:
account_osAccount
.
OsAccountInfo
)
=>
{
console
.
log
(
'
queryCurrentOsAccount, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
console
.
log
(
'
queryCurrentOsAccount, accountInfo:
'
+
JSON
.
stringify
(
accountInfo
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
queryCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
queryCurrentOsAccount err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3628,8 +3723,9 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void
...
@@ -3628,8 +3723,9 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getOsAccountTypeFromProcess
((
err
,
a
ccountType
)
=>
{
accountManager
.
getOsAccountTypeFromProcess
((
err
:
BusinessError
,
accountType
:
account_osAccount
.
OsA
ccountType
)
=>
{
console
.
log
(
'
getOsAccountTypeFromProcess err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountTypeFromProcess err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountTypeFromProcess accountType:
'
+
accountType
);
console
.
log
(
'
getOsAccountTypeFromProcess accountType:
'
+
accountType
);
});
});
...
@@ -3656,10 +3752,11 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType>
...
@@ -3656,10 +3752,11 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getOsAccountTypeFromProcess
().
then
((
accountType
)
=>
{
accountManager
.
getOsAccountTypeFromProcess
().
then
((
accountType
:
account_osAccount
.
OsAccountType
)
=>
{
console
.
log
(
'
getOsAccountTypeFromProcess, accountType:
'
+
accountType
);
console
.
log
(
'
getOsAccountTypeFromProcess, accountType:
'
+
accountType
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountTypeFromProcess err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountTypeFromProcess err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3687,8 +3784,9 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
...
@@ -3687,8 +3784,9 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getDistributedVirtualDeviceId
((
err
,
virtualID
)
=>
{
accountManager
.
getDistributedVirtualDeviceId
((
err
:
BusinessError
,
virtualID
:
string
)
=>
{
console
.
log
(
'
getDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getDistributedVirtualDeviceId virtualID:
'
+
virtualID
);
console
.
log
(
'
getDistributedVirtualDeviceId virtualID:
'
+
virtualID
);
});
});
...
@@ -3717,10 +3815,11 @@ getDistributedVirtualDeviceId(): Promise<string>
...
@@ -3717,10 +3815,11 @@ getDistributedVirtualDeviceId(): Promise<string>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
accountManager
.
getDistributedVirtualDeviceId
().
then
((
virtualID
)
=>
{
accountManager
.
getDistributedVirtualDeviceId
().
then
((
virtualID
:
string
)
=>
{
console
.
log
(
'
getDistributedVirtualDeviceId, virtualID:
'
+
virtualID
);
console
.
log
(
'
getDistributedVirtualDeviceId, virtualID:
'
+
virtualID
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getDistributedVirtualDeviceId err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3747,9 +3846,10 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&
...
@@ -3747,9 +3846,10 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&
**示例:**
查询与SN码12345关联的系统帐号的ID
**示例:**
查询与SN码12345关联的系统帐号的ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
serialNumber
=
12345
;
let
serialNumber
:
number
=
12345
;
accountManager
.
getOsAccountLocalIdBySerialNumber
(
serialNumber
,
(
err
,
localId
)
=>
{
accountManager
.
getOsAccountLocalIdBySerialNumber
(
serialNumber
,
(
err
:
BusinessError
,
localId
:
number
)
=>
{
console
.
log
(
'
ger localId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
ger localId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get localId:
'
+
localId
+
'
by serialNumber:
'
+
serialNumber
);
console
.
log
(
'
get localId:
'
+
localId
+
'
by serialNumber:
'
+
serialNumber
);
});
});
...
@@ -3782,11 +3882,12 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
...
@@ -3782,11 +3882,12 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number>
**示例:**
查询与SN码12345关联的系统帐号的ID
**示例:**
查询与SN码12345关联的系统帐号的ID
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
serialNumber
=
12345
;
let
serialNumber
:
number
=
12345
;
accountManager
.
getOsAccountLocalIdBySerialNumber
(
serialNumber
).
then
((
localId
)
=>
{
accountManager
.
getOsAccountLocalIdBySerialNumber
(
serialNumber
).
then
((
localId
:
number
)
=>
{
console
.
log
(
'
getOsAccountLocalIdBySerialNumber localId:
'
+
localId
);
console
.
log
(
'
getOsAccountLocalIdBySerialNumber localId:
'
+
localId
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getOsAccountLocalIdBySerialNumber err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getOsAccountLocalIdBySerialNumber err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3813,9 +3914,10 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu
...
@@ -3813,9 +3914,10 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu
**示例:**
获取ID为100的系统帐号关联的SN码
**示例:**
获取ID为100的系统帐号关联的SN码
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
getSerialNumberByOsAccountLocalId
(
localId
,
(
err
,
serialN
umber
)
=>
{
accountManager
.
getSerialNumberByOsAccountLocalId
(
localId
,
(
err
:
BusinessError
,
serialNumber
:
n
umber
)
=>
{
console
.
log
(
'
ger serialNumber err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
ger serialNumber err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
get serialNumber:
'
+
serialNumber
+
'
by localId:
'
+
localId
);
console
.
log
(
'
get serialNumber:
'
+
serialNumber
+
'
by localId:
'
+
localId
);
});
});
...
@@ -3848,11 +3950,12 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise<number>
...
@@ -3848,11 +3950,12 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise<number>
**示例:**
获取ID为100的系统帐号关联的SN码
**示例:**
获取ID为100的系统帐号关联的SN码
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
accountManager
=
account_osAccount
.
getAccountManager
();
let
localId
=
100
;
let
localId
:
number
=
100
;
accountManager
.
getSerialNumberByOsAccountLocalId
(
localId
).
then
((
serialNumber
)
=>
{
accountManager
.
getSerialNumberByOsAccountLocalId
(
localId
).
then
((
serialNumber
:
number
)
=>
{
console
.
log
(
'
getSerialNumberByOsAccountLocalId serialNumber:
'
+
serialNumber
);
console
.
log
(
'
getSerialNumberByOsAccountLocalId serialNumber:
'
+
serialNumber
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getSerialNumberByOsAccountLocalId err:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getSerialNumberByOsAccountLocalId err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -3897,7 +4000,7 @@ getVersion(): number;
...
@@ -3897,7 +4000,7 @@ getVersion(): number;
**示例:**
**示例:**
```
js
```
js
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
version
=
userAuth
.
getVersion
();
let
version
:
number
=
userAuth
.
getVersion
();
console
.
log
(
'
getVersion version =
'
+
version
);
console
.
log
(
'
getVersion version =
'
+
version
);
```
```
...
@@ -3974,6 +4077,7 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp
...
@@ -3974,6 +4077,7 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
keys
=
[
let
keys
=
[
account_osAccount
.
GetPropertyType
.
AUTH_SUB_TYPE
,
account_osAccount
.
GetPropertyType
.
AUTH_SUB_TYPE
,
...
@@ -3985,7 +4089,7 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp
...
@@ -3985,7 +4089,7 @@ getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProp
keys
:
keys
keys
:
keys
};
};
try
{
try
{
userAuth
.
getProperty
(
request
,
(
err
,
result
)
=>
{
userAuth
.
getProperty
(
request
,
(
err
:
BusinessError
,
result
:
account_osAccount
.
ExecutorProperty
)
=>
{
console
.
log
(
'
getProperty err =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getProperty err =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getProperty result =
'
+
JSON
.
stringify
(
result
));
console
.
log
(
'
getProperty result =
'
+
JSON
.
stringify
(
result
));
});
});
...
@@ -4027,6 +4131,7 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
...
@@ -4027,6 +4131,7 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
keys
=
[
let
keys
=
[
account_osAccount
.
GetPropertyType
.
AUTH_SUB_TYPE
,
account_osAccount
.
GetPropertyType
.
AUTH_SUB_TYPE
,
...
@@ -4038,9 +4143,9 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
...
@@ -4038,9 +4143,9 @@ getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>;
keys
:
keys
keys
:
keys
};
};
try
{
try
{
userAuth
.
getProperty
(
request
).
then
((
result
)
=>
{
userAuth
.
getProperty
(
request
).
then
((
result
:
account_osAccount
.
ExecutorProperty
)
=>
{
console
.
log
(
'
getProperty result =
'
+
JSON
.
stringify
(
result
));
console
.
log
(
'
getProperty result =
'
+
JSON
.
stringify
(
result
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getProperty error =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getProperty error =
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -4076,6 +4181,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): v
...
@@ -4076,6 +4181,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): v
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
request
=
{
let
request
=
{
authType
:
account_osAccount
.
AuthType
.
PIN
,
authType
:
account_osAccount
.
AuthType
.
PIN
,
...
@@ -4083,7 +4189,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): v
...
@@ -4083,7 +4189,7 @@ setProperty(request: SetPropertyRequest, callback: AsyncCallback<void>): v
setInfo
:
new
Uint8Array
([
0
])
setInfo
:
new
Uint8Array
([
0
])
};
};
try
{
try
{
userAuth
.
setProperty
(
request
,
(
err
)
=>
{
userAuth
.
setProperty
(
request
,
(
err
:
BusinessError
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
setProperty failed, error =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setProperty failed, error =
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -4128,16 +4234,17 @@ setProperty(request: SetPropertyRequest): Promise<void>;
...
@@ -4128,16 +4234,17 @@ setProperty(request: SetPropertyRequest): Promise<void>;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
request
=
{
let
request
2
=
{
authType
:
account_osAccount
.
AuthType
.
PIN
,
authType
:
account_osAccount
.
AuthType
.
PIN
,
key
:
account_osAccount
.
SetPropertyType
.
INIT_ALGORITHM
,
key
:
account_osAccount
.
SetPropertyType
.
INIT_ALGORITHM
,
setInfo
:
new
Uint8Array
([
0
])
setInfo
:
new
Uint8Array
([
0
])
};
};
try
{
try
{
userAuth
.
setProperty
(
request
).
then
(()
=>
{
userAuth
.
setProperty
(
request
2
).
then
(()
=>
{
console
.
log
(
'
setProperty successfully
'
);
console
.
log
(
'
setProperty successfully
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
setProperty failed, error =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
setProperty failed, error =
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -4251,7 +4358,7 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev
...
@@ -4251,7 +4358,7 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev
**示例:**
**示例:**
```
js
```
js
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userID
=
100
;
let
userID
:
number
=
100
;
let
challenge
=
new
Uint8Array
([
0
]);
let
challenge
=
new
Uint8Array
([
0
]);
let
authType
=
account_osAccount
.
AuthType
.
PIN
;
let
authType
=
account_osAccount
.
AuthType
.
PIN
;
let
authTrustLevel
=
account_osAccount
.
AuthTrustLevel
.
ATL1
;
let
authTrustLevel
=
account_osAccount
.
AuthTrustLevel
.
ATL1
;
...
@@ -4295,10 +4402,10 @@ cancelAuth(contextID: Uint8Array): void;
...
@@ -4295,10 +4402,10 @@ cancelAuth(contextID: Uint8Array): void;
**示例:**
**示例:**
```
js
```
js
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
let
challenge
=
new
Uint8Array
([
0
]);
let
challenge
=
new
Uint8Array
([
0
]);
let
contextId
=
userAuth
.
auth
(
challenge
,
account_osAccount
.
AuthType
.
PIN
,
account_osAccount
.
AuthTrustLevel
.
ATL1
,
{
let
contextId
=
userAuth
.
auth
(
challenge
,
account_osAccount
.
AuthType
.
PIN
,
account_osAccount
.
AuthTrustLevel
.
ATL1
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
AuthResult
)
=>
{
console
.
log
(
'
auth result =
'
+
result
);
console
.
log
(
'
auth result =
'
+
result
);
console
.
log
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
}
}
...
@@ -4328,7 +4435,7 @@ constructor()
...
@@ -4328,7 +4435,7 @@ constructor()
**示例:**
**示例:**
```
js
```
js
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
```
```
### registerInputer<sup>8+</sup>
### registerInputer<sup>8+</sup>
...
@@ -4359,11 +4466,11 @@ registerInputer(inputer: IInputer): void;
...
@@ -4359,11 +4466,11 @@ registerInputer(inputer: IInputer): void;
**示例:**
**示例:**
```
js
```
js
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
]);
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
]);
try
{
try
{
let
result
=
pinAuth
.
registerInputer
({
let
result
=
pinAuth
.
registerInputer
({
onGetData
:
(
authSubType
,
callback
)
=>
{
onGetData
:
(
authSubType
:
account_osAccount
.
AuthSubType
,
callback
:
account_osAccount
.
IInputData
)
=>
{
callback
.
onSetData
(
authSubType
,
password
);
callback
.
onSetData
(
authSubType
,
password
);
}
}
});
});
...
@@ -4387,7 +4494,7 @@ unregisterInputer(): void;
...
@@ -4387,7 +4494,7 @@ unregisterInputer(): void;
**示例:**
**示例:**
```
js
```
js
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
pinAuth
.
unregisterInputer
();
pinAuth
.
unregisterInputer
();
```
```
...
@@ -4426,10 +4533,10 @@ static registerInputer(authType: AuthType, inputer: IInputer): void
...
@@ -4426,10 +4533,10 @@ static registerInputer(authType: AuthType, inputer: IInputer): void
**示例:**
**示例:**
```
js
```
js
let
authType
=
account_osAccount
.
AuthType
.
DOMAIN
;
let
authType
=
account_osAccount
.
AuthType
.
DOMAIN
;
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
]);
let
password
:
Uint8Array
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
]);
try
{
try
{
account_osAccount
.
InputerManager
.
registerInputer
(
authType
,
{
account_osAccount
.
InputerManager
.
registerInputer
(
authType
,
{
onGetData
:
(
authSubType
,
callback
)
=>
{
onGetData
:
(
authSubType
:
account_osAccount
.
AuthSubType
,
callback
:
account_osAccount
.
IInputData
)
=>
{
callback
.
onSetData
(
authSubType
,
password
);
callback
.
onSetData
(
authSubType
,
password
);
}
}
});
});
...
@@ -4500,8 +4607,10 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
...
@@ -4500,8 +4607,10 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{
// mock authentication
// mock authentication
// notify authentication result
// notify authentication result
callback
.
onResult
(
0
,
{
callback
.
onResult
(
0
,
{
...
@@ -4510,14 +4619,20 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
...
@@ -4510,14 +4619,20 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
freezingTime
:
0
freezingTime
:
0
});
});
},
},
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccessToken
:
(
options
,
callback
)
=>
{}
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
);
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
);
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
...
@@ -4526,7 +4641,7 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
...
@@ -4526,7 +4641,7 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
let
authTrustLevel
=
account_osAccount
.
AuthTrustLevel
.
ATL1
;
let
authTrustLevel
=
account_osAccount
.
AuthTrustLevel
.
ATL1
;
try
{
try
{
userAuth
.
auth
(
challenge
,
authType
,
authTrustLevel
,
{
userAuth
.
auth
(
challenge
,
authType
,
authTrustLevel
,
{
onResult
:
(
resultCode
,
a
uthResult
)
=>
{
onResult
:
(
resultCode
:
number
,
authResult
:
account_osAccount
.
A
uthResult
)
=>
{
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
}
}
...
@@ -4555,9 +4670,12 @@ authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback)
...
@@ -4555,9 +4670,12 @@ authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback)
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{
// mock authentication
// mock authentication
// notify authentication result
// notify authentication result
callback
.
onResult
(
0
,
{
callback
.
onResult
(
0
,
{
...
@@ -4566,13 +4684,18 @@ authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback)
...
@@ -4566,13 +4684,18 @@ authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback)
freezingTime
:
0
freezingTime
:
0
});
});
},
},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
getAccessToken
:
(
options
,
callback
)
=>
{}
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4597,10 +4720,14 @@ authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback:
...
@@ -4597,10 +4720,14 @@ authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback:
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{
// mock authentication
// mock authentication
// notify authentication result
// notify authentication result
callback
.
onResult
(
0
,
{
callback
.
onResult
(
0
,
{
...
@@ -4609,12 +4736,16 @@ authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback:
...
@@ -4609,12 +4736,16 @@ authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback:
freezingTime
:
0
freezingTime
:
0
});
});
},
},
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
getAccessToken
:
(
options
,
callback
)
=>
{}
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4639,26 +4770,33 @@ getAccountInfo(domain: string, accountName: string, callback: AsyncCallback<D
...
@@ -4639,26 +4770,33 @@ getAccountInfo(domain: string, accountName: string, callback: AsyncCallback<D
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
,
BusinessError
}
from
'
@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{
// mock getting account information
// mock getting account information
// notify result
// notify result
callback
({
let
code
:
BusinessError
code
:
0
callback
(
code
,
{
},
{
domain
:
domain
,
domain
:
domain
,
accountName
:
accountName
,
accountName
:
accountName
,
accountId
:
'
xxxx
'
accountId
:
'
xxxx
'
})
})
},
},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
callback
:
AsyncCallback
<
void
>
)
=>
{},
getAccessToken
:
(
options
,
callback
)
=>
{}
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4682,23 +4820,30 @@ getAuthStatusInfo(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&
...
@@ -4682,23 +4820,30 @@ getAuthStatusInfo(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
,
BusinessError
}
from
'
@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
({
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
code
:
0
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
},
{
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{
let
code
:
BusinessError
;
callback
(
code
,
{
remainTimes
:
5
,
remainTimes
:
5
,
freezingTime
:
0
freezingTime
:
0
})
})
},
},
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
getAccessToken
:
(
options
,
callback
)
=>
{}
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4722,20 +4867,29 @@ bindAccount(domainAccountInfo: DomainAccountInfo, localId: number, callback: Asy
...
@@ -4722,20 +4867,29 @@ bindAccount(domainAccountInfo: DomainAccountInfo, localId: number, callback: Asy
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
,
BusinessError
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{
// mock unbinding operation
// mock unbinding operation
// notify binding result
// notify binding result
callback
({
code
:
0
})
let
code
:
BusinessError
;
callback
(
code
)
},
},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
getAccessToken
:
(
options
,
callback
)
=>
{}
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4759,20 +4913,29 @@ unbindAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<v
...
@@ -4759,20 +4913,29 @@ unbindAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<v
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
,
BusinessError
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{
// mock unbinding operation
// mock unbinding operation
// notify unbinding result
// notify unbinding result
callback
({
code
:
0
})
let
code
:
BusinessError
;
callback
(
code
)
},
},
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
getAccessToken
:
(
options
,
callback
)
=>
{}
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4797,20 +4960,29 @@ isAccountTokenValid(domainAccountInfo: DomainAccountInfo, token: Uint8Array, cal
...
@@ -4797,20 +4960,29 @@ isAccountTokenValid(domainAccountInfo: DomainAccountInfo, token: Uint8Array, cal
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
,
BusinessError
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{
// mock checking operation
// mock checking operation
// notify checking result
// notify checking result
callback
({
code
:
0
},
true
);
let
code
:
BusinessError
callback
(
code
,
true
);
},
},
getAccessToken
:
(
options
,
callback
)
=>
{}
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
```
```
...
@@ -4834,20 +5006,29 @@ getAccessToken(options: GetDomainAccessTokenOptions, callback: AsyncCallback<
...
@@ -4834,20 +5006,29 @@ getAccessToken(options: GetDomainAccessTokenOptions, callback: AsyncCallback<
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
,
BusinessError
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
getAccessToken
:
(
options
,
callback
)
=>
{
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{
// mock getting operation
// mock getting operation
let
token
=
new
Uint8Array
([
0
]);
//
let token = new Uint8Array([0]);
// notify result
// notify result
callback
({
code
:
0
},
token
);
let
code
:
BusinessError
callback
(
code
,
token
);
}
}
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
)
...
@@ -4882,16 +5063,24 @@ static registerPlugin(plugin: DomainPlugin): void
...
@@ -4882,16 +5063,24 @@ static registerPlugin(plugin: DomainPlugin): void
**示例:**
**示例:**
```
js
```
js
import
{
AsyncCallback
}
from
'
./@ohos.base
'
;
let
plugin
=
{
let
plugin
=
{
auth
:
(
domainAccountInfo
,
credential
,
callback
)
=>
{},
auth
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
credential
:
Uint8Array
,
authWithPopup
:
(
domainAccountInfo
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
authWithToken
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
authWithPopup
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
getAccountInfo
:
(
domain
,
accountName
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
getAuthStatusInfo
:
(
domainAccountInfo
,
callback
)
=>
{},
authWithToken
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
bindAccount
:
(
domainAccountInfo
,
localId
,
callback
)
=>
{},
callback
:
account_osAccount
.
IUserAuthCallback
)
=>
{},
unbindAccount
:
(
domainAccountInfo
,
callback
)
=>
{},
getAccountInfo
:
(
domain
:
string
,
accountName
:
string
,
isAccountTokenValid
:
(
domainAccountInfo
,
token
,
callback
)
=>
{},
callback
:
AsyncCallback
<
account_osAccount
.
DomainAccountInfo
>
)
=>
{},
getAccessToken
:
(
options
,
callback
)
=>
{}
getAuthStatusInfo
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
account_osAccount
.
AuthStatusInfo
>
)
=>
{},
bindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
localId
:
number
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
unbindAccount
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
callback
:
AsyncCallback
<
void
>
)
=>
{},
isAccountTokenValid
:
(
domainAccountInfo
:
account_osAccount
.
DomainAccountInfo
,
token
:
Uint8Array
,
callback
:
AsyncCallback
<
boolean
>
)
=>
{},
getAccessToken
:
(
options
:
account_osAccount
.
GetDomainAccessTokenOptions
,
callback
:
AsyncCallback
<
Uint8Array
>
)
=>
{}
}
}
try
{
try
{
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
);
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
);
...
@@ -4968,7 +5157,7 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
...
@@ -4968,7 +5157,7 @@ auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUs
let
credential
=
new
Uint8Array
([
0
])
let
credential
=
new
Uint8Array
([
0
])
try
{
try
{
account_osAccount
.
DomainAccountManager
.
auth
(
domainAccountInfo
,
credential
,
{
account_osAccount
.
DomainAccountManager
.
auth
(
domainAccountInfo
,
credential
,
{
onResult
:
(
resultCode
,
a
uthResult
)
=>
{
onResult
:
(
resultCode
:
number
,
authResult
:
account_osAccount
.
A
uthResult
)
=>
{
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
}
}
...
@@ -5015,7 +5204,7 @@ authWithPopup(callback: IUserAuthCallback): void
...
@@ -5015,7 +5204,7 @@ authWithPopup(callback: IUserAuthCallback): void
```
js
```
js
try
{
try
{
account_osAccount
.
DomainAccountManager
.
authWithPopup
({
account_osAccount
.
DomainAccountManager
.
authWithPopup
({
onResult
:
(
resultCode
,
a
uthResult
)
=>
{
onResult
:
(
resultCode
:
number
,
authResult
:
account_osAccount
.
A
uthResult
)
=>
{
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
}
}
...
@@ -5064,7 +5253,7 @@ authWithPopup(localId: number, callback: IUserAuthCallback): void
...
@@ -5064,7 +5253,7 @@ authWithPopup(localId: number, callback: IUserAuthCallback): void
```
js
```
js
try
{
try
{
account_osAccount
.
DomainAccountManager
.
authWithPopup
(
100
,
{
account_osAccount
.
DomainAccountManager
.
authWithPopup
(
100
,
{
onResult
:
(
resultCode
,
a
uthResult
)
=>
{
onResult
:
(
resultCode
:
number
,
authResult
:
account_osAccount
.
A
uthResult
)
=>
{
console
.
log
(
'
authWithPopup resultCode =
'
+
resultCode
);
console
.
log
(
'
authWithPopup resultCode =
'
+
resultCode
);
console
.
log
(
'
authWithPopup authResult =
'
+
JSON
.
stringify
(
authResult
));
console
.
log
(
'
authWithPopup authResult =
'
+
JSON
.
stringify
(
authResult
));
}
}
...
@@ -5103,12 +5292,13 @@ hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<bool
...
@@ -5103,12 +5292,13 @@ hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback<bool
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
domainAccountInfo
=
{
let
domainAccountInfo
=
{
domain
:
'
CHINA
'
,
domain
:
'
CHINA
'
,
accountName
:
'
zhangsan
'
accountName
:
'
zhangsan
'
}
}
try
{
try
{
account_osAccount
.
DomainAccountManager
.
hasAccount
(
domainAccountInfo
,
(
err
,
result
)
=>
{
account_osAccount
.
DomainAccountManager
.
hasAccount
(
domainAccountInfo
,
(
err
:
BusinessError
,
result
:
boolean
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
'
call hasAccount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
call hasAccount failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -5154,14 +5344,15 @@ hasAccount(domainAccountInfo: DomainAccountInfo): Promise<boolean>
...
@@ -5154,14 +5344,15 @@ hasAccount(domainAccountInfo: DomainAccountInfo): Promise<boolean>
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
domainAccountInfo
=
{
let
domainAccountInfo
=
{
domain
:
'
CHINA
'
,
domain
:
'
CHINA
'
,
accountName
:
'
zhangsan
'
accountName
:
'
zhangsan
'
}
}
try
{
try
{
account_osAccount
.
DomainAccountManager
.
hasAccount
(
domainAccountInfo
).
then
((
result
)
=>
{
account_osAccount
.
DomainAccountManager
.
hasAccount
(
domainAccountInfo
).
then
((
result
:
boolean
)
=>
{
console
.
log
(
'
hasAccount result:
'
+
result
);
console
.
log
(
'
hasAccount result:
'
+
result
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
call hasAccount failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
call hasAccount failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -5199,6 +5390,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, call
...
@@ -5199,6 +5390,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, call
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
domainAccountInfo
=
{
let
domainAccountInfo
=
{
domain
:
'
CHINA
'
,
domain
:
'
CHINA
'
,
accountName
:
'
zhangsan
'
,
accountName
:
'
zhangsan
'
,
...
@@ -5206,7 +5398,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, call
...
@@ -5206,7 +5398,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, call
}
}
let
token
=
new
Uint8Array
([
0
])
let
token
=
new
Uint8Array
([
0
])
try
{
try
{
account_osAccount
.
DomainAccountManager
.
updateAccountToken
(
domainAccountInfo
,
token
,
(
err
)
=>
{
account_osAccount
.
DomainAccountManager
.
updateAccountToken
(
domainAccountInfo
,
token
,
(
err
:
BusinessError
)
=>
{
if
(
err
!=
null
)
{
if
(
err
!=
null
)
{
console
.
log
(
'
updateAccountToken failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
updateAccountToken failed, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
}
else
{
...
@@ -5253,6 +5445,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Pro
...
@@ -5253,6 +5445,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Pro
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
domainAccountInfo
=
{
let
domainAccountInfo
=
{
domain
:
'
CHINA
'
,
domain
:
'
CHINA
'
,
accountName
:
'
zhangsan
'
,
accountName
:
'
zhangsan
'
,
...
@@ -5262,7 +5455,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Pro
...
@@ -5262,7 +5455,7 @@ updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Pro
try
{
try
{
account_osAccount
.
DomainAccountManager
.
updateAccountToken
(
domainAccountInfo
,
token
).
then
(()
=>
{
account_osAccount
.
DomainAccountManager
.
updateAccountToken
(
domainAccountInfo
,
token
).
then
(()
=>
{
console
.
log
(
'
updateAccountToken successfully
'
);
console
.
log
(
'
updateAccountToken successfully
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
updateAccountToken failed, error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
updateAccountToken failed, error:
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -5317,9 +5510,10 @@ openSession(callback: AsyncCallback<Uint8Array>): void;
...
@@ -5317,9 +5510,10 @@ openSession(callback: AsyncCallback<Uint8Array>): void;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
try
{
try
{
userIDM
.
openSession
((
err
,
challenge
)
=>
{
userIDM
.
openSession
((
err
:
BusinessError
,
challenge
:
Uint8Array
)
=>
{
console
.
log
(
'
openSession error =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
openSession error =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
openSession challenge =
'
+
JSON
.
stringify
(
challenge
));
console
.
log
(
'
openSession challenge =
'
+
JSON
.
stringify
(
challenge
));
});
});
...
@@ -5354,11 +5548,12 @@ openSession(): Promise<Uint8Array>;
...
@@ -5354,11 +5548,12 @@ openSession(): Promise<Uint8Array>;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
try
{
try
{
userIDM
.
openSession
().
then
((
challenge
)
=>
{
userIDM
.
openSession
().
then
((
challenge
challenge
:
Uint8Array
)
=>
{
console
.
info
(
'
openSession challenge =
'
+
JSON
.
stringify
(
challenge
));
console
.
info
(
'
openSession challenge =
'
+
JSON
.
stringify
(
challenge
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
'
openSession error =
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
openSession error =
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -5399,23 +5594,24 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
...
@@ -5399,23 +5594,24 @@ addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
**示例:**
**示例:**
```
js
```
js
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
password
:
Uint8Array
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
pinAuth
.
registerInputer
({
pinAuth
.
registerInputer
({
onGetData
:
(
authSubType
,
callback
)
=>
{
onGetData
:
(
authSubType
:
account_osAccount
.
AuthSubType
,
callback
:
account_osAccount
.
IInputData
)
=>
{
callback
.
onSetData
(
authSubType
,
password
);
callback
.
onSetData
(
authSubType
,
password
);
}
}
});
});
let
credentialInfo
=
{
let
credentialInfo
:
account_osAccount
.
CredentialInfo
=
{
credType
:
account_osAccount
.
AuthType
.
PIN
,
credType
:
account_osAccount
.
AuthType
.
PIN
,
credSubType
:
account_osAccount
.
AuthSubType
.
PIN_SIX
,
credSubType
:
account_osAccount
.
AuthSubType
.
PIN_SIX
,
token
:
null
token
:
null
};
};
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
userIDM
.
openSession
((
err
,
challenge
)
=>
{
userIDM
.
openSession
((
err
:
BusinessError
,
challenge
:
Uint8Array
)
=>
{
try
{
try
{
userIDM
.
addCredential
(
credentialInfo
,
{
userIDM
.
addCredential
(
credentialInfo
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
RequestResult
)
=>
{
console
.
log
(
'
addCredential result =
'
+
result
);
console
.
log
(
'
addCredential result =
'
+
result
);
console
.
log
(
'
addCredential extraInfo =
'
+
extraInfo
);
console
.
log
(
'
addCredential extraInfo =
'
+
extraInfo
);
}
}
...
@@ -5459,30 +5655,31 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
...
@@ -5459,30 +5655,31 @@ updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
userAuth
:
account_osAccount
.
UserAuth
=
new
account_osAccount
.
UserAuth
();
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
password
:
Uint8Array
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
credentialInfo
=
{
let
credentialInfo
=
{
credType
:
account_osAccount
.
AuthType
.
PIN
,
credType
:
account_osAccount
.
AuthType
.
PIN
,
credSubType
:
account_osAccount
.
AuthSubType
.
PIN_SIX
,
credSubType
:
account_osAccount
.
AuthSubType
.
PIN_SIX
,
token
:
null
token
:
null
};
};
pinAuth
.
registerInputer
({
pinAuth
.
registerInputer
({
onGetData
:
(
authSubType
,
callback
)
=>
{
onGetData
:
(
authSubType
:
account_osAccount
.
AuthSubType
,
callback
:
account_osAccount
.
IInputData
)
=>
{
callback
.
onSetData
(
authSubType
,
password
);
callback
.
onSetData
(
authSubType
,
password
);
}
}
});
});
userIDM
.
openSession
((
err
,
challenge
)
=>
{
userIDM
.
openSession
((
err
:
BusinessError
,
challenge
:
Uint8Array
)
=>
{
userAuth
.
auth
(
challenge
,
credentialInfo
.
credType
,
account_osAccount
.
AuthTrustLevel
.
ATL1
,
{
userAuth
.
auth
(
challenge
,
credentialInfo
.
credType
,
account_osAccount
.
AuthTrustLevel
.
ATL1
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
AuthResult
)
=>
{
if
(
result
!=
account_osAccount
.
ResultCode
.
SUCCESS
)
{
if
(
result
!=
account_osAccount
.
ResultCode
.
SUCCESS
)
{
return
;
return
;
}
}
credentialInfo
.
token
=
extraInfo
.
token
;
credentialInfo
.
token
=
extraInfo
.
token
;
try
{
try
{
userIDM
.
updateCredential
(
credentialInfo
,
{
userIDM
.
updateCredential
(
credentialInfo
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
RequestResult
)
=>
{
console
.
log
(
'
updateCredential result =
'
+
result
);
console
.
log
(
'
updateCredential result =
'
+
result
);
console
.
log
(
'
updateCredential extraInfo =
'
+
extraInfo
);
console
.
log
(
'
updateCredential extraInfo =
'
+
extraInfo
);
}
}
...
@@ -5541,7 +5738,7 @@ cancel(challenge: Uint8Array): void;
...
@@ -5541,7 +5738,7 @@ cancel(challenge: Uint8Array): void;
**示例:**
**示例:**
```
js
```
js
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
challenge
=
new
Uint8Array
([
0
]);
let
challenge
:
Uint8Array
=
new
Uint8Array
([
0
]);
try
{
try
{
userIDM
.
cancel
(
challenge
);
userIDM
.
cancel
(
challenge
);
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -5578,10 +5775,10 @@ delUser(token: Uint8Array, callback: IIdmCallback): void;
...
@@ -5578,10 +5775,10 @@ delUser(token: Uint8Array, callback: IIdmCallback): void;
**示例:**
**示例:**
```
js
```
js
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
token
=
new
Uint8Array
([
0
]);
let
token
:
Uint8Array
=
new
Uint8Array
([
0
]);
try
{
try
{
userIDM
.
delUser
(
token
,
{
userIDM
.
delUser
(
token
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
RequestResult
)
=>
{
console
.
log
(
'
delUser result =
'
+
result
);
console
.
log
(
'
delUser result =
'
+
result
);
console
.
log
(
'
delUser extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
delUser extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
}
}
...
@@ -5623,11 +5820,11 @@ delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): vo
...
@@ -5623,11 +5820,11 @@ delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): vo
**示例:**
**示例:**
```
js
```
js
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
credentialId
=
new
Uint8Array
([
0
]);
let
credentialId
:
Uint8Array
=
new
Uint8Array
([
0
]);
let
token
=
new
Uint8Array
([
0
]);
let
token
:
Uint8Array
=
new
Uint8Array
([
0
]);
try
{
try
{
userIDM
.
delCred
(
credentialId
,
token
,
{
userIDM
.
delCred
(
credentialId
,
token
,
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
RequestResult
)
=>
{
console
.
log
(
'
delCred result =
'
+
result
);
console
.
log
(
'
delCred result =
'
+
result
);
console
.
log
(
'
delCred extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
delCred extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
}
}
...
@@ -5664,9 +5861,10 @@ getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
...
@@ -5664,9 +5861,10 @@ getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
try
{
try
{
userIDM
.
getAuthInfo
((
err
,
result
)
=>
{
userIDM
.
getAuthInfo
((
err
:
BusinessError
,
result
:
account_osAccount
.
EnrolledCredInfo
[]
)
=>
{
console
.
log
(
'
getAuthInfo err =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAuthInfo err =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAuthInfo result =
'
+
JSON
.
stringify
(
result
));
console
.
log
(
'
getAuthInfo result =
'
+
JSON
.
stringify
(
result
));
});
});
...
@@ -5704,9 +5902,11 @@ getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCred
...
@@ -5704,9 +5902,11 @@ getAuthInfo(authType: AuthType, callback: AsyncCallback<Array<EnrolledCred
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
try
{
try
{
userIDM
.
getAuthInfo
(
account_osAccount
.
AuthType
.
PIN
,
(
err
,
result
)
=>
{
userIDM
.
getAuthInfo
(
account_osAccount
.
AuthType
.
PIN
,
(
err
:
BusinessError
,
result
:
account_osAccount
.
EnrolledCredInfo
[])
=>
{
console
.
log
(
'
getAuthInfo err =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAuthInfo err =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAuthInfo result =
'
+
JSON
.
stringify
(
result
));
console
.
log
(
'
getAuthInfo result =
'
+
JSON
.
stringify
(
result
));
});
});
...
@@ -5749,11 +5949,12 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>;
...
@@ -5749,11 +5949,12 @@ getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>;
**示例:**
**示例:**
```
js
```
js
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
let
userIDM
=
new
account_osAccount
.
UserIdentityManager
();
try
{
try
{
userIDM
.
getAuthInfo
(
account_osAccount
.
AuthType
.
PIN
).
then
((
result
)
=>
{
userIDM
.
getAuthInfo
(
account_osAccount
.
AuthType
.
PIN
).
then
((
result
:
account_osAccount
.
EnrolledCredInfo
[]
)
=>
{
console
.
log
(
'
getAuthInfo result =
'
+
JSON
.
stringify
(
result
))
console
.
log
(
'
getAuthInfo result =
'
+
JSON
.
stringify
(
result
))
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
'
getAuthInfo error =
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAuthInfo error =
'
+
JSON
.
stringify
(
err
));
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -5792,10 +5993,10 @@ onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
...
@@ -5792,10 +5993,10 @@ onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
**示例:**
**示例:**
```
js
```
js
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
password
:
Uint8Array
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
passwordNumber
=
new
Uint8Array
([
1
,
2
,
3
,
4
]);
let
passwordNumber
:
Uint8Array
=
new
Uint8Array
([
1
,
2
,
3
,
4
]);
let
inputer
=
{
let
inputer
=
{
onGetData
:
(
authSubType
,
callback
)
=>
{
onGetData
:
(
authSubType
:
account_osAccount
.
AuthSubType
,
callback
:
account_osAccount
.
IInputData
)
=>
{
if
(
authSubType
==
account_osAccount
.
AuthSubType
.
PIN_NUMBER
)
{
if
(
authSubType
==
account_osAccount
.
AuthSubType
.
PIN_NUMBER
)
{
callback
.
onSetData
(
authSubType
,
passwordNumber
);
callback
.
onSetData
(
authSubType
,
passwordNumber
);
}
else
{
}
else
{
...
@@ -5829,10 +6030,10 @@ onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
...
@@ -5829,10 +6030,10 @@ onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
**示例:**
**示例:**
```
js
```
js
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
password
:
Uint8Array
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
,
0
]);
let
passwordNumber
=
new
Uint8Array
([
1
,
2
,
3
,
4
]);
let
passwordNumber
:
Uint8Array
=
new
Uint8Array
([
1
,
2
,
3
,
4
]);
let
inputer
=
{
let
inputer
=
{
onGetData
:
(
authSubType
,
callback
)
=>
{
onGetData
:
(
authSubType
:
account_osAccount
.
AuthSubType
,
callback
:
account_osAccount
.
IInputData
)
=>
{
if
(
authSubType
==
account_osAccount
.
AuthSubType
.
PIN_NUMBER
)
{
if
(
authSubType
==
account_osAccount
.
AuthSubType
.
PIN_NUMBER
)
{
callback
.
onSetData
(
authSubType
,
passwordNumber
);
callback
.
onSetData
(
authSubType
,
passwordNumber
);
}
else
{
}
else
{
...
@@ -5840,7 +6041,7 @@ onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
...
@@ -5840,7 +6041,7 @@ onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
}
}
}
}
};
};
let
pinAuth
=
new
account_osAccount
.
PINAuth
();
let
pinAuth
:
account_osAccount
.
PINAuth
=
new
account_osAccount
.
PINAuth
();
let
result
=
pinAuth
.
registerInputer
(
inputer
);
let
result
=
pinAuth
.
registerInputer
(
inputer
);
console
.
log
(
'
registerInputer result:
'
+
result
);
console
.
log
(
'
registerInputer result:
'
+
result
);
```
```
...
@@ -5871,7 +6072,7 @@ onResult: (result: number, extraInfo: AuthResult) => void;
...
@@ -5871,7 +6072,7 @@ onResult: (result: number, extraInfo: AuthResult) => void;
**示例:**
**示例:**
```
js
```
js
let
authCallback
=
{
let
authCallback
=
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
account_osAccount
.
AuthSubType
,
extraInfo
:
account_osAccount
.
IInputData
)
=>
{
console
.
log
(
'
auth result =
'
+
result
);
console
.
log
(
'
auth result =
'
+
result
);
console
.
log
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
}
}
...
@@ -5899,11 +6100,11 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
...
@@ -5899,11 +6100,11 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
**示例:**
**示例:**
```
js
```
js
let
authCallback
=
{
let
authCallback
=
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
account_osAccount
.
AuthSubType
,
extraInfo
:
account_osAccount
.
IInputData
)
=>
{
console
.
log
(
'
auth result =
'
+
result
)
console
.
log
(
'
auth result =
'
+
result
)
console
.
log
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
},
},
onAcquireInfo
:
(
module
,
acquire
,
extraInfo
)
=>
{
onAcquireInfo
:
(
module
:
number
,
acquire
:
number
,
extraInfo
:
account_osAccount
.
RequestResult
)
=>
{
console
.
log
(
'
auth module =
'
+
module
);
console
.
log
(
'
auth module =
'
+
module
);
console
.
log
(
'
auth acquire =
'
+
acquire
);
console
.
log
(
'
auth acquire =
'
+
acquire
);
console
.
info
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
info
(
'
auth extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
...
@@ -5937,7 +6138,7 @@ onResult: (result: number, extraInfo: RequestResult) => void;
...
@@ -5937,7 +6138,7 @@ onResult: (result: number, extraInfo: RequestResult) => void;
**示例:**
**示例:**
```
js
```
js
let
idmCallback
=
{
let
idmCallback
=
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
account_osAccount
.
RequestResult
)
=>
{
console
.
log
(
'
callback result =
'
+
result
)
console
.
log
(
'
callback result =
'
+
result
)
console
.
info
(
'
callback extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
info
(
'
callback extraInfo =
'
+
JSON
.
stringify
(
extraInfo
));
}
}
...
@@ -5965,11 +6166,11 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
...
@@ -5965,11 +6166,11 @@ onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void;
**示例:**
**示例:**
```
js
```
js
let
idmCallback
=
{
let
idmCallback
=
{
onResult
:
(
result
,
extraInfo
)
=>
{
onResult
:
(
result
:
number
,
extraInfo
:
Object
)
=>
{
console
.
log
(
'
callback result =
'
+
result
)
console
.
log
(
'
callback result =
'
+
result
)
console
.
log
(
'
callback onResult =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
callback onResult =
'
+
JSON
.
stringify
(
extraInfo
));
},
},
onAcquireInfo
:
(
module
,
acquire
,
extraInfo
)
=>
{
onAcquireInfo
:
(
module
:
number
,
acquire
:
number
,
extraInfo
:
Object
)
=>
{
console
.
log
(
'
callback module =
'
+
module
);
console
.
log
(
'
callback module =
'
+
module
);
console
.
log
(
'
callback acquire =
'
+
acquire
);
console
.
log
(
'
callback acquire =
'
+
acquire
);
console
.
log
(
'
callback onacquireinfo =
'
+
JSON
.
stringify
(
extraInfo
));
console
.
log
(
'
callback onacquireinfo =
'
+
JSON
.
stringify
(
extraInfo
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录