Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2017 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 #ifndef _UID_INFO_H_
     17 #define _UID_INFO_H_
     18 
     19 #include <string>
     20 #include <unordered_map>
     21 
     22 namespace android {
     23 namespace os {
     24 namespace storaged {
     25 
     26 enum uid_stat_t {
     27     FOREGROUND = 0,
     28     BACKGROUND = 1,
     29     UID_STATS = 2
     30 };
     31 
     32 enum charger_stat_t {
     33     CHARGER_OFF = 0,
     34     CHARGER_ON = 1,
     35     CHARGER_STATS = 2
     36 };
     37 
     38 enum io_type_t {
     39     READ = 0,
     40     WRITE = 1,
     41     IO_TYPES = 2
     42 };
     43 
     44 struct io_stats {
     45     uint64_t rchar;                 // characters read
     46     uint64_t wchar;                 // characters written
     47     uint64_t read_bytes;            // bytes read (from storage layer)
     48     uint64_t write_bytes;           // bytes written (to storage layer)
     49     uint64_t fsync;                 // number of fsync syscalls
     50 };
     51 
     52 class task_info {
     53 public:
     54     std::string comm;
     55     pid_t pid;
     56     io_stats io[UID_STATS];
     57     bool parse_task_io_stats(std::string&& s);
     58 };
     59 
     60 class UidInfo : public Parcelable {
     61 public:
     62     uint32_t uid;                     // user id
     63     std::string name;                 // package name
     64     io_stats io[UID_STATS];           // [0]:foreground [1]:background
     65     std::unordered_map<uint32_t, task_info> tasks; // mapped from pid
     66 
     67     status_t writeToParcel(Parcel* parcel) const override;
     68     status_t readFromParcel(const Parcel* parcel) override;
     69 };
     70 
     71 } // namespace storaged
     72 } // namespace os
     73 } // namespace android
     74 
     75 #endif /*  _UID_INFO_H_ */