Skip to content
This repository was archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
parts: drop livedisplay
Browse files Browse the repository at this point in the history
Signed-off-by: lolipuru <banstellazz@gmail.com>
  • Loading branch information
lolipuru authored and spectredev-007 committed Mar 27, 2023
1 parent e485918 commit dcfe65a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions XperiaParts/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ android_app {
system_ext_specific: true,
privileged: true,

libs: [
"framework",
"services",
],

static_libs: [
"androidx.core_core",
"androidx.preference_preference",
"androidx.core_core-ktx",
"org.lineageos.settings.resources",
"org.lineageos.platform.internal",
"vendor.semc.hardware.display-V2.0-java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

package org.lineageos.settings.device.display

import android.app.Activity
import android.content.Context
import android.hardware.display.ColorDisplayManager
import android.provider.Settings
import android.util.Log
import android.view.View

import lineageos.hardware.LiveDisplayManager
import android.graphics.ColorMatrix
import android.graphics.ColorMatrixColorFilter
import androidx.core.content.ContextCompat
import android.hardware.display.ColorDisplayManager

import vendor.semc.hardware.display.V2_0.IDisplay
import vendor.semc.hardware.display.V2_0.IDisplayCallback
Expand All @@ -22,7 +26,6 @@ class CreatorModeUtils(private val context: Context) : IDisplayCallback.Stub() {
?: throw Exception("Display manager is NULL")
private val semcDisplayService: IDisplay =
IDisplay.getService() ?: throw Exception("SEMC Display HIDL not found")
private val liveDisplayManager: LiveDisplayManager = LiveDisplayManager.getInstance(context)

val isEnabled: Boolean
get() = Settings.Secure.getInt(context.contentResolver, CREATOR_MODE_ENABLE, 0) != 0
Expand All @@ -44,9 +47,20 @@ class CreatorModeUtils(private val context: Context) : IDisplayCallback.Stub() {
}

override fun onWhiteBalanceMatrixChanged(matrix: PccMatrix) {
val colorMatrix: FloatArray = floatArrayOf(matrix.red, matrix.green, matrix.blue)
val colorMatrix: ColorMatrix = ColorMatrix().apply {
set(floatArrayOf(
matrix.red, matrix.green, matrix.blue, 0f, 0f,
matrix.red, matrix.green, matrix.blue, 0f, 0f,
matrix.red, matrix.green, matrix.blue, 0f, 0f,
0f, 0f, 0f, 1f, 0f
))
}

val filter = ColorMatrixColorFilter(colorMatrix)

val views = (context as Activity).window.decorView
views.post { views.background.colorFilter = filter }
Log.i(TAG, "New white balance: ${matrix.red}, ${matrix.green}, ${matrix.blue}")
liveDisplayManager.setColorAdjustment(colorMatrix)
}

companion object {
Expand Down

0 comments on commit dcfe65a

Please sign in to comment.