package pxds.iqiv.ioih.gxph

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.util.Log
import com.test.basd.supercleanermax.R
import pxds.lmmd.zmwf.Khko.string

class Zmze : BroadcastReceiver() {

    private var isLock = false

    private var mIsScreenOn = false

    override fun onReceive(context: Context, intent: Intent?) {
        val action = intent?.action ?: 0
        when (action) {
            Intent.ACTION_SCREEN_ON -> {
                mIsScreenOn = true
            }

            Intent.ACTION_SCREEN_OFF -> {
                mIsScreenOn = false
                isLock = true
            }

            Intent.ACTION_USER_PRESENT -> {
                isLock = false
                Log.d(R.string.ޓތޅހޠ_D.string(), "解锁")
                if (mIsScreenOn && !isLock) {

                }
            }

            Intent.ACTION_POWER_CONNECTED -> {
            }

            Intent.ACTION_POWER_DISCONNECTED -> {

            }

            Intent.ACTION_BATTERY_CHANGED -> {
            }

        }
    }

    companion object {
        private val TAG = R.string.ޒޣދޓޛ_D.string()
        fun Context.initBroadcast() {
            val filter = IntentFilter()
            filter.addAction(Intent.ACTION_SCREEN_OFF)
            filter.addAction(Intent.ACTION_SCREEN_ON)
            filter.addAction(Intent.ACTION_USER_PRESENT)
            filter.addAction(Intent.ACTION_POWER_CONNECTED)
            filter.addAction(Intent.ACTION_POWER_DISCONNECTED)
            filter.addAction(Intent.ACTION_BATTERY_CHANGED)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                registerReceiver(Zmze(), filter, Context.RECEIVER_EXPORTED)
            } else {
                registerReceiver(Zmze(), filter)
            }
        }
    }
}