package com.xyzshell.andinfo.libs

import android.app.ActivityManager
import android.content.Context
import android.os.Build

class DeviceInfo(private val context: Context) {

    private val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager

    val device: String
        get() = Build.DEVICE

    val brand: String
        get() = Build.BRAND

    val model: String
        get() = Build.MODEL

    val manufacturer: String
        get() = Build.MANUFACTURER

    val productName: String
        get() = Build.PRODUCT

    val hardwareName: String
        get() = Build.HARDWARE

    val boardName: String
        get() = Build.BOARD

    val hardwareSku: String?
        get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Build.SKU else null

    val odmSku: String?
        get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Build.ODM_SKU else null

    val socManufacturer: String?
        get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Build.SOC_MANUFACTURER else null

    val socModel: String?
        get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Build.SOC_MODEL else null

    fun getMemoryInfo(): ActivityManager.MemoryInfo {
        val memoryInfo = ActivityManager.MemoryInfo()
        activityManager.getMemoryInfo(memoryInfo)
        return memoryInfo
    }
}
