BatteryStats: Prevent double-detaching Counter

Detaching a Counter from a TimeBase means you can't use it anymore.
Only newly constructed Counters are automatically attached to a TimeBase.

Bug: 34200689
Test: make FrameworkCoreTests && adb install ... && adb shell am instrument -w -e class com.android.internal.os.BatteryStatsSensorTest com.android.frameworks.coretests
Change-Id: I9309000d5625aa6fe61a3c05f135e5828137d8ce
2 files changed