AT&T posted higher revenue and profit in the second quarter, with gains in its mobile unit offsetting flat wireline revenue.