Initial commit
This commit is contained in:
148
sources/com/baidu/uaq/agent/android/sample/a.java
Normal file
148
sources/com/baidu/uaq/agent/android/sample/a.java
Normal file
@@ -0,0 +1,148 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
257
sources/com/baidu/uaq/agent/android/sample/b.java
Normal file
257
sources/com/baidu/uaq/agent/android/sample/b.java
Normal file
@@ -0,0 +1,257 @@
|
||||
package com.baidu.uaq.agent.android.sample;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.TelephonyManager;
|
||||
import com.baidu.uaq.agent.android.harvest.bean.f;
|
||||
import com.baidu.uaq.agent.android.util.g;
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/* compiled from: SamplerCommon.java */
|
||||
/* loaded from: classes.dex */
|
||||
public class b implements Runnable {
|
||||
private static Context n;
|
||||
private static b q;
|
||||
private static TelephonyManager s;
|
||||
public static a t;
|
||||
private ScheduledFuture c;
|
||||
private f d;
|
||||
private float f;
|
||||
private float g;
|
||||
private float h;
|
||||
private float i;
|
||||
private float j;
|
||||
private float k;
|
||||
private float l;
|
||||
private static final com.baidu.uaq.agent.android.logging.a m = com.baidu.uaq.agent.android.logging.b.a();
|
||||
private static final Long o = 10000L;
|
||||
private static final ReentrantLock p = new ReentrantLock();
|
||||
private static double r = 0.0d;
|
||||
private double e = 0.0d;
|
||||
private final ScheduledExecutorService a = Executors.newSingleThreadScheduledExecutor(new g("SamplerCommon"));
|
||||
private final AtomicBoolean b = new AtomicBoolean(false);
|
||||
|
||||
/* compiled from: SamplerCommon.java */
|
||||
private static class a extends PhoneStateListener {
|
||||
private static int a;
|
||||
|
||||
private a() {
|
||||
}
|
||||
|
||||
public static int a() {
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // android.telephony.PhoneStateListener
|
||||
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
|
||||
super.onSignalStrengthsChanged(signalStrength);
|
||||
try {
|
||||
a = ((Integer) signalStrength.getClass().getMethod("getDbm", new Class[0]).invoke(signalStrength, new Object[0])).intValue();
|
||||
} catch (IllegalAccessException e) {
|
||||
b.m.a("Caught error while getDbm: ", e);
|
||||
} catch (NoSuchMethodException e2) {
|
||||
b.m.a("Caught error while getDbm: ", e2);
|
||||
} catch (InvocationTargetException e3) {
|
||||
b.m.a("Caught error while getDbm: ", e3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private b() {
|
||||
}
|
||||
|
||||
public static void a(Context context) {
|
||||
p.lock();
|
||||
try {
|
||||
if (q == null) {
|
||||
n = context;
|
||||
q = new b();
|
||||
l();
|
||||
} else {
|
||||
m.d("sampler not null when init samplerCommon!");
|
||||
}
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void b() {
|
||||
p.lock();
|
||||
try {
|
||||
this.d = new f();
|
||||
this.d.a(System.currentTimeMillis());
|
||||
a(0);
|
||||
e();
|
||||
c();
|
||||
com.baidu.uaq.agent.android.harvest.bean.g.b(this.d);
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void c() {
|
||||
NetworkInfo activeNetworkInfo = ((ConnectivityManager) n.getSystemService("connectivity")).getActiveNetworkInfo();
|
||||
if (!a(activeNetworkInfo)) {
|
||||
this.d.a("networkState", 0);
|
||||
this.d.a("networkDbmStrength", 2);
|
||||
} else if (b(activeNetworkInfo)) {
|
||||
this.d.a("networkState", 1);
|
||||
this.d.a("networkDbmStrength", Integer.valueOf(d()));
|
||||
} else if (c(activeNetworkInfo)) {
|
||||
this.d.a("networkState", 2);
|
||||
this.d.a("networkDbmStrength", Integer.valueOf(a.a()));
|
||||
}
|
||||
}
|
||||
|
||||
private int d() {
|
||||
return ((WifiManager) n.getSystemService("wifi")).getConnectionInfo().getRssi();
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:77:0x0177 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:64:0x0170 -> B:36:0x0173). Please report as a decompilation issue!!! */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private void e() {
|
||||
/*
|
||||
Method dump skipped, instructions count: 384
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.baidu.uaq.agent.android.sample.b.e():void");
|
||||
}
|
||||
|
||||
private static void j() {
|
||||
p.lock();
|
||||
try {
|
||||
if (q != null) {
|
||||
q.a(true);
|
||||
m.d("SamplerCommon hard stopped");
|
||||
}
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static void k() {
|
||||
p.lock();
|
||||
try {
|
||||
if (q != null) {
|
||||
j();
|
||||
q = null;
|
||||
m.d("SamplerCommon shutdown");
|
||||
} else {
|
||||
m.d("SamplerCommon shutdown start, sampler null!");
|
||||
}
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static void l() {
|
||||
p.lock();
|
||||
try {
|
||||
m.d("SamplerCommon start!");
|
||||
s = (TelephonyManager) n.getSystemService("phone");
|
||||
if (t == null) {
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.baidu.uaq.agent.android.sample.b.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
b.t = new a();
|
||||
}
|
||||
});
|
||||
}
|
||||
s.listen(t, DataDecryptTool.DECRYPT_ALL_FILE);
|
||||
q.a();
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
if (this.b.get()) {
|
||||
b();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
m.a("Caught error while Sampler run: ", e);
|
||||
com.baidu.uaq.agent.android.harvest.health.a.a(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(boolean z) {
|
||||
p.lock();
|
||||
try {
|
||||
try {
|
||||
if (this.b.get()) {
|
||||
this.b.set(false);
|
||||
if (this.c != null) {
|
||||
this.c.cancel(z);
|
||||
}
|
||||
m.d("SamplerCommon canceled");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
m.a("Caught error while Sampler stop: ", e);
|
||||
}
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean b(NetworkInfo networkInfo) {
|
||||
return networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == 1;
|
||||
}
|
||||
|
||||
private boolean c(NetworkInfo networkInfo) {
|
||||
return networkInfo != null && networkInfo.isConnected() && networkInfo.getType() == 0;
|
||||
}
|
||||
|
||||
private void a() {
|
||||
p.lock();
|
||||
try {
|
||||
if (!this.b.get()) {
|
||||
this.c = this.a.scheduleWithFixedDelay(this, o.longValue(), o.longValue(), TimeUnit.MILLISECONDS);
|
||||
this.b.set(true);
|
||||
}
|
||||
} finally {
|
||||
p.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void a(int i) {
|
||||
if (i >= 2) {
|
||||
this.d.a("appCpuUsagePercentage", Double.valueOf(r));
|
||||
return;
|
||||
}
|
||||
int i2 = i + 1;
|
||||
com.baidu.uaq.agent.android.tracing.a c = com.baidu.uaq.agent.android.sample.a.c();
|
||||
if (c != null) {
|
||||
this.e = ((Double) c.e().a()).doubleValue();
|
||||
double d = this.e;
|
||||
if (d <= 100.0d && d >= 0.0d) {
|
||||
this.d.a("appCpuUsagePercentage", Double.valueOf(d));
|
||||
r = this.e;
|
||||
return;
|
||||
}
|
||||
}
|
||||
a(i2);
|
||||
}
|
||||
|
||||
private static boolean a(NetworkInfo networkInfo) {
|
||||
return networkInfo != null && networkInfo.isConnected();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user