package W;

import a.AbstractC0212a;
import android.content.Context;
import android.content.SharedPreferences;
import d4.C0550i;
import i4.EnumC0643a;
import j4.AbstractC0806h;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashSet;

/* JADX INFO: renamed from: W.g, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0193g extends AbstractC0806h implements q4.l {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f3131k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final /* synthetic */ Y.b f3132l;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C0193g(Y.b bVar, h4.c cVar) {
        super(1, cVar);
        this.f3132l = bVar;
    }

    @Override // j4.AbstractC0799a
    public final h4.c create(h4.c cVar) {
        return new C0193g(this.f3132l, cVar);
    }

    @Override // q4.l
    public final Object invoke(Object obj) {
        return ((C0193g) create((h4.c) obj)).invokeSuspend(C0550i.f6143a);
    }

    @Override // j4.AbstractC0799a
    public final Object invokeSuspend(Object obj) throws Throwable {
        Context context;
        String str;
        EnumC0643a enumC0643a = EnumC0643a.f6670k;
        int i = this.f3131k;
        C0550i c0550i = C0550i.f6143a;
        if (i != 0) {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC0212a.H(obj);
            return c0550i;
        }
        AbstractC0212a.H(obj);
        this.f3131k = 1;
        Y.b bVar = this.f3132l;
        SharedPreferences.Editor editorEdit = ((SharedPreferences) bVar.f3367e.getValue()).edit();
        LinkedHashSet linkedHashSet = bVar.f3368f;
        if (linkedHashSet == null) {
            editorEdit.clear();
        } else {
            Iterator it = linkedHashSet.iterator();
            while (it.hasNext()) {
                editorEdit.remove((String) it.next());
            }
        }
        if (!editorEdit.commit()) {
            throw new IOException("Unable to delete migrated keys from SharedPreferences.");
        }
        if (((SharedPreferences) bVar.f3367e.getValue()).getAll().isEmpty() && (context = bVar.f3365c) != null && (str = bVar.f3366d) != null) {
            context.deleteSharedPreferences(str);
        }
        if (linkedHashSet != null) {
            linkedHashSet.clear();
        }
        return c0550i == enumC0643a ? enumC0643a : c0550i;
    }
}
