Scaling filter is changed to stop filtering small fingers

The threshold is modified to allow small fingers.
Fingers with pressure smaller than one are converted to fingers
with pressure = 1.0

BUG=chromium:475186
TEST=Manually tested and fixes the reported log. Regression test is
performed and no new problem was introduced.
All unittests pass.

Change-Id: I321c31536ea2043369810c33bd0cc8baee54cd5a
Reviewed-on: https://chromium-review.googlesource.com/264783
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Amirhossein Simjour <asimjour@chromium.org>
Commit-Queue: Amirhossein Simjour <asimjour@chromium.org>
diff --git a/include/scaling_filter_interpreter.h b/include/scaling_filter_interpreter.h
index 2d78749..28d1346 100644
--- a/include/scaling_filter_interpreter.h
+++ b/include/scaling_filter_interpreter.h
@@ -100,6 +100,10 @@
   DoubleProperty pressure_scale_;
   DoubleProperty pressure_translate_;
   DoubleProperty pressure_threshold_;
+  // if true, the low pressure touch will be ignored.
+  // if false, or doesn't exist, the low pressure touch will be converted
+  // to touch with pressure 1.0
+  BoolProperty filter_low_pressure_;
 
   // If true, adjust touch count to match finger count when scaling
   // input state. This can help avoid being considered a T5R2 pad.
diff --git a/src/scaling_filter_interpreter.cc b/src/scaling_filter_interpreter.cc
index 0578d6c..9f9219c 100644
--- a/src/scaling_filter_interpreter.cc
+++ b/src/scaling_filter_interpreter.cc
@@ -33,6 +33,7 @@
       pressure_scale_(prop_reg, "Pressure Calibration Slope", 1.0),
       pressure_translate_(prop_reg, "Pressure Calibration Offset", 0.0),
       pressure_threshold_(prop_reg, "Pressure Minimum Threshold", 0.0),
+      filter_low_pressure_(prop_reg, "Filter Low Pressure", 0),
       force_touch_count_to_match_finger_count_(
           prop_reg,
           "Force Touch Count To Match Finger Count",
@@ -129,7 +130,8 @@
 
   if (surface_area_from_pressure_.val_) {
     // Drop the small fingers, i.e. low pressures.
-    FilterLowPressure(hwstate);
+    if (filter_low_pressure_.val_ || pressure_threshold_.val_ > 0.0)
+      FilterLowPressure(hwstate);
   }
 
   for (short i = 0; i < hwstate->finger_cnt; i++) {
@@ -191,6 +193,9 @@
       else
         hwstate->fingers[i].pressure = 0;
     }
+
+    hwstate->fingers[i].pressure = std::max(1.0f,
+                                            hwstate->fingers[i].pressure);
   }
 
   if (!surface_area_from_pressure_.val_) {
diff --git a/src/scaling_filter_interpreter_unittest.cc b/src/scaling_filter_interpreter_unittest.cc
index b43b4b1..7d3ba5a 100644
--- a/src/scaling_filter_interpreter_unittest.cc
+++ b/src/scaling_filter_interpreter_unittest.cc
@@ -323,6 +323,8 @@
 
     has_zero_area[i] = pressure == 0.0;
 
+    pressure = std::max(pressure , 1.0f);
+
     if (has_zero_area[i]) {
       base_interpreter->expected_orientation_.push_back(
           std::vector<float>(0));
@@ -374,7 +376,10 @@
 
   const float e_x = 17;
   const float e_y = 71;
+  const bool kFilterLowPressure = 1;
+
   interpreter.surface_area_from_pressure_.val_ = false;
+  interpreter.filter_low_pressure_.val_ = kFilterLowPressure;
   interpreter.tp_x_bias_.val_ = e_x;
   interpreter.tp_y_bias_.val_ = e_y;