Loading core/java/android/os/BatteryStats.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -521,6 +521,7 @@ public abstract class BatteryStats implements Parcelable { public abstract Timer getForegroundActivityTimer(); public abstract Timer getForegroundActivityTimer(); public abstract Timer getBluetoothScanTimer(); public abstract Timer getBluetoothScanTimer(); public abstract Timer getBluetoothScanBackgroundTimer(); public abstract Timer getBluetoothScanBackgroundTimer(); public abstract Counter getBluetoothScanResultCounter(); // Note: the following times are disjoint. They can be added together to find the // Note: the following times are disjoint. They can be added together to find the // total time a uid has had any processes running at all. // total time a uid has had any processes running at all. Loading Loading @@ -3370,8 +3371,10 @@ public abstract class BatteryStats implements Parcelable { final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeBg = bleTimerBg != null ? final long actualTimeBg = bleTimerBg != null ? bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; final int resultCount = u.getBluetoothScanResultCounter() != null ? u.getBluetoothScanResultCounter().getCountLocked(which) : 0; dumpLine(pw, uid, category, BLUETOOTH_MISC_DATA, totalTime, count, dumpLine(pw, uid, category, BLUETOOTH_MISC_DATA, totalTime, count, countBg, actualTime, actualTimeBg); countBg, actualTime, actualTimeBg, resultCount); } } } } Loading Loading @@ -4523,6 +4526,8 @@ public abstract class BatteryStats implements Parcelable { final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeMsBg = bleTimerBg != null ? final long actualTimeMsBg = bleTimerBg != null ? bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; final int resultCount = u.getBluetoothScanResultCounter() != null ? u.getBluetoothScanResultCounter().getCountLocked(which) : 0; sb.setLength(0); sb.setLength(0); sb.append(prefix); sb.append(prefix); Loading @@ -4547,6 +4552,8 @@ public abstract class BatteryStats implements Parcelable { sb.append(countBg); sb.append(countBg); sb.append(" times)"); sb.append(" times)"); } } sb.append("; Results count "); sb.append(resultCount); pw.println(sb.toString()); pw.println(sb.toString()); uidActivity = true; uidActivity = true; } } Loading core/java/com/android/internal/app/IBatteryStats.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -132,6 +132,7 @@ interface IBatteryStats { void noteBleScanStarted(in WorkSource ws); void noteBleScanStarted(in WorkSource ws); void noteBleScanStopped(in WorkSource ws); void noteBleScanStopped(in WorkSource ws); void noteResetBleScan(); void noteResetBleScan(); void noteBleScanResult(in WorkSource ws); HealthStatsParceler takeUidSnapshot(int uid); HealthStatsParceler takeUidSnapshot(int uid); HealthStatsParceler[] takeUidSnapshots(in int[] uid); HealthStatsParceler[] takeUidSnapshots(in int[] uid); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +53 −1 Original line number Original line Diff line number Diff line Loading @@ -114,7 +114,7 @@ public class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version // Current on-disk Parcel version private static final int VERSION = 155 + (USE_OLD_HISTORY ? 1000 : 0); private static final int VERSION = 156 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; private static final int MAX_HISTORY_ITEMS = 2000; Loading Loading @@ -4704,6 +4704,14 @@ public class BatteryStatsImpl extends BatteryStats { } } } } public void noteBluetoothScanResultFromSourceLocked(WorkSource ws) { final int N = ws.size(); for (int i = 0; i < N; i++) { int uid = mapUid(ws.get(i)); getUidStatsLocked(uid).noteBluetoothScanResultLocked(); } } private void noteWifiRadioApWakeupLocked(final long elapsedRealtimeMillis, private void noteWifiRadioApWakeupLocked(final long elapsedRealtimeMillis, final long uptimeMillis, int uid) { final long uptimeMillis, int uid) { uid = mapUid(uid); uid = mapUid(uid); Loading Loading @@ -5421,6 +5429,7 @@ public class BatteryStatsImpl extends BatteryStats { StopwatchTimer mCameraTurnedOnTimer; StopwatchTimer mCameraTurnedOnTimer; StopwatchTimer mForegroundActivityTimer; StopwatchTimer mForegroundActivityTimer; DualTimer mBluetoothScanTimer; DualTimer mBluetoothScanTimer; Counter mBluetoothScanResultCounter; int mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; int mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; StopwatchTimer[] mProcessStateTimer; StopwatchTimer[] mProcessStateTimer; Loading Loading @@ -5864,6 +5873,17 @@ public class BatteryStatsImpl extends BatteryStats { } } } } public Counter createBluetoothScanResultCounterLocked() { if (mBluetoothScanResultCounter == null) { mBluetoothScanResultCounter = new Counter(mBsi.mOnBatteryTimeBase); } return mBluetoothScanResultCounter; } public void noteBluetoothScanResultLocked() { createBluetoothScanResultCounterLocked().stepAtomic(); } @Override @Override public void noteActivityResumedLocked(long elapsedRealtimeMs) { public void noteActivityResumedLocked(long elapsedRealtimeMs) { // We always start, since we want multiple foreground PIDs to nest // We always start, since we want multiple foreground PIDs to nest Loading Loading @@ -6017,6 +6037,11 @@ public class BatteryStatsImpl extends BatteryStats { return mBluetoothScanTimer.getSubTimer(); return mBluetoothScanTimer.getSubTimer(); } } @Override public Counter getBluetoothScanResultCounter() { return mBluetoothScanResultCounter; } void makeProcessState(int i, Parcel in) { void makeProcessState(int i, Parcel in) { if (i < 0 || i >= NUM_PROCESS_STATE) return; if (i < 0 || i >= NUM_PROCESS_STATE) return; Loading Loading @@ -6266,6 +6291,9 @@ public class BatteryStatsImpl extends BatteryStats { active |= !resetTimerIfNotNull(mCameraTurnedOnTimer, false); active |= !resetTimerIfNotNull(mCameraTurnedOnTimer, false); active |= !resetTimerIfNotNull(mForegroundActivityTimer, false); active |= !resetTimerIfNotNull(mForegroundActivityTimer, false); active |= !resetTimerIfNotNull(mBluetoothScanTimer, false); active |= !resetTimerIfNotNull(mBluetoothScanTimer, false); if (mBluetoothScanResultCounter != null) { mBluetoothScanResultCounter.reset(false); } if (mProcessStateTimer != null) { if (mProcessStateTimer != null) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { Loading Loading @@ -6450,6 +6478,10 @@ public class BatteryStatsImpl extends BatteryStats { mBluetoothScanTimer.detach(); mBluetoothScanTimer.detach(); mBluetoothScanTimer = null; mBluetoothScanTimer = null; } } if (mBluetoothScanResultCounter != null) { mBluetoothScanResultCounter.detach(); mBluetoothScanResultCounter = null; } if (mUserActivityCounters != null) { if (mUserActivityCounters != null) { for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) { for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) { mUserActivityCounters[i].detach(); mUserActivityCounters[i].detach(); Loading Loading @@ -6620,6 +6652,12 @@ public class BatteryStatsImpl extends BatteryStats { } else { } else { out.writeInt(0); out.writeInt(0); } } if (mBluetoothScanResultCounter != null) { out.writeInt(1); mBluetoothScanResultCounter.writeToParcel(out); } else { out.writeInt(0); } for (int i = 0; i < NUM_PROCESS_STATE; i++) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { if (mProcessStateTimer[i] != null) { if (mProcessStateTimer[i] != null) { out.writeInt(1); out.writeInt(1); Loading Loading @@ -6850,6 +6888,11 @@ public class BatteryStatsImpl extends BatteryStats { } else { } else { mBluetoothScanTimer = null; mBluetoothScanTimer = null; } } if (in.readInt() != 0) { mBluetoothScanResultCounter = new Counter(mBsi.mOnBatteryTimeBase, in); } else { mBluetoothScanResultCounter = null; } mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; for (int i = 0; i < NUM_PROCESS_STATE; i++) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { if (in.readInt() != 0) { if (in.readInt() != 0) { Loading Loading @@ -10998,6 +11041,9 @@ public class BatteryStatsImpl extends BatteryStats { if (in.readInt() != 0) { if (in.readInt() != 0) { u.createBluetoothScanTimerLocked().readSummaryFromParcelLocked(in); u.createBluetoothScanTimerLocked().readSummaryFromParcelLocked(in); } } if (in.readInt() != 0) { u.createBluetoothScanResultCounterLocked().readSummaryFromParcelLocked(in); } u.mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; u.mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { if (in.readInt() != 0) { if (in.readInt() != 0) { Loading Loading @@ -11391,6 +11437,12 @@ public class BatteryStatsImpl extends BatteryStats { } else { } else { out.writeInt(0); out.writeInt(0); } } if (u.mBluetoothScanResultCounter != null) { out.writeInt(1); u.mBluetoothScanResultCounter.writeSummaryFromParcelLocked(out); } else { out.writeInt(0); } for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { if (u.mProcessStateTimer[i] != null) { if (u.mProcessStateTimer[i] != null) { out.writeInt(1); out.writeInt(1); Loading core/tests/coretests/src/com/android/internal/os/BatteryStatsNoteTest.java 0 → 100644 +44 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.android.internal.os; import static android.os.BatteryStats.STATS_SINCE_CHARGED; import android.os.WorkSource; import android.support.test.filters.SmallTest; import junit.framework.TestCase; /** * Test various BatteryStatsImpl noteStart methods. */ public class BatteryStatsNoteTest extends TestCase{ private static final int UID = 10500; private static final WorkSource WS = new WorkSource(UID); /** Test that BatteryStatsImpl.Uid.noteBluetoothScanResultLocked. */ @SmallTest public void testNoteBluetoothScanResultLocked() throws Exception { MockBatteryStatsImpl bi = new MockBatteryStatsImpl(new MockClocks()); bi.updateTimeBasesLocked(true, true, 0, 0); bi.noteBluetoothScanResultFromSourceLocked(WS); bi.noteBluetoothScanResultFromSourceLocked(WS); assertEquals(2, bi.getUidStats().get(UID).getBluetoothScanResultCounter() .getCountLocked(STATS_SINCE_CHARGED)); } } core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,7 @@ import org.junit.runners.Suite; BatteryStatsUidTest.class, BatteryStatsUidTest.class, BatteryStatsSensorTest.class, BatteryStatsSensorTest.class, BatteryStatsBackgroundStatsTest.class, BatteryStatsBackgroundStatsTest.class, BatteryStatsNoteTest.class, }) }) public class BatteryStatsTests { public class BatteryStatsTests { } } Loading Loading
core/java/android/os/BatteryStats.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -521,6 +521,7 @@ public abstract class BatteryStats implements Parcelable { public abstract Timer getForegroundActivityTimer(); public abstract Timer getForegroundActivityTimer(); public abstract Timer getBluetoothScanTimer(); public abstract Timer getBluetoothScanTimer(); public abstract Timer getBluetoothScanBackgroundTimer(); public abstract Timer getBluetoothScanBackgroundTimer(); public abstract Counter getBluetoothScanResultCounter(); // Note: the following times are disjoint. They can be added together to find the // Note: the following times are disjoint. They can be added together to find the // total time a uid has had any processes running at all. // total time a uid has had any processes running at all. Loading Loading @@ -3370,8 +3371,10 @@ public abstract class BatteryStats implements Parcelable { final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeBg = bleTimerBg != null ? final long actualTimeBg = bleTimerBg != null ? bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; final int resultCount = u.getBluetoothScanResultCounter() != null ? u.getBluetoothScanResultCounter().getCountLocked(which) : 0; dumpLine(pw, uid, category, BLUETOOTH_MISC_DATA, totalTime, count, dumpLine(pw, uid, category, BLUETOOTH_MISC_DATA, totalTime, count, countBg, actualTime, actualTimeBg); countBg, actualTime, actualTimeBg, resultCount); } } } } Loading Loading @@ -4523,6 +4526,8 @@ public abstract class BatteryStats implements Parcelable { final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeMsBg = bleTimerBg != null ? final long actualTimeMsBg = bleTimerBg != null ? bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; bleTimerBg.getTotalDurationMsLocked(rawRealtimeMs) : 0; final int resultCount = u.getBluetoothScanResultCounter() != null ? u.getBluetoothScanResultCounter().getCountLocked(which) : 0; sb.setLength(0); sb.setLength(0); sb.append(prefix); sb.append(prefix); Loading @@ -4547,6 +4552,8 @@ public abstract class BatteryStats implements Parcelable { sb.append(countBg); sb.append(countBg); sb.append(" times)"); sb.append(" times)"); } } sb.append("; Results count "); sb.append(resultCount); pw.println(sb.toString()); pw.println(sb.toString()); uidActivity = true; uidActivity = true; } } Loading
core/java/com/android/internal/app/IBatteryStats.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -132,6 +132,7 @@ interface IBatteryStats { void noteBleScanStarted(in WorkSource ws); void noteBleScanStarted(in WorkSource ws); void noteBleScanStopped(in WorkSource ws); void noteBleScanStopped(in WorkSource ws); void noteResetBleScan(); void noteResetBleScan(); void noteBleScanResult(in WorkSource ws); HealthStatsParceler takeUidSnapshot(int uid); HealthStatsParceler takeUidSnapshot(int uid); HealthStatsParceler[] takeUidSnapshots(in int[] uid); HealthStatsParceler[] takeUidSnapshots(in int[] uid); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +53 −1 Original line number Original line Diff line number Diff line Loading @@ -114,7 +114,7 @@ public class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version // Current on-disk Parcel version private static final int VERSION = 155 + (USE_OLD_HISTORY ? 1000 : 0); private static final int VERSION = 156 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; private static final int MAX_HISTORY_ITEMS = 2000; Loading Loading @@ -4704,6 +4704,14 @@ public class BatteryStatsImpl extends BatteryStats { } } } } public void noteBluetoothScanResultFromSourceLocked(WorkSource ws) { final int N = ws.size(); for (int i = 0; i < N; i++) { int uid = mapUid(ws.get(i)); getUidStatsLocked(uid).noteBluetoothScanResultLocked(); } } private void noteWifiRadioApWakeupLocked(final long elapsedRealtimeMillis, private void noteWifiRadioApWakeupLocked(final long elapsedRealtimeMillis, final long uptimeMillis, int uid) { final long uptimeMillis, int uid) { uid = mapUid(uid); uid = mapUid(uid); Loading Loading @@ -5421,6 +5429,7 @@ public class BatteryStatsImpl extends BatteryStats { StopwatchTimer mCameraTurnedOnTimer; StopwatchTimer mCameraTurnedOnTimer; StopwatchTimer mForegroundActivityTimer; StopwatchTimer mForegroundActivityTimer; DualTimer mBluetoothScanTimer; DualTimer mBluetoothScanTimer; Counter mBluetoothScanResultCounter; int mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; int mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; StopwatchTimer[] mProcessStateTimer; StopwatchTimer[] mProcessStateTimer; Loading Loading @@ -5864,6 +5873,17 @@ public class BatteryStatsImpl extends BatteryStats { } } } } public Counter createBluetoothScanResultCounterLocked() { if (mBluetoothScanResultCounter == null) { mBluetoothScanResultCounter = new Counter(mBsi.mOnBatteryTimeBase); } return mBluetoothScanResultCounter; } public void noteBluetoothScanResultLocked() { createBluetoothScanResultCounterLocked().stepAtomic(); } @Override @Override public void noteActivityResumedLocked(long elapsedRealtimeMs) { public void noteActivityResumedLocked(long elapsedRealtimeMs) { // We always start, since we want multiple foreground PIDs to nest // We always start, since we want multiple foreground PIDs to nest Loading Loading @@ -6017,6 +6037,11 @@ public class BatteryStatsImpl extends BatteryStats { return mBluetoothScanTimer.getSubTimer(); return mBluetoothScanTimer.getSubTimer(); } } @Override public Counter getBluetoothScanResultCounter() { return mBluetoothScanResultCounter; } void makeProcessState(int i, Parcel in) { void makeProcessState(int i, Parcel in) { if (i < 0 || i >= NUM_PROCESS_STATE) return; if (i < 0 || i >= NUM_PROCESS_STATE) return; Loading Loading @@ -6266,6 +6291,9 @@ public class BatteryStatsImpl extends BatteryStats { active |= !resetTimerIfNotNull(mCameraTurnedOnTimer, false); active |= !resetTimerIfNotNull(mCameraTurnedOnTimer, false); active |= !resetTimerIfNotNull(mForegroundActivityTimer, false); active |= !resetTimerIfNotNull(mForegroundActivityTimer, false); active |= !resetTimerIfNotNull(mBluetoothScanTimer, false); active |= !resetTimerIfNotNull(mBluetoothScanTimer, false); if (mBluetoothScanResultCounter != null) { mBluetoothScanResultCounter.reset(false); } if (mProcessStateTimer != null) { if (mProcessStateTimer != null) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { Loading Loading @@ -6450,6 +6478,10 @@ public class BatteryStatsImpl extends BatteryStats { mBluetoothScanTimer.detach(); mBluetoothScanTimer.detach(); mBluetoothScanTimer = null; mBluetoothScanTimer = null; } } if (mBluetoothScanResultCounter != null) { mBluetoothScanResultCounter.detach(); mBluetoothScanResultCounter = null; } if (mUserActivityCounters != null) { if (mUserActivityCounters != null) { for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) { for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) { mUserActivityCounters[i].detach(); mUserActivityCounters[i].detach(); Loading Loading @@ -6620,6 +6652,12 @@ public class BatteryStatsImpl extends BatteryStats { } else { } else { out.writeInt(0); out.writeInt(0); } } if (mBluetoothScanResultCounter != null) { out.writeInt(1); mBluetoothScanResultCounter.writeToParcel(out); } else { out.writeInt(0); } for (int i = 0; i < NUM_PROCESS_STATE; i++) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { if (mProcessStateTimer[i] != null) { if (mProcessStateTimer[i] != null) { out.writeInt(1); out.writeInt(1); Loading Loading @@ -6850,6 +6888,11 @@ public class BatteryStatsImpl extends BatteryStats { } else { } else { mBluetoothScanTimer = null; mBluetoothScanTimer = null; } } if (in.readInt() != 0) { mBluetoothScanResultCounter = new Counter(mBsi.mOnBatteryTimeBase, in); } else { mBluetoothScanResultCounter = null; } mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; for (int i = 0; i < NUM_PROCESS_STATE; i++) { for (int i = 0; i < NUM_PROCESS_STATE; i++) { if (in.readInt() != 0) { if (in.readInt() != 0) { Loading Loading @@ -10998,6 +11041,9 @@ public class BatteryStatsImpl extends BatteryStats { if (in.readInt() != 0) { if (in.readInt() != 0) { u.createBluetoothScanTimerLocked().readSummaryFromParcelLocked(in); u.createBluetoothScanTimerLocked().readSummaryFromParcelLocked(in); } } if (in.readInt() != 0) { u.createBluetoothScanResultCounterLocked().readSummaryFromParcelLocked(in); } u.mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; u.mProcessState = ActivityManager.PROCESS_STATE_NONEXISTENT; for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { if (in.readInt() != 0) { if (in.readInt() != 0) { Loading Loading @@ -11391,6 +11437,12 @@ public class BatteryStatsImpl extends BatteryStats { } else { } else { out.writeInt(0); out.writeInt(0); } } if (u.mBluetoothScanResultCounter != null) { out.writeInt(1); u.mBluetoothScanResultCounter.writeSummaryFromParcelLocked(out); } else { out.writeInt(0); } for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { for (int i = 0; i < Uid.NUM_PROCESS_STATE; i++) { if (u.mProcessStateTimer[i] != null) { if (u.mProcessStateTimer[i] != null) { out.writeInt(1); out.writeInt(1); Loading
core/tests/coretests/src/com/android/internal/os/BatteryStatsNoteTest.java 0 → 100644 +44 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.android.internal.os; import static android.os.BatteryStats.STATS_SINCE_CHARGED; import android.os.WorkSource; import android.support.test.filters.SmallTest; import junit.framework.TestCase; /** * Test various BatteryStatsImpl noteStart methods. */ public class BatteryStatsNoteTest extends TestCase{ private static final int UID = 10500; private static final WorkSource WS = new WorkSource(UID); /** Test that BatteryStatsImpl.Uid.noteBluetoothScanResultLocked. */ @SmallTest public void testNoteBluetoothScanResultLocked() throws Exception { MockBatteryStatsImpl bi = new MockBatteryStatsImpl(new MockClocks()); bi.updateTimeBasesLocked(true, true, 0, 0); bi.noteBluetoothScanResultFromSourceLocked(WS); bi.noteBluetoothScanResultFromSourceLocked(WS); assertEquals(2, bi.getUidStats().get(UID).getBluetoothScanResultCounter() .getCountLocked(STATS_SINCE_CHARGED)); } }
core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,7 @@ import org.junit.runners.Suite; BatteryStatsUidTest.class, BatteryStatsUidTest.class, BatteryStatsSensorTest.class, BatteryStatsSensorTest.class, BatteryStatsBackgroundStatsTest.class, BatteryStatsBackgroundStatsTest.class, BatteryStatsNoteTest.class, }) }) public class BatteryStatsTests { public class BatteryStatsTests { } } Loading