自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
硬體評估
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
硬體評估會提供三種目標觸覺效果的定量特性,這些特性是透過用於呼叫觸覺效果的常用方法取樣。評估結束後,您可以將每部裝置針對每個目標觸覺回饋效果的效能套用至效能地圖,以便做出結論。
效能地圖會顯示多款目前 Android 裝置的硬體評估結果。目標是透過內容相關的相對比較 (而非通過或失敗的判斷) 來評估目標裝置。以這個概念為架構的具體問題如下:考量到手機的價格層級和致動器類型,與競爭對手相比,效能如何?結果是否符合預期?如果沒有,請問哪些地方需要改進?
圖 1. 觸覺技術硬體評估程序總覽
評估會觀察 Android 觸覺回饋架構中三種方法的結果。
效果 1:預先定義的短觸覺常數
VibrationEffect.EFFECT_CLICK
這個常數是 HAL 和 API 之間的對應常數中提供的 HAL-API 對應項目中的基準效果或共同分母。並與最常用的效果 HapticFeedbackConstants.KEYBOARD_PRESS
對應。評估這項效果有助於您判斷目標裝置是否可支援清晰的觸覺回饋。
效果 2:短暫自訂觸覺技術效果
VibrationEffect.createOneShot(20,255)
針對短暫的單一自訂脈衝,建議的時間長度上限為 20 毫秒。不建議使用長度超過 20 毫秒的單一脈衝,因為系統會將其視為嗡嗡作響的震動。
圖 2. 短暫自訂觸覺技術效果
效果 3:長時間自訂觸覺技術效果,並變更振幅
VibrationEffect.createWaveform(timings[], amplitudes[], int repeat)
能夠產生不同振幅的自訂觸覺效果,是評估裝置豐富觸覺回饋功能的指標之一。建議的 timings [ ]
和 amplitudes [ ]
分別為 {500, 500}
和 {128, 255}
。這張圖表顯示振幅從 50% 增加到 100%,採樣率為 500 毫秒。
圖 3. 長時間自訂觸覺技術效果 (振幅變化)
如要快速檢查效果 3 的振幅控制硬體功能,請試試 Vibrator.hasAmplitudeControl()
。結果必須是 true
,才能依預期執行 VibrationEffect.createWaveform
,並以不同的振幅變化。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Hardware assessment\n\nThe hardware assessment delivers quantitative characteristics of three target\nhaptic effects sampled by common methods used to call haptics. At the end of the\nassessment, performance from each device for each target haptic effect can be\napplied to the [performance map](/docs/core/interaction/haptics/compare) to\ndraw conclusions.\n\nThe performance map shows the hardware assessment results from several current\nAndroid devices. The goal is to evaluate the target device using a contextually\nrelative comparison (rather than a pass or fail judgement). Specific questions\nstructured around that notion are: *Given the price tier and\nactuator type of my phone, how is the performance compared to my competitors? Do\nthe results meet my expectations? If not, what needs improvement?*\n\n**Figure 1.** Haptics hardware assessment process overview\n\nThe assessment observes the results of three methods in the Android haptic\nframework.\n\n### Effect 1: Predefined short haptic constants\n\n[`VibrationEffect.EFFECT_CLICK`](https://developer.android.com/reference/android/os/VibrationEffect.html#EFFECT_CLICK)\n\nThis constant is the baseline effect or common denominator in the HAL-API\nmapping provided in\n[Map constants between HAL and API](/docs/core/interaction/haptics/haptics-map-constants).\nIt's mapped with the most commonly used effect\n[`HapticFeedbackConstants.KEYBOARD_PRESS`](https://developer.android.com/reference/android/view/HapticFeedbackConstants#KEYBOARD_PRESS).\nAssessing this effect helps you determine the readiness of your\ntarget device for\n[clear haptics](/docs/core/interaction/haptics/haptics-ux-foundation#clear-haptics).\n\n### Effect 2: Short custom haptic effect\n\n[`VibrationEffect.createOneShot(20,255)`](https://developer.android.com/reference/android/os/VibrationEffect#createOneShot(long,%20int))\n\nFor short single custom impulses, 20 ms is the recommended maximum\nthreshold to define duration. A single impulse that's longer than 20 ms\nisn't recommended because it's perceived as a\n[buzzy vibration](/docs/core/interaction/haptics/haptics-ux-foundation#buzzy-vibration).\n\n**Figure 2.** Short custom haptic effect\n\n### Effect 3: Long custom haptic effect with amplitude variation\n\n[`VibrationEffect.createWaveform(timings[], amplitudes[], int repeat)`](https://developer.android.com/reference/android/os/VibrationEffect#createWaveform(long%5B%5D,%20int%5B%5D,%20int))\n\nThe ability to produce varying amplitudes for custom haptic effects is one of\nthe indicators to evaluate the device's capabilities for\n[rich haptics](/docs/core/interaction/haptics/haptics-ux-foundation#rich-haptics).\nThe recommended `timings [ ]` and `amplitudes [ ]` are `{500, 500}` and\n`{128, 255}`, respectively. This presents an increasing trend of amplitude from\n50% to 100% with a 500 ms sampling rate.\n\n**Figure 3.** Long custom haptic effect with amplitude variation\n\nTo quickly check the hardware capabilities of amplitude control for Effect 3,\ntry\n[`Vibrator.hasAmplitudeControl()`](https://developer.android.com/reference/android/os/Vibrator#hasAmplitudeControl()).\nThe result has to be `true` to execute\n[`VibrationEffect.createWaveform`](https://developer.android.com/reference/android/os/VibrationEffect#createWaveform(long%5B%5D,%20int%5B%5D,%20int))\nwith varying amplitude as intended."]]