flatpak_dir_list_app_refs_with_runtime (FlatpakDir        *self,
                                        FlatpakDecomposed *runtime_ref,
                                        GCancellable      *cancellable,
                                        GError           **error)
{
  g_autoptr(GPtrArray) app_refs = NULL;
  const char *runtime_pref = flatpak_decomposed_get_pref (runtime_ref);
  g_autoptr(GPtrArray) apps = g_ptr_array_new_with_free_func ((GDestroyNotify)flatpak_decomposed_unref);

  app_refs = flatpak_dir_list_refs (self, FLATPAK_KINDS_APP, NULL, NULL);
  for (int i = 0; app_refs != NULL && i < app_refs->len; i++)
    {
      FlatpakDecomposed *app_ref = g_ptr_array_index (app_refs, i);
      /* deploy v4 guarantees runtime info */
      g_autoptr(GBytes) app_deploy_data = flatpak_dir_get_deploy_data (self, app_ref, 4, NULL, NULL);

      if (app_deploy_data)
        {
          const char *app_runtime = flatpak_deploy_data_get_runtime (app_deploy_data);
          if (g_strcmp0 (app_runtime, runtime_pref) == 0)
            g_ptr_array_add (apps, flatpak_decomposed_ref (app_ref));
        }
    }

  return g_steal_pointer (&apps);
}
flatpak_dir_list_app_refs_with_runtime (FlatpakDir        *self,
                                        FlatpakDecomposed *runtime_ref,
                                        GCancellable      *cancellable,
                                        GError           **error)
{
  g_autoptr(GPtrArray) app_refs = NULL;
  const char *runtime_pref = flatpak_decomposed_get_pref (runtime_ref);
  g_autoptr(GPtrArray) apps = g_ptr_array_new_with_free_func ((GDestroyNotify)flatpak_decomposed_unref);

  app_refs = flatpak_dir_list_refs (self, FLATPAK_KINDS_APP, NULL, NULL);
  for (int i = 0; app_refs != NULL && i < app_refs->len; i++)
    {
      FlatpakDecomposed *app_ref = g_ptr_array_index (app_refs, i);
       
      g_autoptr(GBytes) app_deploy_data = flatpak_dir_get_deploy_data (self, app_ref, 4, NULL, NULL);

      if (app_deploy_data)
        {
          const char *app_runtime = flatpak_deploy_data_get_runtime (app_deploy_data);
          if (g_strcmp0 (app_runtime, runtime_pref) == 0)
            g_ptr_array_add (apps, flatpak_decomposed_ref (app_ref));
        }
    }

  return g_steal_pointer (&apps);
}