package com.google.ads.interactivemedia.pal;

import android.util.Log;
import com.google.android.gms.common.internal.n;
import com.google.android.gms.common.internal.s;
import com.google.android.gms.common.internal.w;
import com.google.android.gms.internal.pal.zzagc;
import hb.a;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes2.dex */
public final class zzat {
    static final String zza;
    public static final int zzb;
    public static final int zzc;
    public static final zzagc zzd;

    static {
        String str;
        InputStream resourceAsStream;
        String str2;
        s sVar = s.f8396c;
        sVar.getClass();
        n nVar = s.f8395b;
        w.checkNotEmpty("play-services-pal", "Please provide a valid libraryName");
        ConcurrentHashMap concurrentHashMap = sVar.f8397a;
        if (concurrentHashMap.containsKey("play-services-pal")) {
            str2 = (String) concurrentHashMap.get("play-services-pal");
        } else {
            Properties properties = new Properties();
            InputStream inputStream = null;
            property = null;
            property = null;
            String property = null;
            InputStream inputStream2 = null;
            try {
                try {
                    resourceAsStream = s.class.getResourceAsStream(String.format("/%s.properties", "play-services-pal"));
                } catch (Throwable th) {
                    th = th;
                }
            } catch (IOException unused) {
                str = null;
            }
            try {
                if (resourceAsStream != null) {
                    properties.load(resourceAsStream);
                    property = properties.getProperty("version", null);
                    StringBuilder sb = new StringBuilder(29 + String.valueOf(property).length());
                    sb.append("play-services-pal version is ");
                    sb.append(property);
                    String string = sb.toString();
                    if (Log.isLoggable(nVar.f8387a, 2)) {
                        nVar.a(string);
                    }
                } else {
                    StringBuilder sb2 = new StringBuilder(60);
                    sb2.append("Failed to get app version for libraryName: play-services-pal");
                    String string2 = sb2.toString();
                    if (Log.isLoggable(nVar.f8387a, 5)) {
                        nVar.a(string2);
                    }
                }
            } catch (IOException unused2) {
                str = property;
                inputStream = resourceAsStream;
                StringBuilder sb3 = new StringBuilder(60);
                sb3.append("Failed to get app version for libraryName: play-services-pal");
                String string3 = sb3.toString();
                if (Log.isLoggable(nVar.f8387a, 6)) {
                    nVar.a(string3);
                }
                resourceAsStream = inputStream;
                property = str;
            } catch (Throwable th2) {
                th = th2;
                inputStream2 = resourceAsStream;
                if (inputStream2 != null) {
                    a.d(inputStream2);
                }
                throw th;
            }
            if (resourceAsStream != null) {
                a.d(resourceAsStream);
            }
            if (property == null) {
                if (Log.isLoggable(nVar.f8387a, 3)) {
                    nVar.a(".properties file is dropped during release process. Failure to read app version is expected during Google internal testing where locally-built libraries are used");
                }
                str2 = "UNKNOWN";
            } else {
                str2 = property;
            }
            concurrentHashMap.put("play-services-pal", str2);
        }
        zza = str2;
        TimeUnit timeUnit = TimeUnit.SECONDS;
        zzb = (int) timeUnit.toMillis(20L);
        zzc = (int) timeUnit.toMillis(20L);
        zzd = zzagc.b(150L);
    }
}
