package com.tencent.open.utils; import android.content.Context; import android.content.SharedPreferences; import java.lang.ref.WeakReference; import java.net.URL; /* compiled from: ProGuard */ /* loaded from: classes.dex */ public class f { private static f a; private volatile WeakReference b = null; public static synchronized f a() { f fVar; synchronized (f.class) { if (a == null) { a = new f(); } fVar = a; } return fVar; } public String a(Context context, String str) { if (this.b == null || this.b.get() == null) { this.b = new WeakReference<>(context.getSharedPreferences("ServerPrefs", 0)); } try { String host = new URL(str).getHost(); if (host == null) { com.tencent.open.a.f.e("openSDK_LOG.ServerSetting", "Get host error. url=" + str); return str; } String string = this.b.get().getString(host, null); if (string != null && !host.equals(string)) { String replace = str.replace(host, string); com.tencent.open.a.f.a("openSDK_LOG.ServerSetting", "return environment url : " + replace); return replace; } com.tencent.open.a.f.a("openSDK_LOG.ServerSetting", "host=" + host + ", envHost=" + string); return str; } catch (Exception e) { com.tencent.open.a.f.e("openSDK_LOG.ServerSetting", "getEnvUrl url=" + str + "error.: " + e.getMessage()); return str; } } }