package aicg.wipf.vzuj.jxkr

import aicg.wipf.vzuj.Kmqp.string
import android.app.usage.UsageEvents
import android.app.usage.UsageStatsManager
import android.content.Context
import com.test.basd.smartjunkcleaner.R
import java.util.LinkedList

class Zxbe(val beginTs: Long, val endTs: Long) {

    private val TAG = R.string.ޏޠޝޝހ_D.string()

    fun run(context: Context): Map<String, Rrkh> {
        return ޅނޣރސނޞޕ(context)
    }

    private fun ރޖޤލޖޔޖޒ(context: Context): Map<String, Rrkh> {
        if (System.currentTimeMillis() < 9665) {
            println(System.currentTimeMillis())
        }
        var obj: UsageEvents.Event?
        class ޏޑޡއޙޑގޠ<T>(val ޏޕއޞޣޑޅޟ: T, val ސޓޤޙގޔގޚ: Int) {
            constructor(ބޚޏށޝޣނޝ: T) : this(ބޚޏށޝޣނޝ, 3123) {
                println("ޏކޚތލޛއޤ")
            }
        }
        println(ޏޑޡއޙޑގޠ("ޗއޥޛޘޙޜޥ"))
        var obj2: UsageEvents.Event?
        val usageStatsManager = context.getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager
        val hashMap = HashMap<String, Rrkh>()
        var j12: Long = 0
        fun ތޣވޥޘޜޔޗ() {
            fun ދޞބޠޒޞޟގ(ނތމބޟޥލޖ: Int) {
                println(ނތމބޟޥލޖ)
            }
            ދޞބޠޒޞޟގ(7455)
            ދޞބޠޒޞޟގ(9063)
            ދޞބޠޒޞޟގ(2155)
        }
        ތޣވޥޘޜޔޗ()
        if (endTs - beginTs > 259200000) {
            val ޏޢޚޕޠގޒތ: (Int, Int) -> Int = { ނހވޅޑޘޕޟ, ލމތޣވޣޤލ -> ނހވޅޑޘޕޟ + ލމތޣވޣޤލ }
            println(ޏޢޚޕޠގޒތ.invoke(7303, 2416))
            val queryUsageStats = usageStatsManager.queryUsageStats(0, beginTs, endTs)
            if (queryUsageStats != null) {
                for (usageStats in queryUsageStats) {
                    class ދކސނޘޤވޒ {
                        val ޒޅޚޙޖޖޘޥ by lazy {
                            println("ފޕލބޓމޥޖ")
                            "ޤޞވޗޢޚޥލ!"
                        }
                    }
                    val ދމބދޠޤތޔ = ދކސނޘޤވޒ()
                    println(ދމބދޠޤތޔ.ޒޅޚޙޖޖޘޥ)
                    if (usageStats.totalTimeInForeground > j12 && usageStats.lastTimeUsed > beginTs) {
                        fun String.ޘޅޒވދރތކ(): Boolean {
                            return this == this.reversed()
                        }
                        val ޓޕޜޟބމޔޣ = "ޣޗއދޕޡވޜ"
                        val ކޘކޥޑޘދގ = ޓޕޜޟބމޔޣ.ޘޅޒވދރތކ()
                        println(ކޘކޥޑޘދގ)
                        val bVar = hashMap[usageStats.packageName]
                        class ޚފޤޙޠފޤޓ {
                            inner class ފޡޒޔޒޗލޤ {
                                fun ޒރޝބޟޞޕޛ() {
                                    println("ބރބޒޚޞޡހ")
                                }
                            }
                        }
                        val ޡޟޘވޙނސޕ = ޚފޤޙޠފޤޓ().ފޡޒޔޒޗލޤ()
                        ޡޟޘވޙނސޕ.ޒރޝބޟޞޕޛ()
                        if (bVar == null) {
                            hashMap[usageStats.packageName] = Rrkh(
                                getAppName(context, usageStats.packageName), usageStats.packageName, usageStats.totalTimeInForeground
                            )
                        } else {
                            bVar.c += usageStats.totalTimeInForeground
                        }
                    }
                    j12 = 0
                }
            }
        } else {
            val linkedList = LinkedList<LinkedList<UsageEvents.Event>>()
            val queryEvents = usageStatsManager.queryEvents(beginTs, endTs)
            while (queryEvents != null && queryEvents.hasNextEvent()) {
                val event = UsageEvents.Event()
                if (queryEvents.getNextEvent(event) && event.eventType != 23 && event.eventType != 11) {
                    if (!linkedList.isEmpty() && linkedList.getLast().getLast().packageName == event.packageName) {
                        class ޒޓޡޖމއއސ {
                            fun ވޓޣށނތޓޙ() {
                                println("ޖޅހތފލށރ")
                            }
                        }
                        ޒޓޡޖމއއސ().ވޓޣށނތޓޙ()
                        linkedList.getLast().addLast(event)
                    } else {
                        val linkedList2 = LinkedList<UsageEvents.Event>()
                        class ޏޛޕޥޒނޜޑ {
                            val ޠޝޘޞޓލޡޠ by lazy {
                                println("ހޠތދޥމނޠ")
                                "ޝޝވޟކވޡޑ!"
                            }
                        }
                        val ނޜކޤއޕޝރ = ޏޛޕޥޒނޜޑ()
                        println(ނޜކޤއޕޝރ.ޠޝޘޞޓލޡޠ)
                        linkedList2.addLast(event)
                        linkedList.addLast(linkedList2)
                    }
                }
            }
            class ރޗނޣކޑތކ<T>(val ޡގޔޑގޤއރ: T, val ޙޗޗޅށވޠހ: Int) {
                constructor(ށޓޣގއޥބޚ: T) : this(ށޓޣގއޥބޚ, 5417) {
                    println("ރކޥގޚށޗޡ")
                }
            }
            println(ރޗނޣކޑތކ("ޝޓރޜބޔރޗ"))
            for (linkedList3 in linkedList) {
                val packageName = linkedList3.getFirst().packageName
                val it2: Iterator<UsageEvents.Event> = linkedList3.iterator()
                while (true) {
                    obj = null
                    if (it2.hasNext()) {
                        obj2 = it2.next()
                        if (obj2.eventType == 1) {
                            break
                        }
                    } else {
                        obj2 = null
                        break
                    }
                }
                class ޖޡހޥޅޞބޘ<T>(val ޗހތފޑޠކޞ: T)
                val ޞޢށނފޔޣޠ = ޖޡހޥޅޞބޘ(5202)
                val ޠޠޙޞޘޤޏޒ = ޖޡހޥޅޞބޘ("މގތށސޟބރ")
                println(ޞޢށނފޔޣޠ)
                println(ޠޠޙޞޘޤޏޒ)
                val event2 = obj2
                val listIterator: ListIterator<UsageEvents.Event> = linkedList3.listIterator(linkedList3.size)
                class ޚތޝޥޔމޒގ<T>(val ޗލނޥޑބގދ: T, val ލވޟޢޔދޗޒ: Int) {
                    constructor(ގބތފއށޘޓ: T) : this(ގބތފއށޘޓ, 652) {
                        println("ޤރޝދށޅދށ")
                    }
                }
                println(ޚތޝޥޔމޒގ("ޙވމރޒޖއޟ"))
                while (true) {
                    if (listIterator.hasPrevious()) {
                        val previous = listIterator.previous()
                        if (previous.eventType == 2) {
                            open class ޔނޝކޔރނޖ {
                                open fun ޔސޜޟޏޞގލ() {}
                            }
                            class ޜޟތޕޜޠއޒ : ޔނޝކޔރނޖ() {
                                override fun ޔސޜޟޏޞގލ() {
                                    println("ވހޜޖބޤޝޠ")
                                }
                            }
                            val ޣށޤޒޅތށޒ = ޜޟތޕޜޠއޒ()
                            println(ޣށޤޒޅތށޒ)
                            obj = previous
                        }
                    } else {
                        break
                    }
                }
                fun ޒޡޏޑށޓހޟ() {
                    fun ޗޙގޑކޢޔދ(ސޓޅޑޥދޚޅ: Int) {
                        println(ސޓޅޑޥދޚޅ)
                    }
                    ޗޙގޑކޢޔދ(5475)
                    ޗޙގޑކޢޔދ(5452)
                    ޗޙގޑކޢޔދ(7972)
                }
                ޒޡޏޑށޓހޟ()
                val event3 = obj
                if (event2 != null && event3 != null && event2.timeStamp < event3.timeStamp) {
                    var bVar2 = hashMap[packageName]
                    val ޓފޢޡޗޜޓޗ = { މފޏވޤޘޖތ: String -> println(މފޏވޤޘޖތ) }
                    ޓފޢޡޗޜޓޗ("ޘޤޥޏޣކޓޚ!")
                    if (bVar2 == null) {
                        val ޣޛވސޞޜޤޞ: (Int, Int) -> Int = { ޖޛކދޖޡޒޡ, ޣޢޠޖޠޏސޏ -> ޖޛކދޖޡޒޡ + ޣޢޠޖޠޏސޏ }
                        println(ޣޛވސޞޜޤޞ.invoke(4711, 9197))
                        bVar2 = Rrkh(getAppName(context, packageName), packageName, 0L)
                    }
                    bVar2.c += event3.timeStamp - event2.timeStamp
                    hashMap[packageName] = bVar2
                }
            }
        }

        return hashMap
    }

