discord-jadx/app/src/main/java/c/i/a/f/m/a.java

258 lines
9.7 KiB
Java

package c.i.a.f.m;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.PowerManager;
import android.os.WorkSource;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import c.i.a.f.e.m.a;
import c.i.a.f.e.o.h;
import c.i.a.f.e.o.i;
import c.i.a.f.e.p.b;
import com.airbnb.lottie.parser.AnimatableValueParser;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class a {
public static ScheduledExecutorService a;
public final Object b;
/* renamed from: c reason: collision with root package name */
public final PowerManager.WakeLock f1219c;
public WorkSource d;
public final int e;
public final String f;
public final Context g;
public boolean h;
public final Map<String, Integer[]> i;
public int j;
public AtomicInteger k;
public a(@NonNull Context context, int i, @NonNull String str) {
a.AbstractC0105a aVar;
WorkSource workSource = null;
String packageName = context == null ? null : context.getPackageName();
this.b = this;
this.h = true;
this.i = new HashMap();
Collections.synchronizedSet(new HashSet());
this.k = new AtomicInteger(0);
AnimatableValueParser.z(context, "WakeLock: context must not be null");
AnimatableValueParser.v(str, "WakeLock: wakeLockName must not be empty");
this.e = i;
this.g = context.getApplicationContext();
if (!"com.google.android.gms".equals(context.getPackageName())) {
this.f = str.length() != 0 ? "*gcore*:".concat(str) : new String("*gcore*:");
} else {
this.f = str;
}
this.f1219c = ((PowerManager) context.getSystemService("power")).newWakeLock(i, str);
if (i.a(context)) {
packageName = h.a(packageName) ? context.getPackageName() : packageName;
if (!(context.getPackageManager() == null || packageName == null)) {
try {
ApplicationInfo applicationInfo = b.a(context).a.getPackageManager().getApplicationInfo(packageName, 0);
if (applicationInfo == null) {
Log.e("WorkSourceUtil", packageName.length() != 0 ? "Could not get applicationInfo from package: ".concat(packageName) : new String("Could not get applicationInfo from package: "));
} else {
int i2 = applicationInfo.uid;
workSource = new WorkSource();
Method method = i.b;
if (method != null) {
try {
method.invoke(workSource, Integer.valueOf(i2), packageName);
} catch (Exception e) {
Log.wtf("WorkSourceUtil", "Unable to assign blame through WorkSource", e);
}
} else {
Method method2 = i.a;
if (method2 != null) {
try {
method2.invoke(workSource, Integer.valueOf(i2));
} catch (Exception e2) {
Log.wtf("WorkSourceUtil", "Unable to assign blame through WorkSource", e2);
}
}
}
}
} catch (PackageManager.NameNotFoundException unused) {
Log.e("WorkSourceUtil", packageName.length() != 0 ? "Could not find package: ".concat(packageName) : new String("Could not find package: "));
}
}
this.d = workSource;
if (workSource != null && i.a(this.g)) {
WorkSource workSource2 = this.d;
if (workSource2 != null) {
workSource2.add(workSource);
} else {
this.d = workSource;
}
try {
this.f1219c.setWorkSource(this.d);
} catch (ArrayIndexOutOfBoundsException | IllegalArgumentException e3) {
Log.wtf("WakeLock", e3.toString());
}
}
}
if (a == null) {
synchronized (c.i.a.f.e.m.a.class) {
if (c.i.a.f.e.m.a.a == null) {
c.i.a.f.e.m.a.a = new c.i.a.f.e.m.b();
}
aVar = c.i.a.f.e.m.a.a;
}
Objects.requireNonNull((c.i.a.f.e.m.b) aVar);
a = Executors.unconfigurableScheduledExecutorService(Executors.newScheduledThreadPool(1));
}
}
/* JADX WARNING: Code restructure failed: missing block: B:19:0x0057, code lost:
if (r3 == false) goto L_0x0059;
*/
/* JADX WARNING: Code restructure failed: missing block: B:23:0x005f, code lost:
if (r7.j == 0) goto L_0x0061;
*/
/* JADX WARNING: Code restructure failed: missing block: B:24:0x0061, code lost:
com.airbnb.lottie.parser.AnimatableValueParser.C0(r7.f1219c, null);
c();
r7.j++;
*/
public void a(long j) {
this.k.incrementAndGet();
if (this.h) {
TextUtils.isEmpty(null);
}
synchronized (this.b) {
boolean z2 = false;
if ((!this.i.isEmpty() || this.j > 0) && !this.f1219c.isHeld()) {
this.i.clear();
this.j = 0;
}
if (this.h) {
Integer[] numArr = this.i.get(null);
if (numArr == null) {
this.i.put(null, new Integer[]{1});
z2 = true;
} else {
numArr[0] = Integer.valueOf(numArr[0].intValue() + 1);
}
}
if (!this.h) {
}
}
this.f1219c.acquire();
if (j > 0) {
a.schedule(new b(this), j, TimeUnit.MILLISECONDS);
}
}
/* JADX WARNING: Code restructure failed: missing block: B:18:0x0051, code lost:
if (r4 == false) goto L_0x0053;
*/
/* JADX WARNING: Code restructure failed: missing block: B:22:0x0059, code lost:
if (r6.j == 1) goto L_0x005b;
*/
/* JADX WARNING: Code restructure failed: missing block: B:23:0x005b, code lost:
com.airbnb.lottie.parser.AnimatableValueParser.C0(r6.f1219c, null);
c();
r6.j--;
*/
public void b() {
if (this.k.decrementAndGet() < 0) {
Log.e("WakeLock", String.valueOf(this.f).concat(" release without a matched acquire!"));
}
if (this.h) {
TextUtils.isEmpty(null);
}
synchronized (this.b) {
if (this.h) {
Integer[] numArr = this.i.get(null);
boolean z2 = false;
if (numArr != null) {
if (numArr[0].intValue() == 1) {
this.i.remove(null);
z2 = true;
} else {
numArr[0] = Integer.valueOf(numArr[0].intValue() - 1);
}
}
}
if (!this.h) {
}
}
d();
}
/* JADX WARNING: Removed duplicated region for block: B:10:0x002f */
/* JADX WARNING: Removed duplicated region for block: B:22:0x0051 */
/* JADX WARNING: Removed duplicated region for block: B:27:0x0057 A[SYNTHETIC] */
public final List<String> c() {
int i;
String str;
Method method;
WorkSource workSource = this.d;
Method method2 = i.a;
ArrayList arrayList = new ArrayList();
if (!(workSource == null || (method = i.f1066c) == null)) {
try {
Object invoke = method.invoke(workSource, new Object[0]);
Objects.requireNonNull(invoke, "null reference");
i = ((Integer) invoke).intValue();
} catch (Exception e) {
Log.wtf("WorkSourceUtil", "Unable to assign blame through WorkSource", e);
}
if (i != 0) {
for (int i2 = 0; i2 < i; i2++) {
Method method3 = i.d;
if (method3 != null) {
try {
str = (String) method3.invoke(workSource, Integer.valueOf(i2));
} catch (Exception e2) {
Log.wtf("WorkSourceUtil", "Unable to assign blame through WorkSource", e2);
}
if (h.a(str)) {
Objects.requireNonNull(str, "null reference");
arrayList.add(str);
}
}
str = null;
if (h.a(str)) {
}
}
}
return arrayList;
}
i = 0;
if (i != 0) {
}
return arrayList;
}
public final void d() {
if (this.f1219c.isHeld()) {
try {
this.f1219c.release();
} catch (RuntimeException e) {
if (e.getClass().equals(RuntimeException.class)) {
Log.e("WakeLock", String.valueOf(this.f).concat(" was already released!"), e);
} else {
throw e;
}
}
this.f1219c.isHeld();
}
}
}