summaryrefslogtreecommitdiffstats
path: root/sdm/AdaptiveBacklight.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sdm/AdaptiveBacklight.cpp')
-rw-r--r--sdm/AdaptiveBacklight.cpp45
1 files changed, 35 insertions, 10 deletions
diff --git a/sdm/AdaptiveBacklight.cpp b/sdm/AdaptiveBacklight.cpp
index a1e75cc..7d9c8b3 100644
--- a/sdm/AdaptiveBacklight.cpp
+++ b/sdm/AdaptiveBacklight.cpp
@@ -14,7 +14,15 @@
* limitations under the License.
*/
+#include <stdio.h>
+#include <string.h>
+
+#include <android-base/properties.h>
+
#include "AdaptiveBacklight.h"
+#include "Constants.h"
+#include "Types.h"
+#include "Utils.h"
namespace vendor {
namespace lineage {
@@ -22,24 +30,41 @@ namespace livedisplay {
namespace V2_0 {
namespace sdm {
+using ::android::base::GetBoolProperty;
+
+AdaptiveBacklight::AdaptiveBacklight() {
+ mEnabled = false;
+}
+
+bool AdaptiveBacklight::isSupported() {
+ return GetBoolProperty(FOSS_PROPERTY, false);
+}
+
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
Return<bool> AdaptiveBacklight::isEnabled() {
- // TODO implement
- return bool {};
+ return mEnabled;
}
Return<bool> AdaptiveBacklight::setEnabled(bool enabled) {
- // TODO implement
- return bool {};
-}
+ if (mEnabled == enabled) {
+ return true;
+ }
+ char* buf = new char[DPPS_BUF_SIZE];
-// Methods from ::android::hidl::base::V1_0::IBase follow.
+ sprintf(buf, "%s", enabled ? FOSS_ON : FOSS_OFF);
+ if (Utils::sendDPPSCommand(buf, DPPS_BUF_SIZE) == 0) {
+ if (strncmp(buf, "Success", 7) == 0) {
+ mEnabled = enabled;
+ delete[] buf;
+ return true;
+ }
+ }
+
+ delete[] buf;
+ return false;
+}
-//IAdaptiveBacklight* HIDL_FETCH_IAdaptiveBacklight(const char* /* name */) {
- //return new AdaptiveBacklight();
-//}
-//
} // namespace sdm
} // namespace V2_0
} // namespace livedisplay