package ῲ.ᨨ.K;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;
import java.util.ArrayList;
import java.util.Iterator;
import K.K.K.ʬ.C2369;

/* renamed from: ῲ.ᨨ.K.㸾  reason: contains not printable characters */
/* compiled from: TaskStackBuilder */
public final class C1831 implements Iterable<Intent> {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Context f6224;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final ArrayList<Intent> f6225 = new ArrayList<>();

    /* renamed from: ῲ.ᨨ.K.㸾$K  reason: contains not printable characters */
    /* compiled from: TaskStackBuilder */
    public interface AbstractC1832 {
        /* renamed from: ῲ  reason: contains not printable characters */
        Intent m4728();
    }

    public C1831(Context context) {
        this.f6224 = context;
    }

    @Override // java.lang.Iterable
    @Deprecated
    public Iterator<Intent> iterator() {
        return this.f6225.iterator();
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1831 m4727(Activity activity) {
        Intent r0 = activity instanceof AbstractC1832 ? ((AbstractC1832) activity).m4728() : null;
        if (r0 == null) {
            r0 = C2369.m6301(activity);
        }
        if (r0 != null) {
            ComponentName component = r0.getComponent();
            if (component == null) {
                component = r0.resolveActivity(this.f6224.getPackageManager());
            }
            int size = this.f6225.size();
            try {
                Intent r4 = C2369.m6302(this.f6224, component);
                while (r4 != null) {
                    this.f6225.add(size, r4);
                    r4 = C2369.m6302(this.f6224, r4.getComponent());
                }
                this.f6225.add(r0);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e("TaskStackBuilder", "Bad ComponentName while traversing activity parent metadata");
                throw new IllegalArgumentException(e);
            }
        }
        return this;
    }
}
