1 /* 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 17 package com.android.internal.os; 18 19 /** 20 * Mocks a BatteryStatsImpl object. 21 */ 22 public class MockBatteryStatsImpl extends BatteryStatsImpl { 23 public BatteryStatsImpl.Clocks clocks; 24 public boolean mForceOnBattery; 25 26 MockBatteryStatsImpl(Clocks clocks) { 27 super(clocks); 28 this.clocks = mClocks; 29 mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase); 30 } 31 32 MockBatteryStatsImpl() { 33 this(new MockClocks()); 34 } 35 36 public TimeBase getOnBatteryTimeBase() { 37 return mOnBatteryTimeBase; 38 } 39 40 public boolean isOnBattery() { 41 return mForceOnBattery ? true : super.isOnBattery(); 42 } 43 44 public TimeBase getOnBatteryBackgroundTimeBase(int uid) { 45 return getUidStatsLocked(uid).mOnBatteryBackgroundTimeBase; 46 } 47 48 public TimeBase getOnBatteryScreenOffBackgroundTimeBase(int uid) { 49 return getUidStatsLocked(uid).mOnBatteryScreenOffBackgroundTimeBase; 50 } 51 } 52 53