package com.seewo.factoryaging.opengl3d.k;

import android.app.Activity;
import android.net.Uri;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/* JADX INFO: compiled from: ContentUtils.java */
/* JADX INFO: loaded from: classes.dex */
public class a {
    private static Map<String, Uri> a = new HashMap();
    private static ThreadLocal<Activity> b = new ThreadLocal<>();
    private static File c = null;

    private static Activity a() {
        return b.get();
    }

    public static InputStream b(Uri uri) throws IOException {
        Log.i("ContentUtils", "Opening stream " + uri.getPath());
        if (!uri.getScheme().equals("assets")) {
            return (uri.getScheme().equals("http") || uri.getScheme().equals("https")) ? new URL(uri.toString()).openStream() : a().getContentResolver().openInputStream(uri);
        }
        Log.i("ContentUtils", "Opening asset: " + uri.getPath());
        return a().getAssets().open(uri.getPath().substring(1));
    }

    public static InputStream c(String str) throws IOException {
        Uri uriD = d(str);
        if (uriD == null && c != null) {
            uriD = Uri.parse("file://" + new File(c, str).getAbsolutePath());
        }
        if (uriD != null) {
            return b(uriD);
        }
        Log.w("ContentUtils", "Media not found: " + str);
        Log.w("ContentUtils", "Available media: " + a);
        return null;
    }

    public static Uri d(String str) {
        return a.get(str);
    }

    public static void e(Activity activity) {
        Log.i("ContentUtils", "Current activity thread: " + Thread.currentThread().getName());
        b.set(activity);
    }
}
