149 lines
4.4 KiB
Java
149 lines
4.4 KiB
Java
package com.discord.utilities.system;
|
|
|
|
import a0.a.a.b;
|
|
import c.d.b.a.a;
|
|
import d0.g;
|
|
import d0.g0.s;
|
|
import d0.g0.w;
|
|
import d0.y.f;
|
|
import d0.z.d.m;
|
|
import java.io.File;
|
|
import java.util.List;
|
|
import kotlin.Lazy;
|
|
/* compiled from: ProcfsReader.kt */
|
|
public final class ProcfsReader {
|
|
public static final ProcfsReader INSTANCE = new ProcfsReader();
|
|
|
|
/* renamed from: default reason: not valid java name */
|
|
private static final Stat f9default = new Stat(0, 0, 0, 0);
|
|
private static final Lazy pid$delegate = g.lazy(ProcfsReader$pid$2.INSTANCE);
|
|
|
|
/* compiled from: ProcfsReader.kt */
|
|
public static final class Stat {
|
|
private final long rssPages;
|
|
private final long systemTime;
|
|
private final long totalTime;
|
|
private final long userTime;
|
|
|
|
public Stat(long j, long j2, long j3, long j4) {
|
|
this.userTime = j;
|
|
this.systemTime = j2;
|
|
this.totalTime = j3;
|
|
this.rssPages = j4;
|
|
}
|
|
|
|
public static /* synthetic */ Stat copy$default(Stat stat, long j, long j2, long j3, long j4, int i, Object obj) {
|
|
return stat.copy((i & 1) != 0 ? stat.userTime : j, (i & 2) != 0 ? stat.systemTime : j2, (i & 4) != 0 ? stat.totalTime : j3, (i & 8) != 0 ? stat.rssPages : j4);
|
|
}
|
|
|
|
public final long component1() {
|
|
return this.userTime;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.systemTime;
|
|
}
|
|
|
|
public final long component3() {
|
|
return this.totalTime;
|
|
}
|
|
|
|
public final long component4() {
|
|
return this.rssPages;
|
|
}
|
|
|
|
public final Stat copy(long j, long j2, long j3, long j4) {
|
|
return new Stat(j, j2, j3, j4);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Stat)) {
|
|
return false;
|
|
}
|
|
Stat stat = (Stat) obj;
|
|
return this.userTime == stat.userTime && this.systemTime == stat.systemTime && this.totalTime == stat.totalTime && this.rssPages == stat.rssPages;
|
|
}
|
|
|
|
public final long getRssPages() {
|
|
return this.rssPages;
|
|
}
|
|
|
|
public final long getSystemTime() {
|
|
return this.systemTime;
|
|
}
|
|
|
|
public final long getTotalTime() {
|
|
return this.totalTime;
|
|
}
|
|
|
|
public final long getUserTime() {
|
|
return this.userTime;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int a = b.a(this.systemTime);
|
|
int a2 = b.a(this.totalTime);
|
|
return b.a(this.rssPages) + ((a2 + ((a + (b.a(this.userTime) * 31)) * 31)) * 31);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Stat(userTime=");
|
|
L.append(this.userTime);
|
|
L.append(", systemTime=");
|
|
L.append(this.systemTime);
|
|
L.append(", totalTime=");
|
|
L.append(this.totalTime);
|
|
L.append(", rssPages=");
|
|
return a.y(L, this.rssPages, ")");
|
|
}
|
|
}
|
|
|
|
private ProcfsReader() {
|
|
}
|
|
|
|
private final int getPid() {
|
|
return ((Number) pid$delegate.getValue()).intValue();
|
|
}
|
|
|
|
private final Stat parsePidStats(String str) {
|
|
if (str.length() == 0) {
|
|
return f9default;
|
|
}
|
|
List split$default = w.split$default((CharSequence) str, new char[]{' '}, false, 0, 6, (Object) null);
|
|
long j = toLong((String) split$default.get(13));
|
|
long j2 = toLong((String) split$default.get(14));
|
|
return new Stat(j, j2, j + j2, toLong((String) split$default.get(23)));
|
|
}
|
|
|
|
private final String readFile(File file) {
|
|
try {
|
|
if (!file.exists()) {
|
|
return null;
|
|
}
|
|
return f.readText$default(file, null, 1, null);
|
|
} catch (Exception unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private final long toLong(String str) {
|
|
Long longOrNull = s.toLongOrNull(str);
|
|
if (longOrNull != null) {
|
|
return longOrNull.longValue();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public final Stat readStatFile() {
|
|
return readStatFile(new File(a.w(a.L("/proc/"), getPid(), "/stat")));
|
|
}
|
|
|
|
public final Stat readStatFile(File file) {
|
|
m.checkNotNullParameter(file, "file");
|
|
String readFile = readFile(file);
|
|
return readFile != null ? parsePidStats(readFile) : f9default;
|
|
}
|
|
}
|