package m4;

import android.util.Log;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/* JADX INFO: renamed from: m4.e, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1169e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final HashMap f14616a = new HashMap();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f14617b = 64;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f14618c;

    public C1169e(int i) {
        this.f14618c = i;
    }

    public static String b(int i, String str) {
        if (str != null) {
            str = str.trim();
            if (str.length() > i) {
                return str.substring(0, i);
            }
        }
        return str;
    }

    public final synchronized Map a() {
        return Collections.unmodifiableMap(new HashMap(this.f14616a));
    }

    public final synchronized boolean c(String str, String str2) {
        if (str == null) {
            throw new IllegalArgumentException("Custom attribute key must not be null.");
        }
        String strB = b(this.f14618c, str);
        if (this.f14616a.size() >= this.f14617b && !this.f14616a.containsKey(strB)) {
            Log.w("FirebaseCrashlytics", "Ignored entry \"" + str + "\" when adding custom keys. Maximum allowable: " + this.f14617b, null);
            return false;
        }
        String strB2 = b(this.f14618c, str2);
        String str3 = (String) this.f14616a.get(strB);
        if (str3 == null ? strB2 == null : str3.equals(strB2)) {
            return false;
        }
        this.f14616a.put(strB, strB2);
        return true;
    }

    public final synchronized void d(Map map) {
        try {
            int i = 0;
            for (Map.Entry entry : map.entrySet()) {
                String str = (String) entry.getKey();
                if (str == null) {
                    throw new IllegalArgumentException("Custom attribute key must not be null.");
                }
                String strB = b(this.f14618c, str);
                if (this.f14616a.size() < this.f14617b || this.f14616a.containsKey(strB)) {
                    String str2 = (String) entry.getValue();
                    this.f14616a.put(strB, str2 == null ? "" : b(this.f14618c, str2));
                } else {
                    i++;
                }
            }
            if (i > 0) {
                Log.w("FirebaseCrashlytics", "Ignored " + i + " entries when adding custom keys. Maximum allowable: " + this.f14617b, null);
            }
        } catch (Throwable th) {
            throw th;
        }
    }
}
