openharmony 鸿蒙 changelogs-sensors

2025-06-12 浏览 (1)

SensorService Kit Changelog

cl.sensors.1 Change of the count Attribute of VibratePreset from Mandatory to Optional

Access Level

Public API

Reason for Change

The count parameter of VibratePreset is mandatory even if the number of vibrations is 1.

Change Impact

This change is a non-compatible change.

Before change: The count attribute of VibratePreset is mandatory.

interface VibratePreset {
    type: 'preset';
    effectId: string;
    count: number;
}

After change: The count attribute of VibratePreset is optional, and the default value is 1.

interface VibratePreset {
    type: 'preset';
    effectId: string;
    count?: number;
}

Start API Level

9

Change Since

OpenHarmony SDK 5.0.0.27

Key API/Component Changes

count of VibratePreset in @ohos.vibrator.d.ts.

Adaptation Guide

The count attribute of VibratePreset is optional. If your app has a dependency on the type of this attribute, adaptation is required. For example, if the type of count is a number before change, you need to set the type of count to number|undefined after change.

let effect: VibratePreset = {
    type: 'preset',
    effectId: 'xxx',
    count: 2
};

let count: number|undefined = effect.count;

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Globalization Changelog

harmony 鸿蒙Multimedia Changelog

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/2K3wj4