    private fun ޟށޠލއރޛހ(context: Context): Map<String, Rrkh> {
        class ޅނޑޅޗޑހޕ<T>(ޅމޞޜޣބފޜ: T) {
            init {
                println("ފޖޑގޒފޥޞ: $ޅމޞޜޣބފޜ")
            }
        }
        println(ޅނޑޅޗޑހޕ("ޚޢށޚޅދޔޓ"))
        return ޘޕވސޙމޛޖ(context)
    }

    private fun ޘޕވސޙމޛޖ(context: Context): Map<String, Rrkh> {
        return ރޖޤލޖޔޖޒ(context)
    }

    companion object {
        fun getAppName(context: Context, str: String?): String {
            return ޣޖތޙއފޛސ(context, str)
        }

        private fun ޣޖތޙއފޛސ(context: Context, str: String?): String {
            return ޣގކޙޚރޟވ(context, str)
        }

        private fun ޣގކޙޚރޟވ(context: Context, str: String?): String {
            class ށޜށޜޠފޠވ<T>(val މދޝޔޕޤސޕ: T)
            val ޤޟމހދގގޏ = ށޜށޜޠފޠވ(3597)
            val ޘދޡޠޕޕޑޝ = ށޜށޜޠފޠވ("ޢޘދވގޤދޞ")
            println(ޤޟމހދގގޏ.މދޝޔޕޤސޕ)
            println(ޘދޡޠޕޕޑޝ.މދޝޔޕޤސޕ)
            return ދޕގކޚލށޒ(context, str)
        }

        private fun ދޕގކޚލށޒ(context: Context, str: String?): String {
            fun ގރސކޤނޥމ(އޗލޅޥއވޙ: Int, ރޠޝރޣކޖތ: Int): Int {
                return އޗލޅޥއވޙ + ރޠޝރޣކޖތ
            }
            val ދޗޔމޖޛޏޚ = ގރސކޤނޥމ(9147, 454)
            println(ދޗޔމޖޛޏޚ)
            return ޤދޑޛޞބޜޑ(context, str)
        }

        private fun ޤދޑޛޞބޜޑ(context: Context, str: String?): String {
            val packageManager = context.packageManager
            return try {
                packageManager.getApplicationLabel(packageManager.getApplicationInfo(str!!, 0)).toString()
            } catch (e10: Exception) {
                ""
            }
        }
    }

    private fun ޅނޣރސނޞޕ(context: Context): Map<String, Rrkh> {
        return ޜޟޙޓލކޥބ(context)
    }

    private fun ޜޟޙޓލކޥބ(context: Context): Map<String, Rrkh> {
        return ޟށޠލއރޛހ(context)
    }
}