package com.google.android.gms.common.internal;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.google.errorprone.annotations.concurrent.GuardedBy;
import java.util.Locale;

/* JADX INFO: loaded from: classes2.dex */
public abstract class e0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final androidx.collection.s f8324a = new androidx.collection.s();

    @Nullable
    @GuardedBy("cache")
    private static Locale zab;

    public static String a(Context context) {
        String packageName = context.getPackageName();
        try {
            Context context2 = j8.e.a(context).f28722a;
            return context2.getPackageManager().getApplicationLabel(context2.getPackageManager().getApplicationInfo(packageName, 0)).toString();
        } catch (PackageManager.NameNotFoundException | NullPointerException unused) {
            String str = context.getApplicationInfo().name;
            return TextUtils.isEmpty(str) ? packageName : str;
        }
    }

    public static String b(Context context, int i10) {
        Resources resources = context.getResources();
        String strA = a(context);
        if (i10 == 1) {
            return resources.getString(c8.c.common_google_play_services_install_text, strA);
        }
        if (i10 == 2) {
            return i8.e.e(context) ? resources.getString(c8.c.common_google_play_services_wear_update_text) : resources.getString(c8.c.common_google_play_services_update_text, strA);
        }
        if (i10 == 3) {
            return resources.getString(c8.c.common_google_play_services_enable_text, strA);
        }
        if (i10 == 5) {
            return d(context, "common_google_play_services_invalid_account_text", strA);
        }
        if (i10 == 7) {
            return d(context, "common_google_play_services_network_error_text", strA);
        }
        if (i10 == 9) {
            return resources.getString(c8.c.common_google_play_services_unsupported_text, strA);
        }
        if (i10 == 20) {
            return d(context, "common_google_play_services_restricted_profile_text", strA);
        }
        switch (i10) {
            case 16:
                return d(context, "common_google_play_services_api_unavailable_text", strA);
            case 17:
                return d(context, "common_google_play_services_sign_in_failed_text", strA);
            case 18:
                return resources.getString(c8.c.common_google_play_services_updating_text, strA);
            default:
                return resources.getString(e8.i.common_google_play_services_unknown_issue, strA);
        }
    }

    public static String c(Context context, int i10) {
        String strZah = i10 == 6 ? zah(context, "common_google_play_services_resolution_required_title") : zaf(context, i10);
        return strZah == null ? context.getResources().getString(c8.c.common_google_play_services_notification_ticker) : strZah;
    }

    public static String d(Context context, String str, String str2) {
        Resources resources = context.getResources();
        String strZah = zah(context, str);
        if (strZah == null) {
            strZah = resources.getString(e8.i.common_google_play_services_unknown_issue);
        }
        return String.format(resources.getConfiguration().locale, strZah, str2);
    }

    @Nullable
    public static String zaf(Context context, int i10) {
        Resources resources = context.getResources();
        if (i10 == 1) {
            return resources.getString(c8.c.common_google_play_services_install_title);
        }
        if (i10 == 2) {
            return resources.getString(c8.c.common_google_play_services_update_title);
        }
        if (i10 == 3) {
            return resources.getString(c8.c.common_google_play_services_enable_title);
        }
        if (i10 == 5) {
            return zah(context, "common_google_play_services_invalid_account_title");
        }
        if (i10 == 7) {
            return zah(context, "common_google_play_services_network_error_title");
        }
        if (i10 == 17) {
            return zah(context, "common_google_play_services_sign_in_failed_title");
        }
        if (i10 != 20) {
            return null;
        }
        return zah(context, "common_google_play_services_restricted_profile_title");
    }

    @Nullable
    private static String zah(Context context, String str) {
        androidx.collection.s sVar = f8324a;
        synchronized (sVar) {
            try {
                Locale locale = new m0.h(new m0.j(context.getResources().getConfiguration().getLocales())).get(0);
                if (!locale.equals(zab)) {
                    sVar.clear();
                    zab = locale;
                }
                String str2 = (String) sVar.get(str);
                if (str2 != null) {
                    return str2;
                }
                int i10 = e8.f.f25523e;
                Resources remoteResource = e8.g.getRemoteResource(context);
                if (remoteResource == null) {
                    return null;
                }
                int identifier = remoteResource.getIdentifier(str, "string", "com.google.android.gms");
                if (identifier == 0) {
                    return null;
                }
                String string = remoteResource.getString(identifier);
                if (TextUtils.isEmpty(string)) {
                    return null;
                }
                sVar.put(str, string);
                return string;
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
