Snap for 7824833 from 9877e18b82fed1dbca0ca3d05d5bce2d8f7b542e to sc-v2-release

Change-Id: Iea5a9e2cd9dc13f3501c781dc3714d063647ea66
diff --git a/system/hwc2/Display.cpp b/system/hwc2/Display.cpp
index 9d754cb..a7cff77 100644
--- a/system/hwc2/Display.cpp
+++ b/system/hwc2/Display.cpp
@@ -114,8 +114,8 @@
                           1000 * 1000 * 1000 / refreshRateHz);
   it->second.setAttribute(HWC2::Attribute::Width, width);
   it->second.setAttribute(HWC2::Attribute::Height, height);
-  it->second.setAttribute(HWC2::Attribute::DpiX, dpiX * 1000);
-  it->second.setAttribute(HWC2::Attribute::DpiY, dpiY * 1000);
+  it->second.setAttribute(HWC2::Attribute::DpiX, dpiX);
+  it->second.setAttribute(HWC2::Attribute::DpiY, dpiY);
 
   mEdid = edid;
 
diff --git a/system/hwc2/DisplayConfig.cpp b/system/hwc2/DisplayConfig.cpp
index b05f907..ee4cbb1 100644
--- a/system/hwc2/DisplayConfig.cpp
+++ b/system/hwc2/DisplayConfig.cpp
@@ -57,10 +57,12 @@
     return mHeight;
   }
   if (attribute == HWC2::Attribute::DpiX) {
-    return mDpiX;
+    // From hwcomposer2.h, HWC2_ATTRIBUTE_DPI_X returns "Dots per thousand inches (DPI * 1000)".
+    return getDotsPerThousandInchesX();
   }
   if (attribute == HWC2::Attribute::DpiY) {
-    return mDpiY;
+    // From hwcomposer2.h, HWC2_ATTRIBUTE_DPI_Y returns "Dots per thousand inches (DPI * 1000)"
+    return getDotsPerThousandInchesY();
   }
   if (attribute == HWC2::Attribute::VsyncPeriod) {
     return mVsyncPeriodNanos;
@@ -75,8 +77,8 @@
   std::string output;
   output += " w:" + std::to_string(mWidth);
   output += " h:" + std::to_string(mHeight);
-  output += " dpi-x:" + std::to_string(mDpiX / 1000.0f);
-  output += " dpi-y:" + std::to_string(mDpiY / 1000.0f);
+  output += " dpi-x:" + std::to_string(mDpiX);
+  output += " dpi-y:" + std::to_string(mDpiY);
   output += " vsync:" + std::to_string(1e9 / mVsyncPeriodNanos);
   output += " config-group:" + std::to_string(mConfigGroup);
   return output;
diff --git a/system/hwc2/DisplayConfig.h b/system/hwc2/DisplayConfig.h
index f7502d7..67e4c49 100644
--- a/system/hwc2/DisplayConfig.h
+++ b/system/hwc2/DisplayConfig.h
@@ -60,6 +60,9 @@
   int32_t getDpiY() const { return mDpiY; }
   void setDpiY(int32_t dpi) { mDpiY = dpi; }
 
+  int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; }
+  int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; }
+
   int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; }
   void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; }