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

!9567 docs一致性整改

Merge pull request !9567 from fanchenxuan/master
......@@ -339,8 +339,8 @@ function OnPermissionStateChanged(data){
}
let atManager = abilityAccessCtrl.createAtManager();
let type: 'permissionStateChange' = 'permissionStateChange';
let tokenIDList: Array<number> = [];
let permissionNameList: Array<string> = [];
let tokenIDList: Array<number> = [];
let permissionNameList: Array<string> = [];
try{
atManager.on(type, tokenIDList, permissionNameList, OnPermissionStateChanged);
}
......@@ -377,8 +377,8 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager();
let type: 'permissionStateChange' = 'permissionStateChange';
let tokenIDList: Array&lt;number&gt; = [];
let permissionNameList: Array&lt;string&gt; = [];
let tokenIDList: Array<number> = [];
let permissionNameList: Array<string> = [];
try{
atManager.off(type, tokenIDList, permissionNameList);
}
......
......@@ -45,13 +45,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
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)}`);
});
async addPermissionUsedRecord() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
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
......@@ -81,13 +83,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
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)}`);
});
async addPermissionUsedRecord() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
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
......@@ -194,16 +198,18 @@ startUsingPermission(tokenID: number, permissionName: string): Promise&lt;number
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.startUsingPermission(tokenID, permissionName).then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`Error: err->${JSON.stringify(err)}`);
});
async startUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.startUsingPermission(tokenID, permissionName).then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`Error: err->${JSON.stringify(err)}`);
});
}
```
## privacyManager.startUsingPermission<sup>9+</sup>
......@@ -230,18 +236,20 @@ startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCal
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
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 {
console.log(`promise: data->${JSON.stringify(data)}`);
}
});
async startUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
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 {
console.log(`promise: data->${JSON.stringify(data)}`);
}
});
}
```
## privacyManager.stopUsingPermission<sup>9+</sup>
......@@ -273,16 +281,18 @@ stopUsingPermission(tokenID: number, permissionName: string): Promise&lt;number&
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.stopUsingPermission(tokenID, permissionName).then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`Error: err->${JSON.stringify(err)}`);
});
async stopUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.stopUsingPermission(tokenID, permissionName).then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`Error: err->${JSON.stringify(err)}`);
});
}
```
## privacyManager.stopUsingPermission<sup>9+</sup>
......@@ -309,18 +319,20 @@ stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCall
import bundle from '@ohos.bundle';
import privacyManager from '@ohos.privacyManager';
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.privacyManager.stopUsingPermission(tokenID, permissionName, (err, data)=> {
if (err) {
console.log(`Error: err->${JSON.stringify(err)}`);
} else {
console.log(`promise: data->${JSON.stringify(data)}`);
}
});
async stopUsingPermission() {
let bundleName = "com.ohos.permissionmanager"; // change to your bundle name
let appInfo = await bundle.getApplicationInfo(bundleName, 16); // need async type function
let tokenID = appInfo.accessTokenId;
let permissionName = "ohos.permission.CAMERA";
privacyManager.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>
......@@ -352,7 +364,7 @@ function OnPermissionUseStateChanged(data){
console.debug("receive permission state change, data:" + JSON.stringify(data));
}
let type: 'activeStateChange' = 'activeStateChange';
let permissionNameList: Array&lt;string&gt; = [];
let permissionNameList: Array<string> = [];
try{
privacyManager.on(type, permissionNameList, OnPermissionUseStateChanged);
}
......@@ -387,7 +399,7 @@ off(type: 'activeStateChange', permissionNameList: Array&lt;string&gt;, callback
import privacyManager from '@ohos.privacyManager';
let type: 'activeStateChange' = 'activeStateChange';
let permissionNameList: Array&lt;string&gt; = [];
let permissionNameList: Array<string> = [];
try{
privacyManager.off(type, permissionNameList);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册