package com.tapjoy.internal; import android.content.Context; import android.content.SharedPreferences; import androidx.work.WorkRequest; import com.tapjoy.TapjoyConstants; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; /* loaded from: classes4.dex */ public final class s2 { public static final s2 c = new s2(); public final a1 a = new a1(); public Context b; public static s2 a() { return c; } public final synchronized void a(Context context) { if (context != null) { try { if (this.b == null) { this.b = context; SharedPreferences sharedPreferences = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0); String string = this.b.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0).getString("configurations", null); if (string != null) { try { if (b0.a == null) { b0.a = e0.n; } e0 e0Var = new e0(new StringReader(string)); try { LinkedHashMap a = e0Var.a(); e0Var.close(); this.a.a(a); } catch (Throwable th) { e0Var.close(); throw th; } } catch (Exception unused) { sharedPreferences.edit().remove("configurations").apply(); } } } } catch (Throwable th2) { throw th2; } } } public final void a(Long l) { try { HashMap hashMap = new HashMap(); hashMap.put("placement_request_content_retry_timeout", l); hashMap.put("placement_request_content_retry_backoff", Arrays.asList(0L, 500L, Long.valueOf(WorkRequest.MIN_BACKOFF_MILLIS), Double.valueOf(2.0d))); this.a.a(hashMap); StringWriter stringWriter = new StringWriter(); i0 i0Var = new i0(stringWriter); try { i0Var.a(l); try { i0Var.a.flush(); this.b.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0).edit().putString("configurations", stringWriter.toString()).apply(); } catch (IOException e) { i2.a(e); throw null; } } catch (IOException e2) { i2.a(e2); throw null; } } catch (Exception unused) { } } }