提交 416ec750 编写于 作者: L liwuli

修改EDM示例代码

Signed-off-by: Nliwuli <liwuli@huawei.com>
上级 b6e7c063
...@@ -75,7 +75,7 @@ onBundleAdded(bundleName: string): void ...@@ -75,7 +75,7 @@ onBundleAdded(bundleName: string): void
```ts ```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onBundleAdded(bundleName: string) { onBundleAdded(bundleName: string) {
console.log("added bundle name: " + bundleName); console.info(`Succeeded in calling onBundleAdded callback, added bundle name : ${bundleName}`);
} }
}; };
``` ```
...@@ -100,8 +100,8 @@ onBundleRemoved(bundleName: string): void ...@@ -100,8 +100,8 @@ onBundleRemoved(bundleName: string): void
```ts ```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onBundleAdded(bundleName: string) { onBundleRemoved(bundleName: string) {
console.log("removed bundle name: " + bundleName); console.info(`Succeeded in calling onBundleRemoved callback, removed bundle name : ${bundleName}`);
} }
}; };
``` ```
...@@ -127,7 +127,7 @@ onAppStart(bundleName: string): void ...@@ -127,7 +127,7 @@ onAppStart(bundleName: string): void
```ts ```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAppStart(bundleName: string) { onAppStart(bundleName: string) {
console.log("started bundle name: " + bundleName); console.info(`Succeeded in calling onAppStart callback, started bundle name : ${bundleName}`);
} }
}; };
``` ```
...@@ -153,7 +153,7 @@ onAppStop(bundleName: string): void ...@@ -153,7 +153,7 @@ onAppStop(bundleName: string): void
```ts ```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAppStop(bundleName: string) { onAppStop(bundleName: string) {
console.log("stopped bundle name: " + bundleName); console.info(`Succeeded in calling onAppStop callback, stopped bundle name : ${bundleName}`);
} }
}; };
``` ```
...@@ -46,13 +46,16 @@ disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback& ...@@ -46,13 +46,16 @@ disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback&
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
accountManager.disallowAddLocalAccount(wantTemp, true, (error) => {
if (error != null) { accountManager.disallowAddLocalAccount(wantTemp, true, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to disallow add local account. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in disallowing add local account');
}); });
``` ```
...@@ -94,12 +97,13 @@ disallowAddLocalAccount(admin: Want, disallow: boolean): Promise&lt;void&gt; ...@@ -94,12 +97,13 @@ disallowAddLocalAccount(admin: Want, disallow: boolean): Promise&lt;void&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
accountManager.disallowAddLocalAccount(wantTemp, true).then(() => { accountManager.disallowAddLocalAccount(wantTemp, true).then(() => {
console.log("success"); console.info('Succeeded in disallowing add local account');
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to disallow add local account. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -47,19 +47,20 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba ...@@ -47,19 +47,20 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let enterpriseInfo = { let enterpriseInfo = {
name: "enterprise name", name: 'enterprise name',
description: "enterprise description" description: 'enterprise description'
} }
adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_SUPER, error => {
if (error != null) { adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_SUPER, (err) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to enable admin. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("enableAdmin success"); }
console.info('Succeeded in enabling admin');
}); });
``` ```
...@@ -99,19 +100,20 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId ...@@ -99,19 +100,20 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let enterpriseInfo = { let enterpriseInfo = {
name: "enterprise name", name: 'enterprise name',
description: "enterprise description" description: 'enterprise description'
} }
adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100, error => {
if (error != null) { adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100, (err) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to enable admin. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("enableAdmin success"); }
console.info('Succeeded in enabling admin');
}); });
``` ```
...@@ -156,16 +158,16 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId ...@@ -156,16 +158,16 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let enterpriseInfo = { let enterpriseInfo = {
name: "enterprise name", name: 'enterprise name',
description: "enterprise description" description: 'enterprise description'
} }
adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100)
.catch(error => { adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100).catch((err) => {
console.log("error occurs" + error); console.error(`Failed to enable admin. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -200,15 +202,16 @@ disableAdmin(admin: Want, callback: AsyncCallback\<void>): void ...@@ -200,15 +202,16 @@ disableAdmin(admin: Want, callback: AsyncCallback\<void>): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
adminManager.disableAdmin(wantTemp, error => {
if (error != null) { adminManager.disableAdmin(wantTemp, (err) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to disable admin. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("disableAdmin success "); }
console.info('Succeeded in disabling admin');
}); });
``` ```
...@@ -244,15 +247,16 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void ...@@ -244,15 +247,16 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
adminManager.disableAdmin(wantTemp, 100, error => {
if (error != null) { adminManager.disableAdmin(wantTemp, 100, (err) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to disable admin. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("disableAdmin success "); }
console.info('Succeeded in disabling admin');
}); });
``` ```
...@@ -293,11 +297,12 @@ disableAdmin(admin: Want, userId?: number): Promise\<void> ...@@ -293,11 +297,12 @@ disableAdmin(admin: Want, userId?: number): Promise\<void>
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
adminManager.disableAdmin(wantTemp, 100).catch(error => {
console.log("error occurs" + error); adminManager.disableAdmin(wantTemp, 100).catch((err) => {
console.error(`Failed to disable admin. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -331,13 +336,14 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void ...@@ -331,13 +336,14 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void
**示例** **示例**
```js ```js
let bundleName = "com.example.myapplication"; let bundleName = 'com.example.myapplication';
adminManager.disableSuperAdmin(bundleName, error => {
if (error != null) { adminManager.disableSuperAdmin(bundleName, (err) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to disable super admin. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("disableSuperAdmin success"); }
console.info('Succeeded in disabling super admin');
}); });
``` ```
...@@ -376,9 +382,10 @@ disableSuperAdmin(bundleName: String): Promise\<void> ...@@ -376,9 +382,10 @@ disableSuperAdmin(bundleName: String): Promise\<void>
**示例** **示例**
```js ```js
let bundleName = "com.example.myapplication"; let bundleName = 'com.example.myapplication';
adminManager.disableSuperAdmin(bundleName).catch(error => {
console.log("error occurs" + error); adminManager.disableSuperAdmin(bundleName).catch((err) => {
console.error(`Failed to disable super admin. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -403,15 +410,16 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void ...@@ -403,15 +410,16 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
adminManager.isAdminEnabled(wantTemp, (error, result) => {
if (error != null) { adminManager.isAdminEnabled(wantTemp, (err, result) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to query admin is enabled or not. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("result is " + result); }
console.info(`Succeeded in querying admin is enabled or not, result : ${result}`);
}); });
``` ```
...@@ -437,15 +445,16 @@ isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): ...@@ -437,15 +445,16 @@ isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>):
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
adminManager.isAdminEnabled(wantTemp, 100, (error, result) => {
if (error != null) { adminManager.isAdminEnabled(wantTemp, 100, (err, result) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to query admin is enabled. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("result is " + result); }
console.info(`Succeeded in querying admin is enabled or not, result : ${result}`);
}); });
``` ```
...@@ -476,13 +485,14 @@ isAdminEnabled(admin: Want, userId?: number): Promise\<boolean> ...@@ -476,13 +485,14 @@ isAdminEnabled(admin: Want, userId?: number): Promise\<boolean>
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
adminManager.isAdminEnabled(wantTemp, 100).then((result) => { adminManager.isAdminEnabled(wantTemp, 100).then((result) => {
console.log("result is " + result); console.info(`Succeeded in querying admin is enabled or not, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error occurs" + error); console.error(`Failed to query admin is enabled or not. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -506,13 +516,14 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void ...@@ -506,13 +516,14 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void
**示例** **示例**
```js ```js
let bundleName = "com.example.myapplication"; let bundleName = 'com.example.myapplication';
adminManager.isSuperAdmin(bundleName, (error, result) => {
if (error != null) { adminManager.isSuperAdmin(bundleName, (err, result) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to query admin is super admin or not. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("result is " + result); }
console.info(`Succeeded in querying admin is super admin or not, result : ${result}`);
}); });
``` ```
...@@ -541,11 +552,12 @@ isSuperAdmin(bundleName: String): Promise\<boolean> ...@@ -541,11 +552,12 @@ isSuperAdmin(bundleName: String): Promise\<boolean>
**示例** **示例**
```js ```js
let bundleName = "com.example.myapplication"; let bundleName = 'com.example.myapplication';
adminManager.isSuperAdmin(bundleName).then((result) => { adminManager.isSuperAdmin(bundleName).then((result) => {
console.log("result is " + result); console.info(`Succeeded in querying admin is super admin or not, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error occurs" + error); console.error(`Failed to query admin is super admin or not. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -581,19 +593,20 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCa ...@@ -581,19 +593,20 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCa
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let enterpriseInfo = { let enterpriseInfo = {
name: "enterprise name", name: 'enterprise name',
description: "enterprise description" description: 'enterprise description'
} }
adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => {
if (error != null) { adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo, (err) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to set enterprise info. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("setEnterpriseInfo success"); }
console.info('Succeeded in setting enterprise info');
}); });
``` ```
...@@ -634,15 +647,16 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>; ...@@ -634,15 +647,16 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let enterpriseInfo = { let enterpriseInfo = {
name: "enterprise name", name: 'enterprise name',
description: "enterprise description" description: 'enterprise description'
} }
adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => {
console.log("error occurs" + error); adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch((err) => {
console.error(`Failed to set enterprise info. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -675,16 +689,16 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback&lt;EnterpriseInfo&gt;): v ...@@ -675,16 +689,16 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback&lt;EnterpriseInfo&gt;): v
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
adminManager.getEnterpriseInfo(wantTemp, (error, result) => {
if (error != null) { adminManager.getEnterpriseInfo(wantTemp, (err, result) => {
console.log("error occurs" + error); if (err) {
return; console.error(`Failed to get enterprise info. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result.name); }
console.log(result.description); console.info(`Succeeded in getting enterprise info, enterprise name : ${result.name}, enterprise description : ${result.description}`);
}); });
``` ```
...@@ -722,14 +736,14 @@ getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt; ...@@ -722,14 +736,14 @@ getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
adminManager.getEnterpriseInfo(wantTemp).then((result) => { adminManager.getEnterpriseInfo(wantTemp).then((result) => {
console.log(result.name); console.info(`Succeeded in getting enterprise info, enterprise name : ${result.name}, enterprise description : ${result.description}`);
console.log(result.description); }).catch((err) => {
}).catch(error => { console.error(`Failed to get enterprise info. Code: ${err.code}, message: ${err.message}`);
console.log("error occurs" + error);
}); });
``` ```
...@@ -766,14 +780,17 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback ...@@ -766,14 +780,17 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
let events = [0, 1]; let events = [0, 1];
adminManager.subscribeManagedEvent(wantTemp, events, (error) => {
if (error) { adminManager.subscribeManagedEvent(wantTemp, events, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to subscribe managed event. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in subscribe managed event');
}); });
``` ```
...@@ -815,13 +832,14 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise ...@@ -815,13 +832,14 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
let events = [0, 1]; let events = [0, 1];
adminManager.subscribeManagedEvent(wantTemp, events).then(() => { adminManager.subscribeManagedEvent(wantTemp, events).then(() => {
}).catch((error) => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to subscribe managed event. Code: ${err.code}, message: ${err.message}`);
}) })
``` ```
...@@ -858,14 +876,17 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callba ...@@ -858,14 +876,17 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callba
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
let events = [0, 1]; let events = [0, 1];
adminManager.unsubscribeManagedEvent(wantTemp, events, (error) => {
if (error) { adminManager.unsubscribeManagedEvent(wantTemp, events, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to unsubscribe managed event. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info('Succeeded in unsubscribe managed event');
}); });
``` ```
...@@ -907,13 +928,14 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promi ...@@ -907,13 +928,14 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promi
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
let events = [0, 1]; let events = [0, 1];
adminManager.unsubscribeManagedEvent(wantTemp, events).then(() => { adminManager.unsubscribeManagedEvent(wantTemp, events).then(() => {
}).catch((error) => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to unsubscribe managed event. Code: ${err.code}, message: ${err.message}`);
}) })
``` ```
......
...@@ -47,15 +47,17 @@ addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: Async ...@@ -47,15 +47,17 @@ addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: Async
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let appIds = ["com.example.myapplication"]; let appIds = ['com.example.myapplication'];
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => { applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (err) => {
if (error != null) { if (err) {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to add disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
} return;
}
console.info('Succeeded in adding disallowed running bundles');
}); });
``` ```
...@@ -93,15 +95,17 @@ addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: number, ...@@ -93,15 +95,17 @@ addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: number,
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let appIds = ["com.example.myapplication"]; let appIds = ['com.example.myapplication'];
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (err) => {
if (error != null) { if (err) {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to add disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
} return;
}
console.info('Succeeded in adding disallowed running bundles');
}); });
``` ```
...@@ -144,15 +148,15 @@ addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: number ...@@ -144,15 +148,15 @@ addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: number
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let appIds = ["com.example.myapplication"]; let appIds = ['com.example.myapplication'];
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.info('Succeeded in adding disallowed running bundles');
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to add disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
}); });
``` ```
...@@ -189,15 +193,17 @@ removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: As ...@@ -189,15 +193,17 @@ removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: As
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let appIds = ["com.example.myapplication"]; let appIds = ['com.example.myapplication'];
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => { applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (err) => {
if (error != null) { if (err) {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to remove disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
} return;
}
console.info('Succeeded in removing disallowed running bundles');
}); });
``` ```
...@@ -235,15 +241,17 @@ removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: numb ...@@ -235,15 +241,17 @@ removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: numb
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let appIds = ["com.example.myapplication"]; let appIds = ['com.example.myapplication'];
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => { applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (err) => {
if (error != null) { if (err) {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to remove disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
} return;
}
console.info('Succeeded in removing disallowed running bundles');
}); });
``` ```
...@@ -286,15 +294,15 @@ removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: num ...@@ -286,15 +294,15 @@ removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: num
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let appIds = ["com.example.myapplication"]; let appIds = ['com.example.myapplication'];
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => { applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
console.log("success"); console.info('Succeeded in removing disallowed running bundles');
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to remove disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
}); });
``` ```
...@@ -330,14 +338,16 @@ getDisallowedRunningBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;str ...@@ -330,14 +338,16 @@ getDisallowedRunningBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;str
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
applicationManager.getDisallowedRunningBundles(wantTemp, (error) => { applicationManager.getDisallowedRunningBundles(wantTemp, (err, result) => {
if (error != null) { if (err) {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
} return;
}
console.info(`Succeeded in getting disallowed running bundles, result : ${JSON.stringify(result)}`);
}); });
``` ```
...@@ -374,14 +384,16 @@ getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback ...@@ -374,14 +384,16 @@ getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
applicationManager.getDisallowedRunningBundles(wantTemp, 100, (error) => { applicationManager.getDisallowedRunningBundles(wantTemp, 100, (err, result) => {
if (error != null) { if (err) {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
} return;
}
console.info(`Succeeded in getting disallowed running bundles, result : ${JSON.stringify(result)}`);
}); });
``` ```
...@@ -423,12 +435,13 @@ getDisallowedRunningBundles(admin: Want, userId?: number): Promise&lt;Array&lt;s ...@@ -423,12 +435,13 @@ getDisallowedRunningBundles(admin: Want, userId?: number): Promise&lt;Array&lt;s
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
applicationManager.getDisallowedRunningBundles(wantTemp, 100).then(() => {
console.log("success"); applicationManager.getDisallowedRunningBundles(wantTemp, 100).then((result) => {
}).catch(error => { console.info(`Succeeded in getting disallowed running bundles, result : ${JSON.stringify(result)}`);
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to get disallowed running bundles. Code is ${err.code}, message is ${err.message}`);
}); });
``` ```
...@@ -46,13 +46,16 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void ...@@ -46,13 +46,16 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
dateTimeManager.setDateTime(wantTemp, 1526003846000, (error) => {
if (error) { dateTimeManager.setDateTime(wantTemp, 1526003846000, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to set date time. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in setting date time');
}) })
``` ```
...@@ -94,12 +97,14 @@ setDateTime(admin: Want, time: number): Promise\<void> ...@@ -94,12 +97,14 @@ setDateTime(admin: Want, time: number): Promise\<void>
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => { dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => {
}).catch((error) => { console.info('Succeeded in setting date time');
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to set date time. Code is ${err.code}, message is ${err.message}`);
}) })
``` ```
...@@ -136,13 +141,16 @@ disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback\< ...@@ -136,13 +141,16 @@ disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback\<
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
dateTimeManager.disallowModifyDateTime(wantTemp, true, (error) => {
if (error) { dateTimeManager.disallowModifyDateTime(wantTemp, true, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to disallow modify date time. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info('Succeeded in disallowing modify date time');
}) })
``` ```
...@@ -184,12 +192,14 @@ disallowModifyDateTime(admin: Want, disallow: boolean): Promise\<void> ...@@ -184,12 +192,14 @@ disallowModifyDateTime(admin: Want, disallow: boolean): Promise\<void>
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
dateTimeManager.disallowModifyDateTime(wantTemp, true).then(() => { dateTimeManager.disallowModifyDateTime(wantTemp, true).then(() => {
}).catch((error) => { console.info('Succeeded in disallowing modify date time');
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to disallow modify date time. Code is ${err.code}, message is ${err.message}`);
}) })
``` ```
...@@ -225,13 +235,16 @@ isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback\<boolean>): void ...@@ -225,13 +235,16 @@ isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback\<boolean>): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
dateTimeManager.isModifyDateTimeDisallowed(wantTemp, (error) => {
if (error) { dateTimeManager.isModifyDateTimeDisallowed(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to query modify date time is disallowed or not. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in querying modify date time is disallowed : ${result}`);
}) })
``` ```
...@@ -272,11 +285,13 @@ isModifyDateTimeDisallowed(admin: Want): Promise\<boolean> ...@@ -272,11 +285,13 @@ isModifyDateTimeDisallowed(admin: Want): Promise\<boolean>
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
dateTimeManager.isModifyDateTimeDisallowed(wantTemp).then(() => {
}).catch((error) => { dateTimeManager.isModifyDateTimeDisallowed(wantTemp).then((result) => {
console.log("error code:" + error.code + " error message:" + error.message); console.info(`Succeeded in querying modify date time is disallowed : ${result}`);
}).catch((err) => {
console.error(`Failed to query modify date time is disallowed or not. Code is ${err.code}, message is ${err.message}`);
}) })
``` ```
\ No newline at end of file
...@@ -45,13 +45,16 @@ resetFactory(admin: Want, callback: AsyncCallback\<void>): void ...@@ -45,13 +45,16 @@ resetFactory(admin: Want, callback: AsyncCallback\<void>): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
deviceControl.resetFactory(wantTemp, (error) => {
if (error) { deviceControl.resetFactory(wantTemp, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
} console.error(`Failed to reset factory. Code is ${err.code}, message is ${err.message}`);
return;
}
console.log('Succeeded in resetting factory');
}) })
``` ```
...@@ -92,11 +95,12 @@ resetFactory(admin: Want): Promise\<void> ...@@ -92,11 +95,12 @@ resetFactory(admin: Want): Promise\<void>
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "bundleName", bundleName: 'bundleName',
abilityName: "abilityName", abilityName: 'abilityName',
}; };
deviceControl.resetFactory(wantTemp).then(() => { deviceControl.resetFactory(wantTemp).then(() => {
}).catch((error) => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to reset factory. Code is ${err.code}, message is ${err.message}`);
}) })
``` ```
...@@ -45,15 +45,16 @@ getDeviceSerial(admin: Want, callback: AsyncCallback&lt;string&gt;): void ...@@ -45,15 +45,16 @@ getDeviceSerial(admin: Want, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceInfo.getDeviceSerial(wantTemp, (error, result) => {
if (error != null) { deviceInfo.getDeviceSerial(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get device serial. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result); }
console.info(`Succeeded in getting device serial, result : ${result}`);
}); });
``` ```
...@@ -94,13 +95,14 @@ getDeviceSerial(admin: Want): Promise&lt;string&gt; ...@@ -94,13 +95,14 @@ getDeviceSerial(admin: Want): Promise&lt;string&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceInfo.getDeviceSerial(wantTemp).then((result) => { deviceInfo.getDeviceSerial(wantTemp).then((result) => {
console.log(result); console.info(`Succeeded in getting device serial, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get device serial. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -136,15 +138,16 @@ getDisplayVersion(admin: Want, callback: AsyncCallback&lt;string&gt;): void; ...@@ -136,15 +138,16 @@ getDisplayVersion(admin: Want, callback: AsyncCallback&lt;string&gt;): void;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceInfo.getDisplayVersion(wantTemp, (error, result) => {
if (error != null) { deviceInfo.getDisplayVersion(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get display version. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result); }
console.info(`Succeeded in getting display version, result : ${result}`);
}); });
``` ```
...@@ -185,13 +188,14 @@ getDisplayVersion(admin: Want): Promise&lt;string&gt; ...@@ -185,13 +188,14 @@ getDisplayVersion(admin: Want): Promise&lt;string&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceInfo.getDisplayVersion(wantTemp).then((result) => { deviceInfo.getDisplayVersion(wantTemp).then((result) => {
console.log(result); console.info(`Succeeded in getting display version, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get display version. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -227,15 +231,16 @@ getDeviceName(admin: Want, callback: AsyncCallback&lt;string&gt;): void ...@@ -227,15 +231,16 @@ getDeviceName(admin: Want, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceInfo.getDeviceName(wantTemp, (error, result) => {
if (error != null) { deviceInfo.getDeviceName(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get device name. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result); }
console.info(`Succeeded in getting device name, result : ${result}`);
}); });
``` ```
...@@ -276,12 +281,13 @@ getDeviceName(admin: Want): Promise&lt;string&gt; ...@@ -276,12 +281,13 @@ getDeviceName(admin: Want): Promise&lt;string&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceInfo.getDeviceName(wantTemp).then((result) => { deviceInfo.getDeviceName(wantTemp).then((result) => {
console.log(result); console.info(`Succeeded in getting device name, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get device name. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
\ No newline at end of file
...@@ -44,15 +44,16 @@ getScreenOffTime(admin: Want, callback: AsyncCallback&lt;number&gt;): void ...@@ -44,15 +44,16 @@ getScreenOffTime(admin: Want, callback: AsyncCallback&lt;number&gt;): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceSettings.getScreenOffTime(wantTemp, (error, result) => {
if (error != null) { deviceSettings.getScreenOffTime(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get screen off time. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result); }
console.info(`Succeeded in getting screen off time, result : ${result}`);
}); });
``` ```
...@@ -93,12 +94,13 @@ getScreenOffTime(admin: Want): Promise&lt;number&gt; ...@@ -93,12 +94,13 @@ getScreenOffTime(admin: Want): Promise&lt;number&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
deviceSettings.getScreenOffTime(wantTemp).then((result) => { deviceSettings.getScreenOffTime(wantTemp).then((result) => {
console.log(result); console.info(`Succeeded in getting screen off time, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get screen off time. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
\ No newline at end of file
...@@ -45,15 +45,16 @@ getAllNetworkInterfaces(admin: Want, callback: AsyncCallback&lt;Array&lt;string& ...@@ -45,15 +45,16 @@ getAllNetworkInterfaces(admin: Want, callback: AsyncCallback&lt;Array&lt;string&
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.getAllNetworkInterfaces(wantTemp, (error, result) => {
if (error != null) { networkManager.getAllNetworkInterfaces(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get all network interfaces. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(JSON.stringify(result)); }
console.info(`Succeeded in getting all network interfaces, result : ${JSON.stringify(result)}`);
}); });
``` ```
...@@ -94,13 +95,14 @@ getAllNetworkInterfaces(admin: Want): Promise&lt;Array&lt;string&gt;&gt; ...@@ -94,13 +95,14 @@ getAllNetworkInterfaces(admin: Want): Promise&lt;Array&lt;string&gt;&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.getAllNetworkInterfaces(wantTemp).then((result) => { networkManager.getAllNetworkInterfaces(wantTemp).then((result) => {
console.log(JSON.stringify(result)); console.info(`Succeeded in getting all network interfaces, result : ${JSON.stringify(result)}`);
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to get all network interfaces. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -137,15 +139,16 @@ getIpAddress(admin: Want, networkInterface: string, callback: AsyncCallback&lt;s ...@@ -137,15 +139,16 @@ getIpAddress(admin: Want, networkInterface: string, callback: AsyncCallback&lt;s
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.getIpAddress(wantTemp, "eth0", (error, result) => {
if (error != null) { networkManager.getIpAddress(wantTemp, 'eth0', (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get ip address. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result); }
console.info(`Succeeded in getting ip address, result : ${result}`);
}); });
``` ```
...@@ -187,13 +190,14 @@ getIpAddress(admin: Want, networkInterface: string): Promise&lt;string&gt; ...@@ -187,13 +190,14 @@ getIpAddress(admin: Want, networkInterface: string): Promise&lt;string&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.getIpAddress(wantTemp, "eth0").then((result) => {
console.log(result); networkManager.getIpAddress(wantTemp, 'eth0').then((result) => {
}).catch(error => { console.info(`Succeeded in getting ip address, result : ${result}`);
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to get ip address. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -230,21 +234,22 @@ getMac(admin: Want, networkInterface: string, callback: AsyncCallback&lt;string& ...@@ -230,21 +234,22 @@ getMac(admin: Want, networkInterface: string, callback: AsyncCallback&lt;string&
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.getMac(wantTemp, "eth0", (error, result) => {
if (error != null) { networkManager.getMac(wantTemp, 'eth0', (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to get mac. Code: ${err.code}, message: ${err.message}`);
} return;
console.log(result); }
console.info(`Succeeded in getting mac, result : ${result}`);
}); });
``` ```
## networkManager.getMac ## networkManager.getMac
getIpAddress(admin: Want, networkInterface: string): Promise&lt;string&gt; getMac(admin: Want, networkInterface: string): Promise\<string>;
指定设备管理员应用根据networkInterface获取设备MAC地址,使用Promise形式返回设备IP地址。 指定设备管理员应用根据networkInterface获取设备MAC地址,使用Promise形式返回设备IP地址。
...@@ -280,13 +285,14 @@ getIpAddress(admin: Want, networkInterface: string): Promise&lt;string&gt; ...@@ -280,13 +285,14 @@ getIpAddress(admin: Want, networkInterface: string): Promise&lt;string&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.getMac(wantTemp, "eth0").then((result) => {
console.log(result); networkManager.getMac(wantTemp, 'eth0').then((result) => {
}).catch(error => { console.info(`Succeeded in getting mac, result : ${result}`);
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to get mac. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -323,15 +329,16 @@ isNetworkInterfaceDisabled(admin: Want, networkInterface: string, callback: Asyn ...@@ -323,15 +329,16 @@ isNetworkInterfaceDisabled(admin: Want, networkInterface: string, callback: Asyn
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.isNetworkInterfaceDisabled(wantTemp, "eth0", (error, result) => {
if (error != null) { networkManager.isNetworkInterfaceDisabled(wantTemp, 'eth0', (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to query network interface is disabled or not. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("result:" + result); }
console.info(`Succeeded in querying network interface is disabled or not, result : ${result}`);
}); });
``` ```
...@@ -373,13 +380,14 @@ isNetworkInterfaceDisabled(admin: Want, networkInterface: string): Promise&lt;bo ...@@ -373,13 +380,14 @@ isNetworkInterfaceDisabled(admin: Want, networkInterface: string): Promise&lt;bo
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.isNetworkInterfaceDisabled(wantTemp, "eth0").then((result) => {
console.log("result:" + result); networkManager.isNetworkInterfaceDisabled(wantTemp, 'eth0').then((result) => {
}).catch(error => { console.info(`Succeeded in querying network interface is disabled or not, result : ${result}`);
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to query network interface is disabled or not. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -417,15 +425,16 @@ setNetworkInterfaceDisabled(admin: Want, networkInterface: string, isDisabled: b ...@@ -417,15 +425,16 @@ setNetworkInterfaceDisabled(admin: Want, networkInterface: string, isDisabled: b
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.setNetworkInterfaceDisabled(wantTemp, "eth0", true, (error) => {
if (error != null) { networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to set network interface disabled. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("setNetworkInterfaceDisabled success!"); }
console.info(`Succeeded in setting network interface disabled`);
}); });
``` ```
...@@ -468,12 +477,13 @@ setNetworkInterfaceDisabled(admin: Want, networkInterface: string, isDisabled: b ...@@ -468,12 +477,13 @@ setNetworkInterfaceDisabled(admin: Want, networkInterface: string, isDisabled: b
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
networkManager.setNetworkInterfaceDisabled(wantTemp, "eth0", true).then(() => {
console.log("setNetworkInterfaceDisabled success!"); networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true).then(() => {
}).catch(error => { console.info(`Succeeded in setting network interface disabled`);
console.log("error code:" + error.code + " error message:" + error.message); }).catch((err) => {
console.error(`Failed to set network interface disabled. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
\ No newline at end of file
...@@ -45,15 +45,16 @@ isWifiActive(admin: Want, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -45,15 +45,16 @@ isWifiActive(admin: Want, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
wifiManager.isWifiActive(wantTemp, (error, result) => {
if (error != null) { wifiManager.isWifiActive(wantTemp, (err, result) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to query is wifi active or not. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("result:" + result); }
console.info(`Succeeded in query is wifi active or not, result : ${result}`);
}); });
``` ```
...@@ -94,13 +95,14 @@ isWifiActive(admin: Want): Promise&lt;boolean&gt; ...@@ -94,13 +95,14 @@ isWifiActive(admin: Want): Promise&lt;boolean&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
wifiManager.isWifiActive(wantTemp).then((result) => { wifiManager.isWifiActive(wantTemp).then((result) => {
console.log("result:" + result); console.info(`Succeeded in query is wifi active or not, result : ${result}`);
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to query is wifi active or not. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
...@@ -137,20 +139,21 @@ setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback&lt;voi ...@@ -137,20 +139,21 @@ setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback&lt;voi
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let profile : wifiManager.WifiProfile = { let profile: wifiManager.WifiProfile = {
"ssid": "name", 'ssid': 'name',
"preSharedKey": "passwd", 'preSharedKey': 'passwd',
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK 'securityType': wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
}; };
wifiManager.setWifiProfile(wantTemp, profile, (error) => {
if (error != null) { wifiManager.setWifiProfile(wantTemp, profile, (err) => {
console.log("error code:" + error.code + " error message:" + error.message); if (err) {
return; console.error(`Failed to set wifi profile. Code: ${err.code}, message: ${err.message}`);
} return;
console.log("set wifi success"); }
console.info('Succeeded in setting wifi profile');
}); });
``` ```
...@@ -192,18 +195,19 @@ setWifiProfile(admin: Want, profile: WifiProfile): Promise&lt;void&gt; ...@@ -192,18 +195,19 @@ setWifiProfile(admin: Want, profile: WifiProfile): Promise&lt;void&gt;
```js ```js
let wantTemp = { let wantTemp = {
bundleName: "com.example.myapplication", bundleName: 'com.example.myapplication',
abilityName: "EntryAbility", abilityName: 'EntryAbility',
}; };
let profile : wifiManager.WifiProfile = { let profile : wifiManager.WifiProfile = {
"ssid": "name", 'ssid': 'name',
"preSharedKey": "passwd", 'preSharedKey': 'passwd',
"securityType": wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK 'securityType': wifiManager.WifiSecurityType.WIFI_SEC_TYPE_PSK
}; };
wifiManager.setWifiProfile(wantTemp, profile).then(() => { wifiManager.setWifiProfile(wantTemp, profile).then(() => {
console.log("set wifi success"); console.info('Succeeded in setting wifi profile');
}).catch(error => { }).catch((err) => {
console.log("error code:" + error.code + " error message:" + error.message); console.error(`Failed to set wifi profile. Code: ${err.code}, message: ${err.message}`);
}); });
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册