jimu-decompiled/sources/com/baidu/uaq/agent/android/sample/a.java
2025-05-13 19:24:51 +02:00

149 lines
4.7 KiB
Java

package com.baidu.uaq.agent.android.sample;
import android.content.Context;
import android.os.Process;
import com.baidu.uaq.agent.android.UAQ;
import com.baidu.uaq.agent.android.tracing.a;
import com.baidu.uaq.agent.android.util.g;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
/* compiled from: Sampler.java */
/* loaded from: classes.dex */
public class a {
private static final int[] d = {Process.myPid()};
private static final com.baidu.uaq.agent.android.logging.a e = com.baidu.uaq.agent.android.logging.b.a();
private static final ReentrantLock f;
private static a g;
private static boolean h;
private static Long i;
private static Long j;
private static RandomAccessFile k;
private static RandomAccessFile l;
private final EnumMap<a.EnumC0004a, Collection<com.baidu.uaq.agent.android.tracing.a>> a = new EnumMap<>(a.EnumC0004a.class);
private final AtomicBoolean b;
private ScheduledFuture c;
static {
UAQ.getInstance();
f = new ReentrantLock();
h = false;
}
private a(Context context) {
Executors.newSingleThreadScheduledExecutor(new g("Sampler"));
this.b = new AtomicBoolean(false);
this.a.put((EnumMap<a.EnumC0004a, Collection<com.baidu.uaq.agent.android.tracing.a>>) a.EnumC0004a.MEMORY, (a.EnumC0004a) new ArrayList());
this.a.put((EnumMap<a.EnumC0004a, Collection<com.baidu.uaq.agent.android.tracing.a>>) a.EnumC0004a.CPU, (a.EnumC0004a) new ArrayList());
}
public static void a(Context context) {
com.baidu.uaq.agent.android.logging.a aVar = e;
StringBuilder sb = new StringBuilder();
sb.append("Sampler init sampleLock");
sb.append(f == null);
aVar.d(sb.toString());
f.lock();
try {
try {
if (g == null) {
g = new a(context);
}
} catch (Exception e2) {
e.a("Caught error while Sampler init: ", e2);
com.baidu.uaq.agent.android.harvest.health.a.a(e2);
}
} finally {
f.unlock();
}
}
private void b() {
i = null;
j = null;
RandomAccessFile randomAccessFile = l;
if (randomAccessFile == null || k == null) {
return;
}
try {
randomAccessFile.close();
k.close();
l = null;
k = null;
} catch (IOException e2) {
e.a("Exception hit while resetting CPU sampler: ", e2);
com.baidu.uaq.agent.android.harvest.health.a.a(e2);
}
}
/* JADX WARN: Removed duplicated region for block: B:38:0x0103 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static com.baidu.uaq.agent.android.tracing.a c() {
/*
Method dump skipped, instructions count: 300
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.sample.a.c():com.baidu.uaq.agent.android.tracing.a");
}
public static void d() {
com.baidu.uaq.agent.android.logging.a aVar = e;
StringBuilder sb = new StringBuilder();
sb.append("Sampler shutdown sampleLock");
sb.append(f == null);
aVar.d(sb.toString());
f.lock();
try {
if (g != null) {
a();
g = null;
e.d("Sampler shutdown");
}
} finally {
f.unlock();
}
}
private void a(boolean z) {
f.lock();
try {
try {
if (this.b.get()) {
this.b.set(false);
if (this.c != null) {
this.c.cancel(z);
}
b();
e.d("Sampler canceled");
}
} catch (Exception e2) {
e.a("Caught error while Sampler stop: ", e2);
}
} finally {
f.unlock();
}
}
private static void a() {
f.lock();
try {
if (g != null) {
g.a(true);
e.d("Sampler hard stopped");
}
} finally {
f.unlock();
}
}
}