Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 363ccf72 authored by Mike Ma's avatar Mike Ma
Browse files

More granular logging when proc file not exist

KernelCpuProcReader records a horrifying exception when the proc file
does not exist, creating confusion that this is the source of error.
Bug: 74074575
Test: KernelCpuProcReaderTest

Change-Id: Ib35e114cd78e1e9f424adf66da5eb85da9f6fe5f
parent c5ad6526
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@ import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
@@ -124,6 +126,11 @@ public class KernelCpuProcReader {
                }
                fc.position(0);
            }
        } catch (NoSuchFileException | FileNotFoundException e) {
            // Happens when the kernel does not provide this file. Not a big issue. Just log it.
            mErrors++;
            Slog.w(TAG, "File not exist: " + mProc);
            return null;
        } catch (IOException e) {
            mErrors++;
            Slog.e(TAG, "Error reading: " + mProc, e);