提交 817bc7a7 编写于 作者: G Gloria

Update docs against 15219+15270+14979+14614+14265

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 7dea9ec9
...@@ -72,13 +72,13 @@ const config = { ...@@ -72,13 +72,13 @@ const config = {
try { try {
abilityManager.updateConfiguration(config, (err) => { abilityManager.updateConfiguration(config, (err) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('updateConfiguration fail, err: ${JSON.stringify(err)}'); console.error('updateConfiguration fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('updateConfiguration success.'); console.log('updateConfiguration success.');
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
``` ```
...@@ -130,10 +130,10 @@ try { ...@@ -130,10 +130,10 @@ try {
abilityManager.updateConfiguration(config).then(() => { abilityManager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success.'); console.log('updateConfiguration success.');
}).catch((err) => { }).catch((err) => {
console.log('updateConfiguration fail, err: ${JSON.stringify(err)}'); console.error('updateConfiguration fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
``` ```
...@@ -169,13 +169,13 @@ import abilityManager from '@ohos.app.ability.abilityManager'; ...@@ -169,13 +169,13 @@ import abilityManager from '@ohos.app.ability.abilityManager';
try { try {
abilityManager.getAbilityRunningInfos((err, data) => { abilityManager.getAbilityRunningInfos((err, data) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('getAbilityRunningInfos fail, error: ${JSON.stringify(err)}'); console.error('getAbilityRunningInfos fail, error: ${JSON.stringify(err)}');
} else { } else {
console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}'); console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}');
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
``` ```
...@@ -212,10 +212,10 @@ try { ...@@ -212,10 +212,10 @@ try {
abilityManager.getAbilityRunningInfos().then((data) => { abilityManager.getAbilityRunningInfos().then((data) => {
console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}'); console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getAbilityRunningInfos fail, err: ${JSON.stringify(err)}'); console.error('getAbilityRunningInfos fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
``` ```
...@@ -254,13 +254,13 @@ let upperLimit = 10; ...@@ -254,13 +254,13 @@ let upperLimit = 10;
try { try {
abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => { abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}'); console.error('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}'); console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}');
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
``` ```
...@@ -305,10 +305,10 @@ try { ...@@ -305,10 +305,10 @@ try {
abilityManager.getExtensionRunningInfos(upperLimit).then((data) => { abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}'); console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}'); console.error('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}'); console.error('error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}');
} }
``` ```
...@@ -341,7 +341,7 @@ import abilityManager from '@ohos.app.ability.abilityManager'; ...@@ -341,7 +341,7 @@ import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager.getTopAbility((err, data) => { abilityManager.getTopAbility((err, data) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('getTopAbility fail, err: ${JSON.stringify(err)}'); console.error('getTopAbility fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('getTopAbility success, data: ${JSON.stringify(data)}'); console.log('getTopAbility success, data: ${JSON.stringify(data)}');
} }
...@@ -378,6 +378,6 @@ import abilityManager from '@ohos.app.ability.abilityManager'; ...@@ -378,6 +378,6 @@ import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager.getTopAbility().then((data) => { abilityManager.getTopAbility().then((data) => {
console.log('getTopAbility success, data: ${JSON.stringify(data)}'); console.log('getTopAbility success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getTopAbility fail, err: ${JSON.stringify(err)}'); console.error('getTopAbility fail, err: ${JSON.stringify(err)}');
}); });
``` ```
...@@ -41,7 +41,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -41,7 +41,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.isRunningInStabilityTest((err, flag) => { appManager.isRunningInStabilityTest((err, flag) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('isRunningInStabilityTest fail, err: ${JSON.stringify(err)}'); console.error('isRunningInStabilityTest fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}'); console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
} }
...@@ -79,7 +79,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -79,7 +79,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.isRunningInStabilityTest().then((flag) => { appManager.isRunningInStabilityTest().then((flag) => {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}'); console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -114,7 +114,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -114,7 +114,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.isRamConstrainedDevice().then((data) => { appManager.isRamConstrainedDevice().then((data) => {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}'); console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -147,7 +147,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -147,7 +147,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.isRamConstrainedDevice((err, data) => { appManager.isRamConstrainedDevice((err, data) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('isRamConstrainedDevice fail, err: ${JSON.stringify(err)}'); console.error('isRamConstrainedDevice fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}'); console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
} }
...@@ -184,7 +184,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -184,7 +184,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getAppMemorySize().then((data) => { appManager.getAppMemorySize().then((data) => {
console.log('The size of app memory is: ${JSON.stringify(data)}'); console.log('The size of app memory is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -217,7 +217,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -217,7 +217,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getAppMemorySize((err, data) => { appManager.getAppMemorySize((err, data) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('getAppMemorySize fail, err: ${JSON.stringify(err)}'); console.error('getAppMemorySize fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('The size of app memory is: ${JSON.stringify(data)}'); console.log('The size of app memory is: ${JSON.stringify(data)}');
} }
...@@ -256,7 +256,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -256,7 +256,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getRunningProcessInformation().then((data) => { appManager.getRunningProcessInformation().then((data) => {
console.log('The running process information is: ${JSON.stringify(data)}'); console.log('The running process information is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -291,7 +291,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -291,7 +291,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getRunningProcessInformation((err, data) => { appManager.getRunningProcessInformation((err, data) => {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('getRunningProcessInformation fail, err: ${JSON.stringify(err)}'); console.error('getRunningProcessInformation fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('The process running information is: ${JSON.stringify(data)}'); console.log('The process running information is: ${JSON.stringify(data)}');
} }
...@@ -357,7 +357,7 @@ try { ...@@ -357,7 +357,7 @@ try {
const observerId = appManager.on('applicationState', applicationStateObserver); const observerId = appManager.on('applicationState', applicationStateObserver);
console.log(`[appManager] observerCode: ${observerId}`); console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) { } catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); console.error(`[appManager] error: ${paramError.code}, ${paramError.message} `);
} }
``` ```
...@@ -422,7 +422,7 @@ try { ...@@ -422,7 +422,7 @@ try {
const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
console.log(`[appManager] observerCode: ${observerId}`); console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) { } catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); console.error(`[appManager] error: ${paramError.code}, ${paramError.message} `);
} }
``` ```
...@@ -484,13 +484,13 @@ try { ...@@ -484,13 +484,13 @@ try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
console.log(`[appManager] observerCode: ${observerId}`); console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) { } catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); console.error(`[appManager] error: ${paramError.code}, ${paramError.message} `);
} }
// 2. Deregister the application state observer. // 2. Deregister the application state observer.
function unregisterApplicationStateObserverCallback(err) { function unregisterApplicationStateObserverCallback(err) {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('unregisterApplicationStateObserverCallback fail, err: ${JSON.stringify(err)}'); console.error('unregisterApplicationStateObserverCallback fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('unregisterApplicationStateObserverCallback success.'); console.log('unregisterApplicationStateObserverCallback success.');
} }
...@@ -498,7 +498,7 @@ function unregisterApplicationStateObserverCallback(err) { ...@@ -498,7 +498,7 @@ function unregisterApplicationStateObserverCallback(err) {
try { try {
appManager.off('applicationState', observerId, unregisterApplicationStateObserverCallback); appManager.off('applicationState', observerId, unregisterApplicationStateObserverCallback);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -565,7 +565,7 @@ try { ...@@ -565,7 +565,7 @@ try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList); observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
console.log(`[appManager] observerCode: ${observerId}`); console.log(`[appManager] observerCode: ${observerId}`);
} catch (paramError) { } catch (paramError) {
console.log(`[appManager] error: ${paramError.code}, ${paramError.message} `); console.error(`[appManager] error: ${paramError.code}, ${paramError.message} `);
} }
// 2. Deregister the application state observer. // 2. Deregister the application state observer.
...@@ -573,10 +573,10 @@ try { ...@@ -573,10 +573,10 @@ try {
appManager.off('applicationState', observerId).then((data) => { appManager.off('applicationState', observerId).then((data) => {
console.log('unregisterApplicationStateObserver success, data: ${JSON.stringify(data)}'); console.log('unregisterApplicationStateObserver success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('unregisterApplicationStateObserver fail, err: ${JSON.stringify(err)}'); console.error('unregisterApplicationStateObserver fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -613,7 +613,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -613,7 +613,7 @@ import appManager from '@ohos.app.ability.appManager';
function getForegroundApplicationsCallback(err, data) { function getForegroundApplicationsCallback(err, data) {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('getForegroundApplicationsCallback fail, err: ${JSON.stringify(err)}'); console.error('getForegroundApplicationsCallback fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('getForegroundApplicationsCallback success, data: ${JSON.stringify(data)}'); console.log('getForegroundApplicationsCallback success, data: ${JSON.stringify(data)}');
} }
...@@ -621,7 +621,7 @@ function getForegroundApplicationsCallback(err, data) { ...@@ -621,7 +621,7 @@ function getForegroundApplicationsCallback(err, data) {
try { try {
appManager.getForegroundApplications(getForegroundApplicationsCallback); appManager.getForegroundApplications(getForegroundApplicationsCallback);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -659,7 +659,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -659,7 +659,7 @@ import appManager from '@ohos.app.ability.appManager';
appManager.getForegroundApplications().then((data) => { appManager.getForegroundApplications().then((data) => {
console.log('getForegroundApplications success, data: ${JSON.stringify(data)}'); console.log('getForegroundApplications success, data: ${JSON.stringify(data)}');
}).catch((err) => { }).catch((err) => {
console.log('getForegroundApplications fail, err: ${JSON.stringify(err)}'); console.error('getForegroundApplications fail, err: ${JSON.stringify(err)}');
}); });
``` ```
...@@ -746,7 +746,7 @@ let bundleName = 'bundleName'; ...@@ -746,7 +746,7 @@ let bundleName = 'bundleName';
let accountId = 0; let accountId = 0;
function killProcessWithAccountCallback(err, data) { function killProcessWithAccountCallback(err, data) {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('killProcessWithAccountCallback fail, err: ${JSON.stringify(err)}'); console.error('killProcessWithAccountCallback fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('killProcessWithAccountCallback success.'); console.log('killProcessWithAccountCallback success.');
} }
...@@ -789,7 +789,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -789,7 +789,7 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName'; let bundleName = 'bundleName';
function killProcessesByBundleNameCallback(err, data) { function killProcessesByBundleNameCallback(err, data) {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('killProcessesByBundleNameCallback fail, err: ${JSON.stringify(err)}'); console.error('killProcessesByBundleNameCallback fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('killProcessesByBundleNameCallback success.'); console.log('killProcessesByBundleNameCallback success.');
} }
...@@ -797,7 +797,7 @@ function killProcessesByBundleNameCallback(err, data) { ...@@ -797,7 +797,7 @@ function killProcessesByBundleNameCallback(err, data) {
try { try {
appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback); appManager.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -843,10 +843,10 @@ try { ...@@ -843,10 +843,10 @@ try {
appManager.killProcessesByBundleName(bundleName).then((data) => { appManager.killProcessesByBundleName(bundleName).then((data) => {
console.log('killProcessesByBundleName success.'); console.log('killProcessesByBundleName success.');
}).catch((err) => { }).catch((err) => {
console.log('killProcessesByBundleName fail, err: ${JSON.stringify(err)}'); console.error('killProcessesByBundleName fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -885,7 +885,7 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -885,7 +885,7 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName'; let bundleName = 'bundleName';
function clearUpApplicationDataCallback(err, data) { function clearUpApplicationDataCallback(err, data) {
if (err && err.code !== 0) { if (err && err.code !== 0) {
console.log('clearUpApplicationDataCallback fail, err: ${JSON.stringify(err)}'); console.error('clearUpApplicationDataCallback fail, err: ${JSON.stringify(err)}');
} else { } else {
console.log('clearUpApplicationDataCallback success.'); console.log('clearUpApplicationDataCallback success.');
} }
...@@ -893,7 +893,7 @@ function clearUpApplicationDataCallback(err, data) { ...@@ -893,7 +893,7 @@ function clearUpApplicationDataCallback(err, data) {
try { try {
appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback); appManager.clearUpApplicationData(bundleName, clearUpApplicationDataCallback);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -939,10 +939,10 @@ try { ...@@ -939,10 +939,10 @@ try {
appManager.clearUpApplicationData(bundleName).then((data) => { appManager.clearUpApplicationData(bundleName).then((data) => {
console.log('clearUpApplicationData success.'); console.log('clearUpApplicationData success.');
}).catch((err) => { }).catch((err) => {
console.log('clearUpApplicationData fail, err: ${JSON.stringify(err)}'); console.error('clearUpApplicationData fail, err: ${JSON.stringify(err)}');
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
......
...@@ -42,7 +42,7 @@ export default class EntryAbility extends UIAbility { ...@@ -42,7 +42,7 @@ export default class EntryAbility extends UIAbility {
let callbackId = applicationContext.on('environment', envCallback); let callbackId = applicationContext.on('environment', envCallback);
console.log('callbackId: ${callbackId}'); console.log('callbackId: ${callbackId}');
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
} }
} }
......
...@@ -73,7 +73,11 @@ export default class MyAbility extends UIAbility { ...@@ -73,7 +73,11 @@ export default class MyAbility extends UIAbility {
onDestroy() { onDestroy() {
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log('unregisterEnvironmentCallback success, err: ${JSON.stringify(error)}'); if (error && error.code !== 0) {
console.error('unregisterEnvironmentCallback fail, error: ${JSON.stringify(error)}');
} else {
console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}');
}
}); });
} }
} }
......
...@@ -44,7 +44,7 @@ let observerId = -1; ...@@ -44,7 +44,7 @@ let observerId = -1;
try { try {
observerId = errorManager.on('error', observer); observerId = errorManager.on('error', observer);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -71,13 +71,13 @@ let observerId = 100; ...@@ -71,13 +71,13 @@ let observerId = 100;
function unregisterErrorObserverCallback(err) { function unregisterErrorObserverCallback(err) {
if (err) { if (err) {
console.log('------------ unregisterErrorObserverCallback ------------', err); console.error('------------ unregisterErrorObserverCallback ------------', err);
} }
} }
try { try {
errorManager.off('error', observerId, unregisterErrorObserverCallback); errorManager.off('error', observerId, unregisterErrorObserverCallback);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -112,10 +112,10 @@ try { ...@@ -112,10 +112,10 @@ try {
console.log('----------- unregisterErrorObserver success ----------', data); console.log('----------- unregisterErrorObserver success ----------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err); console.error('----------- unregisterErrorObserver fail ----------', err);
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -73,7 +73,7 @@ export default class EntryAbility extends UIAbility { ...@@ -73,7 +73,7 @@ export default class EntryAbility extends UIAbility {
}); });
} }
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
console.log('[Demo] EntryAbility onDestroy'); console.log('[Demo] EntryAbility onDestroy');
} }
...@@ -84,7 +84,7 @@ export default class EntryAbility extends UIAbility { ...@@ -84,7 +84,7 @@ export default class EntryAbility extends UIAbility {
try { try {
listenerId = missionManager.on('mission', listener); listenerId = missionManager.on('mission', listener);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
windowStage.loadContent('pages/index', (err, data) => { windowStage.loadContent('pages/index', (err, data) => {
...@@ -155,7 +155,7 @@ export default class EntryAbility extends UIAbility { ...@@ -155,7 +155,7 @@ export default class EntryAbility extends UIAbility {
}); });
} }
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
console.log('[Demo] EntryAbility onDestroy'); console.log('[Demo] EntryAbility onDestroy');
} }
...@@ -166,7 +166,7 @@ export default class EntryAbility extends UIAbility { ...@@ -166,7 +166,7 @@ export default class EntryAbility extends UIAbility {
try { try {
listenerId = missionManager.on('mission', listener); listenerId = missionManager.on('mission', listener);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
windowStage.loadContent('pages/index', (err, data) => { windowStage.loadContent('pages/index', (err, data) => {
...@@ -242,7 +242,7 @@ export default class EntryAbility extends UIAbility { ...@@ -242,7 +242,7 @@ export default class EntryAbility extends UIAbility {
}); });
} }
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
console.log('[Demo] EntryAbility onDestroy'); console.log('[Demo] EntryAbility onDestroy');
} }
...@@ -253,7 +253,7 @@ export default class EntryAbility extends UIAbility { ...@@ -253,7 +253,7 @@ export default class EntryAbility extends UIAbility {
try { try {
listenerId = missionManager.on('mission', listener); listenerId = missionManager.on('mission', listener);
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
windowStage.loadContent('pages/index', (err, data) => { windowStage.loadContent('pages/index', (err, data) => {
...@@ -306,7 +306,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal ...@@ -306,7 +306,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
missionManager.getMissionInfo('', testMissionId, (error, mission) => { missionManager.getMissionInfo('', testMissionId, (error, mission) => {
if (error) { if (error) {
console.log('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
} else { } else {
console.log('mission.missionId = ${mission.missionId}'); console.log('mission.missionId = ${mission.missionId}');
console.log('mission.runningState = ${mission.runningState}'); console.log('mission.runningState = ${mission.runningState}');
...@@ -317,7 +317,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal ...@@ -317,7 +317,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${paramError.code}, error.message: ${paramError.message}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -392,14 +392,14 @@ Obtains information about all missions. This API uses an asynchronous callback t ...@@ -392,14 +392,14 @@ Obtains information about all missions. This API uses an asynchronous callback t
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error) { if (error) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
} else { } else {
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
console.log('missions = ${JSON.stringify(missions)}'); console.log('missions = ${JSON.stringify(missions)}');
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
......
...@@ -57,10 +57,10 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the ...@@ -57,10 +57,10 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| Parameter| Type| Mandatory| Description| | Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.| | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
> **NOTE** > **NOTE**
> >
...@@ -73,13 +73,13 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the ...@@ -73,13 +73,13 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf']; let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => { quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
if (error) { if (error) {
console.info( `applyQuickFix failed with error: ${error}`); console.error( `applyQuickFix failed with error: ${error}`);
} else { } else {
console.info( 'applyQuickFix success'); console.info( 'applyQuickFix success');
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error.code: ${paramError.code}, error.message: ${paramError.message}'); console.error('error.code: ${paramError.code}, error.message: ${paramError.message}');
} }
``` ```
...@@ -97,15 +97,15 @@ Applies a quick fix patch. This API uses a promise to return the result. ...@@ -97,15 +97,15 @@ Applies a quick fix patch. This API uses a promise to return the result.
**Parameters** **Parameters**
| Parameter| Type| Mandatory| Description| | Parameter| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.| | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<void> | Promise used to return the result.| | Promise\<void> | Promise used to return the result.|
**Example** **Example**
...@@ -115,10 +115,10 @@ Applies a quick fix patch. This API uses a promise to return the result. ...@@ -115,10 +115,10 @@ Applies a quick fix patch. This API uses a promise to return the result.
quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => { quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
console.info('applyQuickFix success'); console.info('applyQuickFix success');
}).catch((error) => { }).catch((error) => {
console.info(`applyQuickFix err: ${error}`); console.error(`applyQuickFix err: ${error}`);
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -148,13 +148,13 @@ Obtains the quick fix information of the application. This API uses an asynchron ...@@ -148,13 +148,13 @@ Obtains the quick fix information of the application. This API uses an asynchron
let bundleName = 'bundleName'; let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => { quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) { if (error) {
console.info(`getApplicationQuickFixInfo error: ${error}`); console.error(`getApplicationQuickFixInfo error: ${error}`);
} else { } else {
console.info(`getApplicationQuickFixInfo success: ${data}`); console.info(`getApplicationQuickFixInfo success: ${data}`);
} }
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -178,9 +178,9 @@ Obtains the quick fix information of the application. This API uses a promise to ...@@ -178,9 +178,9 @@ Obtains the quick fix information of the application. This API uses a promise to
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.| | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Example** **Example**
...@@ -190,9 +190,9 @@ Obtains the quick fix information of the application. This API uses a promise to ...@@ -190,9 +190,9 @@ Obtains the quick fix information of the application. This API uses a promise to
quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => { quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
console.info(`getApplicationQuickFixInfo success: ${data}`); console.info(`getApplicationQuickFixInfo success: ${data}`);
}).catch((error) => { }).catch((error) => {
console.info(`getApplicationQuickFixInfo err: ${error}`); console.error(`getApplicationQuickFixInfo err: ${error}`);
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
...@@ -186,10 +186,10 @@ try { ...@@ -186,10 +186,10 @@ try {
WantAgent.getWantAgent(wantAgentInfo).then((data) => { WantAgent.getWantAgent(wantAgentInfo).then((data) => {
wantAgent = data; wantAgent = data;
}).catch((err) => { }).catch((err) => {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}); });
} catch (err) { } catch (err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -275,12 +275,12 @@ function getWantAgentCallback(err, data) { ...@@ -275,12 +275,12 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
} }
// getBundleName callback // getBundleName callback
function getBundleNameCallback(err, data) { function getBundleNameCallback(err, data) {
if(err) { if(err) {
console.info('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('getBundleName ok! ${JSON.stringify(data)}'); console.info('getBundleName ok! ${JSON.stringify(data)}');
} }
...@@ -288,13 +288,13 @@ function getWantAgentCallback(err, data) { ...@@ -288,13 +288,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getBundleName(wantAgent, getBundleNameCallback); WantAgent.getBundleName(wantAgent, getBundleNameCallback);
} catch(err) { } catch(err) {
console.info('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -385,22 +385,22 @@ function getWantAgentCallback(err, data) { ...@@ -385,22 +385,22 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed! ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed! ${JSON.stringify(wantAgent)}');
} }
try { try {
WantAgent.getBundleName(wantAgent).then((data)=>{ WantAgent.getBundleName(wantAgent).then((data)=>{
console.info('getBundleName ok! ${JSON.stringify(data)}'); console.info('getBundleName ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.info('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}); });
} catch(err){ } catch(err){
console.info('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getBundleName failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -492,7 +492,7 @@ function getWantAgentCallback(err, data) { ...@@ -492,7 +492,7 @@ function getWantAgentCallback(err, data) {
// getUid callback // getUid callback
function getUidCallback(err, data) { function getUidCallback(err, data) {
if(err) { if(err) {
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
} }
...@@ -500,13 +500,13 @@ function getWantAgentCallback(err, data) { ...@@ -500,13 +500,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getUid(wantAgent, getUidCallback); WantAgent.getUid(wantAgent, getUidCallback);
} catch(err) { } catch(err) {
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -597,22 +597,22 @@ function getWantAgentCallback(err, data) { ...@@ -597,22 +597,22 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed! ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed! ${JSON.stringify(wantAgent)}');
} }
try { try {
WantAgent.getUid(wantAgent).then((data)=>{ WantAgent.getUid(wantAgent).then((data)=>{
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}); });
} catch(err){ } catch(err){
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -699,12 +699,12 @@ function getWantAgentCallback(err, data) { ...@@ -699,12 +699,12 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
} }
// getWant callback // getWant callback
function getWantCallback(err, data) { function getWantCallback(err, data) {
if(err) { if(err) {
console.info('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('getWant ok! ${JSON.stringify(data)}'); console.info('getWant ok! ${JSON.stringify(data)}');
} }
...@@ -712,13 +712,13 @@ function getWantAgentCallback(err, data) { ...@@ -712,13 +712,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getWant(wantAgent, getWantCallback); WantAgent.getWant(wantAgent, getWantCallback);
} catch(err) { } catch(err) {
console.info('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWant failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -811,22 +811,22 @@ function getWantAgentCallback(err, data) { ...@@ -811,22 +811,22 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed! ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed! ${JSON.stringify(wantAgent)}');
} }
try { try {
WantAgent.getUid(wantAgent).then((data)=>{ WantAgent.getUid(wantAgent).then((data)=>{
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}); });
} catch(err){ } catch(err){
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -912,12 +912,12 @@ function getWantAgentCallback(err, data) { ...@@ -912,12 +912,12 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
} }
// cancel callback // cancel callback
function cancelCallback(err, data) { function cancelCallback(err, data) {
if(err) { if(err) {
console.info('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('cancel ok!'); console.info('cancel ok!');
} }
...@@ -925,13 +925,13 @@ function getWantAgentCallback(err, data) { ...@@ -925,13 +925,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.cancel(wantAgent, cancelCallback); WantAgent.cancel(wantAgent, cancelCallback);
} catch(err) { } catch(err) {
console.info('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -1022,22 +1022,22 @@ function getWantAgentCallback(err, data) { ...@@ -1022,22 +1022,22 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed! ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed! ${JSON.stringify(wantAgent)}');
} }
try { try {
WantAgent.cancel(wantAgent).then((data)=>{ WantAgent.cancel(wantAgent).then((data)=>{
console.info('cancel ok!'); console.info('cancel ok!');
}).catch((err)=>{ }).catch((err)=>{
console.info('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}); });
} catch(err){ } catch(err){
console.info('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('cancel failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -1126,12 +1126,12 @@ function getWantAgentCallback(err, data) { ...@@ -1126,12 +1126,12 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
} }
// trigger callback // trigger callback
function triggerCallback(err, data) { function triggerCallback(err, data) {
if(err) { if(err) {
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('getUid ok! ${JSON.stringify(data)}'); console.info('getUid ok! ${JSON.stringify(data)}');
} }
...@@ -1139,13 +1139,13 @@ function getWantAgentCallback(err, data) { ...@@ -1139,13 +1139,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.trigger(wantAgent, triggerInfo, triggerCallback); WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
} catch(err) { } catch(err) {
console.info('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getUid failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -1234,12 +1234,12 @@ function getWantAgentCallback(err, data) { ...@@ -1234,12 +1234,12 @@ function getWantAgentCallback(err, data) {
wantAgent1 = data; wantAgent1 = data;
wantAgent2 = data; wantAgent2 = data;
} else { } else {
console.info('getWantAgent failed ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
} }
// equal callback // equal callback
function equalCallback(err, data) { function equalCallback(err, data) {
if(err) { if(err) {
console.info('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('equal ok! ${JSON.stringify(data)}'); console.info('equal ok! ${JSON.stringify(data)}');
} }
...@@ -1247,13 +1247,13 @@ function getWantAgentCallback(err, data) { ...@@ -1247,13 +1247,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.equal(wantAgent1,wantAgent2,equalCallback); WantAgent.equal(wantAgent1,wantAgent2,equalCallback);
} catch(err) { } catch(err) {
console.info('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -1347,22 +1347,22 @@ function getWantAgentCallback(err, data) { ...@@ -1347,22 +1347,22 @@ function getWantAgentCallback(err, data) {
wantAgent1 = data; wantAgent1 = data;
wantAgent2 = data; wantAgent2 = data;
} else { } else {
console.info('getWantAgent failed! ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed! ${JSON.stringify(wantAgent)}');
} }
try { try {
WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{ WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{
console.info('equal ok! ${JSON.stringify(data)}'); console.info('equal ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.info('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}) })
} catch(err){ } catch(err){
console.info('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('equal failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -1446,12 +1446,12 @@ function getWantAgentCallback(err, data) { ...@@ -1446,12 +1446,12 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed ${JSON.stringify(wantAgent)}');
} }
// getOperationTypeCallback callback // getOperationTypeCallback callback
function getOperationTypeCallback(err, data) { function getOperationTypeCallback(err, data) {
if(err) { if(err) {
console.info('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} else { } else {
console.info('getOperationType ok! ${JSON.stringify(data)}'); console.info('getOperationType ok! ${JSON.stringify(data)}');
} }
...@@ -1459,13 +1459,13 @@ function getWantAgentCallback(err, data) { ...@@ -1459,13 +1459,13 @@ function getWantAgentCallback(err, data) {
try { try {
WantAgent.getOperationTypeCallback(wantAgent, getOperationTypeCallback); WantAgent.getOperationTypeCallback(wantAgent, getOperationTypeCallback);
} catch(err) { } catch(err) {
console.info('getOperationTypeCallback failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationTypeCallback failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
...@@ -1554,22 +1554,22 @@ function getWantAgentCallback(err, data) { ...@@ -1554,22 +1554,22 @@ function getWantAgentCallback(err, data) {
if (err === undefined) { if (err === undefined) {
wantAgent = data; wantAgent = data;
} else { } else {
console.info('getWantAgent failed! ${JSON.stringify(wantAgent)}'); console.error('getWantAgent failed! ${JSON.stringify(wantAgent)}');
} }
try { try {
WantAgent.getOperationType(wantAgent).then((data)=>{ WantAgent.getOperationType(wantAgent).then((data)=>{
console.info('getOperationType ok! ${JSON.stringify(data)}'); console.info('getOperationType ok! ${JSON.stringify(data)}');
}).catch((err)=>{ }).catch((err)=>{
console.info('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
}); });
} catch(err){ } catch(err){
console.info('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getOperationType failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
} }
try { try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
} catch(err) { } catch(err) {
console.info('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}'); console.error('getWantAgent failed! ${JSON.stringify(err.code)} ${JSON.stringify(err.message)}');
} }
``` ```
......
...@@ -29,9 +29,12 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -29,9 +29,12 @@ Checks whether this application is undergoing a stability test. This API uses an
**Example** **Example**
```ts ```ts
appManager.isRunningInStabilityTest((err, flag) => { appManager.isRunningInStabilityTest((error, flag) => {
console.log('error: ${JSON.stringify(err)}'); if (error && error.code !== 0) {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}'); console.error('isRunningInStabilityTest fail, error: ${JSON.stringify(error)}');
} else {
console.log('isRunningInStabilityTest success, the result is: ${JSON.stringify(flag)}');
}
}); });
``` ```
...@@ -56,7 +59,7 @@ Checks whether this application is undergoing a stability test. This API uses a ...@@ -56,7 +59,7 @@ Checks whether this application is undergoing a stability test. This API uses a
appManager.isRunningInStabilityTest().then((flag) => { appManager.isRunningInStabilityTest().then((flag) => {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}'); console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -81,7 +84,7 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -81,7 +84,7 @@ Checks whether this application is running on a RAM constrained device. This API
appManager.isRamConstrainedDevice().then((data) => { appManager.isRamConstrainedDevice().then((data) => {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}'); console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -102,9 +105,12 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -102,9 +105,12 @@ Checks whether this application is running on a RAM constrained device. This API
**Example** **Example**
```ts ```ts
appManager.isRamConstrainedDevice((err, data) => { appManager.isRamConstrainedDevice((error, data) => {
console.log('error: ${JSON.stringify(err)}'); if (error && error.code !== 0) {
console.error('isRamConstrainedDevice fail, error: ${JSON.stringify(error)}');
} else {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}'); console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
}
}); });
``` ```
...@@ -128,7 +134,7 @@ Obtains the memory size of this application. This API uses a promise to return t ...@@ -128,7 +134,7 @@ Obtains the memory size of this application. This API uses a promise to return t
appManager.getAppMemorySize().then((data) => { appManager.getAppMemorySize().then((data) => {
console.log('The size of app memory is: ${JSON.stringify(data)}'); console.log('The size of app memory is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -149,9 +155,12 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -149,9 +155,12 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Example** **Example**
```ts ```ts
appManager.getAppMemorySize((err, data) => { appManager.getAppMemorySize((error, data) => {
console.log('error: ${JSON.stringify(err)}'); if (error && error.code !== 0) {
console.error('getAppMemorySize fail, error: ${JSON.stringify(error)}');
} else {
console.log('The size of app memory is: ${JSON.stringify(data)}'); console.log('The size of app memory is: ${JSON.stringify(data)}');
}
}); });
``` ```
## appManager.getProcessRunningInfos<sup>(deprecated)</sup> ## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
...@@ -178,7 +187,7 @@ Obtains information about the running processes. This API uses a promise to retu ...@@ -178,7 +187,7 @@ Obtains information about the running processes. This API uses a promise to retu
appManager.getProcessRunningInfos().then((data) => { appManager.getProcessRunningInfos().then((data) => {
console.log('The process running infos is: ${JSON.stringify(data)}'); console.log('The process running infos is: ${JSON.stringify(data)}');
}).catch((error) => { }).catch((error) => {
console.log('error: ${JSON.stringify(error)}'); console.error('error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -203,9 +212,12 @@ Obtains information about the running processes. This API uses an asynchronous c ...@@ -203,9 +212,12 @@ Obtains information about the running processes. This API uses an asynchronous c
**Example** **Example**
```ts ```ts
appManager.getProcessRunningInfos((err, data) => { appManager.getProcessRunningInfos((error, data) => {
console.log('error: ${JSON.stringify(err)}'); if (error && error.code !== 0) {
console.log('The process running infos is: ${JSON.stringify(data)}'); console.error('getProcessRunningInfos fail, error: ${JSON.stringify(error)}');
} else {
console.log('getProcessRunningInfos success, data: ${JSON.stringify(data)}');
}
}); });
``` ```
...@@ -320,7 +332,7 @@ Deregisters the application state observer. This API uses an asynchronous callba ...@@ -320,7 +332,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
function unregisterApplicationStateObserverCallback(err) { function unregisterApplicationStateObserverCallback(err) {
if (err) { if (err) {
console.log('------------ unregisterApplicationStateObserverCallback ------------', err); console.error('------------ unregisterApplicationStateObserverCallback ------------', err);
} }
} }
appManager.unregisterApplicationStateObserver(observerId, unregisterApplicationStateObserverCallback); appManager.unregisterApplicationStateObserver(observerId, unregisterApplicationStateObserverCallback);
...@@ -360,7 +372,7 @@ Deregisters the application state observer. This API uses a promise to return th ...@@ -360,7 +372,7 @@ Deregisters the application state observer. This API uses a promise to return th
console.log('----------- unregisterApplicationStateObserver success ----------', data); console.log('----------- unregisterApplicationStateObserver success ----------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('----------- unregisterApplicationStateObserver fail ----------', err); console.error('----------- unregisterApplicationStateObserver fail ----------', err);
}); });
``` ```
...@@ -387,7 +399,7 @@ Obtains information about the applications that are running in the foreground. T ...@@ -387,7 +399,7 @@ Obtains information about the applications that are running in the foreground. T
```ts ```ts
function getForegroundApplicationsCallback(err, data) { function getForegroundApplicationsCallback(err, data) {
if (err) { if (err) {
console.log('--------- getForegroundApplicationsCallback fail ---------', err); console.error('--------- getForegroundApplicationsCallback fail ---------', err);
} else { } else {
console.log('--------- getForegroundApplicationsCallback success ---------', data); console.log('--------- getForegroundApplicationsCallback success ---------', data);
} }
...@@ -421,7 +433,7 @@ Obtains information about the applications that are running in the foreground. T ...@@ -421,7 +433,7 @@ Obtains information about the applications that are running in the foreground. T
console.log('--------- getForegroundApplications success -------', data); console.log('--------- getForegroundApplications success -------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('--------- getForegroundApplications fail -------', err); console.error('--------- getForegroundApplications fail -------', err);
}); });
``` ```
...@@ -454,7 +466,7 @@ appManager.killProcessWithAccount(bundleName, accountId) ...@@ -454,7 +466,7 @@ appManager.killProcessWithAccount(bundleName, accountId)
console.log('------------ killProcessWithAccount success ------------', data); console.log('------------ killProcessWithAccount success ------------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('------------ killProcessWithAccount fail ------------', err); console.error('------------ killProcessWithAccount fail ------------', err);
}); });
``` ```
...@@ -486,7 +498,7 @@ let bundleName = 'bundleName'; ...@@ -486,7 +498,7 @@ let bundleName = 'bundleName';
let accountId = 0; let accountId = 0;
function killProcessWithAccountCallback(err, data) { function killProcessWithAccountCallback(err, data) {
if (err) { if (err) {
console.log('------------- killProcessWithAccountCallback fail, err: --------------', err); console.error('------------- killProcessWithAccountCallback fail, err: --------------', err);
} else { } else {
console.log('------------- killProcessWithAccountCallback success, data: --------------', data); console.log('------------- killProcessWithAccountCallback success, data: --------------', data);
} }
...@@ -519,7 +531,7 @@ Kills a process by bundle name. This API uses an asynchronous callback to return ...@@ -519,7 +531,7 @@ Kills a process by bundle name. This API uses an asynchronous callback to return
let bundleName = 'bundleName'; let bundleName = 'bundleName';
function killProcessesByBundleNameCallback(err, data) { function killProcessesByBundleNameCallback(err, data) {
if (err) { if (err) {
console.log('------------- killProcessesByBundleNameCallback fail, err: --------------', err); console.error('------------- killProcessesByBundleNameCallback fail, err: --------------', err);
} else { } else {
console.log('------------- killProcessesByBundleNameCallback success, data: --------------', data); console.log('------------- killProcessesByBundleNameCallback success, data: --------------', data);
} }
...@@ -560,7 +572,7 @@ Kills a process by bundle name. This API uses a promise to return the result. ...@@ -560,7 +572,7 @@ Kills a process by bundle name. This API uses a promise to return the result.
console.log('------------ killProcessesByBundleName success ------------', data); console.log('------------ killProcessesByBundleName success ------------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('------------ killProcessesByBundleName fail ------------', err); console.error('------------ killProcessesByBundleName fail ------------', err);
}); });
``` ```
...@@ -589,7 +601,7 @@ Clears application data by bundle name. This API uses an asynchronous callback t ...@@ -589,7 +601,7 @@ Clears application data by bundle name. This API uses an asynchronous callback t
let bundleName = 'bundleName'; let bundleName = 'bundleName';
function clearUpApplicationDataCallback(err, data) { function clearUpApplicationDataCallback(err, data) {
if (err) { if (err) {
console.log('------------- clearUpApplicationDataCallback fail, err: --------------', err); console.error('------------- clearUpApplicationDataCallback fail, err: --------------', err);
} else { } else {
console.log('------------- clearUpApplicationDataCallback success, data: --------------', data); console.log('------------- clearUpApplicationDataCallback success, data: --------------', data);
} }
...@@ -630,6 +642,6 @@ Clears application data by bundle name. This API uses a promise to return the re ...@@ -630,6 +642,6 @@ Clears application data by bundle name. This API uses a promise to return the re
console.log('------------ clearUpApplicationData success ------------', data); console.log('------------ clearUpApplicationData success ------------', data);
}) })
.catch((err) => { .catch((err) => {
console.log('------------ clearUpApplicationData fail ------------', err); console.error('------------ clearUpApplicationData fail ------------', err);
}); });
``` ```
...@@ -41,10 +41,10 @@ export default class EntryAbility extends UIAbility { ...@@ -41,10 +41,10 @@ export default class EntryAbility extends UIAbility {
windowStage.loadContent('pages/index', (err, data) => { windowStage.loadContent('pages/index', (err, data) => {
if (err.code) { if (err.code) {
console.error('failed to load the content, error: + ${JSON.stringify(err)}'); console.error('failed to load the content, error: ${JSON.stringify(err)}');
return; return;
} }
console.info('Succeeded in loading the content, data: + ${JSON.stringify(data)}'); console.info('Succeeded in loading the content, data: ${JSON.stringify(data)}');
}); });
} }
} }
......
...@@ -54,7 +54,7 @@ export default class EntryAbility extends UIAbility { ...@@ -54,7 +54,7 @@ export default class EntryAbility extends UIAbility {
onCreate() { onCreate() {
console.log('MyAbility onCreate'); console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext(); globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = { let environmentCallback = {
onConfigurationUpdated(config){ onConfigurationUpdated(config){
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}'); console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
}, },
...@@ -65,13 +65,17 @@ export default class EntryAbility extends UIAbility { ...@@ -65,13 +65,17 @@ export default class EntryAbility extends UIAbility {
// 1. Obtain an applicationContext object. // 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object. // 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); callbackId = applicationContext.registerEnvironmentCallback(environmentCallback);
console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}'); console.log('registerEnvironmentCallback number: ${JSON.stringify(callbackId)}');
} }
onDestroy() { onDestroy() {
let applicationContext = globalThis.applicationContext; let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log('unregisterEnvironmentCallback success, err: ${JSON.stringify(error)}'); if (error && error.code !== 0) {
console.error('unregisterEnvironmentCallback fail, error: ${JSON.stringify(error)}');
} else {
console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}');
}
}); });
} }
} }
......
...@@ -92,7 +92,7 @@ Deregisters a mission status listener. This API uses an asynchronous callback to ...@@ -92,7 +92,7 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
let listenerid = missionManager.registerMissionListener(listener); let listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid, (error) => { missionManager.unregisterMissionListener(listenerid, (error) => {
console.log('unregisterMissionListener'); console.error('unregisterMissionListener fail, error: ${error}');
}); });
``` ```
...@@ -136,8 +136,8 @@ Deregisters a mission status listener. This API uses a promise to return the res ...@@ -136,8 +136,8 @@ Deregisters a mission status listener. This API uses a promise to return the res
console.log('registerMissionListener'); console.log('registerMissionListener');
let listenerid = missionManager.registerMissionListener(listener); let listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid).catch(function (err) { missionManager.unregisterMissionListener(listenerid).catch(function (error) {
console.log(err); console.error('unregisterMissionListener fail, error: ${error}');
}); });
``` ```
...@@ -170,7 +170,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal ...@@ -170,7 +170,7 @@ Obtains the information about a given mission. This API uses an asynchronous cal
let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);}); let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => { missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => {
if (error.code) { if (error.code) {
console.log('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfo failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
...@@ -214,8 +214,8 @@ Obtains the information about a given mission. This API uses a promise to return ...@@ -214,8 +214,8 @@ Obtains the information about a given mission. This API uses a promise to return
```ts ```ts
import missionManager from '@ohos.application.missionManager'; import missionManager from '@ohos.application.missionManager';
let mission = missionManager.getMissionInfo('', 10).catch(function (err){ let mission = missionManager.getMissionInfo('', 10).catch(function (error){
console.log(err); console.error('getMissionInfo fail, error: ${error}');
}); });
``` ```
...@@ -247,7 +247,7 @@ Obtains information about all missions. This API uses an asynchronous callback t ...@@ -247,7 +247,7 @@ Obtains information about all missions. This API uses an asynchronous callback t
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -286,8 +286,8 @@ Obtains information about all missions. This API uses a promise to return the re ...@@ -286,8 +286,8 @@ Obtains information about all missions. This API uses a promise to return the re
```ts ```ts
import missionManager from '@ohos.application.missionManager'; import missionManager from '@ohos.application.missionManager';
let allMissions = missionManager.getMissionInfos('', 10).catch(function (err){ let allMissions = missionManager.getMissionInfos('', 10).catch(function (error){
console.log(err); console.error('getMissionInfos fail, error: ${error}');
}); });
``` ```
...@@ -319,7 +319,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback ...@@ -319,7 +319,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -328,7 +328,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback ...@@ -328,7 +328,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
missionManager.getMissionSnapShot('', id, (error, snapshot) => { missionManager.getMissionSnapShot('', id, (error, snapshot) => {
if (error.code) { if (error.code) {
console.log('getMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('bundleName = ${snapshot.ability.bundleName}'); console.log('bundleName = ${snapshot.ability.bundleName}');
...@@ -370,13 +370,15 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r ...@@ -370,13 +370,15 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
let allMissions; let allMissions;
missionManager.getMissionInfos('',10).then(function(res){ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res; allMissions=res;
}).catch(function(err){console.log(err);}); }).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}'); console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}'); console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId; let id = allMissions[0].missionId;
let snapshot = missionManager.getMissionSnapShot('', id).catch(function (err){ let snapshot = missionManager.getMissionSnapShot('', id).catch(function (error){
console.log(err); console.error('getMissionSnapShot fail, error: ${error}');
}); });
``` ```
...@@ -407,7 +409,7 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr ...@@ -407,7 +409,7 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -416,8 +418,7 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr ...@@ -416,8 +418,7 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr
missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => { missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => {
if (error.code) { if (error.code) {
console.log('getLowResolutionMissionSnapShot failed, error.code: ${JSON.stringify(error.code)} console.error('getLowResolutionMissionSnapShot failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
'error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('bundleName = ${snapshot.ability.bundleName}'); console.log('bundleName = ${snapshot.ability.bundleName}');
...@@ -459,13 +460,15 @@ Obtains the low-resolution snapshot of a given mission. This API uses a promise ...@@ -459,13 +460,15 @@ Obtains the low-resolution snapshot of a given mission. This API uses a promise
let allMissions; let allMissions;
missionManager.getMissionInfos('',10).then(function(res){ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res; allMissions=res;
}).catch(function(err){console.log(err);}); }).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}'); console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}'); console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId; let id = allMissions[0].missionId;
let snapshot = missionManager.getLowResolutionMissionSnapShot('', id).catch(function (err){ let snapshot = missionManager.getLowResolutionMissionSnapShot('', id).catch(function (error){
console.log(err); console.error('getLowResolutionMissionSnapShot fail, error: ${error}');
}); });
``` ```
...@@ -496,8 +499,7 @@ Locks a given mission. This API uses an asynchronous callback to return the resu ...@@ -496,8 +499,7 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)} console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
'error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -542,13 +544,15 @@ Locks a given mission. This API uses a promise to return the result. ...@@ -542,13 +544,15 @@ Locks a given mission. This API uses a promise to return the result.
let allMissions; let allMissions;
missionManager.getMissionInfos('',10).then(function(res){ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res; allMissions=res;
}).catch(function(err){console.log(err);}); }).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}'); console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}'); console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId; let id = allMissions[0].missionId;
missionManager.lockMission(id).catch(function (err){ missionManager.lockMission(id).catch(function (error){
console.log(err); console.error('lockMission fail, error: ${error}');
}); });
``` ```
...@@ -579,7 +583,7 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re ...@@ -579,7 +583,7 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -625,16 +629,18 @@ Unlocks a given mission. This API uses a promise to return the result. ...@@ -625,16 +629,18 @@ Unlocks a given mission. This API uses a promise to return the result.
let allMissions; let allMissions;
missionManager.getMissionInfos('',10).then(function(res){ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res; allMissions=res;
}).catch(function(err){console.log(err);}); }).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}'); console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}'); console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId; let id = allMissions[0].missionId;
missionManager.lockMission(id).catch(function (err){ missionManager.lockMission(id).catch(function (error){
console.log(err); console.error('lockMission fail, error: ${error}');
}); });
missionManager.unlockMission(id).catch(function (err){ missionManager.unlockMission(id).catch(function (error){
console.log(err); console.error('unlockMission fail, error: ${error}');
}); });
``` ```
...@@ -665,7 +671,7 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy ...@@ -665,7 +671,7 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -711,13 +717,15 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom ...@@ -711,13 +717,15 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
let allMissions; let allMissions;
missionManager.getMissionInfos('',10).then(function(res){ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res; allMissions=res;
}).catch(function(err){console.log(err);}); }).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}'); console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}'); console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId; let id = allMissions[0].missionId;
missionManager.clearMission(id).catch(function (err){ missionManager.clearMission(id).catch(function (error){
console.log(err); console.error('clearMission fail, error: ${error}');
}); });
``` ```
...@@ -767,8 +775,8 @@ Clears all unlocked missions. This API uses a promise to return the result. ...@@ -767,8 +775,8 @@ Clears all unlocked missions. This API uses a promise to return the result.
```ts ```ts
import missionManager from '@ohos.application.missionManager'; import missionManager from '@ohos.application.missionManager';
missionManager.clearAllMissions().catch(function (err){ missionManager.clearAllMissions().catch(function (error){
console.log(err); console.error('clearAllMissions fail, error: ${error}');
}); });
``` ```
...@@ -799,7 +807,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba ...@@ -799,7 +807,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -840,7 +848,7 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -840,7 +848,7 @@ Switches a given mission to the foreground, with the startup parameters for the
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -887,12 +895,14 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -887,12 +895,14 @@ Switches a given mission to the foreground, with the startup parameters for the
let allMissions; let allMissions;
missionManager.getMissionInfos('',10).then(function(res){ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res; allMissions=res;
}).catch(function(err){console.log(err);}); }).catch(function(error) {
console.error('getMissionInfos fail, error: ${error}');
});
console.log('size = ${allMissions.length}'); console.log('size = ${allMissions.length}');
console.log('missions = ${JSON.stringify(allMissions)}'); console.log('missions = ${JSON.stringify(allMissions)}');
let id = allMissions[0].missionId; let id = allMissions[0].missionId;
missionManager.moveMissionToFront(id).catch(function (err){ missionManager.moveMissionToFront(id).catch(function (error){
console.log(err); console.error('moveMissionToFront fail, error: ${error}');
}); });
``` ```
...@@ -15,10 +15,10 @@ Want is a carrier for information transfer between objects (application componen ...@@ -15,10 +15,10 @@ Want is a carrier for information transfer between objects (application componen
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.| | abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | uri | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. | | type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantconstantflags). | | flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).|
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantconstantaction). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). | | action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. | | parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantconstantentity). | | entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). |
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.| | moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
**Example** **Example**
...@@ -34,7 +34,7 @@ Want is a carrier for information transfer between objects (application componen ...@@ -34,7 +34,7 @@ Want is a carrier for information transfer between objects (application componen
}; };
this.context.startAbility(want, (error) => { this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log('error.code = ${error.code}'); console.error('error.code = ${error.code}');
}); });
``` ```
...@@ -48,7 +48,7 @@ Want is a carrier for information transfer between objects (application componen ...@@ -48,7 +48,7 @@ Want is a carrier for information transfer between objects (application componen
try { try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) { } catch(e) {
console.log('openSync fail: ${JSON.stringify(e)}'); console.error('openSync fail: ${JSON.stringify(e)}');
} }
let want = { let want = {
'deviceId': '', // An empty deviceId indicates the local device. 'deviceId': '', // An empty deviceId indicates the local device.
...@@ -61,7 +61,7 @@ Want is a carrier for information transfer between objects (application componen ...@@ -61,7 +61,7 @@ Want is a carrier for information transfer between objects (application componen
}; };
this.context.startAbility(want, (error) => { this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability. // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log('error.code = ${error.code}'); console.error('error.code = ${error.code}');
}); });
// ... // ...
``` ```
......
...@@ -38,7 +38,7 @@ Adds an **AbilityMonitor** instance. This API uses an asynchronous callback to r ...@@ -38,7 +38,7 @@ Adds an **AbilityMonitor** instance. This API uses an asynchronous callback to r
let abilityDelegator; let abilityDelegator;
function onAbilityCreateCallback(data) { function onAbilityCreateCallback(data) {
console.info('onAbilityCreateCallback'); console.info('onAbilityCreateCallback, data: ${JSON.stringify(data)}');
} }
let monitor = { let monitor = {
...@@ -47,8 +47,8 @@ let monitor = { ...@@ -47,8 +47,8 @@ let monitor = {
}; };
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (err : any) => { abilityDelegator.addAbilityMonitor(monitor, (error : any) => {
console.info('addAbilityMonitor callback'); console.error('addAbilityMonitor fail, error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -122,8 +122,8 @@ let monitor = { ...@@ -122,8 +122,8 @@ let monitor = {
}; };
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.removeAbilityMonitor(monitor, (err : any) => { abilityDelegator.removeAbilityMonitor(monitor, (error : any) => {
console.info('removeAbilityMonitor callback'); console.error('removeAbilityMonitor fail, error: ${JSON.stringify(error)}');
}); });
``` ```
...@@ -197,8 +197,12 @@ let monitor = { ...@@ -197,8 +197,12 @@ let monitor = {
}; };
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityMonitor(monitor, (err : any, data : any) => { abilityDelegator.waitAbilityMonitor(monitor, (error : any, data : any) => {
console.info('waitAbilityMonitor callback'); if (error && error.code !== 0) {
console.error('waitAbilityMonitor fail, error: ${JSON.stringify(error)}');
} else {
console.log('waitAbilityMonitor success, data: ${JSON.stringify(data)}');
}
}); });
``` ```
...@@ -234,8 +238,12 @@ let monitor = { ...@@ -234,8 +238,12 @@ let monitor = {
}; };
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityMonitor(monitor, timeout, (err : any, data : any) => { abilityDelegator.waitAbilityMonitor(monitor, timeout, (error : any, data : any) => {
console.info('waitAbilityMonitor callback'); if (error && error.code !== 0) {
console.error('waitAbilityMonitor fail, error: ${JSON.stringify(error)}');
} else {
console.log('waitAbilityMonitor success, data: ${JSON.stringify(data)}');
}
}); });
``` ```
......
...@@ -27,7 +27,7 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -27,7 +27,7 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error.code) {
console.log('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -36,7 +36,7 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -36,7 +36,7 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
missionManager.getMissionSnapShot('', id, (err, snapshot) => { missionManager.getMissionSnapShot('', id, (err, snapshot) => {
if (err.code) { if (err.code) {
console.log('getMissionInfos failed, err.code: ${JSON.stringify(err.code)}, err.message: ${JSON.stringify(err.message)}'); console.error('getMissionInfos failed, err.code: ${JSON.stringify(err.code)}, err.message: ${JSON.stringify(err.message)}');
return; return;
} }
...@@ -45,6 +45,6 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -45,6 +45,6 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
}); });
}); });
} catch (paramError) { } catch (paramError) {
console.log('error: ${paramError.code}, ${paramError.message}'); console.error('error: ${paramError.code}, ${paramError.message}');
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册