ReviewOS

craft-native/craft

fix(android): haptic, vibrate, startListening and stopListening answer nothing, where iOS now does

#219
Closed glennmichael123 opened this 9 days ago ·
9 days ago

The fix for #207 makes four iOS page calls return a promise with native's answer. On Android the same four calls still return undefined, so a page written against one platform behaves differently on the other.

page calliOS after #207Android today
craft.haptic(style)resolves true; rejects CAPABILITY_DISABLED when enableHaptics is offreturns undefined (CraftBridge.kt.template:359)
craft.vibrate(pattern)resolves truereturns undefined (:502); Kotlin catches and logs every failure
craft.startListening()resolves true once the request is taken; rejects CAPABILITY_DISABLEDreturns undefined (:364). If RECORD_AUDIO is not granted, it asks for the permission and then reports nothing, not even craftSpeechError, and does not start after the grant
craft.stopListening()resolves truereturns undefined (:367), and sends no craftSpeechEnd

craft.d.ts types all four as Promise<boolean> | void, with "Android returns nothing yet", until this is fixed.

What parity looks like

  • Return a promise from each, through the __craftPromise channel pattern share uses since #210.
  • haptic and startListening can only reject CAPABILITY_DISABLED once Android checks its enable* flags, which is #209. Until then, they would resolve true.
  • startListening without the microphone permission should at least emit craftSpeechError, so a page is not left waiting on an event.
  • The Android E2E suite can then run the same haptic.resolvesTrue and vibrate.resolvesTrue cases the iOS suite gained in #207.

Found while fixing #207.

Sign in to comment on this issue.