package com.gh.gamecenter.common.utils

import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import android.provider.Settings


object SystemUtils {
    @SuppressLint("PrivateApi")
    @JvmStatic
    fun getSystemProperty(key: String?): String? {
        return try {
            Class.forName("android.os.SystemProperties")
                .getDeclaredMethod("get", String::class.java)
                .invoke(null, key) as String
        } catch (e: Exception) {
            null
        }
    }

    /**
     * 是否开启开发者选项
     * @param context 上下文
     */
    @JvmStatic
    fun isDevelopmentSettingsEnabled(context: Context): Boolean = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Settings.Global.getInt(context.contentResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) > 0
    } else {
        Settings.Secure.getInt(context.contentResolver, Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) > 0
    }

}