Cleanup properties

bug:19967854

Separate properties from Caches, into static, RenderThread-only class.

Also rewrites the means for java to set properties to correctly handle
threading, and adds an override for profile bars so that SysUi doesn't clutter
the screen with them.

Change-Id: I6e21a96065f52b9ecc49d1a126244804ba106fa9
diff --git a/libs/hwui/DrawProfiler.cpp b/libs/hwui/DrawProfiler.cpp
index ecde5ff..7addef9 100644
--- a/libs/hwui/DrawProfiler.cpp
+++ b/libs/hwui/DrawProfiler.cpp
@@ -18,12 +18,11 @@
 #include <cutils/compiler.h>
 
 #include "OpenGLRenderer.h"
-#include "Properties.h"
 
 #define DEFAULT_MAX_FRAMES 128
 
-#define RETURN_IF_PROFILING_DISABLED() if (CC_LIKELY(mType == kNone)) return
-#define RETURN_IF_DISABLED() if (CC_LIKELY(mType == kNone && !mShowDirtyRegions)) return
+#define RETURN_IF_PROFILING_DISABLED() if (CC_LIKELY(mType == ProfileType::None)) return
+#define RETURN_IF_DISABLED() if (CC_LIKELY(mType == ProfileType::None && !mShowDirtyRegions)) return
 
 #define NANOS_TO_MILLIS_FLOAT(nanos) ((nanos) * 0.000001f)
 
@@ -56,18 +55,7 @@
     return (int) (dp * density + 0.5f);
 }
 
-DrawProfiler::DrawProfiler()
-        : mType(kNone)
-        , mDensity(0)
-        , mData(nullptr)
-        , mDataSize(0)
-        , mCurrentFrame(-1)
-        , mPreviousTime(0)
-        , mVerticalUnit(0)
-        , mHorizontalUnit(0)
-        , mThresholdStroke(0)
-        , mShowDirtyRegions(false)
-        , mFlashToggle(false) {
+DrawProfiler::DrawProfiler() {
     setDensity(1);
 }
 
@@ -135,7 +123,7 @@
         }
     }
 
-    if (mType == kBars) {
+    if (mType == ProfileType::Bars) {
         prepareShapes(canvas->getViewportHeight());
         drawGraph(canvas);
         drawCurrentFrame(canvas);
@@ -217,32 +205,20 @@
     canvas->drawLines(pts, 4, &paint);
 }
 
-DrawProfiler::ProfileType DrawProfiler::loadRequestedProfileType() {
-    ProfileType type = kNone;
-    char buf[PROPERTY_VALUE_MAX] = {'\0',};
-    if (property_get(PROPERTY_PROFILE, buf, "") > 0) {
-        if (!strcmp(buf, PROPERTY_PROFILE_VISUALIZE_BARS)) {
-            type = kBars;
-        } else if (!strcmp(buf, "true")) {
-            type = kConsole;
-        }
-    }
-    return type;
-}
-
-bool DrawProfiler::loadSystemProperties() {
+bool DrawProfiler::consumeProperties() {
     bool changed = false;
-    ProfileType newType = loadRequestedProfileType();
+    ProfileType newType = Properties::getProfileType();
     if (newType != mType) {
         mType = newType;
-        if (mType == kNone) {
+        if (mType == ProfileType::None) {
             destroyData();
         } else {
             createData();
         }
         changed = true;
     }
-    bool showDirty = property_get_bool(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false);
+
+    bool showDirty = Properties::showDirtyRegions;
     if (showDirty != mShowDirtyRegions) {
         mShowDirtyRegions = showDirty;
         changed = true;