Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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.Uid; |
| 19 | |
| 20 | /** |
| 21 | * Contains power usage of an application, system service, or hardware type. |
| 22 | */ |
| 23 | public class BatterySipper implements Comparable<BatterySipper> { |
| 24 | public int userId; |
| 25 | public Uid uidObj; |
| 26 | public double value; |
| 27 | public double[] values; |
| 28 | public DrainType drainType; |
| 29 | public long usageTime; |
| 30 | public long cpuTime; |
| 31 | public long gpsTime; |
| 32 | public long wifiRunningTime; |
| 33 | public long cpuFgTime; |
| 34 | public long wakeLockTime; |
| 35 | public long mobileRxPackets; |
| 36 | public long mobileTxPackets; |
| 37 | public long wifiRxPackets; |
| 38 | public long wifiTxPackets; |
| 39 | public long mobileRxBytes; |
| 40 | public long mobileTxBytes; |
| 41 | public long wifiRxBytes; |
| 42 | public long wifiTxBytes; |
| 43 | public double percent; |
| 44 | public double noCoveragePercent; |
| 45 | public String[] mPackages; |
| 46 | public String packageWithHighestDrain; |
| 47 | |
| 48 | public enum DrainType { |
| 49 | IDLE, |
| 50 | CELL, |
| 51 | PHONE, |
| 52 | WIFI, |
| 53 | BLUETOOTH, |
| 54 | SCREEN, |
| 55 | APP, |
| 56 | USER, |
| 57 | UNACCOUNTED, |
| 58 | OVERCOUNTED |
| 59 | } |
| 60 | |
| 61 | public BatterySipper(DrainType drainType, Uid uid, double[] values) { |
| 62 | this.values = values; |
| 63 | if (values != null) value = values[0]; |
| 64 | this.drainType = drainType; |
| 65 | uidObj = uid; |
| 66 | } |
| 67 | |
| 68 | public double[] getValues() { |
| 69 | return values; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public int compareTo(BatterySipper other) { |
| 74 | // Return the flipped value because we want the items in descending order |
| 75 | return Double.compare(other.value, value); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Gets a list of packages associated with the current user |
| 80 | */ |
| 81 | public String[] getPackages() { |
| 82 | return mPackages; |
| 83 | } |
| 84 | |
| 85 | public int getUid() { |
| 86 | // Bail out if the current sipper is not an App sipper. |
| 87 | if (uidObj == null) { |
| 88 | return 0; |
| 89 | } |
| 90 | return uidObj.getUid(); |
| 91 | } |
| 92 | } |