package androidx.core.app;

import android.app.Notification;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseArray;
import androidx.core.app.b;
import java.lang.reflect.Field;
import java.util.List;

/* JADX INFO: compiled from: NotificationCompatJellybean.java */
/* JADX INFO: loaded from: classes.dex */
class d {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static Field f739b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static boolean f740c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static final Object f738a = new Object();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private static final Object f741d = new Object();

    public static SparseArray<Bundle> a(List<Bundle> list) {
        int size = list.size();
        SparseArray<Bundle> sparseArray = null;
        for (int i = 0; i < size; i++) {
            Bundle bundle = list.get(i);
            if (bundle != null) {
                if (sparseArray == null) {
                    sparseArray = new SparseArray<>();
                }
                sparseArray.put(i, bundle);
            }
        }
        return sparseArray;
    }

    static Bundle b(b.a aVar) {
        Bundle bundle = new Bundle();
        bundle.putInt("icon", aVar.e());
        bundle.putCharSequence("title", aVar.i());
        bundle.putParcelable("actionIntent", aVar.a());
        Bundle bundle2 = aVar.d() != null ? new Bundle(aVar.d()) : new Bundle();
        bundle2.putBoolean("android.support.allowGeneratedReplies", aVar.b());
        bundle.putBundle("extras", bundle2);
        bundle.putParcelableArray("remoteInputs", e(aVar.f()));
        bundle.putBoolean("showsUserInterface", aVar.h());
        bundle.putInt("semanticAction", aVar.g());
        return bundle;
    }

    public static Bundle c(Notification notification) {
        synchronized (f738a) {
            if (f740c) {
                return null;
            }
            try {
                if (f739b == null) {
                    Field declaredField = Notification.class.getDeclaredField("extras");
                    if (!Bundle.class.isAssignableFrom(declaredField.getType())) {
                        Log.e("NotificationCompat", "Notification.extras field is not of type Bundle");
                        f740c = true;
                        return null;
                    }
                    declaredField.setAccessible(true);
                    f739b = declaredField;
                }
                Bundle bundle = (Bundle) f739b.get(notification);
                if (bundle == null) {
                    bundle = new Bundle();
                    f739b.set(notification, bundle);
                }
                return bundle;
            } catch (IllegalAccessException e2) {
                Log.e("NotificationCompat", "Unable to access notification extras", e2);
                f740c = true;
                return null;
            } catch (NoSuchFieldException e3) {
                Log.e("NotificationCompat", "Unable to access notification extras", e3);
                f740c = true;
                return null;
            }
        }
    }

    private static Bundle d(e eVar) {
        new Bundle();
        throw null;
    }

    private static Bundle[] e(e[] eVarArr) {
        if (eVarArr == null) {
            return null;
        }
        Bundle[] bundleArr = new Bundle[eVarArr.length];
        for (int i = 0; i < eVarArr.length; i++) {
            bundleArr[i] = d(eVarArr[i]);
        }
        return bundleArr;
    }

    public static Bundle f(Notification.Builder builder, b.a aVar) {
        builder.addAction(aVar.e(), aVar.i(), aVar.a());
        Bundle bundle = new Bundle(aVar.d());
        if (aVar.f() != null) {
            bundle.putParcelableArray("android.support.remoteInputs", e(aVar.f()));
        }
        if (aVar.c() != null) {
            bundle.putParcelableArray("android.support.dataRemoteInputs", e(aVar.c()));
        }
        bundle.putBoolean("android.support.allowGeneratedReplies", aVar.b());
        return bundle;
    }
}
