未验证 提交 ddf0eb32 编写于 作者: O openharmony_ci 提交者: Gitee

!9798 docs一致性整改

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