提交 70e8834c 编写于 作者: F fanchenxuan

docs一致性整改

Signed-off-by: Nfanchenxuan <fanchenxuan@huawei.com>
上级 73ae49f2
......@@ -45,15 +45,14 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
async addPermissionUsedRecord() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
bundle.getApplicationInfo(bundleName, 16).then(appInfo => {
var tokenID = appInfo.accessTokenId; // 可以通过getApplicationInfo获取accessTokenId
privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED_STATS", 1, 0).then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
}
})
```
## privacyManager.addPermissionUsedRecord
......@@ -83,15 +82,14 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
async addPermissionUsedRecord() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
bundle.getApplicationInfo(bundleName, 16).then(appInfo => {
var tokenID = appInfo.accessTokenId; // 可以通过getApplicationInfo获取accessTokenId
privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED_STATS", 1, 0, (err, data) => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
}
})
```
## privacyManager.getPermissionUsedRecords
......@@ -198,10 +196,8 @@ startUsingPermission(tokenID: number, permissionName: string): Promise&lt;number
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
async startUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
bundle.getApplicationInfo(bundleName, 16).then(appInfo => {
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.startUsingPermission(tokenID, permissionName).then(data => {
......@@ -209,7 +205,8 @@ async startUsingPermission() {
}).catch(err => {
console.log(`Error: err->${JSON.stringify(err)}`);
});
}
})
```
## privacyManager.startUsingPermission<sup>9+</sup>
......@@ -236,20 +233,19 @@ startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCal
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
async startUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
bundle.getApplicationInfo(bundleName, 16).then(appInfo => {
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.startUsingPermission(tokenID, permissionName, (err, data)=> {
if (err) {
console.log(`Error: err->${JSON.stringify(err)}`);
} else {
} else {S
console.log(`promise: data->${JSON.stringify(data)}`);
}
});
}
})
```
## privacyManager.stopUsingPermission<sup>9+</sup>
......@@ -281,10 +277,8 @@ stopUsingPermission(tokenID: number, permissionName: string): Promise&lt;number&
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
async stopUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
bundle.getApplicationInfo(bundleName, 16).then(appInfo => {
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.stopUsingPermission(tokenID, permissionName).then(data => {
......@@ -292,7 +286,8 @@ async stopUsingPermission() {
}).catch(err => {
console.log(`Error: err->${JSON.stringify(err)}`);
});
}
})
```
## privacyManager.stopUsingPermission<sup>9+</sup>
......@@ -319,20 +314,19 @@ stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCall
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
async stopUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
bundle.getApplicationInfo(bundleName, 16).then(appInfo => {
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.privacyManager.stopUsingPermission(tokenID, permissionName, (err, data)=> {
privacyManager.stopUsingPermission(tokenID, permissionName, (err, data)=> {
if (err) {
console.log(`Error: err->${JSON.stringify(err)}`);
} else {
console.log(`promise: data->${JSON.stringify(data)}`);
}
});
}
})
```
## privacyManager.on<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册