提交 f8622672 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 c1b4d839
# Account Subsystem ChangeLog
# Account Subsystem Changelog
## cl.account_os_account.1 createOsAccountForDomain Error Code Change
Changed the error code returned when the **createOsAccountForDomain** API is used to create a domain account that already exists from **12300001** to **12300004**.
The error information is changed from a common system error to an error indicating that the account already exists.
Changed the error code returned when the domain account created by **createOsAccountForDomain()** already exists from **12300001** to **12300004**.
Changed the error information from "common system error" to "The account already exists".
**Change Impacts**
**Change Impact**
The application developed based on earlier versions needs to adapt the new error code. Otherwise, the original service logic will be affected.
......@@ -16,11 +16,10 @@ The application developed based on earlier versions needs to adapt the new error
**Adaptation Guide**
The sample code for returning an error when a domain account is repeatedly created is as follows:
The sample code is as follows:
```ts
import account_osAccount from "@ohos.account.osAccount"
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
let accountMgr = account_osAccount.getAccountManager();
let domainInfo = {
......@@ -31,6 +30,67 @@ try {
await accountMgr.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo);
await accountMgr.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo);
} catch (err) {
expect(err.code).assertEqual(12300004);
console.log("activateOsAccount err: " + JSON.stringify(err)); // error.code = 12300004;
}
```
## cl.account_os_account.2 Application Account getAllAccounts() Permission Change
Removed the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission that is originally required for an application to call **getAllAccounts()** to obtain accessible accounts.
**Change Impact**
From this version, applications do not need the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission when calling **getAllAccounts()**.
**Key API/Component Changes**
- AccountManager
- getAllAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
- getAllAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
**Adaptation Guide**
The following is the sample code for an application to obtain the accessible accounts without the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission:
```ts
import account_appAccount from "@ohos.account.appAccount"
let accountMgr = account_appAccount.createAppAccountManager();
try {
await accountMgr.addAccount("accessibleAccount_promise_nopermission");
var data = await accountMgr.getAllAccounts();
if (data[0].name == "accessibleAccount_promise_nopermission") {
console.log("getAllAccounts successfully");
}
} catch (err) {
console.log("getAllAccounts err: " + JSON.stringify(err));
}
```
## cl.account_os_account.3 Application Account getAccountsByOwner() Permission Change
Removed the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission that is originally required for an application to call **getAccountsByOwner()** to obtain the accessible accounts based on the account owner .
**Change Impact**
From this version, applications do not need the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission when calling **getAccountsByOwner()**.
**Key API/Component Changes**
- AccountManager
- getAccountsByOwner(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
- getAccountsByOwner(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
**Adaptation Guide**
The following is the sample code for an application to obtain the accessible accounts based on the account owner without the **ohos.permission.GET_ALL_APP_ACCOUNTS** permission:
```ts
import account_appAccount from "@ohos.account.appAccount"
let accountMgr = account_appAccount.createAppAccountManager();
try {
var ownerName = "com.example.owner";
var data = await accountMgr.getAllAccounts(ownerName);
} catch (err) {
console.log("getAllAccounts err: " + JSON.stringify(err));
}
```
# App Access Control Subsystem ChangeLog
OpenHarmony 4.0.3.2 has the following changes in the APIs of the app access control subsystem:
## cl.access_token.1 getPermissionUsedRecords Name Change
Changed **getPermissionUsedRecords** to **getPermissionUsedRecord**.
**Change Impact**
The **getPermissionUsedRecords()** API cannot be used in OpenHarmony 4.0.3.3 and later versions.
**Key API/Component Changes**
- Involved APIs:
function getPermissionUsedRecords
- Before change:
```ts
function getPermissionUsedRecords
```
- After change:
```ts
function getPermissionUsedRecord
```
**Adaptation Guide**
Use **getPermissionUsedRecord()**.
# File Management Subsystem Changelog
## cl.filemanagement.1 Filter Module Change
Moved **Filter** from **@ohos.fileio** to **@ohos.file.fs**. The attributes of **Filter** remain unchanged.
**Change Impact**
If your application is developed using the APIs of earlier versions, note that the position of **Filter** in the **d.ts** file and the module name are changed. The **Filter** type is moved to **@ohos.file.fs**.
**Key API/Component Changes**
Before the change, **Filter** is in the **@ohos.fileio** module and imported as follows:
```js
import Filter from '@ohos.fileio';
```
**Adaptation Guide**
Now, **Filter** is in the **@ohos.file.fs** module and imported as follows:
```js
import Filter from '@ohos.file.fs';
```
# Account Subsystem ChangeLog
# Account Subsystem Changelog
## cl.account_os_account.1 OsAccountInfo.type Value Type Change
Changed the value type of **OsAccountInfo.type** from **Object** to **OsAccountType** enumeration.
Changed the value type of **OsAccountInfo.type** from object to **OsAccountType** enum.
**Change Impacts**
**Change Impact**
The mode for reading the **OsAccountInfo.type** value needs to be changed for the application developed based on earlier versions. Otherwise, the original service logic will be affected.
......@@ -33,25 +33,25 @@ The following APIs are involved:
**Adaptation Guide**
```ts
import account_osAccount from "@ohos.account.osAccount"
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
let accountMgr = account_osAccount.getAccountManager();
accountMgr.createOsAccount('account_test', account_osAccount.OsAccountType.GUEST).then((accountInfo) => {
expect(accountInfo.type).assertEqual(account_osAccount.OsAccountType.GUEST);
accountMgr.createOsAccount("account_test", account_osAccount.OsAccountType.GUEST).then((accountInfo) => {
if (accountInfo.type == account_osAccount.OsAccountType.GUEST) {
console.log("createOsAccount successfully");
}
accountMgr.activateOsAccount(accountInfo.localId).then(() => {
console.log('activateOsAccount successfully');
console.log("activateOsAccount successfully");
accountMgr.getOsAccountTypeFromProcess().then((accountType) => {
expect(accountType).assertEqual(account_osAccount.OsAccountType.GUEST);
if (accountType == account_osAccount.OsAccountType.GUEST) {
console.log("getOsAccountTypeFromProcess successfully");
}
}).catch((err) => {
console.log('activateOsAccount err: ' + JSON.stringify(err));
expect().assertFail();
console.log("activateOsAccount err: " + JSON.stringify(err));
});
}).catch((err) => {
console.log('activateOsAccount err: ' + JSON.stringify(err));
expect().assertFail();
console.log("activateOsAccount err: " + JSON.stringify(err));
});
}).catch((err) => {
console.log('createOsAccount err: ' + JSON.stringify(err));
expect().assertFail();
console.log("createOsAccount err: " + JSON.stringify(err));
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册