• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #include <binder/Parcel.h>
18 
19 #include "uid_info.h"
20 
21 using namespace android;
22 using namespace android::os::storaged;
23 
writeToParcel(Parcel * parcel) const24 status_t UidInfo::writeToParcel(Parcel* parcel) const {
25     parcel->writeInt32(uid);
26     parcel->writeCString(name.c_str());
27     parcel->write(&io, sizeof(io));
28 
29     parcel->writeInt32(tasks.size());
30     for (const auto& task_it : tasks) {
31         parcel->writeInt32(task_it.first);
32         parcel->writeCString(task_it.second.comm.c_str());
33         parcel->write(&task_it.second.io, sizeof(task_it.second.io));
34     }
35     return OK;
36 }
37 
readFromParcel(const Parcel * parcel)38 status_t UidInfo::readFromParcel(const Parcel* parcel) {
39     uid = parcel->readInt32();
40     name = parcel->readCString();
41     parcel->read(&io, sizeof(io));
42 
43     uint32_t tasks_size = parcel->readInt32();
44     for (uint32_t i = 0; i < tasks_size; i++) {
45         task_info task;
46         task.pid = parcel->readInt32();
47         task.comm = parcel->readCString();
48         parcel->read(&task.io, sizeof(task.io));
49         tasks[task.pid] = task;
50     }
51     return OK;
52 }
53