2021-12-17 22:01:24 +00:00
package b.i.a.f.j.b.e ;
2021-08-09 22:50:52 +00:00
import android.app.Activity ;
import android.os.Handler ;
import android.os.Looper ;
import androidx.annotation.Nullable ;
2021-12-17 22:01:24 +00:00
import b.c.a.a0.d ;
import b.i.a.f.e.h.a ;
import b.i.a.f.e.h.b ;
import b.i.a.f.e.h.j.c0 ;
import b.i.a.f.e.h.j.d0 ;
import b.i.a.f.e.h.j.g ;
import b.i.a.f.e.h.j.k ;
import b.i.a.f.e.h.j.n0 ;
import b.i.a.f.e.k.c ;
2021-08-09 22:50:52 +00:00
import com.google.android.gms.common.api.Status ;
import com.google.android.gms.nearby.messages.Message ;
import com.google.android.gms.nearby.messages.MessageListener ;
import com.google.android.gms.nearby.messages.MessagesClient ;
import com.google.android.gms.nearby.messages.PublishOptions ;
import com.google.android.gms.nearby.messages.SubscribeOptions ;
import com.google.android.gms.tasks.Task ;
import com.google.android.gms.tasks.TaskCompletionSource ;
import java.util.Objects ;
2022-03-01 22:12:19 +00:00
/* loaded from: classes3.dex */
2021-08-09 22:50:52 +00:00
public final class i extends MessagesClient {
public static final a . g < f > j ;
2022-03-01 22:12:19 +00:00
public static final a . AbstractC0111a < f , b . i . a . f . j . b . a > k ;
2021-12-17 22:01:24 +00:00
public static final a < b . i . a . f . j . b . a > l ;
2021-08-09 22:50:52 +00:00
public final int m = 1 ;
static {
a . g < f > gVar = new a . g < > ( ) ;
j = gVar ;
q qVar = new q ( ) ;
k = qVar ;
l = new a < > ( " Nearby.MESSAGES_API " , qVar , gVar ) ;
}
2021-12-17 22:01:24 +00:00
public i ( Activity activity , @Nullable b . i . a . f . j . b . a aVar ) {
2021-08-09 22:50:52 +00:00
super ( activity , l , aVar , b . a . a ) ;
activity . getApplication ( ) . registerActivityLifecycleCallbacks ( new z ( activity , this , null ) ) ;
}
public static k j ( i iVar , TaskCompletionSource taskCompletionSource ) {
Objects . requireNonNull ( iVar ) ;
t tVar = new t ( taskCompletionSource ) ;
String name = Status . class . getName ( ) ;
Looper looper = iVar . e ;
2021-10-11 07:48:45 +00:00
d . z ( tVar , " Listener must not be null " ) ;
d . z ( looper , " Looper must not be null " ) ;
d . z ( name , " Listener type must not be null " ) ;
2021-08-09 22:50:52 +00:00
return new k ( looper , tVar , name ) ;
}
2021-12-17 22:01:24 +00:00
@Override // b.i.a.f.e.h.b
2021-08-09 22:50:52 +00:00
public final c . a a ( ) {
return super . a ( ) ;
}
@Override // com.google.android.gms.nearby.messages.MessagesClient
public final Task < Void > f ( Message message , PublishOptions publishOptions ) {
k m = m ( message ) ;
2022-03-11 01:20:22 +00:00
return k ( m , new j ( this , message , new r ( this , m ( publishOptions . f2990b ) , m ) , publishOptions ) , new k ( message ) ) ;
2021-08-09 22:50:52 +00:00
}
@Override // com.google.android.gms.nearby.messages.MessagesClient
public final Task < Void > g ( MessageListener messageListener , SubscribeOptions subscribeOptions ) {
2022-03-11 01:20:22 +00:00
d . o ( subscribeOptions . a . f2991s = = 0 , " Strategy.setBackgroundScanMode() is only supported by background subscribe (the version which takes a PendingIntent). " ) ;
2021-08-09 22:50:52 +00:00
k m = m ( messageListener ) ;
2021-12-17 22:01:24 +00:00
return k ( m , new l ( this , m , new s ( this , m ( subscribeOptions . c ) , m ) , subscribeOptions ) , new m ( m ) ) ;
2021-08-09 22:50:52 +00:00
}
@Override // com.google.android.gms.nearby.messages.MessagesClient
public final Task < Void > h ( Message message ) {
return l ( message ) ;
}
@Override // com.google.android.gms.nearby.messages.MessagesClient
public final Task < Void > i ( MessageListener messageListener ) {
return l ( messageListener ) ;
}
public final < T > Task < Void > k ( k < T > kVar , a0 a0Var , a0 a0Var2 ) {
v vVar = new v ( this , kVar , a0Var ) ;
2021-12-17 22:01:24 +00:00
k . a < T > aVar = kVar . c ;
2021-08-09 22:50:52 +00:00
x xVar = new x ( this , aVar , a0Var2 ) ;
2021-12-17 22:01:24 +00:00
d . z ( kVar . c , " Listener has already been released. " ) ;
2021-10-11 07:48:45 +00:00
d . z ( aVar , " Listener has already been released. " ) ;
2022-01-17 16:29:36 +00:00
d . o ( d . h0 ( kVar . c , aVar ) , " Listener registration and unregistration methods must be constructed with the same ListenerHolder. " ) ;
2021-08-09 22:50:52 +00:00
g gVar = this . i ;
2021-12-17 22:01:24 +00:00
Runnable runnable = b . i . a . f . e . h . k . j ;
2021-08-09 22:50:52 +00:00
Objects . requireNonNull ( gVar ) ;
TaskCompletionSource taskCompletionSource = new TaskCompletionSource ( ) ;
2021-09-07 07:54:21 +00:00
n0 n0Var = new n0 ( new d0 ( vVar , xVar , runnable ) , taskCompletionSource ) ;
2022-01-31 08:58:36 +00:00
Handler handler = gVar . f1356x ;
handler . sendMessage ( handler . obtainMessage ( 8 , new c0 ( n0Var , gVar . f1355s . get ( ) , this ) ) ) ;
2021-08-09 22:50:52 +00:00
return taskCompletionSource . a ;
}
public final < T > Task < Void > l ( T t ) {
TaskCompletionSource taskCompletionSource = new TaskCompletionSource ( ) ;
String name = t . getClass ( ) . getName ( ) ;
2021-10-11 07:48:45 +00:00
d . z ( t , " Listener must not be null " ) ;
d . z ( name , " Listener type must not be null " ) ;
d . v ( name , " Listener type must not be empty " ) ;
2022-01-17 16:29:36 +00:00
b ( new k . a < > ( t , name ) ) . b ( new u ( taskCompletionSource ) ) ;
2021-08-09 22:50:52 +00:00
return taskCompletionSource . a ;
}
public final < T > k < T > m ( T t ) {
if ( t = = null ) {
return null ;
}
String name = t . getClass ( ) . getName ( ) ;
Looper looper = this . e ;
2021-10-11 07:48:45 +00:00
d . z ( t , " Listener must not be null " ) ;
d . z ( looper , " Looper must not be null " ) ;
d . z ( name , " Listener type must not be null " ) ;
2021-08-09 22:50:52 +00:00
return new k < > ( looper , t , name ) ;
}
}