package com.bytedance.sysoptimizer;

import X.0HH;
import android.content.Context;
import android.view.LayoutInflater;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.lang.reflect.Field;
import java.util.HashMap;

public class LayoutInflaterAsyncCrashOptimizer {
    public static boolean hasFixed;

    static {
        Covode.recordClassIndex(38410);
    }

    public static final class FixLayoutInflaterAsyncHashMap<K, V> extends HashMap<K, V> {
        static {
            Covode.recordClassIndex(38411);
        }

        public final synchronized void clear() {
            MethodCollector.i(14312);
            super.clear();
            MethodCollector.o(14312);
        }

        public final synchronized V remove(Object obj) {
            V remove;
            MethodCollector.i(14311);
            remove = super.remove(obj);
            MethodCollector.o(14311);
            return remove;
        }

        public final synchronized V put(K k, V v) {
            V put;
            MethodCollector.i(14310);
            put = super.put(k, v);
            MethodCollector.o(14310);
            return put;
        }
    }

    public static synchronized void fix(Context context) {
        synchronized (LayoutInflaterAsyncCrashOptimizer.class) {
            MethodCollector.i(14510);
            if (hasFixed) {
                MethodCollector.o(14510);
                return;
            }
            hasFixed = true;
            try {
                Field declaredField = LayoutInflater.class.getDeclaredField("sConstructorMap");
                declaredField.setAccessible(true);
                declaredField.set((Object) null, new FixLayoutInflaterAsyncHashMap());
                MethodCollector.o(14510);
            } catch (Exception e) {
                0HH.LIZ(e);
                MethodCollector.o(14510);
            }
        }
    }
}
