package w8;

import android.content.Context;
import android.graphics.Bitmap;
import android.icu.text.SimpleDateFormat;
import androidx.core.content.FileProvider;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Locale;

/* loaded from: classes.dex */
public abstract class t {
    public static final Object a(Context context, Bitmap bitmap, vm.d dVar) {
        File cacheDir = context.getCacheDir();
        File file = new File(cacheDir != null ? cacheDir.getAbsolutePath() : null, "images");
        try {
            file.mkdirs();
            File file2 = new File(file, new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date()) + ".png");
            FileOutputStream fileOutputStream = new FileOutputStream(file2);
            bitmap.compress(Bitmap.CompressFormat.PNG, 90, fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
            return FileProvider.h(context, context.getApplicationContext().getPackageName() + ".provider", file2);
        } catch (IOException e10) {
            tr.a.f36618a.c("IOException while trying to write file for sharing: " + e10.getMessage(), new Object[0]);
            return null;
        }
    }
}
