Apple’s strong second quarter performance momentarily overshadowed its legal difficulties, while Google dealt with growing lobbying bills from its own courtroom troubles.