1# Pan-sensor Subsystem Changelog 2 3## cl.vibrator Added isSupportEffect 4 5The **isSupportEffect** API is added. 6 7**Change Impact** 8 9Applications developed based on OpenHarmony4.0.5.2 or a later SDK version can use **isSupportEffect** to check whether the passed effect ID is supported. 10 11**Key API/Component Changes** 12 13The **isSupportEffect** API is added in **@ohos.vibrator.d.ts**. 14 15| Module| Class| Method/Attribute/Enum/Constant| Change Type| 16| -- | -- | -- | -- | 17| @ohos.vibrator.d.ts | vibrator | isSupportEffect(effectId: string, callback: AsyncCallback<boolean>): void | Added| 18| @ohos.vibrator.d.ts | vibrator | isSupportEffect(effectId: string): Promise<boolean> | Added| 19 20**Adaptation Guide** 21 22Call **isSupportEffect** to check whether the passed effect ID is supported. 23 24```ts 25import vibrator from '@ohos.vibrator'; 26try { 27 // Check whether 'haptic.clock.timer' is supported. 28 vibrator.isSupportEffect('haptic.clock.timer', function (err, state) { 29 if (err) { 30 console.error('isSupportEffect failed, error:' + JSON.stringify(err)); 31 return; 32 } 33 console.log('The effectId is ' + (state ? 'supported' : 'unsupported')); 34 if (state) { 35 try { 36 vibrator.startVibration({ // To use startVibration, you must configure the ohos.permission.VIBRATE permission. 37 type: 'preset', 38 effectId: 'haptic.clock.timer', 39 count: 1, 40 }, { 41 usage: 'unknown' 42 }, (error) => { 43 if(error) { 44 console.error('haptic.clock.timer vibrator error:' + JSON.stringify(error)); 45 } else { 46 console.log('haptic.clock.timer vibrator success'); 47 } 48 }); 49 } catch (error) { 50 console.error('Exception in, error:' + JSON.stringify(error)); 51 } 52 } 53 }) 54} catch (error) { 55 console.error('Exception in, error:' + JSON.stringify(error)); 56} 57``` 58 59## cl.vibrator Added stopVibration 60 61The **stopVibration** API is added. 62 63**Change Impact** 64 65Applications developed based on OpenHarmony4.0.5.2 or a later SDK version can use **stopVibration** to stop vibration in all modes. 66 67**Key API/Component Changes** 68 69The **stopVibration** API is added in **@ohos.vibrator.d.ts**. 70 71| Module | Class | Method/Attribute/Enum/Constant | Change Type| 72| ------------------- | -------- | -------------------------------------------------------- | -------- | 73| @ohos.vibrator.d.ts | vibrator | stopVibration(callback: AsyncCallback<void>): void | Added | 74| @ohos.vibrator.d.ts | vibrator | stopVibration(): Promise<void> | Added | 75 76**Adaptation Guide** 77 78Call **stopVibration** to stop vibration in all modes. 79 80```ts 81import vibrator from '@ohos.vibrator'; 82try { 83 // Stop vibration in all modes. 84 vibrator.stopVibration(function (error) { 85 if (error) { 86 console.log('error.code' + error.code + 'error.message' + error.message); 87 return; 88 } 89 console.log('Callback returned to indicate successful.'); 90 }) 91} catch (error) { 92 console.info('errCode: ' + error.code + ' ,msg: ' + error.message); 93} 94``` 95