Skip to content

Commit 7c5af17

Browse files
committed
VibratorInfo: Don't log error when frequency profile is absent
HALs that don't report CAP_FREQUENCY_CONTROL (e.g. AIDL V1) have no frequency profile data. The framework creates FrequencyProfile with null arrays and NaN resonant frequency, which is a valid 'no data' state — not an error. Before this change, the constructor logged an ERROR-level message: Invalid frequency profile received from HAL. resonantFrequencyHz=NaN, frequenciesHz=null, outputAccelerationsGs=null This spams logcat on every boot for devices with older vibrator HALs that work perfectly fine without frequency control. Add an early return when both frequency arrays are null, silently setting all profile fields to null/NaN. The error log is preserved for genuinely invalid states (e.g. mismatched array lengths, one array null but the other non-null). Signed-off-by: Quince <quinceroms@gmail.com>
1 parent f5cb5cb commit 7c5af17

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

core/java/android/os/VibratorInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,15 @@ public FrequencyProfile(float resonantFrequencyHz, float[] frequenciesHz,
690690

691691
mResonantFrequencyHz = resonantFrequencyHz;
692692

693+
if (frequenciesHz == null && outputAccelerationsGs == null) {
694+
mFrequenciesHz = null;
695+
mOutputAccelerationsGs = null;
696+
mMinFrequencyHz = Float.NaN;
697+
mMaxFrequencyHz = Float.NaN;
698+
mMaxOutputAccelerationGs = Float.NaN;
699+
return;
700+
}
701+
693702
boolean isValid = (frequenciesHz != null && outputAccelerationsGs != null)
694703
&& (frequenciesHz.length == outputAccelerationsGs.length)
695704
&& (frequenciesHz.length > 0);

0 commit comments

Comments
 (0)