package com.gh.common.prioritychain

import androidx.fragment.app.FragmentActivity
import com.gh.common.util.PackageHelper
import com.gh.gamecenter.common.base.GlobalActivityManager

class RequestInstalledListPermissionHandler : PriorityChainHandler(-1000) {

    init {
        updateStatus(STATUS_VALID)
    }

    override fun onProcess(): Boolean {
        val currentActivity = GlobalActivityManager.currentActivity ?: return false

        if (currentActivity !is FragmentActivity) return false

        PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(
            activity = currentActivity,
            ignorePermanentlyDenied = true
        ) {
            processNext()
        }

        return true
    }

}