blob: a123fce0748cdfa34889a2c426240810d77a1bbe [file] [log] [blame]
Joe Onoratoabded112016-02-08 16:49:39 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.os;
18
Joe Onoratoabded112016-02-08 16:49:39 -080019/**
20 * Mocks a BatteryStatsImpl object.
21 */
22public class MockBatteryStatsImpl extends BatteryStatsImpl {
23 public BatteryStatsImpl.Clocks clocks;
Amith Yamasaniab9ad192016-12-06 12:46:59 -080024 public boolean mForceOnBattery;
25
26 MockBatteryStatsImpl(Clocks clocks) {
27 super(clocks);
28 this.clocks = mClocks;
Bookatz867c0d72017-03-07 18:23:42 -080029 mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase);
Amith Yamasaniab9ad192016-12-06 12:46:59 -080030 }
Joe Onoratoabded112016-02-08 16:49:39 -080031
32 MockBatteryStatsImpl() {
Amith Yamasaniab9ad192016-12-06 12:46:59 -080033 this(new MockClocks());
Joe Onoratoabded112016-02-08 16:49:39 -080034 }
35
36 public TimeBase getOnBatteryTimeBase() {
37 return mOnBatteryTimeBase;
38 }
39
Amith Yamasaniab9ad192016-12-06 12:46:59 -080040 public boolean isOnBattery() {
41 return mForceOnBattery ? true : super.isOnBattery();
42 }
Bookatz867c0d72017-03-07 18:23:42 -080043
44 public TimeBase getOnBatteryBackgroundTimeBase(int uid) {
45 return getUidStatsLocked(uid).mOnBatteryBackgroundTimeBase;
46 }
Bookatzc8c44962017-05-11 12:12:54 -070047
48 public TimeBase getOnBatteryScreenOffBackgroundTimeBase(int uid) {
49 return getUidStatsLocked(uid).mOnBatteryScreenOffBackgroundTimeBase;
50 }
Joe Onoratoabded112016-02-08 16:49:39 -080051}
52