the following kotlin code is of a android process manger but there are some issues please fix those 
1)the cpu graph is also showing zero 
2) the cpu usage and memory usage of each process for almost process is showing zero percent 
give me the whole updated code 
the old code 
package com.example.androidprocessmonitor

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.*
import androidx.compose.material3.Button
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.androidprocessmonitor.ui.theme.AndroidProcessMonitorTheme
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.BufferedReader
import java.io.FileReader
import java.io.InputStreamReader

data class ProcessInfo(
    val pid: String,
    val name: String,
    val cpuUsage: String,
    val memoryUsage: String
)

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            AndroidProcessMonitorTheme {
                Surface {
                    ProcessMonitorScreen()
                }
            }
        }
    }
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ProcessMonitorScreen() {
    var processList by remember { mutableStateOf(emptyList<ProcessInfo>()) }
    var searchQuery by remember { mutableStateOf("") }
    val coroutineScope = rememberCoroutineScope()

    val cpuUsageHistory = remember { mutableStateListOf<Float>() }
    val memoryUsageHistory = remember { mutableStateListOf<Float>() }
    var prevCpuStats by remember { mutableStateOf(mapOf<String, Pair<Long, Long>>()) }
    val MAX_HISTORY_SIZE = 60 // Store last 60 seconds of data

    // Start monitoring CPU and Memory Usage
    LaunchedEffect(Unit) {
        while (true) {
            val cpuUsage = getCpuUsage()
            cpuUsageHistory.add(cpuUsage)
            if (cpuUsageHistory.size > MAX_HISTORY_SIZE) {
                cpuUsageHistory.removeAt(0)
            }

            val memoryUsage = getMemoryUsage()
            memoryUsageHistory.add(memoryUsage)
            if (memoryUsageHistory.size > MAX_HISTORY_SIZE) {
                memoryUsageHistory.removeAt(0)
            }

            delay(1000L) // Update every second
        }
    }

    // Start monitoring processes
    LaunchedEffect(Unit) {
        while (true) {
            val newProcessList = getProcessList()
            val updatedProcessList = newProcessList.map { process ->
                val cpuUsage = getProcessCpuUsage(process.pid)
                val memUsage = getProcessMemoryUsage(process.pid)
                process.copy(
                    cpuUsage = "%.1f%%".format(cpuUsage),
                    memoryUsage = "%.1f%%".format(memUsage)
                )
            }
            processList = updatedProcessList
            delay(2000L) // Update every 2 seconds
        }
    }

    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text("Process Monitor", fontSize = 20.sp, fontWeight = FontWeight.Bold) }
            )
        }
    ) { paddingValues ->
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(paddingValues)
                .padding(16.dp)
        ) {
            PerformanceGraphs(cpuUsageHistory, memoryUsageHistory)
            Spacer(modifier = Modifier.height(16.dp))
            SearchBar(searchQuery) { newQuery ->
                searchQuery = newQuery
            }
            Spacer(modifier = Modifier.height(8.dp))
            ProcessList(
                processList = processList.filter {
                    it.name.contains(searchQuery, ignoreCase = true)
                },
                onKillProcess = { pid ->
                    coroutineScope.launch {
                        killProcess(pid)
                        processList = processList.filter { it.pid != pid }
                    }
                }
            )
        }
    }
}

@Composable
fun PerformanceGraphs(cpuUsageHistory: List<Float>, memoryUsageHistory: List<Float>) {
    Column(modifier = Modifier.fillMaxWidth()) {
        Text("CPU Usage", fontWeight = FontWeight.Bold, fontSize = 16.sp)
        UsageGraph(usageHistory = cpuUsageHistory, color = Color(0xFF6200EE))
        Spacer(modifier = Modifier.height(16.dp))
        Text("Memory Usage", fontWeight = FontWeight.Bold, fontSize = 16.sp)
        UsageGraph(usageHistory = memoryUsageHistory, color = Color(0xFF03DAC6))
    }
}

@Composable
fun UsageGraph(usageHistory: List<Float>, color: Color) {
    val maxUsage = 100f
    val dataPoints = usageHistory.takeLast(60)

    Canvas(modifier = Modifier
        .fillMaxWidth()
        .height(100.dp)
        .background(Color(0xFFE0E0E0))
    ) {
        val canvasWidth = size.width
        val canvasHeight = size.height

        if (dataPoints.isNotEmpty()) {
            val spacing = canvasWidth / (dataPoints.size.coerceAtLeast(2) - 1)
            val path = Path()

            dataPoints.forEachIndexed { index, usage ->
                val x = index * spacing
                val y = canvasHeight - (usage / maxUsage) * canvasHeight
                if (index == 0) {
                    path.moveTo(x, y)
                } else {
                    path.lineTo(x, y)
                }
            }

            drawPath(
                path = path,
                color = color,
                style = Stroke(width = 2.dp.toPx(), cap = StrokeCap.Round)
            )
        }
    }
}

@Composable
fun SearchBar(query: String, onQueryChange: (String) -> Unit) {
    TextField(
        value = query,
        onValueChange = onQueryChange,
        label = { Text("Search Processes") },
        modifier = Modifier.fillMaxWidth()
    )
}

