package com.yidian.bcommon.utils

import android.app.ActivityManager
import android.content.Context
import android.os.Process
import com.yidian.news.util.ProcessUtil
import timber.log.Timber


object AppUtils {

  fun getProcessInfo() {
    val pid = Process.myPid()
    Timber.tag("启动").e("YdBaseApplication  onCreate ->>>>> pid:   $pid")
    val currentProcessName = ProcessUtil.getCurrentProcessName()
    Timber.tag("启动").e("YdBaseApplication  onCreate ->>>>> processName:  $currentProcessName")
  }

  private fun getCurrentProcessName(context: Context): String? {
    val pid = Process.myPid()
    val mActivityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
    for (appProcess in mActivityManager.runningAppProcesses) {
      if (appProcess.pid == pid) {
        return appProcess.processName
      }
    }
    return null
  }
}
