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 */ 16 package com.android.internal.os; 17 18 import android.os.BatteryStats; 19 20 /** 21 * Calculates power use of a device subsystem for an app. 22 */ 23 public 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. As of {@link android.os.Build.VERSION_CODES#Q}, this can 31 * only be {@link BatteryStats#STATS_SINCE_CHARGED}, since 32 * {@link BatteryStats#STATS_CURRENT} and 33 * {@link BatteryStats#STATS_SINCE_UNPLUGGED} are deprecated. 34 */ calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, long rawUptimeUs, int statsType)35 public abstract void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, 36 long rawUptimeUs, int statsType); 37 38 /** 39 * Calculate the remaining power that can not be attributed to an app. 40 * @param app The BatterySipper that will represent this remaining power. 41 * @param stats The BatteryStats object from which to retrieve data. 42 * @param rawRealtimeUs The raw system realtime in microseconds. 43 * @param rawUptimeUs The raw system uptime in microseconds. 44 * @param statsType The type of stats. As of {@link android.os.Build.VERSION_CODES#Q}, this can 45 * only be {@link BatteryStats#STATS_SINCE_CHARGED}, since 46 * {@link BatteryStats#STATS_CURRENT} and 47 * {@link BatteryStats#STATS_SINCE_UNPLUGGED} are deprecated. 48 */ calculateRemaining(BatterySipper app, BatteryStats stats, long rawRealtimeUs, long rawUptimeUs, int statsType)49 public void calculateRemaining(BatterySipper app, BatteryStats stats, long rawRealtimeUs, 50 long rawUptimeUs, int statsType) { 51 } 52 53 /** 54 * Reset any state maintained in this calculator. 55 */ reset()56 public void reset() { 57 } 58 } 59