Fix the Nav. bar and divider pixel color difference checking when size of logical display is not matching with size of physical display.

  Displays             Main Display                   |	       Cover Display
               Resoultion  | Density | Smallest Width | Resoultion | Density | Smallest Width
Physical Info   1536x2152  | 420 dpi | 585 dpi        |  720x1680  | 420 dpi | 274 dpi
Logical Info    1536x2152  | 420 dpi | 585 dpi        |  840x1920  | 420 dpi | 320 dpi

Pixel color from screenshot is not same with drawn color while in testing so that tc will use the color difference threshold so that pixel can be regarded as the same color.

BUG: 126767808
Test: run cts -m CtsSystemUiTestCases -t android.systemui.cts.LightBarTests#testNavigationBarDivider

Change-Id: Id29219bbe40c424f88225b2e8aafb769a656c675
Merged-In: Id29219bbe40c424f88225b2e8aafb769a656c675
Signed-off-by: Mark Hong <sungmin.h@samsung.com>
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
index 14d4bcb..27dd44f 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
@@ -26,6 +26,7 @@
 import android.content.pm.PackageManager;
 import android.content.res.Configuration;
 import android.graphics.Bitmap;
+import android.graphics.Color;
 import android.graphics.Rect;
 import android.support.test.InstrumentationRegistry;
 import android.support.test.rule.ActivityTestRule;
@@ -48,6 +49,8 @@
     public static final Path DUMP_PATH = FileSystems.getDefault()
             .getPath("/sdcard/LightBarTestBase/");
 
+    private static final int COLOR_DIFF_THESHOLDS = 2;
+
     private ArrayList<Rect> mCutouts;
 
     protected Bitmap takeStatusBarScreenshot(LightBarBaseActivity activity) {
@@ -169,7 +172,7 @@
                 continue;
             }
 
-            if (dividerColor != pixels[col]) {
+            if (!isColorSame(dividerColor, pixels[col])) {
                 diffCount++;
             }
         }
@@ -189,6 +192,13 @@
         }
     }
 
+    private static boolean isColorSame(int c1, int c2) {
+        return Math.abs(Color.alpha(c1) - Color.alpha(c2)) < COLOR_DIFF_THESHOLDS
+                && Math.abs(Color.red(c1) - Color.red(c2)) < COLOR_DIFF_THESHOLDS
+                && Math.abs(Color.green(c1) - Color.green(c2)) < COLOR_DIFF_THESHOLDS
+                && Math.abs(Color.blue(c1) - Color.blue(c2)) < COLOR_DIFF_THESHOLDS;
+    }
+
     protected void assumeNavigationBarChangesColor(int backgroundColorPixelCount, int totalPixel) {
         assumeTrue("Not enough background pixels. The navigation bar may not be able to change "
                 + "color.", backgroundColorPixelCount > 0.3f * totalPixel);