From 7205b3f49014501c6f615253d04bc5a29dfad211 Mon Sep 17 00:00:00 2001 From: limeimetw Date: Wed, 24 Jun 2026 19:14:34 +0800 Subject: [PATCH] fix: make regular keypress sounds audible on Pixel --- .../net/toload/main/hd/LIMEServiceTest.java | 27 +++++++++++++++++++ .../java/net/toload/main/hd/LIMEService.java | 4 ++- docs/#128_ISSUE.md | 12 ++++----- docs/BACKLOG.md | 2 +- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/LimeStudio/app/src/androidTest/java/net/toload/main/hd/LIMEServiceTest.java b/LimeStudio/app/src/androidTest/java/net/toload/main/hd/LIMEServiceTest.java index 526547d8..b85c7664 100644 --- a/LimeStudio/app/src/androidTest/java/net/toload/main/hd/LIMEServiceTest.java +++ b/LimeStudio/app/src/androidTest/java/net/toload/main/hd/LIMEServiceTest.java @@ -10443,6 +10443,33 @@ public void doVibrateSoundUsesCustomKeypressSoundVolumeWhenConfigured() throws E .commit(); } + @Test + public void doVibrateSoundUsesAudibleKeypressEffectForRegularKeys() throws Exception { + LIMEService service = new LIMEService(); + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + androidx.preference.PreferenceManager.getDefaultSharedPreferences(appContext) + .edit() + .putString("keypress_sound_volume", "1.00") + .commit(); + ensureLIMEPrefInitialized(service); + + AudioManager mockAudioManager = createMockAudioManager(); + injectMockComponents(service, null, null, null, mockAudioManager); + + Field hasSoundField = LIMEService.class.getDeclaredField("hasSound"); + hasSoundField.setAccessible(true); + hasSoundField.setBoolean(service, true); + + service.doVibrateSound(android.view.KeyEvent.KEYCODE_A); + + verify(mockAudioManager).playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR, 1.0f); + verify(mockAudioManager, never()).playSoundEffect(eq(AudioManager.FX_KEYPRESS_STANDARD), anyFloat()); + androidx.preference.PreferenceManager.getDefaultSharedPreferences(appContext) + .edit() + .remove("keypress_sound_volume") + .commit(); + } + /** * Tests switchKeyboard with mocked KeyboardSwitcher. * Lines 3038-3102 in LIMEService.java diff --git a/LimeStudio/app/src/main/java/net/toload/main/hd/LIMEService.java b/LimeStudio/app/src/main/java/net/toload/main/hd/LIMEService.java index 754f5f94..22ca3c14 100644 --- a/LimeStudio/app/src/main/java/net/toload/main/hd/LIMEService.java +++ b/LimeStudio/app/src/main/java/net/toload/main/hd/LIMEService.java @@ -5958,7 +5958,9 @@ public void doVibrateSound(int primaryCode) { } if (hasSound && mAudioManager != null) { - int sound = AudioManager.FX_KEYPRESS_STANDARD; + // Use the spacebar effect for regular keys because some Pixel/AOSP builds + // ship FX_KEYPRESS_STANDARD at a much lower audible level than other keys. + int sound = AudioManager.FX_KEYPRESS_SPACEBAR; switch (primaryCode) { case LIMEBaseKeyboard.KEYCODE_DELETE: sound = AudioManager.FX_KEYPRESS_DELETE; diff --git a/docs/#128_ISSUE.md b/docs/#128_ISSUE.md index 602f00cc..2942aefc 100644 --- a/docs/#128_ISSUE.md +++ b/docs/#128_ISSUE.md @@ -4,7 +4,7 @@ Community reporter `s9228034david-spec` reports that on a Samsung A55, enabling **喜好設定 / 打字震動** does not produce any vibration while typing with the LIME Android soft keyboard. -**Status: closed / GitHub APK v6.1.25 now contains the PR #133 follow-up, pending device verification.** PR #132 merged to `master` as merge commit `e0659dac3670e42b0970cae54fdc7fd299c2a19e`, and Android APK `LIMEHD2026-6.1.24.apk` contains that Samsung-oriented haptic fix. The original Samsung reporter later confirmed v6.1.24 restored both vibration and sound on Samsung A55 / Android 16 / One UI 8.5, and Jeremy verified on Samsung A17 that vibration works and the vibration-level preference changes the pulse. Jeremy then reported a new Pixel / Android 17 regression where both keypress vibration and keypress sound stopped working after the Samsung fix. PR #133 merged to `master` as merge commit `6791f14a06047047c39dc53875ce2ebaebcf1327`, restoring the Google/Pixel API 31+ system keyboard-tap haptic path while preserving Samsung/raw-pulse routing, adding the Samsung sound-volume preference, and closing #128. GitHub APK `LIMEHD2026-6.1.25.apk` now contains PR #133; remaining verification is Pixel / Android 17 plus Samsung A17 sound-volume and stronger-pulse device checks. The original community reporter already confirmed the Samsung A55 issue on v6.1.24, so no duplicate public reporter retest is needed unless new evidence appears. +**Status: closed / follow-up Pixel sound fix in progress.** PR #132 merged to `master` as merge commit `e0659dac3670e42b0970cae54fdc7fd299c2a19e`, and Android APK `LIMEHD2026-6.1.24.apk` contains that Samsung-oriented haptic fix. The original Samsung reporter later confirmed v6.1.24 restored both vibration and sound on Samsung A55 / Android 16 / One UI 8.5, and Jeremy verified on Samsung A17 that vibration works and the vibration-level preference changes the pulse. Jeremy then reported a new Pixel / Android 17 regression where both keypress vibration and keypress sound stopped working after the Samsung fix. PR #133 merged to `master` as merge commit `6791f14a06047047c39dc53875ce2ebaebcf1327`, restoring the Google/Pixel API 31+ system keyboard-tap haptic path while preserving Samsung/raw-pulse routing, adding the Samsung sound-volume preference, and closing #128. GitHub APK `LIMEHD2026-6.1.25.apk` now contains PR #133; Jeremy confirmed Pixel vibration is OK on that follow-up, but normal character-key sound remains much quieter than Backspace / Space / Enter even with phone sound and LIME volume at maximum. The current Pixel sound follow-up routes regular character keys away from Android's near-silent `FX_KEYPRESS_STANDARD` sample and needs device APK verification. The original community reporter already confirmed the Samsung A55 issue on v6.1.24, so no duplicate public reporter retest is needed unless new evidence appears. Issue: https://github.com/lime-ime/limeime/issues/128 @@ -84,7 +84,7 @@ The root-cause fix (`createOneShot`) applies to all API levels, but only API 33+ Samsung path: confirmed and fixed on a maintainer-tested Samsung SM-A1760 / Android 16 device, the original reporter later confirmed v6.1.24 restored both vibration and sound on Samsung A55 / Android 16 / One UI 8.5, and Jeremy verified vibration plus the vibration-level preference on Samsung A17. The Samsung fix replaces predefined `VibrationEffect`s — which the tested Samsung device's vibrator HAL silently discards as `ignored_unsupported` — with `createOneShot(...)` raw pulses, tagged `USAGE_TOUCH` on API 33+. -Pixel regression path: Jeremy reports Pixel / Android 17 now has both keypress vibration and keypress sound not working after the Samsung fix, while Pixel vibration worked before. The follow-up restores the pre-Samsung Google/Pixel API 31+ system keyboard-tap path when `mInputView` exists, while keeping Samsung and unknown OEMs on direct raw pulses. Because sound shares the same `onPress(...)` / `doVibrateSound(...)` path and was not changed by the haptic split, any remaining Pixel sound failure still needs targeted debugging. +Pixel regression path: Jeremy reports Pixel / Android 17 lost both keypress vibration and keypress sound after the Samsung fix, while Pixel vibration worked before. The PR #133 follow-up restores the pre-Samsung Google/Pixel API 31+ system keyboard-tap path when `mInputView` exists, while keeping Samsung and unknown OEMs on direct raw pulses. After PR #133, Pixel vibration is confirmed OK. Remaining Pixel sound evidence is narrower: regular character keys are nearly inaudible, while Backspace / Space / Enter remain audible even with phone sound and LIME keypress volume at maximum. That isolates sound to the Android effect constant used for normal keys (`FX_KEYPRESS_STANDARD`) rather than `onPress(...)`, `hasSound`, `mAudioManager`, or preference plumbing. ### iOS @@ -123,14 +123,14 @@ Raw pulse behavior remains: - **Samsung A17 maintainer retest on v6.1.24:** Jeremy verified vibration works, `vibrate_level` changes the pulse, and sound works. `super weak` was barely perceptible on that build. ✅ - **Samsung A17 follow-up added in PR #133:** runtime vibration maps the stored preference values to stronger pulse durations without changing the persisted values. Multiple Android system-volume attempts (`playSoundEffect(sound)`, explicit `STREAM_SYSTEM`, `STREAM_MUSIC`, and `-1.0f`) were still not enough on device, so LIME now has a `keypress_sound_volume` preference: system default by default, with custom 10% / 25% / 50% / 75% / 100% levels when Samsung/system behavior is too loud. These PR #133-only follow-ups are now present in GitHub APK v6.1.25 and need device retest. ⏳ - **Java compile gates:** `:app:compileDebugJavaWithJavac` and `:app:compileDebugAndroidTestJavaWithJavac` both passed during PR #132 verification. -- **Regression follow-up:** PR #133 (`6791f14a06047047c39dc53875ce2ebaebcf1327`) restores Google/Pixel API 31+ view haptics while preserving Samsung raw pulses and adds the Samsung sound-volume preference / stronger vibration mapping. GitHub APK `LIMEHD2026-6.1.25.apk` now contains this follow-up and is ready for Pixel / Android 17 and Samsung A17 device verification. Pixel keypress sound, if still failing on v6.1.25, remains a separate feedback-path investigation because the haptic split does not change the sound primitive. +- **Regression follow-up:** PR #133 (`6791f14a06047047c39dc53875ce2ebaebcf1327`) restores Google/Pixel API 31+ view haptics while preserving Samsung raw pulses and adds the Samsung sound-volume preference / stronger vibration mapping. GitHub APK `LIMEHD2026-6.1.25.apk` contains this follow-up. Jeremy verified Pixel vibration is OK, but regular Pixel character-key sound remains far quieter than Backspace / Space / Enter. The next sound follow-up changes regular character keys to use the audible `FX_KEYPRESS_SPACEBAR` effect instead of Pixel/AOSP's near-silent `FX_KEYPRESS_STANDARD`, with an androidTest regression asserting the regular-key mapping. - **Not verified:** API 31–32 (Android 12 / 12L) — no device available; see the API 31–32 caveat above. ## Current status -- **Closed / APK-delivered, awaiting device verification.** #128 remains closed after the PR #133 merge. GitHub APK `LIMEHD2026-6.1.25.apk` now contains merge commit `6791f14a06047047c39dc53875ce2ebaebcf1327` and the PR #133 haptic/sound-volume follow-up. +- **Closed / APK-delivered, Pixel sound follow-up in progress.** #128 remains closed after the PR #133 merge. GitHub APK `LIMEHD2026-6.1.25.apk` contains merge commit `6791f14a06047047c39dc53875ce2ebaebcf1327` and the PR #133 haptic/sound-volume follow-up. Pixel vibration is now OK; remaining Pixel sound issue is regular character-key audibility. - Samsung root cause remains valid for the Samsung path: device vibrator reports an empty supported-effects table, so predefined `VibrationEffect`s were dropped at the HAL. The original "Samsung returns `false` from `performHapticFeedback`" hypothesis was disproven on hardware (it returns `true`). -- PR #133 follow-up in v6.1.25: stored `vibrate_level` values remain `20/30/40/50/60` for compatibility, but runtime maps them to `30/40/50/60/70` ms pulses; keypress sound defaults to Android's one-arg `playSoundEffect(...)` path and adds a LIME-owned `keypress_sound_volume` preference for custom scalar levels when Samsung/system behavior is too loud. +- PR #133 follow-up in v6.1.25: stored `vibrate_level` values remain `20/30/40/50/60` for compatibility, but runtime maps them to `30/40/50/60/70` ms pulses; keypress sound defaults to Android's one-arg `playSoundEffect(...)` path and adds a LIME-owned `keypress_sound_volume` preference for custom scalar levels when Samsung/system behavior is too loud. The Pixel sound follow-up is separate: when the platform's standard-key sample itself is too quiet, volume scalar alone is insufficient, so regular keys avoid `FX_KEYPRESS_STANDARD`. - Android APK `LIMEHD2026-6.1.25.apk` verified on `master`: GitHub Contents blob SHA `11476f674bfb859704f834ba159caae8c137e19e`, size 7,407,192 bytes, downloaded SHA-256 `d89cfffaf2f252a4eb4570fa3ad95866ccb4018e921fe9aaae0c465e8a94e66f`, raw link https://raw.githubusercontent.com/lime-ime/limeime/master/LimeStudio/app/release/LIMEHD2026-6.1.25.apk. -- Next verification: test Pixel / Android 17 keypress vibration and sound on v6.1.25; retest Samsung A17 stronger vibration levels and the new `keypress_sound_volume` preference. If Pixel sound is still failing, verify `onPress(...)`, `doVibrateSound(...)`, `hasSound`, `mAudioManager`, and preference reload; the haptic split does not change the sound effect path. +- Next verification: after the Pixel sound follow-up APK is built, verify Pixel / Android 17 vibration remains OK and regular character keys are as audible as Backspace / Space / Enter; also retest Samsung A17 stronger vibration levels and the new `keypress_sound_volume` preference. - No iOS/TestFlight retest is implied by this Android report. No duplicate public retest request is needed for the original Samsung A55 reporter because they already confirmed the original issue fixed on v6.1.24. diff --git a/docs/BACKLOG.md b/docs/BACKLOG.md index 3d68d926..d4191a28 100644 --- a/docs/BACKLOG.md +++ b/docs/BACKLOG.md @@ -10,7 +10,7 @@ Last reviewed: 2026-06-24 ## Source fixed / awaiting build or release verification -- #128 Android: GitHub APK `LIMEHD2026-6.1.25.apk` now contains PR #133 (`6791f14a06047047c39dc53875ce2ebaebcf1327`), which restores the Google/Pixel API 31+ system keyboard-tap haptic path while preserving Samsung/raw-pulse routing, adds the Samsung keypress-sound volume preference, and maps stored vibration levels to stronger runtime pulses. Verified GitHub Contents blob SHA `11476f674bfb859704f834ba159caae8c137e19e`, size 7,407,192 bytes, downloaded SHA-256 `d89cfffaf2f252a4eb4570fa3ad95866ccb4018e921fe9aaae0c465e8a94e66f`. Remaining release QA: verify Pixel / Android 17 keypress vibration and sound on v6.1.25, and retest Samsung A17 stronger vibration levels plus the new `keypress_sound_volume` preference. The original Samsung A55 community reporter already confirmed the original issue fixed on v6.1.24, so no duplicate public reporter retest is needed unless new evidence appears. +- #128 Android: GitHub APK `LIMEHD2026-6.1.25.apk` contains PR #133 (`6791f14a06047047c39dc53875ce2ebaebcf1327`), which restores the Google/Pixel API 31+ system keyboard-tap haptic path while preserving Samsung/raw-pulse routing, adds the Samsung keypress-sound volume preference, and maps stored vibration levels to stronger runtime pulses. Verified GitHub Contents blob SHA `11476f674bfb859704f834ba159caae8c137e19e`, size 7,407,192 bytes, downloaded SHA-256 `d89cfffaf2f252a4eb4570fa3ad95866ccb4018e921fe9aaae0c465e8a94e66f`. Pixel / Android 17 vibration is now OK, but regular character-key sound remains far quieter than Backspace / Space / Enter even with phone sound and LIME volume at maximum; the current Pixel sound follow-up routes regular keys away from Android's near-silent `FX_KEYPRESS_STANDARD` effect. Remaining release QA after the follow-up APK: verify Pixel regular-key audibility, confirm Pixel vibration remains OK, and retest Samsung A17 stronger vibration levels plus the new `keypress_sound_volume` preference. The original Samsung A55 community reporter already confirmed the original issue fixed on v6.1.24, so no duplicate public reporter retest is needed unless new evidence appears. - #119 iOS: `.lime` / `.cin` text import now has explicit intended keyboard layouts for known IMs, with iOS writing a keyboard config row after text import. Android source delivery is covered through GitHub APK v6.1.24, including the PR #131 metadata-preservation follow-up; remaining release QA is iOS TestFlight/App Store delivery unless new Android evidence appears. - #121 iOS: cloud/download IM first-switch sync fix landed on `master` in merge commit `e3aef89cca52b08fd48d68105dce2fe0042f0f19` and the maintainer-created issue is closed. Remaining validation is iOS unit/simulator/device and TestFlight/App Store release QA; no Android APK retest applies.