Effect AIDL: Refactor effect capability with Range

Bug: 258124419
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts:presubmit
Change-Id: I608fb7654591fb46061ecd5edbff20ccc977c5dd
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl
index 1d51ade..1ec7dad 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl
@@ -42,10 +42,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.AcousticEchoCanceler.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-    int maxEchoDelayUs;
-    boolean supportMobileMode;
-  }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl
index 39068d5..f3dd523 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl
@@ -43,12 +43,6 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.AutomaticGainControl.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-    int maxFixedDigitalGainMb;
-    int maxSaturationMarginMb;
-  }
   @Backing(type="int") @VintfStability
   enum LevelEstimator {
     RMS = 0,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl
index ff010c6..57d4418 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl
@@ -43,9 +43,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.AutomaticGainControlV1.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-    android.hardware.audio.effect.Range[] ranges;
-  }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl
index f8baa2a..d09fe54 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl
@@ -41,10 +41,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.BassBoost.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-    int maxStrengthPm;
-    boolean strengthSupported;
-  }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
index 28f77b3..c9df073 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
@@ -33,20 +33,7 @@
 
 package android.hardware.audio.effect;
 @VintfStability
-union Capability {
+parcelable Capability {
   android.hardware.audio.effect.VendorExtension vendorExtension;
-  android.hardware.audio.effect.AcousticEchoCanceler.Capability acousticEchoCanceler;
-  android.hardware.audio.effect.AutomaticGainControl.Capability automaticGainControl;
-  android.hardware.audio.effect.BassBoost.Capability bassBoost;
-  android.hardware.audio.effect.Downmix.Capability downmix;
-  android.hardware.audio.effect.DynamicsProcessing.Capability dynamicsProcessing;
-  android.hardware.audio.effect.EnvironmentalReverb.Capability environmentalReverb;
-  android.hardware.audio.effect.Equalizer.Capability equalizer;
-  android.hardware.audio.effect.HapticGenerator.Capability hapticGenerator;
-  android.hardware.audio.effect.LoudnessEnhancer.Capability loudnessEnhancer;
-  android.hardware.audio.effect.NoiseSuppression.Capability noiseSuppression;
-  android.hardware.audio.effect.PresetReverb.Capability presetReverb;
-  android.hardware.audio.effect.Virtualizer.Capability virtualizer;
-  android.hardware.audio.effect.Visualizer.Capability visualizer;
-  android.hardware.audio.effect.Volume.Capability volume;
+  android.hardware.audio.effect.Range range;
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
index 402441d..45a1f28 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
@@ -42,10 +42,6 @@
     android.hardware.audio.effect.Downmix.Tag commonTag;
   }
   @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-  }
-  @VintfStability
   enum Type {
     STRIP,
     FOLD,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
index 8e5b719..3e20e33 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
@@ -49,12 +49,6 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.DynamicsProcessing.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-    float minCutOffFreq;
-    float maxCutOffFreq;
-  }
   enum ResolutionPreference {
     FAVOR_FREQUENCY_RESOLUTION,
     FAVOR_TIME_RESOLUTION,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
index 9edad09..a193102 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
@@ -49,20 +49,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.EnvironmentalReverb.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-    int minRoomLevelMb;
-    int maxRoomLevelMb;
-    int minRoomHfLevelMb;
-    int maxRoomHfLevelMb;
-    int maxDecayTimeMs;
-    int minDecayHfRatioPm;
-    int maxDecayHfRatioPm;
-    int minLevelMb;
-    int maxLevelMb;
-    int maxDelayMs;
-    int maxDiffusionPm;
-    int maxDensityPm;
-  }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
index ea63de5..3e3539f 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
@@ -38,18 +38,14 @@
   android.hardware.audio.effect.Equalizer.BandLevel[] bandLevels;
   int preset;
   int[] centerFreqMh;
+  android.hardware.audio.effect.Equalizer.BandFrequency[] bandFrequencies;
+  android.hardware.audio.effect.Equalizer.Preset[] presets;
   @VintfStability
   union Id {
     int vendorExtensionTag;
     android.hardware.audio.effect.Equalizer.Tag commonTag;
   }
   @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-    android.hardware.audio.effect.Equalizer.BandFrequency[] bandFrequencies;
