content: package top.niunaijun.blackbox.fake.provider;
  
  import android.content.Context;
  import android.content.pm.ProviderInfo;
  import android.net.Uri;
  
  import java.io.File;
  import java.util.List;
  
  import top.niunaijun.blackbox.BlackBoxCore;
  import top.niunaijun.blackbox.app.BActivityThread;
  import top.niunaijun.blackbox.utils.compat.BuildCompat;
  
  /**
   * updated by alex5402 on 4/18/21.
   * * ∧＿∧
   * (`･ω･∥
   * 丶　つ０
   * しーＪ
   * TFNQw5HgWUS33Ke1eNmSFTwoQySGU7XNsK (USDT TRC20)
   */
  public class FileProviderHandler {
  
      public static Uri convertFileUri(Context context, Uri uri) {
          if (BuildCompat.isN()) {
              File file = convertFile(context, uri);
              if (file == null)
                  return null;
              return BlackBoxCore.getBStorageManager().getUriForFile(file.getAbsolutePath());
          }
          return uri;
      }
  
      public static File convertFile(Context context, Uri uri) {
          List<ProviderInfo> providers = BActivityThread.getProviders();
          for (ProviderInfo provider : providers) {
              try {
                  File fileForUri = FileProvider.getFileForUri(context, provider.authority, uri);
                  if (fileForUri != null && fileForUri.exists()) {
                      return fileForUri;
                  }
              } catch (Exception ignored) {
              }
          }
          return null;
      }
  }
  