1 /*
2  * Copyright (C) 2022 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.server.uwb.info;
17 
18 /**
19  * Power related status reported by the UWB subsystem.
20  * All values should never decrease after the start of subsystem.
21  */
22 public class UwbPowerStats {
23     private static final String TAG = UwbPowerStats.class.getSimpleName();
24 
25     /**
26      * The duration of UWB operating in the idle mode (neither Tx nor Rx).
27      * For the HW with very low idle current, it may not be meaningful to maintain this
28      * count and thus the value could be always zero.
29      */
30     private int mIdleTimeMs;
31 
32     /**
33      * The duration of UWB operating in the Tx mode in millis.
34      * This may include time for HW configuration, ramp up and down.
35      */
36     private int mTxTimeMs;
37 
38     /**
39      * The duration of UWB operating in the Rx mode in millis.
40      * This may include time for HW configuration and listen mode.
41      */
42     private int mRxTimeMs;
43 
44     /**
45      * Total count of host wakeup due to UWB subsystem event.
46      */
47     private int mTotalWakeCount;
48 
UwbPowerStats(int idleTimeMs, int txTimeMs, int rxTimeMs, int totalWakeCount)49     public UwbPowerStats(int idleTimeMs, int txTimeMs, int rxTimeMs, int totalWakeCount) {
50         mIdleTimeMs = idleTimeMs;
51         mTxTimeMs = txTimeMs;
52         mRxTimeMs = rxTimeMs;
53         mTotalWakeCount = totalWakeCount;
54     }
55 
56     /**
57      * get total idle time in millis
58      */
getIdleTimeMs()59     public int getIdleTimeMs() {
60         return mIdleTimeMs;
61     }
62 
63     /**
64      * get total Tx time in millis
65      */
getTxTimeMs()66     public int getTxTimeMs() {
67         return mTxTimeMs;
68     }
69 
70     /**
71      * get total Rx time in millis
72      */
getRxTimeMs()73     public int getRxTimeMs() {
74         return mRxTimeMs;
75     }
76 
77     /**
78      * get total wakeup count
79      */
getTotalWakeCount()80     public int getTotalWakeCount() {
81         return mTotalWakeCount;
82     }
83 
84     @Override
toString()85     public String toString() {
86         StringBuilder sb = new StringBuilder();
87         sb.append("UwbPowerStats: idle_time_ms=").append(mIdleTimeMs)
88                 .append(" tx_time_ms=").append(mTxTimeMs)
89                 .append(" rx_time_ms=").append(mRxTimeMs)
90                 .append(" total_wake_count=").append(mTotalWakeCount);
91         return sb.toString();
92     }
93 }
94