157 lines
5.7 KiB
Java
157 lines
5.7 KiB
Java
package com.google.android.gms.measurement.internal;
|
|
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.ServiceConnection;
|
|
import android.os.Bundle;
|
|
import android.os.DeadObjectException;
|
|
import android.os.IBinder;
|
|
import android.os.IInterface;
|
|
import android.os.Looper;
|
|
import android.os.RemoteException;
|
|
import com.google.android.gms.common.ConnectionResult;
|
|
import com.google.android.gms.common.internal.BaseGmsClient;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.stats.ConnectionTracker;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class zzes implements ServiceConnection, BaseGmsClient.BaseConnectionCallbacks, BaseGmsClient.BaseOnConnectionFailedListener {
|
|
private volatile boolean a;
|
|
private volatile zzar b;
|
|
final /* synthetic */ zzeb c;
|
|
|
|
protected zzes(zzeb zzebVar) {
|
|
this.c = zzebVar;
|
|
}
|
|
|
|
public final void a(Intent intent) {
|
|
zzes zzesVar;
|
|
this.c.f();
|
|
Context b = this.c.b();
|
|
ConnectionTracker a = ConnectionTracker.a();
|
|
synchronized (this) {
|
|
if (this.a) {
|
|
this.c.e().B().a("Connection attempt already in progress");
|
|
return;
|
|
}
|
|
this.c.e().B().a("Using local app measurement service");
|
|
this.a = true;
|
|
zzesVar = this.c.c;
|
|
a.a(b, intent, zzesVar, 129);
|
|
}
|
|
}
|
|
|
|
public final void b() {
|
|
this.c.f();
|
|
Context b = this.c.b();
|
|
synchronized (this) {
|
|
if (this.a) {
|
|
this.c.e().B().a("Connection attempt already in progress");
|
|
return;
|
|
}
|
|
if (this.b != null && (this.b.d() || this.b.b())) {
|
|
this.c.e().B().a("Already awaiting connection attempt");
|
|
return;
|
|
}
|
|
this.b = new zzar(b, Looper.getMainLooper(), this, this);
|
|
this.c.e().B().a("Connecting to remote service");
|
|
this.a = true;
|
|
this.b.j();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.internal.BaseGmsClient.BaseConnectionCallbacks
|
|
public final void d(Bundle bundle) {
|
|
Preconditions.a("MeasurementServiceConnection.onConnected");
|
|
synchronized (this) {
|
|
try {
|
|
this.c.a().a(new zzev(this, this.b.s()));
|
|
} catch (DeadObjectException | IllegalStateException unused) {
|
|
this.b = null;
|
|
this.a = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.internal.BaseGmsClient.BaseConnectionCallbacks
|
|
public final void i(int i) {
|
|
Preconditions.a("MeasurementServiceConnection.onConnectionSuspended");
|
|
this.c.e().A().a("Service connection suspended");
|
|
this.c.a().a(new zzew(this));
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public final void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
|
zzes zzesVar;
|
|
Preconditions.a("MeasurementServiceConnection.onServiceConnected");
|
|
synchronized (this) {
|
|
if (iBinder == null) {
|
|
this.a = false;
|
|
this.c.e().t().a("Service connected with null binder");
|
|
return;
|
|
}
|
|
zzaj zzajVar = null;
|
|
try {
|
|
String interfaceDescriptor = iBinder.getInterfaceDescriptor();
|
|
if ("com.google.android.gms.measurement.internal.IMeasurementService".equals(interfaceDescriptor)) {
|
|
if (iBinder != null) {
|
|
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.measurement.internal.IMeasurementService");
|
|
zzajVar = queryLocalInterface instanceof zzaj ? (zzaj) queryLocalInterface : new zzal(iBinder);
|
|
}
|
|
this.c.e().B().a("Bound to IMeasurementService interface");
|
|
} else {
|
|
this.c.e().t().a("Got binder with a wrong descriptor", interfaceDescriptor);
|
|
}
|
|
} catch (RemoteException unused) {
|
|
this.c.e().t().a("Service connect failed to get IMeasurementService");
|
|
}
|
|
if (zzajVar == null) {
|
|
this.a = false;
|
|
try {
|
|
ConnectionTracker a = ConnectionTracker.a();
|
|
Context b = this.c.b();
|
|
zzesVar = this.c.c;
|
|
a.a(b, zzesVar);
|
|
} catch (IllegalArgumentException unused2) {
|
|
}
|
|
} else {
|
|
this.c.a().a(new zzet(this, zzajVar));
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public final void onServiceDisconnected(ComponentName componentName) {
|
|
Preconditions.a("MeasurementServiceConnection.onServiceDisconnected");
|
|
this.c.e().A().a("Service disconnected");
|
|
this.c.a().a(new zzeu(this, componentName));
|
|
}
|
|
|
|
public final void a() {
|
|
if (this.b != null && (this.b.b() || this.b.d())) {
|
|
this.b.a();
|
|
}
|
|
this.b = null;
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.internal.BaseGmsClient.BaseOnConnectionFailedListener
|
|
public final void a(ConnectionResult connectionResult) {
|
|
Preconditions.a("MeasurementServiceConnection.onConnectionFailed");
|
|
zzas v = this.c.a.v();
|
|
if (v != null) {
|
|
v.w().a("Service connection failed", connectionResult);
|
|
}
|
|
synchronized (this) {
|
|
this.a = false;
|
|
this.b = null;
|
|
}
|
|
this.c.a().a(new zzex(this));
|
|
}
|
|
|
|
static /* synthetic */ boolean a(zzes zzesVar, boolean z) {
|
|
zzesVar.a = false;
|
|
return false;
|
|
}
|
|
}
|