1/*
2 * Copyright (C) 2015 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 */
16package com.android.internal.os;
17
18import android.os.BatteryStats;
19
20/**
21 * Calculates power use of a device subsystem for an app.
22 */
23public abstract class PowerCalculator {
24    /**
25     * Calculate the amount of power an app used for this subsystem.
26     * @param app The BatterySipper that represents the power use of an app.
27     * @param u The recorded stats for the app.
28     * @param rawRealtimeUs The raw system realtime in microseconds.
29     * @param rawUptimeUs The raw system uptime in microseconds.
30     * @param statsType The type of stats. Can be {@link BatteryStats#STATS_CURRENT},
31     *                  {@link BatteryStats#STATS_SINCE_CHARGED}, or
32     *                  {@link BatteryStats#STATS_SINCE_UNPLUGGED}.
33     */
34    public abstract void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs,
35                                      long rawUptimeUs, int statsType);
36
37    /**
38     * Calculate the remaining power that can not be attributed to an app.
39     * @param app The BatterySipper that will represent this remaining power.
40     * @param stats The BatteryStats object from which to retrieve data.
41     * @param rawRealtimeUs The raw system realtime in microseconds.
42     * @param rawUptimeUs The raw system uptime in microseconds.
43     * @param statsType The type of stats. Can be {@link BatteryStats#STATS_CURRENT},
44     *                  {@link BatteryStats#STATS_SINCE_CHARGED}, or
45     *                  {@link BatteryStats#STATS_SINCE_UNPLUGGED}.
46     */
47    public void calculateRemaining(BatterySipper app, BatteryStats stats, long rawRealtimeUs,
48                                   long rawUptimeUs, int statsType) {
49    }
50
51    /**
52     * Reset any state maintained in this calculator.
53     */
54    public void reset() {
55    }
56}
57