Really hard to give you any conclusive answer from the pictures. You don't show the long black bugs as far as I could see. The fruit flies are likely attracted to the wound in the fruit caused by something else. What is causing the initial wound is another story. In one picture, it might even be damage from the branch rubbing on the exterior of the fruit. In my yard, birds and rats are the biggest threats to the integrity of the exterior of the fruits.