Answered by ZUPAN | Dec. 19, 2019 09:33
Your itinerary is definitely eligible for 24 hour visa free transit both ways and you don't need any kind of visa.
You will print out your flight tickets and have those printouts with you. Also, you will declare at check-in in Jakarta that you will travel to Osaka via Shanghai using 24 hour visa free transit. After a short inspection of your flight tickets, you will be allowed to board the plane. You will also ask whether your luggage will be tagged all the way to Osaka. I assume it will, but you should ask, just for a case.
The procedure for your return flight is the same, but you just need to reverse the order of the cities and countries that will follow.
Upon your first arrival in Shanghai, you will decide whether you will apply for a temporary entry permit to exit the airport or to remain at the airport. In my opinion, you can try to exit even during your first stop in Shanghai, although your chances will be relatively weak because the layover, although not so short, is not considered to be a long one by Chinese immigration authorities. For your second stop in Shanghai, you should definitely apply for a temporary entry permit at 24 hour visa free transit counter. You should have in mind that you will have to book your accommodation in advance and to print out a confirmation of your accommodation booking. So, when you apply for a temporary entry permit during your second stop in Shanghai, you will immediately enclose this accommodation booking confirmation.
I really do not know what has happened with my answer to your question that was written yesterday, but during the night it was mysteriously disappeared. Never, mind, here is the new (old) answer and you are ready for your travel :)