Use libbase API to access system properties in libhwui

Calls to licutils properties API are replaced by calls to libbase
properties API. This will make it easier to make a host target for
libhwui as libbase provides a host implementation for its properties
API.

Bug: 117921091
Test: N/A
Change-Id: I15b4fe1a16d2bc7b271387d8cf3403940b8aae2d
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index af20c4f..2196b0f 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -23,8 +23,8 @@
 #include <algorithm>
 #include <cstdlib>
 
+#include <android-base/properties.h>
 #include <cutils/compiler.h>
-#include <cutils/properties.h>
 #include <log/log.h>
 
 namespace android {
@@ -67,64 +67,54 @@
 int Properties::contextPriority = 0;
 int Properties::defaultRenderAhead = -1;
 
-static int property_get_int(const char* key, int defaultValue) {
-    char buf[PROPERTY_VALUE_MAX] = {
-            '\0',
-    };
-
-    if (property_get(key, buf, "") > 0) {
-        return atoi(buf);
-    }
-    return defaultValue;
-}
-
 bool Properties::load() {
-    char property[PROPERTY_VALUE_MAX];
     bool prevDebugLayersUpdates = debugLayersUpdates;
     bool prevDebugOverdraw = debugOverdraw;
 
     debugOverdraw = false;
-    if (property_get(PROPERTY_DEBUG_OVERDRAW, property, nullptr) > 0) {
-        INIT_LOGD("  Overdraw debug enabled: %s", property);
-        if (!strcmp(property, "show")) {
+    std::string debugOverdrawProperty = base::GetProperty(PROPERTY_DEBUG_OVERDRAW, "");
+    if (debugOverdrawProperty != "") {
+        INIT_LOGD("  Overdraw debug enabled: %s", debugOverdrawProperty);
+        if (debugOverdrawProperty == "show") {
             debugOverdraw = true;
             overdrawColorSet = OverdrawColorSet::Default;
-        } else if (!strcmp(property, "show_deuteranomaly")) {
+        } else if (debugOverdrawProperty == "show_deuteranomaly") {
             debugOverdraw = true;
             overdrawColorSet = OverdrawColorSet::Deuteranomaly;
         }
     }
 
     sProfileType = ProfileType::None;
-    if (property_get(PROPERTY_PROFILE, property, "") > 0) {
-        if (!strcmp(property, PROPERTY_PROFILE_VISUALIZE_BARS)) {
+    std::string profileProperty = base::GetProperty(PROPERTY_PROFILE, "");
+    if (profileProperty != "") {
+        if (profileProperty == PROPERTY_PROFILE_VISUALIZE_BARS) {
             sProfileType = ProfileType::Bars;
-        } else if (!strcmp(property, "true")) {
+        } else if (profileProperty == "true") {
             sProfileType = ProfileType::Console;
         }
     }
 
-    debugLayersUpdates = property_get_bool(PROPERTY_DEBUG_LAYERS_UPDATES, false);
+    debugLayersUpdates = base::GetBoolProperty(PROPERTY_DEBUG_LAYERS_UPDATES, false);
     INIT_LOGD("  Layers updates debug enabled: %d", debugLayersUpdates);
 
-    showDirtyRegions = property_get_bool(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false);
+    showDirtyRegions = base::GetBoolProperty(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false);
 
-    debugLevel = (DebugLevel)property_get_int(PROPERTY_DEBUG, kDebugDisabled);
+    debugLevel = (DebugLevel)base::GetIntProperty(PROPERTY_DEBUG, (int)kDebugDisabled);
 
-    skipEmptyFrames = property_get_bool(PROPERTY_SKIP_EMPTY_DAMAGE, true);
-    useBufferAge = property_get_bool(PROPERTY_USE_BUFFER_AGE, true);
-    enablePartialUpdates = property_get_bool(PROPERTY_ENABLE_PARTIAL_UPDATES, true);
+    skipEmptyFrames = base::GetBoolProperty(PROPERTY_SKIP_EMPTY_DAMAGE, true);
+    useBufferAge = base::GetBoolProperty(PROPERTY_USE_BUFFER_AGE, true);
+    enablePartialUpdates = base::GetBoolProperty(PROPERTY_ENABLE_PARTIAL_UPDATES, true);
 
-    filterOutTestOverhead = property_get_bool(PROPERTY_FILTER_TEST_OVERHEAD, false);
+    filterOutTestOverhead = base::GetBoolProperty(PROPERTY_FILTER_TEST_OVERHEAD, false);
 
-    skpCaptureEnabled = debuggingEnabled && property_get_bool(PROPERTY_CAPTURE_SKP_ENABLED, false);
+    skpCaptureEnabled = debuggingEnabled && base::GetBoolProperty(PROPERTY_CAPTURE_SKP_ENABLED, false);
 
     SkAndroidFrameworkTraceUtil::setEnableTracing(
-            property_get_bool(PROPERTY_SKIA_ATRACE_ENABLED, false));
+            base::GetBoolProperty(PROPERTY_SKIA_ATRACE_ENABLED, false));
 
-    runningInEmulator = property_get_bool(PROPERTY_QEMU_KERNEL, false);
+    runningInEmulator = base::GetBoolProperty(PROPERTY_QEMU_KERNEL, false);
 
-    defaultRenderAhead = std::max(-1, std::min(2, property_get_int(PROPERTY_RENDERAHEAD,
+    defaultRenderAhead = std::max(-1, std::min(2, base::GetIntProperty(PROPERTY_RENDERAHEAD,
             render_ahead().value_or(0))));
 
     return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
@@ -175,9 +165,8 @@
         return sRenderPipelineType;
     }
     bool useVulkan = use_vulkan().value_or(false);
-    char prop[PROPERTY_VALUE_MAX];
-    property_get(PROPERTY_RENDERER, prop, useVulkan ? "skiavk" : "skiagl");
-    if (!strcmp(prop, "skiavk")) {
+    std::string rendererProperty = base::GetProperty(PROPERTY_RENDERER, useVulkan ? "skiavk" : "skiagl");
+    if (rendererProperty == "skiavk") {
         return RenderPipelineType::SkiaVulkan;
     }
     return RenderPipelineType::SkiaGL;