package com.d.b.d; import android.content.SharedPreferences; import android.text.TextUtils; import android.util.Log; import com.d.a.c.b; import com.d.a.c.m; import com.d.a.c.w; import com.d.b.k; import com.huawei.hms.framework.common.ContainerUtils; import java.net.CookieManager; import java.net.HttpCookie; import java.net.URI; import java.util.List; import java.util.Map; /* compiled from: CookieMiddleware */ public class a extends w { /* renamed from: ʻ reason: contains not printable characters */ CookieManager f5506; /* renamed from: ʼ reason: contains not printable characters */ SharedPreferences f5507; /* renamed from: ʽ reason: contains not printable characters */ k f5508; public a(k kVar) { this.f5508 = kVar; } /* renamed from: ʻ reason: contains not printable characters */ public void m7688() { this.f5506 = new CookieManager(null, null); SharedPreferences sharedPreferences = this.f5508.m7784().getSharedPreferences(this.f5508.m7786() + "-cookies", 0); this.f5507 = sharedPreferences; for (String str : sharedPreferences.getAll().keySet()) { try { String string = this.f5507.getString(str, null); m mVar = new m(); String[] split = string.split("\n"); boolean z = true; for (String str2 : split) { if (z) { z = false; } else if (!TextUtils.isEmpty(str2)) { mVar.m7255(str2); } } this.f5506.put(URI.create(str), mVar.m7253()); } catch (Exception e) { Log.e("Ion", "unable to load cookies", e); } } } /* renamed from: ʻ reason: contains not printable characters */ public static void m7686(Map<String, List<String>> map, m mVar) { for (Map.Entry<String, List<String>> entry : map.entrySet()) { String key = entry.getKey(); if ("Cookie".equalsIgnoreCase(key) || "Cookie2".equalsIgnoreCase(key)) { mVar.m7252(key, entry.getValue()); } } } /* renamed from: ʼ reason: contains not printable characters */ private void m7687() { if (this.f5506 == null) { m7688(); } } @Override // com.d.a.c.w, com.d.a.c.b /* renamed from: ʻ reason: contains not printable characters */ public void m7690(b.e eVar) { m7687(); try { m7686(this.f5506.get(URI.create(eVar.f4738.m6800().toString()), eVar.f4738.m6801().m7253()), eVar.f4738.m6801()); } catch (Exception unused) { } } @Override // com.d.a.c.w, com.d.a.c.b /* renamed from: ʻ reason: contains not printable characters */ public void m7689(b.d dVar) { m7687(); try { m7691(URI.create(dVar.f4738.m6800().toString()), dVar.f4715.m6780()); } catch (Exception unused) { } } /* renamed from: ʻ reason: contains not printable characters */ public void m7691(URI uri, m mVar) { m7687(); try { this.f5506.put(uri, mVar.m7253()); if (mVar.m7254("Set-Cookie") != null) { List<HttpCookie> list = this.f5506.getCookieStore().get(uri); m mVar2 = new m(); for (HttpCookie httpCookie : list) { mVar2.m7256("Set-Cookie", httpCookie.getName() + ContainerUtils.KEY_VALUE_DELIMITER + httpCookie.getValue() + "; path=" + httpCookie.getPath()); } this.f5507.edit().putString(uri.getScheme() + "://" + uri.getAuthority(), mVar2.m7260("HTTP/1.1 200 OK")).commit(); } } catch (Exception unused) { } } }