109 lines
4.0 KiB
Java
109 lines
4.0 KiB
Java
|
package com.google.firebase.iid;
|
||
|
|
||
|
import android.content.ComponentName;
|
||
|
import android.content.Context;
|
||
|
import android.content.Intent;
|
||
|
import android.content.pm.PackageItemInfo;
|
||
|
import android.content.pm.ResolveInfo;
|
||
|
import android.content.pm.ServiceInfo;
|
||
|
import com.huawei.hms.support.api.entity.common.CommonConstant;
|
||
|
import java.util.ArrayDeque;
|
||
|
import java.util.Queue;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class zzaw {
|
||
|
private static zzaw zza;
|
||
|
private String zzb = null;
|
||
|
private Boolean zzc = null;
|
||
|
private Boolean zzd = null;
|
||
|
private final Queue<Intent> zze = new ArrayDeque();
|
||
|
|
||
|
public static zzaw zza() {
|
||
|
zzaw zzawVar;
|
||
|
synchronized (zzaw.class) {
|
||
|
if (zza == null) {
|
||
|
zza = new zzaw();
|
||
|
}
|
||
|
zzawVar = zza;
|
||
|
}
|
||
|
return zzawVar;
|
||
|
}
|
||
|
|
||
|
private zzaw() {
|
||
|
}
|
||
|
|
||
|
public final Intent zzb() {
|
||
|
return this.zze.poll();
|
||
|
}
|
||
|
|
||
|
public final int zza(Context context, Intent intent) {
|
||
|
this.zze.offer(intent);
|
||
|
Intent intent2 = new Intent("com.google.firebase.MESSAGING_EVENT");
|
||
|
intent2.setPackage(context.getPackageName());
|
||
|
return zzb(context, intent2);
|
||
|
}
|
||
|
|
||
|
private final int zzb(Context context, Intent intent) {
|
||
|
ComponentName startService;
|
||
|
String zzc = zzc(context, intent);
|
||
|
if (zzc != null) {
|
||
|
intent.setClassName(context.getPackageName(), zzc);
|
||
|
}
|
||
|
try {
|
||
|
if (zza(context)) {
|
||
|
startService = zzbd.zza(context, intent);
|
||
|
} else {
|
||
|
startService = context.startService(intent);
|
||
|
}
|
||
|
return startService == null ? 404 : -1;
|
||
|
} catch (IllegalStateException unused) {
|
||
|
return 402;
|
||
|
} catch (SecurityException unused2) {
|
||
|
return 401;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final String zzc(Context context, Intent intent) {
|
||
|
synchronized (this) {
|
||
|
String str = this.zzb;
|
||
|
if (str != null) {
|
||
|
return str;
|
||
|
}
|
||
|
ResolveInfo resolveService = context.getPackageManager().resolveService(intent, 0);
|
||
|
if (resolveService != null && resolveService.serviceInfo != null) {
|
||
|
ServiceInfo serviceInfo = resolveService.serviceInfo;
|
||
|
if (context.getPackageName().equals(PackageItemInfo.class.getField(CommonConstant.ReqAccessTokenParam.PACKAGE_NAME).get(serviceInfo)) && PackageItemInfo.class.getField("name").get(serviceInfo) != null) {
|
||
|
if (((String) PackageItemInfo.class.getField("name").get(serviceInfo)).startsWith(".")) {
|
||
|
String valueOf = String.valueOf(context.getPackageName());
|
||
|
String valueOf2 = String.valueOf(PackageItemInfo.class.getField("name").get(serviceInfo));
|
||
|
this.zzb = valueOf2.length() != 0 ? valueOf.concat(valueOf2) : new String(valueOf);
|
||
|
} else {
|
||
|
this.zzb = (String) PackageItemInfo.class.getField("name").get(serviceInfo);
|
||
|
}
|
||
|
return this.zzb;
|
||
|
}
|
||
|
PackageItemInfo.class.getField(CommonConstant.ReqAccessTokenParam.PACKAGE_NAME).get(serviceInfo);
|
||
|
PackageItemInfo.class.getField("name").get(serviceInfo);
|
||
|
return null;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean zza(Context context) {
|
||
|
if (this.zzc == null) {
|
||
|
this.zzc = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.WAKE_LOCK") == 0);
|
||
|
}
|
||
|
return this.zzc.booleanValue();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean zzb(Context context) {
|
||
|
if (this.zzd == null) {
|
||
|
this.zzd = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") == 0);
|
||
|
}
|
||
|
return this.zzd.booleanValue();
|
||
|
}
|
||
|
}
|