For me, 2 hours at PVG is enough time
Since you're flying on AA, which will in all likelihood be accomodating should you miss your flight and put you on the next day, I would have no hesitation with attempting a 2-hour connection, even if you need a transit visa. Since you are already planning on getting a visa, and a double-entry visa can be had for ~$25 more than the single-entry price, this would make entry a little less time consuming. It will also avoid the most likely problem, which is that Malaysia Airlines might deny boarding at KUL if they are unfamiliar with the visa-free transit issue (avaliable to US, Canadian, Austrailian and Eurozone passport holders). It also protects you in the case that you are forced to stay in China for more than 24 hours (i.e., AA can't accomodate you the next day if you miss your flight an/or your flight is late enough to miss the connection yet not late enough to be within 24 hours of the next day's AA flight)
As an AA EXP, you can use premium check-in at the airport - the lines really shouldn't be an issue so close to check-in. If not in premium classes on MY, try to get a seat towards the front of the coach section, so you'll at least be ahead of most on your own plane for passport control.
Checking in at AA (IIRC they are MU employees), if time is tight ask for an escort through exit passport control. They may agree, may not.
I've arrived internationally at PVG three times around @2 pm. and have waited between 0-15 minutes for passport control. Assuming an ontime arrival on MY, I'd put your chances at a successful connection at 90% or more.
Others may disagree, but assuming your own sense of risk/reward, this is much more desireable than forcing an overnight in Shanghai when you'd otherwise be on your way home.