@Composable
fun ProcessList(processList: List<ProcessInfo>, onKillProcess: (String) -> Unit) {
    if (processList.isEmpty()) {
        Text("No processes found or root access denied.")
    } else {
        LazyColumn(modifier = Modifier.fillMaxSize()) {
            items(processList) { process ->
                ProcessItem(process, onKillProcess)
                Divider(color = Color.Gray, thickness = 1.dp)
            }
        }
    }
}

@Composable
fun ProcessItem(process: ProcessInfo, onKillProcess: (String) -> Unit) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .padding(8.dp)
            .background(Color(0xFFF0F0F0))
            .padding(8.dp),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.SpaceBetween
    ) {
        Column(modifier = Modifier.weight(1f)) {
            Text(text = "PID: ${process.pid}", fontWeight = FontWeight.Bold, fontSize = 16.sp)
            Text(text = process.name, fontSize = 14.sp)
            Text(text = "CPU: ${process.cpuUsage}", fontSize = 12.sp, color = Color.Gray)
            Text(text = "Memory: ${process.memoryUsage}", fontSize = 12.sp, color = Color.Gray)
        }

        Button(
            onClick = { onKillProcess(process.pid) },
            modifier = Modifier
                .width(100.dp)
                .height(40.dp)
        ) {
            Text("Kill Process", color = Color.White)
        }
    }
}

suspend fun getProcessList(): List<ProcessInfo> = withContext(Dispatchers.IO) {
    val processList = mutableListOf<ProcessInfo>()
    try {
        val process = Runtime.getRuntime().exec("su -c ps -e -o PID,NAME,CPU,RSS")
        val reader = BufferedReader(InputStreamReader(process.inputStream))
        reader.readLine() // Skip header

        reader.forEachLine { line ->
            val parts = line.trim().split("\\s+".toRegex())
            if (parts.size >= 2) {
                val pid = parts[0]
                val name = parts[1]
                processList.add(ProcessInfo(pid, name, "0%", "0%"))
            }
        }
        reader.close()
    } catch (e: Exception) {
        e.printStackTrace()
    }
    processList
}

suspend fun killProcess(pid: String) = withContext(Dispatchers.IO) {
    try {
        Runtime.getRuntime().exec("su -c kill -9 $pid")
    } catch (e: Exception) {
        e.printStackTrace()
    }
}

suspend fun getCpuUsage(): Float = withContext(Dispatchers.IO) {
    try {
        val reader = BufferedReader(FileReader("/proc/stat"))
        val cpuLine = reader.readLine()
        reader.close()

        val values = cpuLine.split("\\s+".toRegex()).drop(1).map { it.toLong() }
        val idle = values[3]
        val total = values.sum()

        val deltaIdle = idle
        val deltaTotal = total

        if (deltaTotal == 0L) 0f else {
            ((1 - deltaIdle.toFloat() / deltaTotal) * 100).coerceIn(0f, 100f)
        }
    } catch (e: Exception) {
        e.printStackTrace()
        0f
    }
}

suspend fun getProcessCpuUsage(pid: String): Float = withContext(Dispatchers.IO) {
    try {
        val statFile = BufferedReader(FileReader("/proc/$pid/stat"))
        val stats = statFile.readLine().split(" ")
        statFile.close()

        val utime = stats[13].toLong()
        val stime = stats[14].toLong()
        val totalTime = utime + stime

        val uptime = BufferedReader(FileReader("/proc/uptime")).use {
            it.readLine().split(" ")[0].toFloat()
        }

        val seconds = uptime - (stats[21].toLong() / 100f)
        if (seconds <= 0) return@withContext 0f

        val cpuUsage = 100f * ((totalTime / 100f) / seconds)
        cpuUsage.coerceIn(0f, 100f)
    } catch (e: Exception) {
        0f
    }
}

suspend fun getProcessMemoryUsage(pid: String): Float = withContext(Dispatchers.IO) {
    try {
        val totalMem = BufferedReader(FileReader("/proc/meminfo")).use { reader ->
            reader.readLine().split("\\s+".toRegex())[1].toLong()
        }

        val processMem = BufferedReader(FileReader("/proc/$pid/status")).use { reader ->
            var vmRss = 0L
            reader.forEachLine { line ->
                if (line.startsWith("VmRSS:")) {
                    vmRss = line.split("\\s+".toRegex())[1].toLong()
                }
            }
            vmRss
        }

        (processMem.toFloat() / totalMem * 100).coerceIn(0f, 100f)
    } catch (e: Exception) {
        0f
    }
}

suspend fun getMemoryUsage(): Float = withContext(Dispatchers.IO) {
    try {
        val reader = BufferedReader(FileReader("/proc/meminfo"))
        var totalMem = 0L
        var availableMem = 0L

        reader.forEachLine { line ->
            when {
                line.startsWith("MemTotal:") -> {
                    totalMem = line.split("\\s+".toRegex())[1].toLong()
                }
                line.startsWith("MemAvailable:") -> {
                    availableMem = line.split("\\s+".toRegex())[1].toLong()
                }
            }
        }
        reader.close()

        val usedMem = totalMem - availableMem
        ((usedMem.toFloat() / totalMem) * 100).coerceIn(0f, 100f)
    } catch (e: Exception) {
        e.printStackTrace()
        0f
    }
}