提交 7e7c1dd8 编写于 作者: L longxiaofeng

fix: Adaptation changes of adding internal public event

Signed-off-by: Nlongxiaofeng <longxiaofeng5@huawei.com>
上级 d6467882
...@@ -42,10 +42,10 @@ getBatteryStats(): Promise<Array&lt;BatteryStatsInfo&gt;> ...@@ -42,10 +42,10 @@ getBatteryStats(): Promise<Array&lt;BatteryStatsInfo&gt;>
```js ```js
batteryStats.getBatteryStats() batteryStats.getBatteryStats()
.then(data => { .then((data: batteryStats.BatteryStatsInfo[]) => {
console.info('battery statistics info: ' + data); console.info('battery statistics info: ' + data);
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('get battery statistics failed, err: ' + err); console.error('get battery statistics failed, err: ' + err);
}); });
``` ```
...@@ -77,7 +77,7 @@ getBatteryStats(callback: AsyncCallback<Array&lt;BatteryStatsInfo&gt;>): void ...@@ -77,7 +77,7 @@ getBatteryStats(callback: AsyncCallback<Array&lt;BatteryStatsInfo&gt;>): void
**示例:** **示例:**
```js ```js
batteryStats.getBatteryStats((err, data) => { batteryStats.getBatteryStats((err: BusinessError<void>, data: batteryStats.BatteryStatsInfo[]) => {
if (typeof err === 'undefined') { if (typeof err === 'undefined') {
console.info('battery statistics info: ' + data); console.info('battery statistics info: ' + data);
} else { } else {
...@@ -120,7 +120,7 @@ getAppPowerValue(uid: number): number ...@@ -120,7 +120,7 @@ getAppPowerValue(uid: number): number
```js ```js
try { try {
var value = batteryStats.getAppPowerValue(10021); let value = batteryStats.getAppPowerValue(10021);
console.info('battery statistics value of app is: ' + value); console.info('battery statistics value of app is: ' + value);
} catch(err) { } catch(err) {
console.error('get battery statistics value of app failed, err: ' + err); console.error('get battery statistics value of app failed, err: ' + err);
...@@ -161,7 +161,7 @@ getAppPowerPercent(uid: number): number ...@@ -161,7 +161,7 @@ getAppPowerPercent(uid: number): number
```js ```js
try { try {
var percent = batteryStats.getAppPowerPercent(10021); let percent = batteryStats.getAppPowerPercent(10021);
console.info('battery statistics percent of app is: ' + percent); console.info('battery statistics percent of app is: ' + percent);
} catch(err) { } catch(err) {
console.error('get battery statistics percent of app failed, err: ' + err); console.error('get battery statistics percent of app failed, err: ' + err);
...@@ -202,7 +202,7 @@ getHardwareUnitPowerValue(type: ConsumptionType): number ...@@ -202,7 +202,7 @@ getHardwareUnitPowerValue(type: ConsumptionType): number
```js ```js
try { try {
var value = batteryStats.getHardwareUnitPowerValue(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN); let value = batteryStats.getHardwareUnitPowerValue(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics value of hardware is: ' + value); console.info('battery statistics value of hardware is: ' + value);
} catch(err) { } catch(err) {
console.error('get battery statistics percent of hardware failed, err: ' + err); console.error('get battery statistics percent of hardware failed, err: ' + err);
...@@ -243,7 +243,7 @@ getHardwareUnitPowerPercent(type: ConsumptionType): number ...@@ -243,7 +243,7 @@ getHardwareUnitPowerPercent(type: ConsumptionType): number
```js ```js
try { try {
var percent = batteryStats.getHardwareUnitPowerPercent(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN); let percent = batteryStats.getHardwareUnitPowerPercent(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN);
console.info('battery statistics percent of hardware is: ' + percent); console.info('battery statistics percent of hardware is: ' + percent);
} catch(err) { } catch(err) {
console.error('get battery statistics percent of hardware failed, err: ' + err); console.error('get battery statistics percent of hardware failed, err: ' + err);
......
...@@ -104,7 +104,7 @@ isActive(): boolean ...@@ -104,7 +104,7 @@ isActive(): boolean
```js ```js
try { try {
var isActive = power.isActive(); let isActive = power.isActive();
console.info('power is active: ' + isActive); console.info('power is active: ' + isActive);
} catch(err) { } catch(err) {
console.error('check active status failed, err: ' + err); console.error('check active status failed, err: ' + err);
...@@ -206,7 +206,7 @@ getPowerMode(): DevicePowerMode ...@@ -206,7 +206,7 @@ getPowerMode(): DevicePowerMode
```js ```js
try { try {
var mode = power.getPowerMode(); let mode = power.getPowerMode();
console.info('power mode: ' + mode); console.info('power mode: ' + mode);
} catch(err) { } catch(err) {
console.error('get power mode failed, err: ' + err); console.error('get power mode failed, err: ' + err);
...@@ -243,7 +243,7 @@ setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void ...@@ -243,7 +243,7 @@ setPowerMode(mode: DevicePowerMode, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, err => { power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, (err: BusinessError<void>) => {
if (typeof err === 'undefined') { if (typeof err === 'undefined') {
console.info('set power mode to MODE_PERFORMANCE'); console.info('set power mode to MODE_PERFORMANCE');
} else { } else {
...@@ -322,7 +322,7 @@ isStandby(): boolean ...@@ -322,7 +322,7 @@ isStandby(): boolean
```js ```js
try { try {
var isStandby = power.isStandby(); let isStandby = power.isStandby();
console.info('device is in standby: ' + isStandby); console.info('device is in standby: ' + isStandby);
} catch(err) { } catch(err) {
console.error('check isStandby failed, err: ' + err); console.error('check isStandby failed, err: ' + err);
...@@ -372,7 +372,7 @@ isScreenOn(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -372,7 +372,7 @@ isScreenOn(callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```js
power.isScreenOn((err, data) => { power.isScreenOn((err: BusinessError<void>, data: boolean) => {
if (typeof err === 'undefined') { if (typeof err === 'undefined') {
console.info('screen on status is ' + data); console.info('screen on status is ' + data);
} else { } else {
...@@ -400,10 +400,10 @@ isScreenOn(): Promise&lt;boolean&gt; ...@@ -400,10 +400,10 @@ isScreenOn(): Promise&lt;boolean&gt;
```js ```js
power.isScreenOn() power.isScreenOn()
.then(data => { .then((data: boolean) => {
console.info('screen on status is ' + data); console.info('screen on status is ' + data);
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('check screen status failed, err: ' + err); console.error('check screen status failed, err: ' + err);
}) })
``` ```
......
...@@ -44,7 +44,7 @@ isSupported(type: RunningLockType): boolean; ...@@ -44,7 +44,7 @@ isSupported(type: RunningLockType): boolean;
```js ```js
try { try {
var isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND); let isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND);
console.info('BACKGROUND type supported: ' + isSupported); console.info('BACKGROUND type supported: ' + isSupported);
} catch(err) { } catch(err) {
console.error('check supported failed, err: ' + err); console.error('check supported failed, err: ' + err);
...@@ -72,7 +72,7 @@ create(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLo ...@@ -72,7 +72,7 @@ create(name: string, type: RunningLockType, callback: AsyncCallback&lt;RunningLo
**示例:** **示例:**
```js ```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => { runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err: BusinessError<void>, lock: runningLock.RunningLock) => {
if (typeof err === 'undefined') { if (typeof err === 'undefined') {
console.info('created running lock: ' + lock); console.info('created running lock: ' + lock);
} else { } else {
...@@ -108,10 +108,10 @@ create(name: string, type: RunningLockType): Promise&lt;RunningLock&gt; ...@@ -108,10 +108,10 @@ create(name: string, type: RunningLockType): Promise&lt;RunningLock&gt;
```js ```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
console.info('created running lock: ' + lock); console.info('created running lock: ' + lock);
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('create running lock failed, error: ' + err); console.error('create running lock failed, error: ' + err);
}); });
``` ```
...@@ -136,7 +136,7 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback&lt;boo ...@@ -136,7 +136,7 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback&lt;boo
**示例:** **示例:**
```js ```js
runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (err, data) => { runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (err: BusinessError<void>, data: boolean) => {
if (typeof err === 'undefined') { if (typeof err === 'undefined') {
console.info('BACKGROUND lock support status: ' + data); console.info('BACKGROUND lock support status: ' + data);
} else { } else {
...@@ -171,10 +171,10 @@ isRunningLockTypeSupported(type: RunningLockType): Promise&lt;boolean> ...@@ -171,10 +171,10 @@ isRunningLockTypeSupported(type: RunningLockType): Promise&lt;boolean>
```js ```js
runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND) runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND)
.then(data => { .then((data: boolean) => {
console.info('BACKGROUND lock support status: ' + data); console.info('BACKGROUND lock support status: ' + data);
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.log('check BACKGROUND lock support status failed, err: ' + err); console.log('check BACKGROUND lock support status failed, err: ' + err);
}); });
``` ```
...@@ -202,7 +202,7 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l ...@@ -202,7 +202,7 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l
**示例:** **示例:**
```js ```js
runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => { runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err: BusinessError<void>, lock: runningLock.RunningLock) => {
if (typeof err === 'undefined') { if (typeof err === 'undefined') {
console.info('created running lock: ' + lock); console.info('created running lock: ' + lock);
} else { } else {
...@@ -240,10 +240,10 @@ createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&g ...@@ -240,10 +240,10 @@ createRunningLock(name: string, type: RunningLockType): Promise&lt;RunningLock&g
```js ```js
runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
console.info('created running lock: ' + lock); console.info('created running lock: ' + lock);
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.log('create running lock failed, err: ' + err); console.log('create running lock failed, err: ' + err);
}); });
``` ```
...@@ -280,7 +280,7 @@ hold(timeout: number): void ...@@ -280,7 +280,7 @@ hold(timeout: number): void
```js ```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
console.info('create running lock success'); console.info('create running lock success');
try { try {
lock.hold(500); lock.hold(500);
...@@ -289,7 +289,7 @@ runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) ...@@ -289,7 +289,7 @@ runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
console.error('hold running lock failed, err: ' + err); console.error('hold running lock failed, err: ' + err);
} }
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('create running lock failed, err: ' + err); console.error('create running lock failed, err: ' + err);
}); });
``` ```
...@@ -316,7 +316,7 @@ unhold(): void ...@@ -316,7 +316,7 @@ unhold(): void
```js ```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
console.info('create running lock success'); console.info('create running lock success');
try { try {
lock.unhold(); lock.unhold();
...@@ -325,7 +325,7 @@ runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) ...@@ -325,7 +325,7 @@ runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
console.error('unhold running lock failed, err: ' + err); console.error('unhold running lock failed, err: ' + err);
} }
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('create running lock failed, err: ' + err); console.error('create running lock failed, err: ' + err);
}); });
``` ```
...@@ -356,16 +356,16 @@ isHolding(): boolean ...@@ -356,16 +356,16 @@ isHolding(): boolean
```js ```js
runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
console.info('create running lock success'); console.info('create running lock success');
try { try {
var isHolding = lock.isHolding(); let isHolding = lock.isHolding();
console.info('check running lock holding status: ' + isHolding); console.info('check running lock holding status: ' + isHolding);
} catch(err) { } catch(err) {
console.error('check running lock holding status failed, err: ' + err); console.error('check running lock holding status failed, err: ' + err);
} }
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('create running lock failed, err: ' + err); console.error('create running lock failed, err: ' + err);
}); });
``` ```
...@@ -392,11 +392,11 @@ lock(timeout: number): void ...@@ -392,11 +392,11 @@ lock(timeout: number): void
```js ```js
runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
lock.lock(500); lock.lock(500);
console.info('create running lock and lock success'); console.info('create running lock and lock success');
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('create running lock failed, err: ' + err); console.error('create running lock failed, err: ' + err);
}); });
``` ```
...@@ -417,11 +417,11 @@ unlock(): void ...@@ -417,11 +417,11 @@ unlock(): void
```js ```js
runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
lock.unlock(); lock.unlock();
console.info('create running lock and unlock success'); console.info('create running lock and unlock success');
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('create running lock failed, err: ' + err); console.error('create running lock failed, err: ' + err);
}); });
``` ```
...@@ -445,11 +445,11 @@ isUsed(): boolean ...@@ -445,11 +445,11 @@ isUsed(): boolean
```js ```js
runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND)
.then(lock => { .then((lock: runningLock.RunningLock) => {
var isUsed = lock.isUsed(); let isUsed = lock.isUsed();
console.info('check running lock used status: ' + isUsed); console.info('check running lock used status: ' + isUsed);
}) })
.catch(err => { .catch((err: { code: number, message: string }) => {
console.error('check running lock used status failed, err: ' + err); console.error('check running lock used status failed, err: ' + err);
}); });
``` ```
......
...@@ -33,10 +33,10 @@ getStatus(options?: GetStatusOptions): void; ...@@ -33,10 +33,10 @@ getStatus(options?: GetStatusOptions): void;
```js ```js
battery.getStatus({ battery.getStatus({
success: function(data) { success: (data: BatteryResponse) => {
console.log('success get battery level:' + data.level); console.log('success get battery level:' + data.level);
}, },
fail: function(data, code) { fail: (data: string, code: number) => {
console.error('fail to get battery level code:' + code + ', data: ' + data); console.error('fail to get battery level code:' + code + ', data: ' + data);
} }
}); });
......
...@@ -34,10 +34,10 @@ getValue(options?: GetBrightnessOptions): void ...@@ -34,10 +34,10 @@ getValue(options?: GetBrightnessOptions): void
```js ```js
brightness.getValue({ brightness.getValue({
success: function(data) { success: (data: BrightnessResponse) => {
console.log('success get brightness value:' + data.value); console.log('success get brightness value:' + data.value);
}, },
fail: function(data, code) { fail: (data: string, code: number) => {
console.error('get brightness fail, code: ' + code + ', data: ' + data); console.error('get brightness fail, code: ' + code + ', data: ' + data);
} }
}); });
...@@ -63,10 +63,10 @@ setValue(options?: SetBrightnessOptions): void ...@@ -63,10 +63,10 @@ setValue(options?: SetBrightnessOptions): void
```js ```js
brightness.setValue({ brightness.setValue({
value: 100, value: 100,
success: function() { success: () => {
console.log('handling set brightness success.'); console.log('handling set brightness success.');
}, },
fail: function(data, code) { fail: (data: string, code: number) => {
console.error('handling set brightness value fail, code:' + code + ', data: ' + data); console.error('handling set brightness value fail, code:' + code + ', data: ' + data);
} }
}); });
...@@ -91,10 +91,10 @@ getMode(options?: GetBrightnessModeOptions): void ...@@ -91,10 +91,10 @@ getMode(options?: GetBrightnessModeOptions): void
```js ```js
brightness.getMode({ brightness.getMode({
success: function(data) { success: (data: BrightnessModeResponse) => {
console.log('success get mode:' + data.mode); console.log('success get mode:' + data.mode);
}, },
fail: function(data, code){ fail: (data: string, code: number) => {
console.error('handling get mode fail, code:' + code + ', data: ' + data); console.error('handling get mode fail, code:' + code + ', data: ' + data);
} }
}); });
...@@ -119,10 +119,10 @@ setMode(options?: SetBrightnessModeOptions): void ...@@ -119,10 +119,10 @@ setMode(options?: SetBrightnessModeOptions): void
```js ```js
brightness.setMode({ brightness.setMode({
mode: 1, mode: 1,
success: function() { success: () => {
console.log('handling set mode success.'); console.log('handling set mode success.');
}, },
fail: function(data, code) { fail: (data: string, code: number) => {
console.error('handling set mode fail, code:' + code + ', data: ' + data); console.error('handling set mode fail, code:' + code + ', data: ' + data);
} }
}); });
...@@ -150,10 +150,10 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -150,10 +150,10 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
```js ```js
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: true, keepScreenOn: true,
success: function () { success: () => {
console.log('handling set keep screen on success.'); console.log('handling set keep screen on success.');
}, },
fail: function (data, code) { fail: (data: string, code: number) => {
console.error('handling set keep screen on fail, code:' + code + ', data: ' + data); console.error('handling set keep screen on fail, code:' + code + ', data: ' + data);
} }
}); });
......
...@@ -38,7 +38,7 @@ registerThermalLevelCallback(callback: Callback&lt;ThermalLevel&gt;): void ...@@ -38,7 +38,7 @@ registerThermalLevelCallback(callback: Callback&lt;ThermalLevel&gt;): void
```js ```js
try { try {
thermal.registerThermalLevelCallback(level => { thermal.registerThermalLevelCallback((level: thermal.ThermalLevel) => {
console.info('thermal level is: ' + level); console.info('thermal level is: ' + level);
}); });
console.info('register thermal level callback success.'); console.info('register thermal level callback success.');
...@@ -108,7 +108,7 @@ getLevel(): ThermalLevel ...@@ -108,7 +108,7 @@ getLevel(): ThermalLevel
```js ```js
try { try {
var level = thermal.getLevel(); let level = thermal.getLevel();
console.info('thermal level is: ' + level); console.info('thermal level is: ' + level);
} catch(err) { } catch(err) {
console.error('get thermal level failed, err: ' + err); console.error('get thermal level failed, err: ' + err);
...@@ -134,7 +134,7 @@ subscribeThermalLevel(callback: AsyncCallback&lt;ThermalLevel&gt;): void ...@@ -134,7 +134,7 @@ subscribeThermalLevel(callback: AsyncCallback&lt;ThermalLevel&gt;): void
**示例:** **示例:**
```js ```js
thermal.subscribeThermalLevel((level) => { thermal.subscribeThermalLevel((err: BusinessError<void>, level: thermal.ThermalLevel) => {
console.info('thermal level is: ' + level); console.info('thermal level is: ' + level);
}); });
``` ```
...@@ -182,7 +182,7 @@ getThermalLevel(): ThermalLevel ...@@ -182,7 +182,7 @@ getThermalLevel(): ThermalLevel
**示例:** **示例:**
```js ```js
var level = thermal.getThermalLevel(); let level = thermal.getThermalLevel();
console.info('thermal level is: ' + level); console.info('thermal level is: ' + level);
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册