-    android.hardware.audio.effect.Equalizer.Preset[] presets;
-  }
-  @VintfStability
   parcelable BandLevel {
     int index;
     int levelMb;
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
index 35186c3..a7dc265 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
@@ -42,10 +42,6 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.HapticGenerator.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-  }
   @Backing(type="int") @VintfStability
   enum VibratorScale {
     MUTE = (-100) /* -100 */,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl
index 5c6ca16..774f45f 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl
@@ -41,8 +41,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.LoudnessEnhancer.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-  }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
index 153e021..f1a3449 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
@@ -42,10 +42,6 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.NoiseSuppression.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    ParcelableHolder extension;
-  }
   @Backing(type="int") @VintfStability
   enum Level {
     LOW,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
index 4651742..148f79d 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
@@ -35,6 +35,7 @@
 @VintfStability
 union PresetReverb {
   android.hardware.audio.effect.VendorExtension vendor;
+  android.hardware.audio.effect.PresetReverb.Presets[] supportedPresets;
   android.hardware.audio.effect.PresetReverb.Presets preset;
   @Backing(type="int") @VintfStability
   enum Presets {
@@ -51,9 +52,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.PresetReverb.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-    android.hardware.audio.effect.PresetReverb.Presets[] supportedPresets;
-  }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl
index 531d3a1..14e9cd8 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl
@@ -33,34 +33,101 @@
 
 package android.hardware.audio.effect;
 @VintfStability
-parcelable Range {
-  int tag;
-  android.hardware.audio.effect.Range.Types types;
+union Range {
+  android.hardware.audio.effect.Range.VendorExtensionRange[] vendorExtension = {};
+  android.hardware.audio.effect.Range.AcousticEchoCancelerRange[] acousticEchoCanceler;
+  android.hardware.audio.effect.Range.AutomaticGainControlRange[] automaticGainControl;
+  android.hardware.audio.effect.Range.AutomaticGainControlV1Range[] automaticGainControlV1;
+  android.hardware.audio.effect.Range.BassBoostRange[] bassBoost;
+  android.hardware.audio.effect.Range.DownmixRange[] downmix;
+  android.hardware.audio.effect.Range.DynamicsProcessingRange[] dynamicsProcessing;
+  android.hardware.audio.effect.Range.EnvironmentalReverbRange[] environmentalReverb;
+  android.hardware.audio.effect.Range.EqualizerRange[] equalizer;
+  android.hardware.audio.effect.Range.HapticGeneratorRange[] hapticGenerator;
+  android.hardware.audio.effect.Range.LoudnessEnhancerRange[] loudnessEnhancer;
+  android.hardware.audio.effect.Range.NoiseSuppressionRange[] noiseSuppression;
+  android.hardware.audio.effect.Range.PresetReverbRange[] presetReverb;
+  android.hardware.audio.effect.Range.VirtualizerRange[] virtualizer;
+  android.hardware.audio.effect.Range.VisualizerRange[] visualizer;
+  android.hardware.audio.effect.Range.VolumeRange[] volume;
   @VintfStability
-  parcelable Int {
-    int min;
-    int max;
+  parcelable AcousticEchoCancelerRange {
+    android.hardware.audio.effect.AcousticEchoCanceler min;
+    android.hardware.audio.effect.AcousticEchoCanceler max;
   }
   @VintfStability
-  parcelable Float {
-    float min;
-    float max;
+  parcelable AutomaticGainControlRange {
+    android.hardware.audio.effect.AutomaticGainControl min;
+    android.hardware.audio.effect.AutomaticGainControl max;
   }
   @VintfStability
-  parcelable Long {
-    long min;
-    long max;
+  parcelable AutomaticGainControlV1Range {
+    android.hardware.audio.effect.AutomaticGainControlV1 min;
+    android.hardware.audio.effect.AutomaticGainControlV1 max;
   }
   @VintfStability
-  parcelable Byte {
-    byte min;
-    byte max;
+  parcelable BassBoostRange {
+    android.hardware.audio.effect.BassBoost min;
+    android.hardware.audio.effect.BassBoost max;
   }
   @VintfStability
-  union Types {
-    android.hardware.audio.effect.Range.Int rangeInt;
-    android.hardware.audio.effect.Range.Float rangeFloat;
-    android.hardware.audio.effect.Range.Long rangeLong;
-    android.hardware.audio.effect.Range.Byte rangeByte;
+  parcelable DownmixRange {
+    android.hardware.audio.effect.Downmix min;
+    android.hardware.audio.effect.Downmix max;
+  }
+  @VintfStability
+  parcelable DynamicsProcessingRange {
+    android.hardware.audio.effect.DynamicsProcessing min;
+    android.hardware.audio.effect.DynamicsProcessing max;
+  }
+  @VintfStability
+  parcelable EnvironmentalReverbRange {
+    android.hardware.audio.effect.EnvironmentalReverb min;
+    android.hardware.audio.effect.EnvironmentalReverb max;
+  }
+  @VintfStability
+  parcelable EqualizerRange {
+    android.hardware.audio.effect.Equalizer min;
+    android.hardware.audio.effect.Equalizer max;
+  }
+  @VintfStability
+  parcelable HapticGeneratorRange {
+    android.hardware.audio.effect.HapticGenerator min;
+    android.hardware.audio.effect.HapticGenerator max;
+  }
+  @VintfStability
+  parcelable LoudnessEnhancerRange {
+    android.hardware.audio.effect.LoudnessEnhancer min;
+    android.hardware.audio.effect.LoudnessEnhancer max;
+  }
+  @VintfStability
+  parcelable NoiseSuppressionRange {
+    android.hardware.audio.effect.NoiseSuppression min;
+    android.hardware.audio.effect.NoiseSuppression max;
+  }
+  @VintfStability
+  parcelable PresetReverbRange {
+    android.hardware.audio.effect.PresetReverb min;
+    android.hardware.audio.effect.PresetReverb max;
+  }
+  @VintfStability
+  parcelable VendorExtensionRange {
+    android.hardware.audio.effect.VendorExtension min;
+    android.hardware.audio.effect.VendorExtension max;
+  }
+  @VintfStability
+  parcelable VirtualizerRange {
+    android.hardware.audio.effect.Virtualizer min;
+    android.hardware.audio.effect.Virtualizer max;
+  }
+  @VintfStability
+  parcelable VisualizerRange {
+    android.hardware.audio.effect.Visualizer min;
+    android.hardware.audio.effect.Visualizer max;
+  }
+  @VintfStability
+  parcelable VolumeRange {
+    android.hardware.audio.effect.Volume min;
+    android.hardware.audio.effect.Volume max;
   }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
index 2f367d9..e9611e4 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
@@ -50,12 +50,6 @@
     android.media.audio.common.AudioDeviceDescription device;
   }
   @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-    int maxStrengthPm;
-    boolean strengthSupported;
-  }
-  @VintfStability
   parcelable ChannelAngle {
     int channel;
     int azimuthDegree;
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
index c8cb551..d1b1b3e 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
@@ -36,30 +36,18 @@
 union Visualizer {
   android.hardware.audio.effect.Visualizer.Id id;
   android.hardware.audio.effect.VendorExtension vendor;
-  android.hardware.audio.effect.Visualizer.GetOnlyParameters getOnlyParameters;
-  android.hardware.audio.effect.Visualizer.SetOnlyParameters setOnlyParameters;
+  android.hardware.audio.effect.Visualizer.Measurement measurement;
+  byte[] captureSampleBuffer;
+  int latencyMs;
   int captureSamples;
   android.hardware.audio.effect.Visualizer.ScalingMode scalingMode;
   android.hardware.audio.effect.Visualizer.MeasurementMode measurementMode;
   @VintfStability
   union Id {
     int vendorExtensionTag;
-    android.hardware.audio.effect.Visualizer.GetOnlyParameters.Tag getOnlyParamTag;
-    android.hardware.audio.effect.Visualizer.SetOnlyParameters.Tag setOnlyParamTag;
     android.hardware.audio.effect.Visualizer.Tag commonTag;
   }
   @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-    int maxLatencyMs;
-    android.hardware.audio.effect.Visualizer.CaptureSamplesRange captureSampleRange;
-  }
-  @VintfStability
-  parcelable CaptureSamplesRange {
-    int min;
-    int max;
-  }
-  @VintfStability
   enum ScalingMode {
     NORMALIZED = 0,
     AS_PLAYED,
@@ -70,17 +58,8 @@
     PEAK_RMS,
   }
   @VintfStability
-  union GetOnlyParameters {
-    android.hardware.audio.effect.Visualizer.GetOnlyParameters.Measurement measurement;
-    byte[] captureSampleBuffer;
-    @VintfStability
-    parcelable Measurement {
-      int rms;
-      int peak;
-    }
-  }
-  @VintfStability
-  union SetOnlyParameters {
-    int latencyMs;
+  parcelable Measurement {
+    int rms;
+    int peak;
   }
 }
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl
index 6259cfb..c2b2df7 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl
@@ -42,10 +42,4 @@
     int vendorExtensionTag;
     android.hardware.audio.effect.Volume.Tag commonTag;
   }
-  @VintfStability
-  parcelable Capability {
-    android.hardware.audio.effect.VendorExtension extension;
-    int minLevelDb;
-    int maxLevelDb;
-  }
 }
diff --git a/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl b/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl
index 19d60b6..49377d6 100644
--- a/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl
+++ b/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl
@@ -22,9 +22,9 @@
  * Acoustic Echo Canceler (AEC) is an audio pre-processor which removes the contribution of the
  * signal received from the remote party from the captured audio signal.
  *
- * All parameters defined in union AcousticEchoCanceler must be gettable and settable. The
- * capabilities defined in AcousticEchoCanceler.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.acousticEchoCanceler
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
  */
 @VintfStability
 union AcousticEchoCanceler {
@@ -43,35 +43,20 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by AEC implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * AEC capability extension, vendor can use this extension in case existing capability
-         * definition not enough.
-         */
-        ParcelableHolder extension;
-
-        /**
-         * Maximum AEC echo delay in microseconds supported.
-         */
-        int maxEchoDelayUs;
-        /**
-         * If AEC mobile mode was supported by the AEC implementation.
-         */
-        boolean supportMobileMode;
-    }
-
-    /**
      * The AEC echo delay in microseconds.
-     * Must never be negative, and not larger than maxEchoDelayUs in capability.
      */
     int echoDelayUs;
     /**
-     * If AEC mobile mode enabled.
-     * Can only be false if AEC implementation indicate not support mobile mode by set
-     * supportMobileMode to false in capability.
+     * Indicate if the AEC mobile mode is enabled or not.
+     * If an effect implementation supports enabling and disabling mobileMode at runtime, it does
+     * not need to set the min and max range for mobileMode, or report the mobileMode min/max range
+     * as [false, true] in Range.AcousticEchoCancelerRange. If the effect implementation doesn't
+     * support mobileMode, it must report the mobileMode range as [false, false]. If the effect
+     * implementation supports mobileMode and cannot be disabled, it must report the mobileMode
+     * range as [true, true].
+     * If the effect implementation sets the range as invalid: [true, false], it indicates that
+     * mobileMode setParameter is not supported, and clients can only use getParameter to check if
+     * it's enabled or not.
      */
     boolean mobileMode;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl b/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl
index e82a564..0c984b5 100644
--- a/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl
+++ b/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl
@@ -24,9 +24,9 @@
  * so that the output signal level is virtually constant. AGC can be used by applications where the
  * input signal dynamic range is not important but where a constant strong capture level is desired.
  *
- * All parameters defined in union AutomaticGainControl must be gettable and settable. The
- * capabilities defined in AutomaticGainControl.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.automaticGainControl
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
  */
 @VintfStability
 union AutomaticGainControl {
@@ -44,26 +44,6 @@
      */
     VendorExtension vendor;
 
-    /**
-     * Capability supported by AutomaticGainControl implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * AutomaticGainControl capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        ParcelableHolder extension;
-        /**
-         * Max fixed digital gain supported by AGC implementation in millibel.
-         */
-        int maxFixedDigitalGainMb;
-        /**
-         * Max fixed saturation margin supported by AGC implementation in millibel.
-         */
-        int maxSaturationMarginMb;
-    }
-
     @VintfStability
     @Backing(type="int")
     enum LevelEstimator {
@@ -75,7 +55,6 @@
 
     /**
      * The AGC fixed digital gain in millibel.
-     * Must never be negative, and not larger than maxFixedDigitalGainMb in capability.
      */
     int fixedDigitalGainMb;
     /*
@@ -84,7 +63,6 @@
     LevelEstimator levelEstimator;
     /**
      * The AGC saturation margin in millibel.
-     * Must never be negative, and not larger than maxSaturationMarginMb in capability.
      */
     int saturationMarginMb;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl b/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl
index d6e0648..9b2feff 100644
--- a/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl
+++ b/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl
@@ -16,7 +16,6 @@
 
 package android.hardware.audio.effect;
 
-import android.hardware.audio.effect.Range;
 import android.hardware.audio.effect.VendorExtension;
 
 /**
@@ -25,9 +24,9 @@
  * so that the output signal level is virtually constant. AGC can be used by applications where the
  * input signal dynamic range is not important but where a constant strong capture level is desired.
  *
- * All parameters defined in union AutomaticGainControlV1 must be gettable and settable. The
- * capabilities defined in AutomaticGainControlV1.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.automaticGainControlV1
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
  */
 @VintfStability
 union AutomaticGainControlV1 {
@@ -46,31 +45,13 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by AutomaticGainControlV1 implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * AutomaticGainControlV1 capability extension, vendor can use this extension in case
-         * existing capability definition not enough.
-         */
-        ParcelableHolder extension;
-        /**
-         * Supported range for parameters.
-         */
-        Range[] ranges;
-    }
-
-    /**
      * Target peak level (or envelope) of the AGC implementation in dBFs (dB relative to full
      * scale).
-     * Must be in range of AutomaticGainControlV1.Capability.ranges with targetPeakLevelDbFs tag.
      */
     int targetPeakLevelDbFs;
     /*
      * Sets the maximum gain the digital compression stage may apply, in dB. A higher number
      * corresponds to greater compression, while a value of 0 will leave the signal uncompressed.
-     * Must be in range of AutomaticGainControlV1.Capability.ranges with maxCompressionGainDb tag.
      */
     int maxCompressionGainDb;
     /**
diff --git a/audio/aidl/android/hardware/audio/effect/BassBoost.aidl b/audio/aidl/android/hardware/audio/effect/BassBoost.aidl
index 6a94242..d734825 100644
--- a/audio/aidl/android/hardware/audio/effect/BassBoost.aidl
+++ b/audio/aidl/android/hardware/audio/effect/BassBoost.aidl
@@ -22,8 +22,8 @@
  * Bass boost is an audio effect to boost or amplify low frequencies of the sound. It is comparable
  * to a simple equalizer but limited to one band amplification in the low frequency range.
  *
- * All parameters defined in union BassBoost must be gettable and settable. The capabilities defined
- * in BassBoost.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.bassBoost definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
  */
 @VintfStability
 union BassBoost {
@@ -42,35 +42,11 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by BassBoost implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * BassBoost capability extension, vendor can use this extension in case existing capability
-         * definition not enough.
-         */
-        ParcelableHolder extension;
-        /**
-         * Maximum possible per mille strength.
-         */
-        int maxStrengthPm;
-        /**
-         * Indicates whether setting strength is supported. False value indicates only one strength
-         * is supported and setParameter() method will return EX_ILLEGAL_ARGUMENT.
-         */
-        boolean strengthSupported;
-    }
-
-    /**
      * The per mille strength of the bass boost effect.
      *
      * If the implementation does not support per mille accuracy for setting the strength, it is
      * allowed to round the given strength to the nearest supported value. In this case {@link
      * #IEffect.getParameter()} method should return the rounded value that was actually set.
-     *
-     * The value of the strength must be non-negative and not exceed the value specified by
-     * the 'maxStrengthPm' capability.
      */
     int strengthPm;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/Capability.aidl b/audio/aidl/android/hardware/audio/effect/Capability.aidl
index 30780e6..06c2024 100644
--- a/audio/aidl/android/hardware/audio/effect/Capability.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Capability.aidl
@@ -16,21 +16,8 @@
 
 package android.hardware.audio.effect;
 
-import android.hardware.audio.effect.AcousticEchoCanceler;
-import android.hardware.audio.effect.AutomaticGainControl;
-import android.hardware.audio.effect.BassBoost;
-import android.hardware.audio.effect.Downmix;
-import android.hardware.audio.effect.DynamicsProcessing;
-import android.hardware.audio.effect.EnvironmentalReverb;
-import android.hardware.audio.effect.Equalizer;
-import android.hardware.audio.effect.HapticGenerator;
-import android.hardware.audio.effect.LoudnessEnhancer;
-import android.hardware.audio.effect.NoiseSuppression;
-import android.hardware.audio.effect.PresetReverb;
+import android.hardware.audio.effect.Range;
 import android.hardware.audio.effect.VendorExtension;
-import android.hardware.audio.effect.Virtualizer;
-import android.hardware.audio.effect.Visualizer;
-import android.hardware.audio.effect.Volume;
 
 /**
  * Effect capability definitions.
@@ -38,32 +25,19 @@
  * not meant to change at runtime.
  */
 @VintfStability
-union Capability {
+parcelable Capability {
     /**
      * Vendor defined effect capability.
-     * This extension can be used when vendor have a new effect implementated and need
+     * This extension can be used when vendor has a new effect implementation and needs
      * capability definition for this new type of effect.
-     * If vendor want to extend existing effect capabilities, it is recommended to expose though
-     * the ParcelableHolder in each effect capability definition. For example:
-     * Equalizer.Capability.extension.
+     * If vendor want to extend existing effect capabilities, it is recommended to expose through
+     * the ParcelableHolder in each effect definition. For example: Equalizer.vendorExtension. And
+     * define an appropriate Range for the extension.
      */
     VendorExtension vendorExtension;
 
     /**
-     * Effect capabilities.
+     * Supported range for parameters. See Range.aidl.
      */
-    AcousticEchoCanceler.Capability acousticEchoCanceler;
-    AutomaticGainControl.Capability automaticGainControl;
-    BassBoost.Capability bassBoost;
-    Downmix.Capability downmix;
-    DynamicsProcessing.Capability dynamicsProcessing;
-    EnvironmentalReverb.Capability environmentalReverb;
-    Equalizer.Capability equalizer;
-    HapticGenerator.Capability hapticGenerator;
-    LoudnessEnhancer.Capability loudnessEnhancer;
-    NoiseSuppression.Capability noiseSuppression;
-    PresetReverb.Capability presetReverb;
-    Virtualizer.Capability virtualizer;
-    Visualizer.Capability visualizer;
-    Volume.Capability volume;
+    Range range;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/Downmix.aidl b/audio/aidl/android/hardware/audio/effect/Downmix.aidl
index ee57baf..f90e339 100644
--- a/audio/aidl/android/hardware/audio/effect/Downmix.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Downmix.aidl
@@ -21,8 +21,8 @@
 /**
  * Downmix specific definitions.
  *
- * All parameters defined in union Downmix must be gettable and settable. The capabilities defined
- * in Downmix.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.downmix definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
  */
 @VintfStability
 union Downmix {
@@ -40,18 +40,6 @@
      */
     VendorExtension vendor;
 
-    /**
-     * Capability supported by Downmix implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * Downmix capability extension, vendor can use this extension in case existing capability
-         * definition not enough.
-         */
-        ParcelableHolder extension;
-    }
-
     @VintfStability
     enum Type {
         /**
diff --git a/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl b/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
index 6db3338..486d4f4 100644
--- a/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
+++ b/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
@@ -21,9 +21,9 @@
 /**
  * DynamicsProcessing specific definitions.
  *
- * All parameters defined in union DynamicsProcessing must be gettable and settable. The
- * capabilities defined in DynamicsProcessing.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.dynamicsProcessing definition
+ * if the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
  */
 @VintfStability
 union DynamicsProcessing {
@@ -42,26 +42,6 @@
     VendorExtension vendorExtension;
 
     /**
-     * Capability supported by DynamicsProcessing implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * DynamicsProcessing capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        ParcelableHolder extension;
-        /**
-         * Min Cut off frequency (in Hz) for all Bands.
-         */
-        float minCutOffFreq;
-        /**
-         * Max Cut off frequency (in Hz) for all Bands.
-         */
-        float maxCutOffFreq;
-    }
-
-    /**
      * Resolution preference definition.
      */
     enum ResolutionPreference {
@@ -159,8 +139,7 @@
          */
         boolean enable;
         /**
-         * Topmost frequency number (in Hz) this band will process. Must be in the range of
-         * [minCutOffFreq, maxCutOffFreq] defined in Capability.
+         * Topmost frequency number (in Hz) this band will process.
          */
         float cutoffFrequencyHz;
         /**
@@ -190,8 +169,7 @@
          */
         boolean enable;
         /**
-         * Topmost frequency number (in Hz) this band will process. Must be in the range of
-         * [minCutOffFreq, maxCutOffFreq] defined in Capability.
+         * Topmost frequency number (in Hz) this band will process.
          */
         float cutoffFrequencyHz;
         /**
diff --git a/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl
index fc98fe6..a158dca 100644
--- a/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl
+++ b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl
@@ -21,9 +21,9 @@
 /**
  * Environmental Reverb specific definitions.
  *
- * All parameters defined in union Environmental must be gettable and settable. The capabilities
- * * defined in EnvironmentalReverb.Capability can only acquired with IEffect.getDescriptor() and
- * not * settable.
+ * All parameter settings must be inside the range of Capability.Range.environmentalReverb
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
  */
 
 @VintfStability
@@ -43,103 +43,35 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by effect implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        VendorExtension extension;
-
-        /**
-         * Minimal possible room level in millibels.
-         */
-        int minRoomLevelMb;
-        /**
-         * Maximum possible room level in millibels.
-         */
-        int maxRoomLevelMb;
-        /**
-         * Minimal possible room hf level in millibels.
-         */
-        int minRoomHfLevelMb;
-        /**
-         * Maximum possible room hf level in millibels.
-         */
-        int maxRoomHfLevelMb;
-        /**
-         * Max decay time supported in millisecond.
-         */
-        int maxDecayTimeMs;
-        /**
-         * Minimal possible per mille decay hf ratio.
-         */
-        int minDecayHfRatioPm;
-        /**
-         * Maximum possible per mille decay hf ratio.
-         */
-        int maxDecayHfRatioPm;
-        /**
-         * Minimal possible room level in millibels.
-         */
-        int minLevelMb;
-        /**
-         * Maximum possible room level in millibels.
-         */
-        int maxLevelMb;
-        /**
-         * Maximum possible delay time in milliseconds.
-         */
-        int maxDelayMs;
-        /**
-         * Maximum possible per mille diffusion.
-         */
-        int maxDiffusionPm;
-        /**
-         * Maximum possible per mille density.
-         */
-        int maxDensityPm;
-    }
-
-    /**
-     * Room level apply to the reverb effect in millibels. The value of the roomLevelMb must be in
-     * range of the value specified by the 'minRoomLevelMb' capability and the 'maxRoomLevelMb'
-     * capability.
+     * Room level apply to the reverb effect in millibels.
      */
     int roomLevelMb;
     /**
-     * Room HF level apply to the reverb effect in millibels. The value of the roomHfLevelMb must be
-     * in range of the value specified by the 'minRoomHfLevelMb' capability and the
-     * 'maxRoomHfLevelMb' capability.
+     * Room HF level apply to the reverb effect in millibels.
      */
     int roomHfLevelMb;
     /**
-     * Delay time apply to the reverb effect in milliseconds.The value of the decayTimeMs must
-     * be non-negative and not exceed the value specified by the 'maxDecayTimeMs' capability.
+     * Delay time apply to the reverb effect in milliseconds.
      */
     int decayTimeMs;
     /**
-     * HF decay ratio in permilles. The value of the decayHfRatioPm must be in range
-     * of the value specified by the 'minDecayHfRatioPm' capability and the 'maxDecayHfRatioPm'
-     * capability.
+     * HF decay ratio in permilles.
      */
     int decayHfRatioPm;
     /**
-     * Reverb level in millibels. The value of the levelMb must be in range
-     * of the value specified by the 'minLevelMb' capability and the 'maxLevelMb' capability.
+     * Reverb level in millibels.
      */
     int levelMb;
     /**
-     * Reverb delay in milliseconds. The value of the delayMs must be non-negative and not
-     * exceed the value specified by the 'maxDelayMs' capability.
+     * Reverb delay in milliseconds.
      */
     int delayMs;
     /**
-     * Diffusion in permilles. The value of the diffusionPm must be non-negative and not
-     * exceed the value specified by the 'maxDiffusionPm' capability.
+     * Diffusion in permilles.
      */
     int diffusionPm;
     /**
-     * Density in permilles. The value of the densityPm must be non-negative and not
-     * exceed the value specified by the 'maxDensityPm' capability.
+     * Density in permilles.
      */
     int densityPm;
 
diff --git a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
index 7903fde..2bce151 100644
--- a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
@@ -21,8 +21,8 @@
 /**
  * Equalizer specific definitions.
  *
- * All parameters defined in union Equalizer must be gettable and settable. The capabilities defined
- * in Equalizer.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.equalizer definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
  */
 @VintfStability
 union Equalizer {
@@ -41,28 +41,6 @@
     VendorExtension vendorExtension;
 
     /**
-     * Capability MUST be supported by Equalizer implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * Equalizer capability extension, vendor can use this extension in case existing capability
-         * definition not enough.
-         */
-        ParcelableHolder extension;
-
-        /**
-         * Bands frequency ranges supported.
-         */
-        BandFrequency[] bandFrequencies;
-
-        /**
-         * Presets name and index.
-         */
-        Preset[] presets;
-    }
-
-    /**
      * Level setting for each band in millibels.
      */
     @VintfStability
@@ -107,4 +85,14 @@
      * Get only parameter, get the center frequency for all bands in milliHertz.
      */
     int[] centerFreqMh;
+
+    /**
+     * Get only parameter, indicating bands frequency ranges supported by implementation.
+     */
+    BandFrequency[] bandFrequencies;
+
+    /**
+     * Get only parameter, indicating presets name and index supported by implementation.
+     */
+    Preset[] presets;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl b/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl
index 3063ee3..a8e4564 100644
--- a/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl
+++ b/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl
@@ -22,9 +22,9 @@
  * HapticGenerator specific definitions. HapticGenerator effect provide HapticGenerator control and
  * mute/unmute functionality.
  *
- * All parameters defined in union HapticGenerator must be gettable and settable. The capabilities
- * defined in HapticGenerator.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.hapticGenerator definition if
+ * the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
  */
 @VintfStability
 union HapticGenerator {
@@ -42,18 +42,6 @@
      */
     VendorExtension vendorExtension;
 
-    /**
-     * Capability supported by HapticGenerator implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * HapticGenerator capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        VendorExtension extension;
-    }
-
     @VintfStability
     @Backing(type="int")
     enum VibratorScale {
diff --git a/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl b/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl
index 0441f10..a7cbe8d 100644
--- a/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl
@@ -21,9 +21,9 @@
 /**
  * LoudnessEnhancer specific definitions.
  *
- * All parameters defined in union LoudnessEnhancer must be gettable and settable. The capabilities
- * defined in LoudnessEnhancer.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.loudnessEnhancer definition
+ * if the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
  */
 @VintfStability
 union LoudnessEnhancer {
@@ -42,18 +42,6 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by LoudnessEnhancer implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * LoudnessEnhancer capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        VendorExtension extension;
-    }
-
-    /**
      * The maximum gain in millibels (mB) applied to the signal to process, default value is 0 which
      * corresponds to no amplification.
      */
diff --git a/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl b/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
index c4baff8..6c2fb5f 100644
--- a/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
+++ b/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
@@ -24,9 +24,9 @@
  * engine, AC system) or non-stationary (other peoples conversations, car horn) for more advanced
  * implementations.
  *
- * All parameters defined in union NoiseSuppression must be gettable and settable. The capabilities
- * defined in NoiseSuppression.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.noiseSuppression definition
+ * if the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
  */
 @VintfStability
 union NoiseSuppression {
@@ -45,18 +45,6 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by NoiseSuppression implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * NoiseSuppression capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        ParcelableHolder extension;
-    }
-
-    /**
      * Different level of Noise Suppression to set.
      * As an example, webrtc have NsConfig::SuppressionLevel::k6dB applied for LOW level noise
      * suppression, NsConfig::SuppressionLevel::k12dB for MEDIUM, and
diff --git a/audio/aidl/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
index 473dfb5..be7144f 100644
--- a/audio/aidl/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
@@ -44,6 +44,14 @@
  * 2. Parameters defined for a specific effect type.
  * 3. Extension parameters ParcelableHolder can be used for vendor effect definition.
  *
+ * All parameter settings must be inside the range of Capability.Range.$EffectType$ definition. If
+ * an effect implementation doesn't have limitation for a parameter, then don't define any effect
+ * range.
+ *
+ * All parameters are get-able, if any parameter doesn't support set, effect implementation should
+ * report the supported range for this parameter as range.min > range.max. If no support range is
+ * defined for a parameter, it means this parameter doesn't have any limitation.
+ *
  */
 @VintfStability
 union Parameter {
diff --git a/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl b/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl
index 6048eea..87c78b0 100644
--- a/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl
+++ b/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl
@@ -21,9 +21,9 @@
 /**
  * PresetReverb specific definitions.
  *
- * All parameters defined in union PresetReverb must be gettable and settable. The capabilities
- * defined in PresetReverb.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.presetReverb definition if
+ * the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
  */
 @VintfStability
 union PresetReverb {
@@ -78,21 +78,24 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by effect implementation.
+     * The list of presets supported by implementation, effect implementation must declare the
+     * support of Presets with Capability.Range.presetReverb definition. For example, if an effect
+     * implementation supports all Presets in PresetReverb.Presets, then the capability will be:
+     *  const std::vector<PresetReverb::Presets> kSupportedPresets{
+     *          ndk::enum_range<PresetReverb::Presets>().begin(),
+     *          ndk::enum_range<PresetReverb::Presets>().end()};
+     *  const std::vector<Range::PresetReverbRange> kRanges = {
+     *          MAKE_RANGE(PresetReverb, supportedPresets, kSupportedPresets, kSupportedPresets)};
      */
-    @VintfStability
-    parcelable Capability {
-        VendorExtension extension;
-
-        /**
-         * List of presets supported.
-         */
-        Presets[] supportedPresets;
-    }
+    Presets[] supportedPresets;
 
     /**
      * Get current reverb preset when used in getParameter.
      * Enable a preset reverb when used in setParameter.
+     * With the current Range definition, there is no good way to define enum capability, so the
+     * Presets vector supportedPresets is used to defined the capability. Client must check the
+     * capability in PresetReverb.supportedPresets, and make sure to get the list of supported
+     * presets before setting.
      */
     Presets preset;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/Range.aidl b/audio/aidl/android/hardware/audio/effect/Range.aidl
index c052502..30e2359 100644
--- a/audio/aidl/android/hardware/audio/effect/Range.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Range.aidl
@@ -16,50 +16,205 @@
 
 package android.hardware.audio.effect;
 
+import android.hardware.audio.effect.AcousticEchoCanceler;
+import android.hardware.audio.effect.AutomaticGainControl;
+import android.hardware.audio.effect.AutomaticGainControlV1;
+import android.hardware.audio.effect.BassBoost;
+import android.hardware.audio.effect.Downmix;
+import android.hardware.audio.effect.DynamicsProcessing;
+import android.hardware.audio.effect.EnvironmentalReverb;
+import android.hardware.audio.effect.Equalizer;
+import android.hardware.audio.effect.HapticGenerator;
+import android.hardware.audio.effect.LoudnessEnhancer;
+import android.hardware.audio.effect.NoiseSuppression;
+import android.hardware.audio.effect.PresetReverb;
+import android.hardware.audio.effect.VendorExtension;
+import android.hardware.audio.effect.Virtualizer;
+import android.hardware.audio.effect.Visualizer;
+import android.hardware.audio.effect.Volume;
+
 /**
- * Define the range (min and max) of a certain field, identified by tag.
- * Can be used by effect capabilities to define supported value ranges.
+ * Define the supported range of effect parameters.
+ * Effect implementation must report the supported range of parameter/capability if there is any
+ * limitation.
+ * Range of each effect type is defined with a vector, because each $EffectType$Range can only
+ * describe the range of one parameter. For example, Range::AcousticEchoCancelerRange can only
+ * describe one of vendor, echoDelayUs, and mobileMode.
+ *
+ * If an effect implementation needs to define the valid range for a certain parameter, it can
+ * write the minimum/maximum supported value to the corresponding effect range, and add the range
+ * to vector of this effect type.
+ * Say if an AcousticEchoCanceler implementation wants to define the supported range of echoDelayUs
+ * to [0, 500], then the Capability range should include an item in acousticEchoCanceler list:
+ * std::vector<Range::AcousticEchoCancelerRange> kRanges = {
+ *       MAKE_RANGE(AcousticEchoCanceler, echoDelayUs, 0, 500)};
+ *
+ * For a more complex example, if a DynamicsProcessing implementation wants to define the
+ * supported range of preEqBand channel to [0, 1], band index to [0, 5], and cutoffFrequencyHz to
+ * [220, 20000]:
+ * Range::DynamicsProcessingRange kRange = {
+ *   .min = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
+ *           {EqBandConfig({.channel = 0,
+ *                          .band = 0,
+ *                          .enable = false,
+ *                          .cutoffFrequencyHz = 220,
+ *                          .gainDb = std::numeric_limits<float>::min()})}),
+ *   .max = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
+ *           {EqBandConfig({.channel = 1,
+ *                          .band = 5,
+ *                          .enable = true,
+ *                          .cutoffFrequencyHz = 20000,
+ *                          .gainDb = std::numeric_limits<float>::max()})})};
+ *
+ * For get only parameters, the effect implementation must define an invalid range (min > max), to
+ * indicate no parameter from the effect client can be accepted for setting. The effect
+ * implementation must return EX_ILLEGAL_ARGUMENT if it receives any setParameter call for a get
+ * only parameter.
+ * As an example, the get-only parameter Virtualizer.speakerAngles can be defined with:
+ *   Range::VirtualizerRange kRanges = {
+ *       MAKE_RANGE(Virtualizer, speakerAngles,
+ *                  {Virtualizer::ChannelAngle({.channel = 1},
+ *                  {Virtualizer::ChannelAngle({.channel = 0})};
+ *
+ * For a capability definition (which is also get only), the effect implementation must define a
+ * range with min == max, to indicate this is a fixed capability which shouldn't set by client.
+ * As an example, the Equalizer presets capability can be defined with:
+ * std::vector<Equalizer::Preset> kPresets = {
+ *       {0, "Normal"},      {1, "Classical"}, {2, "Dance"}, {3, "Flat"}, {4, "Folk"},
+ *       {5, "Heavy Metal"}, {6, "Hip Hop"},   {7, "Jazz"},  {8, "Pop"},  {9, "Rock"}};
+ * Range::EqualizerRange kRanges =
+ *      MAKE_RANGE(Equalizer, presets, EqualizerSw::kPresets, EqualizerSw::kPresets);
+ *
+ * For enum capability, it's necessary to either list a range, or explicitly list out all enums in
+ * the Range definition, see PresetReverb.supportedPresets as example.
+ *
+ * The effect implementation must return EX_ILLEGAL_ARGUMENT if:
+ * 1. receive any setParameter call for get only parameter (min > max).
+ * 2. receive any setParameter call for capability parameter definition (min == max).
+ * 3. receive any setParameter call for parameters not in the range of [min, max].
+ *
  */
 @VintfStability
-parcelable Range {
+union Range {
+    @VintfStability
+    parcelable AcousticEchoCancelerRange {
+        AcousticEchoCanceler min;
+        AcousticEchoCanceler max;
+    }
+
+    @VintfStability
+    parcelable AutomaticGainControlRange {
+        AutomaticGainControl min;
+        AutomaticGainControl max;
+    }
+
+    @VintfStability
+    parcelable AutomaticGainControlV1Range {
+        AutomaticGainControlV1 min;
+        AutomaticGainControlV1 max;
+    }
+
+    @VintfStability
+    parcelable BassBoostRange {
+        BassBoost min;
+        BassBoost max;
+    }
+
+    @VintfStability
+    parcelable DownmixRange {
+        Downmix min;
+        Downmix max;
+    }
+
+    @VintfStability
+    parcelable DynamicsProcessingRange {
+        DynamicsProcessing min;
+        DynamicsProcessing max;
+    }
+
+    @VintfStability
+    parcelable EnvironmentalReverbRange {
+        EnvironmentalReverb min;
+        EnvironmentalReverb max;
+    }
+
+    @VintfStability
+    parcelable EqualizerRange {
+        Equalizer min;
+        Equalizer max;
+    }
+
+    @VintfStability
+    parcelable HapticGeneratorRange {
+        HapticGenerator min;
+        HapticGenerator max;
+    }
+
+    @VintfStability
+    parcelable LoudnessEnhancerRange {
+        LoudnessEnhancer min;
+        LoudnessEnhancer max;
+    }
+
+    @VintfStability
+    parcelable NoiseSuppressionRange {
+        NoiseSuppression min;
+        NoiseSuppression max;
+    }
+
+    @VintfStability
+    parcelable PresetReverbRange {
+        PresetReverb min;
+        PresetReverb max;
+    }
+
+    @VintfStability
+    parcelable VendorExtensionRange {
+        VendorExtension min;
+        VendorExtension max;
+    }
+
+    @VintfStability
+    parcelable VirtualizerRange {
+        Virtualizer min;
+        Virtualizer max;
+    }
+
+    @VintfStability
+    parcelable VisualizerRange {
+        Visualizer min;
+        Visualizer max;
+    }
+
+    @VintfStability
+    parcelable VolumeRange {
+        Volume min;
+        Volume max;
+    }
+
     /**
-     * The union tag name which the range is defined for.
-     * For example: if used in AutomaticGainControlV1.Capability, value of Range.tag could be
-     * targetLevelDbFs or compressionGainDb.
+     * The vector of range defined for parameters of each effect implementation.
+     * Each element of the vector represents the min and max range of a parameter, so the size of
+     * vector is the number of parameter ranges defined for this effect implementation.
+     *
+     * The effect implementation must not have duplicated parameter range definition in the vector.
+     * Client side must go though the vector and make sure the parameter setting to effect
+     * implementation is in valid range.
      */
-    int tag;
-
-    @VintfStability
-    parcelable Int {
-        int min;
-        int max;
-    }
-
-    @VintfStability
-    parcelable Float {
-        float min;
-        float max;
-    }
-
-    @VintfStability
-    parcelable Long {
-        long min;
-        long max;
-    }
-
-    @VintfStability
-    parcelable Byte {
-        byte min;
-        byte max;
-    }
-
-    @VintfStability
-    union Types {
-        Int rangeInt;
-        Float rangeFloat;
-        Long rangeLong;
-        Byte rangeByte;
-    }
-
-    Types types;
+    VendorExtensionRange[] vendorExtension = {};
+    AcousticEchoCancelerRange[] acousticEchoCanceler;
+    AutomaticGainControlRange[] automaticGainControl;
+    AutomaticGainControlV1Range[] automaticGainControlV1;
+    BassBoostRange[] bassBoost;
+    DownmixRange[] downmix;
+    DynamicsProcessingRange[] dynamicsProcessing;
+    EnvironmentalReverbRange[] environmentalReverb;
+    EqualizerRange[] equalizer;
+    HapticGeneratorRange[] hapticGenerator;
+    LoudnessEnhancerRange[] loudnessEnhancer;
+    NoiseSuppressionRange[] noiseSuppression;
+    PresetReverbRange[] presetReverb;
+    VirtualizerRange[] virtualizer;
+    VisualizerRange[] visualizer;
+    VolumeRange[] volume;
 }
diff --git a/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl b/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
index fc453ad..37ea2a4 100644
--- a/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
@@ -24,9 +24,8 @@
  * Virtualizer specific definitions. An audio virtualizer is a general name for an effect to
  * spatialize audio channels.
  *
- * All parameters defined in union Virtualizer must be gettable and settable. The capabilities
- * defined in Virtualizer.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.virtualizer definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
  */
 @VintfStability
 union Virtualizer {
@@ -65,35 +64,12 @@
     }
 
     /**
-     * Capability supported by Virtualizer implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * Virtualizer capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        VendorExtension extension;
-        /**
-         * Maximum possible per mille strength.
-         */
-        int maxStrengthPm;
-        /**
-         * Indicates whether setting strength is supported. False value indicates only one strength
-         * is supported and setParameter() method will always return EX_ILLEGAL_ARGUMENT.
-         */
-        boolean strengthSupported;
-    }
-
-    /**
      * The per mille strength of the virtualizer effect.
      *
      * If the implementation does not support per mille accuracy for setting the strength, it is
      * allowed to round the given strength to the nearest supported value. In this case {@link
      * #IEffect.getParameter()} method should return the rounded value that was actually set.
      *
-     * The value of the strength must be non-negative and not exceed the value specified by
-     * the 'maxStrengthPm' capability.
      */
     int strengthPm;
 
@@ -128,6 +104,7 @@
     ChannelAngle[] speakerAngles;
 
     /**
+     * Get only parameter.
      * The audio device on which virtualzation mode is forced.
      */
     AudioDeviceDescription device;
diff --git a/audio/aidl/android/hardware/audio/effect/Visualizer.aidl b/audio/aidl/android/hardware/audio/effect/Visualizer.aidl
index dfe29c8..8f2faaa 100644
--- a/audio/aidl/android/hardware/audio/effect/Visualizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Visualizer.aidl
@@ -22,9 +22,8 @@
  * Visualizer specific definitions. Visualizer enables application to retrieve part of the currently
  * playing audio for visualization purpose
  *
- * All parameters defined in union Visualizer other than these in GetOnlyParameters and
- * SetOnlyParameters must be gettable and settable. The capabilities defined in
- * Visualizer.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.visualizer definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
  *
  */
 @VintfStability
@@ -35,8 +34,6 @@
     @VintfStability
     union Id {
         int vendorExtensionTag;
-        GetOnlyParameters.Tag getOnlyParamTag;
-        SetOnlyParameters.Tag setOnlyParamTag;
         Visualizer.Tag commonTag;
     }
     Id id;
@@ -47,35 +44,6 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by Visualizer implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * Visualizer capability extension, vendor can use this extension in case existing
-         * capability definition not enough.
-         */
-        VendorExtension extension;
-        /**
-         * Max latency supported in millseconds.
-         */
-        int maxLatencyMs;
-        /**
-         *  Capture size range.
-         */
-        CaptureSamplesRange captureSampleRange;
-    }
-
-    /**
-     * Supported capture size range in samples.
-     */
-    @VintfStability
-    parcelable CaptureSamplesRange {
-        int min;
-        int max;
-    }
-
-    /**
      * Type of scaling applied on the captured visualization data.
      */
     @VintfStability
@@ -115,51 +83,42 @@
     }
 
     /**
-     * Any parameter defined in this union must be gettable via getParameter(), but must not
-     * settable.
+     * Get only parameter to get the current measurements.
      */
     @VintfStability
-    union GetOnlyParameters {
-        /**
-         * Get the current measurements.
-         */
-        @VintfStability
-        parcelable Measurement {
-            int rms;
-            int peak;
-        }
-        Measurement measurement;
-
-        /**
-         * Get the latest captureSamples of PCM samples (8 bits per sample).
-         */
-        byte[] captureSampleBuffer;
+    parcelable Measurement {
+        int rms;
+        int peak;
     }
-    GetOnlyParameters getOnlyParameters;
+    Measurement measurement;
 
     /**
-     * Any parameter defined in this union must be settable via setParameter(), but must not
-     * gettable.
+     * Get only parameter to get the latest captured samples of PCM samples (8 bits per sample).
      */
-    @VintfStability
-    union SetOnlyParameters {
-        /**
-         * Used by framework to inform the visualizer about the downstream latency (audio hardware
-         * driver estimated latency in milliseconds).
-         */
-        int latencyMs;
-    }
-    SetOnlyParameters setOnlyParameters;
+    byte[] captureSampleBuffer;
 
     /**
-     * Current capture size in number of samples. The capture size must be inside
-     * Capability.captureSizeRange.
+     * Used by framework to inform the visualizer about the downstream latency (audio hardware
+     * driver estimated latency in milliseconds).
+     *
+     * Visualizer implementation must use Range.VisualizerRange to define the range of supported
+     * latency.
+     */
+    int latencyMs;
+
+    /**
+     * Current capture size in number of samples.
+     *
+     * Visualizer implementation must use Range.VisualizerRange to define the range of supported
+     * capture size.
      */
     int captureSamples;
+
     /**
      * Visualizer capture mode
      */
     ScalingMode scalingMode;
+
     /**
      * Visualizer measurement mode.
      */
diff --git a/audio/aidl/android/hardware/audio/effect/Volume.aidl b/audio/aidl/android/hardware/audio/effect/Volume.aidl
index 5033881..4a76703 100644
--- a/audio/aidl/android/hardware/audio/effect/Volume.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Volume.aidl
@@ -21,8 +21,8 @@
 /**
  * Volume specific definitions. Volume effect provide volume control and mute/unmute functionality.
  *
- * All parameters defined in union Volume must be gettable and settable. The capabilities defined in
- * Volume.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.volume definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
  */
 @VintfStability
 union Volume {
@@ -41,29 +41,7 @@
     VendorExtension vendor;
 
     /**
-     * Capability supported by Volume implementation.
-     */
-    @VintfStability
-    parcelable Capability {
-        /**
-         * Volume capability extension, vendor can use this extension in case existing capability
-         * definition not enough.
-         */
-        VendorExtension extension;
-
-        /**
-         * Minimum Volume level supported in dB.
-         */
-        int minLevelDb;
-
-        /**
-         * Maximum Volume level supported in dB.
-         */
-        int maxLevelDb;
-    }
-
-    /**
-     * Current level in dB with supported minimum and maximum level specified in capability.
+     * Current level in dB.
      */
     int levelDb;
     /**