I had the same issue with my Huawei P10 and I tried the same as you told and it definitely worked!! Since then when I need to take some photo I just hit it against my belly LOL Manu Galdeano
Could you let me know where did you buy the replacement part (share the link) and tell me if it has fixed...