diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-time.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-time.md new file mode 100644 index 0000000000000000000000000000000000000000..ace0e64602be8ef7cb1462d3288476a65675e071 --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.1/changelogs-time.md @@ -0,0 +1,266 @@ +# 时间时区子系统ChangeLog + +## cl.time.1 接口异常抛出变更 + +时间时区子系统定时器接口异常抛出:202非系统应用异常和401参数无效异常。 + +**变更影响** + +该接口变更前向兼容,基于此前版本开发的应用可继续使用接口,增加相应的异常处理,原有功能不受影响。 + +**关键接口/组件变更** + +变更前: + - 接口异常抛出message,无错误码。 + +变更后: + - 接口异常抛出message和code,包括202非系统应用异常和401参数无效异常。 + + | 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | + | ----------------- | ----------- | ------------------------------------------------------------ | -------- | + | @ohos.systemTimer | systemTimer | function createTimer(options: TimerOptions, callback: AsyncCallback): void | 变更 | + | @ohos.systemTimer | systemTimer | function createTimer(options: TimerOptions): Promise | 变更 | + | @ohos.systemTimer | systemTimer | function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void | 变更 | + | @ohos.systemTimer | systemTimer | function startTimer(timer: number, triggerTime: number): Promise | 变更 | + | @ohos.systemTimer | systemTimer | function stopTimer(timer: number, callback: AsyncCallback): void | 变更 | + | @ohos.systemTimer | systemTimer | function stopTimer(timer: number): Promise | 变更 | + | @ohos.systemTimer | systemTimer | function destroyTimer(timer: number, callback: AsyncCallback): void | 变更 | + | @ohos.systemTimer | systemTimer | function destroyTimer(timer: number): Promise | 变更 | + + +**适配指导** + +应用中调用systemTimer所有接口可参考下列代码进行异常捕获 + +createTimer callback形式调用: + +**示例:** + +```js +export default { + systemTimer () { + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat: false + }; + try { + systemTimer.createTimer(options, (error, data) => { + if (error) { + //捕获权限否定异常 + console.info(`Failed to create timer. message:${error.message}, code:${error.code}`); + } + }); + } catch(e) { + //捕获参数校验失败异常 + console.info(`Failed to create timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +createTimer promise形式调用: + +**示例:** + +```js +export default { + systemTimer () { + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat: false + }; + try { + systemTimer.createTimer(options).then((data) => { + console.info(`Succeeded in creating timer. Data:` + data); + }).catch((error) => { + //捕获权限否定异常 + console.info(`Failed to create timer. message:${error.message}, code:${error.code}`); + }); + } catch(e) { + //捕获参数校验失败异常 + console.info(`Failed to create timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +startTimer callback形式调用: + +**示例:** + +```js +export default { + async systemTimer () { + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options); + let triggerTime = new Date().getTime(); + triggerTime += 3000; + try { + systemTimer.startTimer(timerId, triggerTime, (error) => { + if (error) { + //捕获权限否定异常 + console.error(`Failed to start timer. message:${error.message}, code:${error.code}`); + } + }); + } catch (e) { + //捕获参数校验失败异常 + console.info(`Failed to start timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +startTimer promise形式调用: + +**示例:** + +```js +export default { + async systemTimer (){ + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options); + let triggerTime = new Date().getTime(); + triggerTime += 3000; + try { + systemTimer.startTimer(timerId, triggerTime).then((data) => { + console.log(`Succeeded in startting timer. Data:` + data); + }).catch((error) => { + //捕获权限否定异常 + console.info(`Failed to start timer. message:${error.message}, code:${error.code}`); + }); + } catch (e) { + //捕获参数校验失败异常 + console.info(`Failed to start timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +stopTimer callback形式调用: + +**示例:** + +```js +export default { + async systemTimer () { + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options); + let triggerTime = new Date().getTime(); + triggerTime += 3000; + systemTimer.startTimer(timerId, triggerTime); + try { + systemTimer.stopTimer(timerId, triggerTime, (error) => { + if (error) { + //捕获权限否定异常 + console.error(`Failed to stop timer. message:${error.message}, code:${error.code}`); + } + }); + } catch (e) { + //捕获参数校验失败异常 + console.info(`Failed to stop timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +stopTimer promise形式调用: + +**示例:** + +```js +export default { + async systemTimer (){ + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options); + let triggerTime = new Date().getTime(); + triggerTime += 3000; + systemTimer.startTimer(timerId, triggerTime); + try { + systemTimer.stopTimer(timerId, triggerTime).then((data) => { + console.log(`Succeeded in stop timer. Data:` + data); + }).catch((error) => { + //捕获权限否定异常 + console.info(`Failed to stop timer. message:${error.message}, code:${error.code}`); + }); + } catch (e) { + //捕获参数校验失败异常 + console.info(`Failed to stop timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +destroyTimer callback形式调用: + +**示例:** + +```js +export default { + async systemTimer () { + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options); + let triggerTime = new Date().getTime(); + triggerTime += 3000; + systemTimer.startTimer(timerId, triggerTime); + systemTimer.stopTimer(timerId); + try { + systemTimer.destroyTimer(timerId, triggerTime, (error) => { + if (error) { + //捕获权限否定异常 + console.error(`Failed to destroy timer. message:${error.message}, code:${error.code}`); + } + }); + } catch (e) { + //捕获参数校验失败异常 + console.info(`Failed to destroy timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + +destroyTimer promise形式调用: + +**示例:** + +```js +export default { + async systemTimer (){ + let options = { + type: systemTimer.TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = await systemTimer.createTimer(options); + let triggerTime = new Date().getTime(); + triggerTime += 3000; + systemTimer.startTimer(timerId, triggerTime); + systemTimer.stopTimer(timerId); + try { + systemTimer.destroyTimer(timerId, triggerTime).then((data) => { + console.log(`Succeeded in destroy timer. Data:` + data); + }).catch((error) => { + //捕获权限否定异常 + console.info(`Failed to destroy timer. message:${error.message}, code:${error.code}`); + }); + } catch (e) { + //捕获参数校验失败异常 + console.info(`Failed to destroy timer. message:${e.message}, code:${e.code}`); + } + } +} +``` + diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-time.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-time.md deleted file mode 100644 index 3a31803cc7ba744c449fe784b587a13b2a22fea8..0000000000000000000000000000000000000000 --- a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.1.1/changelogs-time.md +++ /dev/null @@ -1,31 +0,0 @@ -# 时间时区子系统ChangeLog - -## cl.time.1 接口异常抛出变更 - -时间时区子系统定时器接口异常抛出:202非系统应用异常和401参数无效异常。 - -**变更影响** - -该接口变更前向兼容,基于此前版本开发的应用可继续使用接口,增加相应的异常处理,原有功能不受影响。 - -**关键接口/组件变更** - -变更前: - - 接口异常抛出message,无错误码。 - -变更后: - - 接口异常抛出message和code,包括202非系统应用异常和401参数无效异常。 - - | 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | - | ----------------- | ----------- | ------------------------------------------------------------ | -------- | - | @ohos.systemTimer | systemTimer | function createTimer(options: TimerOptions, callback: AsyncCallback): void | 变更 | - | @ohos.systemTimer | systemTimer | function createTimer(options: TimerOptions): Promise | 变更 | - | @ohos.systemTimer | systemTimer | function startTimer(timer: number, triggerTime: number, callback: AsyncCallback): void | 变更 | - | @ohos.systemTimer | systemTimer | function startTimer(timer: number, triggerTime: number): Promise | 变更 | - | @ohos.systemTimer | systemTimer | function stopTimer(timer: number, callback: AsyncCallback): void | 变更 | - | @ohos.systemTimer | systemTimer | function stopTimer(timer: number): Promise | 变更 | - | @ohos.systemTimer | systemTimer | function destroyTimer(timer: number, callback: AsyncCallback): void | 变更 | - | @ohos.systemTimer | systemTimer | function destroyTimer(timer: number): Promise | 变更 | - - -