Nexus 4 problems when charging My Nexus 4 is not charging when plugged into wall but it charges when connected to PC USB. When plugged into wall nothing happens, the battery icon shows nothing.
This problem appears and disappears randomly. Few weeks ago I had this problem, then it disappeared and now it reappeared again.

I tried to enable and disable MTP and PTP but didn't solve it.
I tried to use the wall charger on other devices and it wors (sometimes work also on this device)
I tried to plug it in different places and it doesn't work.
I tried to move the cable to check if contacts are good and nothing happens.
I tried different USB cables and the behavior is the same.

What can I do?

EDIT: The issue is temporarily solved. Here's what happened:


The device was charging only from PC
I plugged it to PC and the charge was 11%
I came back after less than 10 minutes: the device was off and pretty hot
I turned it on and the charge was 1%. The icon said "charging" but it seemed to charge very slowly
I turned it off.
I unplugged it.
I replugged it to PC: it was charging.
I unplugged it and I plugged it to wall charger. It was charging.
Initially the battery monitor reported AC, however after some minutes believed that the phone was connected to USB mode.
The phone charged very slowly.


OTHER INFOS:
Today I was run out of battery and I plugged the cable.


The battery was 18% but in few minutes went down to 4% (I was gaming with a poker game but it went down too fast as it was short circuited)
The device has shut down automatically
The device was warm
After rebooting it I saw the battery charging but a red exclamation mark was blinking
The red led (which turn on when it's charging) was noisy.
The system was extremely slow also when I tried to check the battery manager.
It was not charging. Sometimes a "flash" was on the battery sign but the manager reported "not charging". Another battery manager reported 38mA and then 0 (as if battery was not working).
I cooled it down with a fan and it seem to start charging but very slowly (from 1% to 4% in 15 minutes)
I shut it down and after 10 minutes I turned on again and it was 12%. Then it seems to charge properly (from 12% to 14% in a couple of minutes and current was 34mA), but after some seconds current went down to 9mA and then to 0.




 Click on picture for larger version 

Soon after this screenshot it seemed to start charging better, current was more than 200mA, but as soon as I took a screenshot it went down to few mA and then 0 again.

Another update:

Today I plugged the cable when battery was 29%. During the day I checked current usage, it was fine with an average of 200mA. When I plugged the cable (either via USB or from charger) the current usage went up to 1A, again with red exclamation mark, warming etc. I don't know what I should do now.



 Click on picture for larger version 

NOTE: it's not a short circuit in the Nexus pins because if I plug the cable in it but I don't plug the other end, nothing happens.

UPDATE: I tried to plug the phone to other USB ports and it works with higher probability. Sometimes the problem appears also in the other USB ports, but less frequently. However the charging current is only 200mA, which doesn't seem correct, in my opinion. Sometimes the phone appears to be in discharge while plugged via USB. I download a CPU monitor to check if the dicharge was due to high CPU load and I verified that when I plug USB the CPU load increases near 100%, see image:



 Click on picture for larger version 

From 19:26.03 to 19:28.49 the phone was plugged to the first USB port, then I plugged it to another port (CPU went down to zero) and the I plugged it again into the first port.  

The process which consumes high CPU is system_server.
There are a few things that could be happening here:


It could be that the charger is not powerful enough (either something happened to it or it never was). This means that although charge is going into your phone the phone is using it too fast to add any battery life. To see if this is the case try to charge your phone when it is off or in airplane mode.
A software issue could be causing the charging circuit to disengage due to excess charge (this is pretty much a guess). 
The battery level on the phone (or charging symbol) may not be accurate and therefore not give an accurate representation of charging. To test this see if the phone gains actual usable charge when plugged in (leave it overnight starting at close to 0% and if it makes the night your all good).


Hope this helps.

[EDIT]

Looking at your CPU monitor I have a few more suggestions that might help (more in diagnosing than anything).

Attempt to connect your phone via ADB and access your phone via adb shell (there should be some tutorials around the web which I may post later).

Then use the "top" command to view all running processes.

Identify the offending process (it should have a high CPU load and be named system_server)

Get the PID of the process and run the command: "kill PID" with PID being the PID of the process.

See if this fixes the issue.

Let me know what happens or if you run into any issues (I really want to figure this out now).