BP’s second-quarter earnings come as the oil and gas company continues to try to rebuild investor confidence.