few points here:
Firstly, those Tu-4 were not sold to China, they were donated to China as Stalin's present to Chairman Mao for his birthday. I believe those planes were brand new as well, not retired ones. At the time (mid-1950s) China and Soviet Union still had a very close alliance
Secondly, the Tu-4 used for the AEW role was actually fitted with four turboprop engines, not the original piston engines used by Tu-4. China removed the old engines and replaced them with WJ-6 turboprop engines.
The last few Tu-4 bombers in service with the PLAAF retired in the mid-1980s. Of course by that time they were no longer used as bombers, but special electronic intelliegnce aircraft and UAV carrier