My Google Nexus 4 suddenly began to stop unexpectedly at random times. After few times I could not even boot up the OS. I could recover by factory reset wipe from the recovery mode. Unfortunately sudden stop issue persisted even after factory wipe. Then I flash factory image according to this androidcentral post. Now OS is up and running, but sudden stopping is still there when disconnected from charging cable. Phone works fine when connected to main power line. Though phone stopped suddenly, battery is not empty, I can boot up again and live for few seconds still.
Is this a hardware failure or some battery cache?