Loading packages/SystemUI/src/com/android/systemui/biometrics/TetrisUdfpsDisplayModeProvider.kt 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.biometrics import android.content.Context import android.view.Surface import java.io.File import java.io.IOException private const val TAG = "TetrisUdfpsDisplayModeProvider" private const val HBM_PATH = "/sys/devices/platform/soc/1401a000.dsi0/hbm" private const val UI_STATUS_PATH = "/sys/panel_feature/ui_status" class TetrisUdfpsDisplayModeProvider constructor( private val context: Context ): UdfpsDisplayModeProvider { override fun enable(onEnabled: Runnable?) { setNodeValue(HBM_PATH, "1") setNodeValue(UI_STATUS_PATH, "1") onEnabled?.run() } override fun disable(onDisabled: Runnable?) { setNodeValue(HBM_PATH, "0") setNodeValue(UI_STATUS_PATH, "0") onDisabled?.run() } private fun setNodeValue(nodePath: String, value: String) { try { File(nodePath).writeText(value) logger.v(TAG, "setNodeValue | Wrote $value to $nodePath") } catch (e: IOException) { logger.e(TAG, "setNodeValue | Failed to write $value to $nodePath", e) } } } Loading
packages/SystemUI/src/com/android/systemui/biometrics/TetrisUdfpsDisplayModeProvider.kt 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.biometrics import android.content.Context import android.view.Surface import java.io.File import java.io.IOException private const val TAG = "TetrisUdfpsDisplayModeProvider" private const val HBM_PATH = "/sys/devices/platform/soc/1401a000.dsi0/hbm" private const val UI_STATUS_PATH = "/sys/panel_feature/ui_status" class TetrisUdfpsDisplayModeProvider constructor( private val context: Context ): UdfpsDisplayModeProvider { override fun enable(onEnabled: Runnable?) { setNodeValue(HBM_PATH, "1") setNodeValue(UI_STATUS_PATH, "1") onEnabled?.run() } override fun disable(onDisabled: Runnable?) { setNodeValue(HBM_PATH, "0") setNodeValue(UI_STATUS_PATH, "0") onDisabled?.run() } private fun setNodeValue(nodePath: String, value: String) { try { File(nodePath).writeText(value) logger.v(TAG, "setNodeValue | Wrote $value to $nodePath") } catch (e: IOException) { logger.e(TAG, "setNodeValue | Failed to write $value to $nodePath", e) } } }