discord-jadx/app/src/main/java/b/i/a/f/e/k/b.java

778 lines
25 KiB
Java

package b.i.a.f.e.k;
import android.accounts.Account;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.Handler;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.BinderThread;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RecentlyNonNull;
import androidx.annotation.RecentlyNullable;
import androidx.annotation.WorkerThread;
import b.i.a.f.e.h.j.w;
import b.i.a.f.e.h.j.x;
import b.i.a.f.e.k.e;
import b.i.a.f.e.k.h;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.Feature;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.common.internal.GetServiceRequest;
import com.google.android.gms.common.internal.zzc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public abstract class b<T extends IInterface> {
public static final Feature[] a = new Feature[0];
@Nullable
/* renamed from: b reason: collision with root package name */
public volatile String f1363b = null;
public j0 c;
public final Context d;
public final e e;
public final b.i.a.f.e.c f;
public final Handler g;
public final Object h = new Object();
public final Object i = new Object();
@Nullable
public j j;
@RecentlyNonNull
public c k;
@Nullable
public T l;
public final ArrayList<h<?>> m = new ArrayList<>();
@Nullable
public i n;
public int o = 1;
@Nullable
public final a p;
@Nullable
public final AbstractC0105b q;
public final int r;
@Nullable
/* renamed from: s reason: collision with root package name */
public final String f1364s;
@Nullable
public ConnectionResult t = null;
public boolean u = false;
@Nullable
public volatile zzc v = null;
@RecentlyNonNull
public AtomicInteger w = new AtomicInteger(0);
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public interface a {
void e(@RecentlyNonNull int i);
void h(@Nullable Bundle bundle);
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
/* renamed from: b.i.a.f.e.k.b$b reason: collision with other inner class name */
public interface AbstractC0105b {
void g(@RecentlyNonNull ConnectionResult connectionResult);
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public interface c {
void a(@RecentlyNonNull ConnectionResult connectionResult);
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public class d implements c {
public d() {
}
@Override // b.i.a.f.e.k.b.c
public void a(@RecentlyNonNull ConnectionResult connectionResult) {
if (connectionResult.x0()) {
b bVar = b.this;
bVar.b(null, bVar.v());
return;
}
AbstractC0105b bVar2 = b.this.q;
if (bVar2 != null) {
bVar2.g(connectionResult);
}
}
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public interface e {
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public abstract class f extends h<Boolean> {
public final int d;
@Nullable
public final Bundle e;
@BinderThread
public f(int i, @Nullable Bundle bundle) {
super(Boolean.TRUE);
this.d = i;
this.e = bundle;
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // b.i.a.f.e.k.b.h
public final /* synthetic */ void a(Boolean bool) {
PendingIntent pendingIntent = null;
if (this.d != 0) {
b.this.C(1, null);
Bundle bundle = this.e;
if (bundle != null) {
pendingIntent = (PendingIntent) bundle.getParcelable("pendingIntent");
}
d(new ConnectionResult(this.d, pendingIntent));
} else if (!e()) {
b.this.C(1, null);
d(new ConnectionResult(8, null));
}
}
@Override // b.i.a.f.e.k.b.h
public final void b() {
}
public abstract void d(ConnectionResult connectionResult);
public abstract boolean e();
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public final class g extends b.i.a.f.h.g.d {
public g(Looper looper) {
super(looper);
}
public static boolean a(Message message) {
int i = message.what;
return i == 2 || i == 1 || i == 7;
}
/* JADX WARNING: Code restructure failed: missing block: B:11:0x002f, code lost:
if (r0 == 5) goto L_0x0031;
*/
@Override // android.os.Handler
public final void handleMessage(Message message) {
TListener tlistener;
if (b.this.w.get() == message.arg1) {
int i = message.what;
if (!(i == 1 || i == 7)) {
if (i == 4) {
Objects.requireNonNull(b.this);
}
}
if (!b.this.e()) {
h hVar = (h) message.obj;
hVar.b();
hVar.c();
return;
}
int i2 = message.what;
PendingIntent pendingIntent = null;
if (i2 == 4) {
b.this.t = new ConnectionResult(message.arg2);
if (b.F(b.this)) {
b bVar = b.this;
if (!bVar.u) {
bVar.C(3, null);
return;
}
}
ConnectionResult connectionResult = b.this.t;
if (connectionResult == null) {
connectionResult = new ConnectionResult(8);
}
b.this.k.a(connectionResult);
Objects.requireNonNull(b.this);
System.currentTimeMillis();
} else if (i2 == 5) {
ConnectionResult connectionResult2 = b.this.t;
if (connectionResult2 == null) {
connectionResult2 = new ConnectionResult(8);
}
b.this.k.a(connectionResult2);
Objects.requireNonNull(b.this);
System.currentTimeMillis();
} else if (i2 == 3) {
Object obj = message.obj;
if (obj instanceof PendingIntent) {
pendingIntent = (PendingIntent) obj;
}
b.this.k.a(new ConnectionResult(message.arg2, pendingIntent));
Objects.requireNonNull(b.this);
System.currentTimeMillis();
} else if (i2 == 6) {
b.this.C(5, null);
a aVar = b.this.p;
if (aVar != null) {
aVar.e(message.arg2);
}
b.this.A(message.arg2);
b.E(b.this, 5, 1, null);
} else if (i2 == 2 && !b.this.j()) {
h hVar2 = (h) message.obj;
hVar2.b();
hVar2.c();
} else if (a(message)) {
h hVar3 = (h) message.obj;
synchronized (hVar3) {
tlistener = hVar3.a;
if (hVar3.f1365b) {
String valueOf = String.valueOf(hVar3);
StringBuilder sb = new StringBuilder(valueOf.length() + 47);
sb.append("Callback proxy ");
sb.append(valueOf);
sb.append(" being reused. This is not safe.");
Log.w("GmsClient", sb.toString());
}
}
if (tlistener != 0) {
try {
hVar3.a(tlistener);
} catch (RuntimeException e) {
hVar3.b();
throw e;
}
} else {
hVar3.b();
}
synchronized (hVar3) {
hVar3.f1365b = true;
}
hVar3.c();
} else {
Log.wtf("GmsClient", b.d.b.a.a.f(45, "Don't know how to handle message: ", message.what), new Exception());
}
} else if (a(message)) {
h hVar4 = (h) message.obj;
hVar4.b();
hVar4.c();
}
}
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public abstract class h<TListener> {
@Nullable
public TListener a;
/* renamed from: b reason: collision with root package name */
public boolean f1365b = false;
public h(TListener tlistener) {
this.a = tlistener;
}
public abstract void a(TListener tlistener);
public abstract void b();
public final void c() {
synchronized (this) {
this.a = null;
}
synchronized (b.this.m) {
b.this.m.remove(this);
}
}
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public final class i implements ServiceConnection {
public final int j;
public i(int i) {
this.j = i;
}
@Override // android.content.ServiceConnection
public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
if (iBinder == null) {
b.D(b.this);
return;
}
synchronized (b.this.i) {
b bVar = b.this;
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.common.internal.IGmsServiceBroker");
bVar.j = (queryLocalInterface == null || !(queryLocalInterface instanceof j)) ? new i(iBinder) : (j) queryLocalInterface;
}
b bVar2 = b.this;
int i = this.j;
Handler handler = bVar2.g;
handler.sendMessage(handler.obtainMessage(7, i, -1, new l(0)));
}
@Override // android.content.ServiceConnection
public final void onServiceDisconnected(ComponentName componentName) {
b bVar;
synchronized (b.this.i) {
bVar = b.this;
bVar.j = null;
}
Handler handler = bVar.g;
handler.sendMessage(handler.obtainMessage(6, this.j, 1));
}
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public static final class j extends h.a {
@Nullable
public b a;
/* renamed from: b reason: collision with root package name */
public final int f1366b;
public j(@NonNull b bVar, int i) {
this.a = bVar;
this.f1366b = i;
}
@BinderThread
public final void g(int i, @NonNull IBinder iBinder, @Nullable Bundle bundle) {
b.c.a.a0.d.z(this.a, "onPostInitComplete can be called only once per call to getRemoteService");
b bVar = this.a;
int i2 = this.f1366b;
Handler handler = bVar.g;
handler.sendMessage(handler.obtainMessage(1, i2, -1, new k(i, iBinder, bundle)));
this.a = null;
}
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public final class k extends f {
@Nullable
public final IBinder g;
@BinderThread
public k(int i, @Nullable IBinder iBinder, @Nullable Bundle bundle) {
super(i, bundle);
this.g = iBinder;
}
@Override // b.i.a.f.e.k.b.f
public final void d(ConnectionResult connectionResult) {
AbstractC0105b bVar = b.this.q;
if (bVar != null) {
bVar.g(connectionResult);
}
Objects.requireNonNull(b.this);
System.currentTimeMillis();
}
@Override // b.i.a.f.e.k.b.f
public final boolean e() {
try {
IBinder iBinder = this.g;
Objects.requireNonNull(iBinder, "null reference");
String interfaceDescriptor = iBinder.getInterfaceDescriptor();
if (!b.this.x().equals(interfaceDescriptor)) {
String x2 = b.this.x();
Log.e("GmsClient", b.d.b.a.a.k(b.d.b.a.a.b(interfaceDescriptor, b.d.b.a.a.b(x2, 34)), "service descriptor mismatch: ", x2, " vs. ", interfaceDescriptor));
return false;
}
IInterface r = b.this.r(this.g);
if (r == null || (!b.E(b.this, 2, 4, r) && !b.E(b.this, 3, 4, r))) {
return false;
}
b bVar = b.this;
bVar.t = null;
a aVar = bVar.p;
if (aVar == null) {
return true;
}
aVar.h(null);
return true;
} catch (RemoteException unused) {
Log.w("GmsClient", "service probably died");
return false;
}
}
}
/* compiled from: com.google.android.gms:play-services-basement@@17.4.0 */
public final class l extends f {
@BinderThread
public l(int i) {
super(i, null);
}
@Override // b.i.a.f.e.k.b.f
public final void d(ConnectionResult connectionResult) {
Objects.requireNonNull(b.this);
b.this.k.a(connectionResult);
Objects.requireNonNull(b.this);
System.currentTimeMillis();
}
@Override // b.i.a.f.e.k.b.f
public final boolean e() {
b.this.k.a(ConnectionResult.j);
return true;
}
}
public b(@RecentlyNonNull Context context, @RecentlyNonNull Looper looper, @RecentlyNonNull e eVar, @RecentlyNonNull b.i.a.f.e.c cVar, @RecentlyNonNull int i2, @Nullable a aVar, @Nullable AbstractC0105b bVar, @Nullable String str) {
b.c.a.a0.d.z(context, "Context must not be null");
this.d = context;
b.c.a.a0.d.z(looper, "Looper must not be null");
b.c.a.a0.d.z(eVar, "Supervisor must not be null");
this.e = eVar;
b.c.a.a0.d.z(cVar, "API availability must not be null");
this.f = cVar;
this.g = new g(looper);
this.r = i2;
this.p = aVar;
this.q = bVar;
this.f1364s = str;
}
public static void D(b bVar) {
boolean z2;
int i2;
synchronized (bVar.h) {
z2 = bVar.o == 3;
}
if (z2) {
i2 = 5;
bVar.u = true;
} else {
i2 = 4;
}
Handler handler = bVar.g;
handler.sendMessage(handler.obtainMessage(i2, bVar.w.get(), 16));
}
public static boolean E(b bVar, int i2, int i3, IInterface iInterface) {
boolean z2;
synchronized (bVar.h) {
if (bVar.o != i2) {
z2 = false;
} else {
bVar.C(i3, iInterface);
z2 = true;
}
}
return z2;
}
public static boolean F(b bVar) {
if (bVar.u || TextUtils.isEmpty(bVar.x()) || TextUtils.isEmpty(null)) {
return false;
}
try {
Class.forName(bVar.x());
return true;
} catch (ClassNotFoundException unused) {
return false;
}
}
@CallSuper
public void A(@RecentlyNonNull int i2) {
System.currentTimeMillis();
}
public final String B() {
String str = this.f1364s;
return str == null ? this.d.getClass().getName() : str;
}
public final void C(int i2, @Nullable T t) {
j0 j0Var;
b.c.a.a0.d.l((i2 == 4) == (t != null));
synchronized (this.h) {
this.o = i2;
this.l = t;
if (i2 == 1) {
i iVar = this.n;
if (iVar != null) {
e eVar = this.e;
String str = this.c.a;
Objects.requireNonNull(str, "null reference");
Objects.requireNonNull(this.c);
String B = B();
Objects.requireNonNull(this.c);
Objects.requireNonNull(eVar);
eVar.c(new e.a(str, "com.google.android.gms", 4225, false), iVar, B);
this.n = null;
}
} else if (i2 == 2 || i2 == 3) {
i iVar2 = this.n;
if (!(iVar2 == null || (j0Var = this.c) == null)) {
String str2 = j0Var.a;
StringBuilder sb = new StringBuilder(String.valueOf(str2).length() + 70 + "com.google.android.gms".length());
sb.append("Calling connect() while still connected, missing disconnect() for ");
sb.append(str2);
sb.append(" on ");
sb.append("com.google.android.gms");
Log.e("GmsClient", sb.toString());
e eVar2 = this.e;
String str3 = this.c.a;
Objects.requireNonNull(str3, "null reference");
Objects.requireNonNull(this.c);
String B2 = B();
Objects.requireNonNull(this.c);
Objects.requireNonNull(eVar2);
eVar2.c(new e.a(str3, "com.google.android.gms", 4225, false), iVar2, B2);
this.w.incrementAndGet();
}
i iVar3 = new i(this.w.get());
this.n = iVar3;
String y2 = y();
Object obj = e.a;
this.c = new j0("com.google.android.gms", y2, false, 4225, false);
e eVar3 = this.e;
Objects.requireNonNull(y2, "null reference");
Objects.requireNonNull(this.c);
String B3 = B();
Objects.requireNonNull(this.c);
if (!eVar3.b(new e.a(y2, "com.google.android.gms", 4225, false), iVar3, B3)) {
String str4 = this.c.a;
StringBuilder sb2 = new StringBuilder(String.valueOf(str4).length() + 34 + "com.google.android.gms".length());
sb2.append("unable to connect to service: ");
sb2.append(str4);
sb2.append(" on ");
sb2.append("com.google.android.gms");
Log.e("GmsClient", sb2.toString());
int i3 = this.w.get();
Handler handler = this.g;
handler.sendMessage(handler.obtainMessage(7, i3, -1, new l(16)));
}
} else if (i2 == 4) {
Objects.requireNonNull(t, "null reference");
z(t);
}
}
}
@WorkerThread
public void b(@Nullable g gVar, @RecentlyNonNull Set<Scope> set) {
Bundle u = u();
GetServiceRequest getServiceRequest = new GetServiceRequest(this.r);
getServiceRequest.m = this.d.getPackageName();
getServiceRequest.p = u;
if (set != null) {
getServiceRequest.o = (Scope[]) set.toArray(new Scope[set.size()]);
}
if (o()) {
Account s2 = s();
if (s2 == null) {
s2 = new Account("<<default account>>", "com.google");
}
getServiceRequest.q = s2;
if (gVar != null) {
getServiceRequest.n = gVar.asBinder();
}
}
getServiceRequest.r = a;
getServiceRequest.f2964s = t();
try {
synchronized (this.i) {
j jVar = this.j;
if (jVar != null) {
jVar.w(new j(this, this.w.get()), getServiceRequest);
} else {
Log.w("GmsClient", "mServiceBroker is null, client disconnected");
}
}
} catch (DeadObjectException e2) {
Log.w("GmsClient", "IGmsServiceBroker.getService failed", e2);
Handler handler = this.g;
handler.sendMessage(handler.obtainMessage(6, this.w.get(), 3));
} catch (SecurityException e3) {
throw e3;
} catch (RemoteException | RuntimeException e4) {
Log.w("GmsClient", "IGmsServiceBroker.getService failed", e4);
int i2 = this.w.get();
Handler handler2 = this.g;
handler2.sendMessage(handler2.obtainMessage(1, i2, -1, new k(8, null, null)));
}
}
public void c(@RecentlyNonNull String str) {
this.f1363b = str;
h();
}
@RecentlyNonNull
public boolean e() {
boolean z2;
synchronized (this.h) {
int i2 = this.o;
if (i2 != 2) {
if (i2 != 3) {
z2 = false;
}
}
z2 = true;
}
return z2;
}
@RecentlyNonNull
public String f() {
j0 j0Var;
if (!j() || (j0Var = this.c) == null) {
throw new RuntimeException("Failed to connect when checking package");
}
Objects.requireNonNull(j0Var);
return "com.google.android.gms";
}
public void g(@RecentlyNonNull c cVar) {
b.c.a.a0.d.z(cVar, "Connection progress callbacks cannot be null.");
this.k = cVar;
C(2, null);
}
@Override // b.i.a.f.e.h.a.f
public void h() {
this.w.incrementAndGet();
synchronized (this.m) {
int size = this.m.size();
for (int i2 = 0; i2 < size; i2++) {
h<?> hVar = this.m.get(i2);
synchronized (hVar) {
hVar.a = null;
}
}
this.m.clear();
}
synchronized (this.i) {
this.j = null;
}
C(1, null);
}
public void i(@RecentlyNonNull e eVar) {
x xVar = (x) eVar;
b.i.a.f.e.h.j.g.this.f1344x.post(new w(xVar));
}
@RecentlyNonNull
public boolean j() {
boolean z2;
synchronized (this.h) {
z2 = this.o == 4;
}
return z2;
}
@Override // b.i.a.f.e.h.a.f
@RecentlyNonNull
public boolean k() {
return true;
}
@Override // b.i.a.f.e.h.a.f
@RecentlyNonNull
public int l() {
return b.i.a.f.e.c.a;
}
@RecentlyNullable
public final Feature[] m() {
zzc zzc = this.v;
if (zzc == null) {
return null;
}
return zzc.k;
}
@RecentlyNullable
public String n() {
return this.f1363b;
}
@Override // b.i.a.f.e.h.a.f
@RecentlyNonNull
public boolean o() {
return false;
}
public void q() {
int b2 = this.f.b(this.d, l());
if (b2 != 0) {
C(1, null);
d dVar = new d();
b.c.a.a0.d.z(dVar, "Connection progress callbacks cannot be null.");
this.k = dVar;
Handler handler = this.g;
handler.sendMessage(handler.obtainMessage(3, this.w.get(), b2, null));
return;
}
g(new d());
}
@RecentlyNullable
public abstract T r(@RecentlyNonNull IBinder iBinder);
@RecentlyNullable
public Account s() {
return null;
}
@RecentlyNonNull
public Feature[] t() {
return a;
}
@RecentlyNonNull
public Bundle u() {
return new Bundle();
}
@RecentlyNonNull
public Set<Scope> v() {
return Collections.emptySet();
}
@RecentlyNonNull
public final T w() throws DeadObjectException {
T t;
synchronized (this.h) {
if (this.o == 5) {
throw new DeadObjectException();
} else if (j()) {
T t2 = this.l;
b.c.a.a0.d.z(t2, "Client is connected but service is null");
t = t2;
} else {
throw new IllegalStateException("Not connected. Call connect() and wait for onConnected() to be called.");
}
}
return t;
}
@NonNull
public abstract String x();
@NonNull
public abstract String y();
@CallSuper
public void z(@RecentlyNonNull T t) {
System.currentTimeMillis();
}
}