1abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato/*
2abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * Copyright (C) 2016 The Android Open Source Project
3abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato *
4abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License");
5abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * you may not use this file except in compliance with the License.
6abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * You may obtain a copy of the License at
7abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato *
8abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato *      http://www.apache.org/licenses/LICENSE-2.0
9abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato *
10abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * Unless required by applicable law or agreed to in writing, software
11abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS,
12abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * See the License for the specific language governing permissions and
14abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * limitations under the License.
15abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato */
16abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato
17abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onoratopackage com.android.internal.os;
18abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato
19abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato/**
20abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato * Mocks a BatteryStatsImpl object.
21abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato */
22abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onoratopublic class MockBatteryStatsImpl extends BatteryStatsImpl {
23abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato    public BatteryStatsImpl.Clocks clocks;
24ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani    public boolean mForceOnBattery;
25abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato
26ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani    MockBatteryStatsImpl(Clocks clocks) {
27ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani        super(clocks);
28abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato        this.clocks = mClocks;
29867c0d72af63b67cd0abce8a0f40e94e04193aa6Bookatz        mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase);
30abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato    }
31abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato
32ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani    MockBatteryStatsImpl() {
33ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani        this(new MockClocks());
34ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani    }
35ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani
36abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato    public TimeBase getOnBatteryTimeBase() {
37abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato        return mOnBatteryTimeBase;
38abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato    }
39abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato
40ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani    public boolean isOnBattery() {
41ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani        return mForceOnBattery ? true : super.isOnBattery();
42ab9ad195d1e873f7569dec45c4e627a4e8ba67e4Amith Yamasani    }
43867c0d72af63b67cd0abce8a0f40e94e04193aa6Bookatz
44867c0d72af63b67cd0abce8a0f40e94e04193aa6Bookatz    public TimeBase getOnBatteryBackgroundTimeBase(int uid) {
45867c0d72af63b67cd0abce8a0f40e94e04193aa6Bookatz        return getUidStatsLocked(uid).mOnBatteryBackgroundTimeBase;
46867c0d72af63b67cd0abce8a0f40e94e04193aa6Bookatz    }
47c8c44960c0051dacac0a6cb6c65ddfafc9d1cb84Bookatz
48c8c44960c0051dacac0a6cb6c65ddfafc9d1cb84Bookatz    public TimeBase getOnBatteryScreenOffBackgroundTimeBase(int uid) {
49c8c44960c0051dacac0a6cb6c65ddfafc9d1cb84Bookatz        return getUidStatsLocked(uid).mOnBatteryScreenOffBackgroundTimeBase;
50c8c44960c0051dacac0a6cb6c65ddfafc9d1cb84Bookatz    }
51abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato}
52abded113bde548734600dc1b6e4ce2e94f48e32eJoe Onorato
53