Merge a76131a3c190fb8193e6ca65c9e15d27333b183b on remote branch

Change-Id: I66d01dad2d7f2f1f425287857516592090f36d57
diff --git a/Power.cpp b/Power.cpp
index e451990..c37fb31 100644
--- a/Power.cpp
+++ b/Power.cpp
@@ -96,6 +96,12 @@
 
     switch(type){
         case Mode::EXPENSIVE_RENDERING:
+            if (is_expensive_rendering_supported()) {
+                *_aidl_return = true;
+            } else {
+                *_aidl_return = false;
+            }
+            break;
         case Mode::INTERACTIVE:
         case Mode::SUSTAINED_PERFORMANCE:
         case Mode::FIXED_PERFORMANCE:
diff --git a/power-common.c b/power-common.c
index a7a32e5..21a6d69 100644
--- a/power-common.c
+++ b/power-common.c
@@ -116,6 +116,13 @@
     }
 }
 
+bool is_expensive_rendering_supported() {
+    char property[PROPERTY_VALUE_MAX];
+    strlcpy(property, perf_get_property("vendor.perf.expensive_rendering", "0").value,
+            PROPERTY_VALUE_MAX);
+    return atoi(property) == 1 ? true : false;
+}
+
 void set_expensive_rendering(bool enabled)
 {
     if (enabled) {
diff --git a/power-common.h b/power-common.h
index b95ea22..688fb81 100644
--- a/power-common.h
+++ b/power-common.h
@@ -62,6 +62,7 @@
 
 void power_init(void);
 void power_hint(power_hint_t hint, void *data);
+bool is_expensive_rendering_supported();
 void set_expensive_rendering(bool enabled);
 void set_interactive(int on);
 
diff --git a/utils.c b/utils.c
index d586df8..d9ecb84 100644
--- a/utils.c
+++ b/utils.c
@@ -56,6 +56,7 @@
     int list[], int numArgs);
 static int (*perf_lock_rel)(int handle);
 static int (*perf_hint)(int, const char *, int, int);
+static PropVal (*perf_get_prop)(const char *prop , const char *def_val);
 static struct list_node active_hint_list_head;
 const char *pkg = "QTI PowerHAL";
 
@@ -102,6 +103,11 @@
         if (!perf_hint) {
             ALOGE("Unable to get perf_hint function handle.\n");
         }
+
+        perf_get_prop = dlsym(qcopt_handle, "perf_get_prop");
+        if (!perf_get_prop) {
+            ALOGE("Unable to get perf_get_prop function handle.\n");
+        }
     }
 }
 
@@ -210,6 +216,16 @@
    return 0;
 }
 
+PropVal perf_get_property(const char *prop , const char *def_val) {
+    PropVal retVal;
+    if (qcopt_handle && perf_get_prop) {
+        retVal = perf_get_prop(prop, def_val);
+    } else {
+        strlcpy(retVal.value, def_val, PROPERTY_VALUE_MAX);
+    }
+    return retVal;
+}
+
 void interaction(int duration, int num_args, int opt_list[])
 {
 #ifdef INTERACTION_BOOST
diff --git a/utils.h b/utils.h
index 4c3dc7f..8a36c70 100644
--- a/utils.h
+++ b/utils.h
@@ -29,6 +29,10 @@
 
 #include <cutils/properties.h>
 
+typedef struct {
+    char value[PROP_VALUE_MAX];
+} PropVal;
+
 int sysfs_read(char *path, char *s, int num_bytes);
 int sysfs_write(char *path, char *s);
 int get_scaling_governor(char governor[], int size);
@@ -45,3 +49,4 @@
 void release_request(int lock_handle);
 int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
 int perf_hint_enable(int hint_id, int duration);
+PropVal perf_get_property(const char *prop , const char *def_val);