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

!3333 描述修改

Merge pull request !3333 from wuang/OpenHarmony-3.1-Release
...@@ -42,7 +42,8 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ...@@ -42,7 +42,8 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
console.info("Request suspension delay will time out."); console.info("Request suspension delay will time out.");
}); });
var id = delayInfo.requestId;console.info("requestId is: " + id); var id = delayInfo.requestId;
console.info("requestId is: " + id);
``` ```
...@@ -50,9 +51,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ...@@ -50,9 +51,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
```js ```js
backgroundTaskManager.getRemainingDelayTime(id).then( res => { backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res)); console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data); console.log('promise => Operation getRemainingDelayTime failed. Cause: ' + err.data);
}); });
``` ```
...@@ -83,9 +84,9 @@ console.info("The actualDelayTime is: " + time); ...@@ -83,9 +84,9 @@ console.info("The actualDelayTime is: " + time);
// 获取应用程序进入挂起状态前的剩余时间 // 获取应用程序进入挂起状态前的剩余时间
backgroundTaskManager.getRemainingDelayTime(id).then( res => { backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res)); console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data); console.log('promise => Operation getRemainingDelayTime failed. Cause: ' + err.data);
}); });
// 取消延迟挂起 // 取消延迟挂起
...@@ -172,16 +173,16 @@ ohos.permission.KEEP_BACKGROUND_RUNNING ...@@ -172,16 +173,16 @@ ohos.permission.KEEP_BACKGROUND_RUNNING
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
// 通过wantAgent模块的getWantAgent方法获取WantAgent对象 // 通过wantAgent模块的getWantAgent方法获取WantAgent对象
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation succeeded"); console.info("Operation startBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
console.error("Operation failed Cause: " + err); console.error("Operation startBackgroundRunning failed Cause: " + err);
}); });
}); });
``` ```
...@@ -193,9 +194,9 @@ ohos.permission.KEEP_BACKGROUND_RUNNING ...@@ -193,9 +194,9 @@ ohos.permission.KEEP_BACKGROUND_RUNNING
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation succeeded"); console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
console.error("Operation failed Cause: " + err); console.error("Operation stopBackgroundRunning failed Cause: " + err);
}); });
``` ```
...@@ -220,25 +221,25 @@ function startBackgroundRunning() { ...@@ -220,25 +221,25 @@ function startBackgroundRunning() {
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
// 通过wantAgent模块的getWantAgent方法获取WantAgent对象 // 通过wantAgent模块的getWantAgent方法获取WantAgent对象
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation succeeded"); console.info("Operation startBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
console.error("Operation failed Cause: " + err); console.error("Operation startBackgroundRunning failed Cause: " + err);
}); });
}); });
} }
function stopBackgroundRunning() { function stopBackgroundRunning() {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation succeeded"); console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
console.error("Operation failed Cause: " + err); console.error("Operation stopBackgroundRunning failed Cause: " + err);
}); });
} }
......
...@@ -33,11 +33,17 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen ...@@ -33,11 +33,17 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen
| [DelaySuspendInfo](#delaysuspendinfo) | 返回延迟挂起信息。 | | [DelaySuspendInfo](#delaysuspendinfo) | 返回延迟挂起信息。 |
**示例** **示例**
```js ```js
let myReason = 'test requestSuspendDelay'; let myReason = 'test requestSuspendDelay';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.info("Request suspension delay will time out."); console.info("Request suspension delay will time out.");
}) })
var id = delayInfo.requestId;
var time = delayInfo.actualDelayTime;
console.info("The requestId is: " + id);
console.info("The actualDelayTime is: " + time);
``` ```
...@@ -61,9 +67,9 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): ...@@ -61,9 +67,9 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>):
let id = 1; let id = 1;
backgroundTaskManager.getRemainingDelayTime(id, (err, res) => { backgroundTaskManager.getRemainingDelayTime(id, (err, res) => {
if(err.data === 0) { if(err.data === 0) {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res)); console.log('callback => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
} else { } else {
console.log('promise => Operation failed. Cause: ' + err.data); console.log('callback => Operation getRemainingDelayTime failed. Cause: ' + err.data);
} }
}) })
``` ```
...@@ -91,9 +97,9 @@ getRemainingDelayTime(requestId: number): Promise<number> ...@@ -91,9 +97,9 @@ getRemainingDelayTime(requestId: number): Promise<number>
```js ```js
let id = 1; let id = 1;
backgroundTaskManager.getRemainingDelayTime(id).then( res => { backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res)); console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data); console.log('promise => Operation getRemainingDelayTime failed. Cause: ' + err.data);
}) })
``` ```
...@@ -143,9 +149,9 @@ import wantAgent from '@ohos.wantAgent'; ...@@ -143,9 +149,9 @@ import wantAgent from '@ohos.wantAgent';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
console.error("Operation failed Cause: " + err); console.error("Operation startBackgroundRunning failed Cause: " + err);
} else { } else {
console.info("Operation succeeded"); console.info("Operation startBackgroundRunning succeeded");
} }
} }
...@@ -158,7 +164,7 @@ let wantAgentInfo = { ...@@ -158,7 +164,7 @@ let wantAgentInfo = {
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
...@@ -206,15 +212,15 @@ let wantAgentInfo = { ...@@ -206,15 +212,15 @@ let wantAgentInfo = {
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}; };
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation succeeded"); console.info("Operation startBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
console.error("Operation failed Cause: " + err); console.error("Operation startBackgroundRunning failed Cause: " + err);
}); });
}); });
...@@ -241,9 +247,9 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -241,9 +247,9 @@ import featureAbility from '@ohos.ability.featureAbility';
function callback(err, data) { function callback(err, data) {
if (err) { if (err) {
console.error("Operation failed Cause: " + err); console.error("Operation stopBackgroundRunning failed Cause: " + err);
} else { } else {
console.info("Operation succeeded"); console.info("Operation stopBackgroundRunning succeeded");
} }
} }
...@@ -275,9 +281,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ...@@ -275,9 +281,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation succeeded"); console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
console.error("Operation failed Cause: " + err); console.error("Operation stopBackgroundRunning failed Cause: " + err);
}); });
``` ```
...@@ -298,14 +304,14 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() ...@@ -298,14 +304,14 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(()
**系统能力:** 以下各项对应的系统能力均为SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **系统能力:** 以下各项对应的系统能力均为SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
| 参数名 | 参数值 | 描述 | | 参数名 | 参数值 | 描述 |
| ----------------------- | ---- | ------------ | | ----------------------- | ------ | ---------------------------- |
| DATA_TRANSFER | 1 | 数据传输 | | DATA_TRANSFER | 1 | 数据传输 |
| AUDIO_PLAYBACK | 2 | 音频播放 | | AUDIO_PLAYBACK | 2 | 音频播放 |
| AUDIO_RECORDING | 3 | 录音 | | AUDIO_RECORDING | 3 | 录音 |
| LOCATION | 4 | 定位导航 | | LOCATION | 4 | 定位导航 |
| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | | BLUETOOTH_INTERACTION | 5 | 蓝牙相关 |
| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | | MULTI_DEVICE_CONNECTION | 6 | 多设备互联 |
| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | | WIFI_INTERACTION | 7 | WLAN相关(系统保留) |
| VOIP | 8 | 音视频通话(系统保留) | | VOIP | 8 | 音视频通话(系统保留) |
| TASK_KEEPING | 9 | 计算任务 | | TASK_KEEPING | 9 | 计算任务(仅在特定设备生效) |
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册