Joe Onorato | abded11 | 2016-02-08 16:49:39 -0800 | [diff] [blame] | 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 | |
Joe Onorato | abded11 | 2016-02-08 16:49:39 -0800 | [diff] [blame] | 19 | /** |
| 20 | * Mocks a BatteryStatsImpl object. |
| 21 | */ |
| 22 | public class MockBatteryStatsImpl extends BatteryStatsImpl { |
| 23 | public BatteryStatsImpl.Clocks clocks; |
Amith Yamasani | ab9ad19 | 2016-12-06 12:46:59 -0800 | [diff] [blame] | 24 | public boolean mForceOnBattery; |
| 25 | |
| 26 | MockBatteryStatsImpl(Clocks clocks) { |
| 27 | super(clocks); |
| 28 | this.clocks = mClocks; |
Bookatz | 867c0d7 | 2017-03-07 18:23:42 -0800 | [diff] [blame] | 29 | mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase); |
Amith Yamasani | ab9ad19 | 2016-12-06 12:46:59 -0800 | [diff] [blame] | 30 | } |
Joe Onorato | abded11 | 2016-02-08 16:49:39 -0800 | [diff] [blame] | 31 | |
| 32 | MockBatteryStatsImpl() { |
Amith Yamasani | ab9ad19 | 2016-12-06 12:46:59 -0800 | [diff] [blame] | 33 | this(new MockClocks()); |
Joe Onorato | abded11 | 2016-02-08 16:49:39 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | public TimeBase getOnBatteryTimeBase() { |
| 37 | return mOnBatteryTimeBase; |
| 38 | } |
| 39 | |
Amith Yamasani | ab9ad19 | 2016-12-06 12:46:59 -0800 | [diff] [blame] | 40 | public boolean isOnBattery() { |
| 41 | return mForceOnBattery ? true : super.isOnBattery(); |
| 42 | } |
Bookatz | 867c0d7 | 2017-03-07 18:23:42 -0800 | [diff] [blame] | 43 | |
| 44 | public TimeBase getOnBatteryBackgroundTimeBase(int uid) { |
| 45 | return getUidStatsLocked(uid).mOnBatteryBackgroundTimeBase; |
| 46 | } |
Bookatz | c8c4496 | 2017-05-11 12:12:54 -0700 | [diff] [blame] | 47 | |
| 48 | public TimeBase getOnBatteryScreenOffBackgroundTimeBase(int uid) { |
| 49 | return getUidStatsLocked(uid).mOnBatteryScreenOffBackgroundTimeBase; |
| 50 | } |
Joe Onorato | abded11 | 2016-02-08 16:49:39 -0800 | [diff] [blame] | 51 | } |
| 52 | |