How to know if phone has been connected via USB? (connection log on the phone?) I'm trying to find out if someone has connected the Android phone (Samsung Note 4) to the PC via USB. Is there a log somewhere on the device showing the timestamp of connection? Preferably without turning on the debug mode?
Preferably without turning on the debug mode?


Sorry! I don't have a solution that doesn't require USB debugging as of now. A workaround is to use a rooted device and run ssh server on Wi-Fi.

Anyhow, if the device has been connected to PC using USB, then it must have drawn some power, miniscule and momentarily it may be.

Setup adb in PC, turn on USB debugging on phone or use the workaround, and enter the command:


For Lollipop 5.0.2:

dumpsys batterystats | grep -A30 "Statistics since last unplugged:"


or, to get the most relevant details only:

dumpsys batterystats | grep -A30 "Statistics since last unplugged:" | grep -B30 "Device is currently"


The output could be like:

Statistics since last unplugged:
  Time on battery: 23m 13s 868ms (100.0%) realtime, 23m 13s 868ms (100.0%) uptime
  Time on battery screen off: 22m 13s 363ms (95.7%) realtime, 22m 13s 362ms (95.7%) uptime
  Total run time: 23m 13s 868ms realtime, 23m 13s 868ms uptime
  Start clock time: 2015-08-09-06-50-16
  Screen on: 1m 0s 505ms (4.3%) 0x, Interactive: 1m 0s 758ms (4.4%)
  Screen brightnesses:
  dark 1m 0s 505ms (100.0%)
  Total partial wakelock time: 22m 13s 363ms
  Mobile total received: 0B, sent: 0B (packets received 0, sent 0)
  Phone signal levels:
  moderate 22m 35s 311ms (97.2%) 1x
  good 38s 557ms (2.8%) 0x
  Signal scanning time: 0ms
  Radio types:
  none 23m 13s 868ms (100.0%) 0x
  ...
  Device is currently unplugged


I've removed some output denoted by ... since it's not relevant here.

Now, the latest unplugged detail highlights:


Start clock time: 2015-08-09-06-50-16 -- On Aug 9, 2015 at 06:50:16 AM, my device was unplugged from USB
Time on battery: 23m 13s 868ms -- time for which the device has been running on battery since last unplugged


You can do the calculation now, based on your case.

Note that this info has nothing to do with full charge details. It simply tells us the details for the event when the device was connected to a source that supplied it power.
For Android 4.4.2:

dumpsys batterystats | grep -A30 "Statistics since last unplugged:" | grep -B30 "Device is currently*"

For Android 4.2.1:

dumpsys batteryinfo | grep -A30 "Statistics since last unplugged" | grep -B30 "Device is currently*"



Note: In the last two cases, Start clock time isn't available but Time on battery among other things.



All of this info would be helpful if only you have not plugged the device into charger or PC since the above battery-stats doesn't differentiate between the two.

Nonetheless, it is still a good lead!