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 package android.system;
18 
19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
20 
21 import android.annotation.SystemApi;
22 
23 import libcore.util.Objects;
24 
25 /**
26  * Corresponds to Linux' __user_cap_data_struct for capget and capset.
27  * Used in {@link Os.capget(StructCapUserHeader)} and
28  * {@link Os.capset(StructCapUserHeader, StructCapUserData[])}.
29  *
30  * See <a href="https://man7.org/linux/man-pages/man2/capget.2.html">capget(2)</a>.
31  *
32  * @hide
33  */
34 @SystemApi(client = MODULE_LIBRARIES)
35 public final class StructCapUserData {
36     /**
37      * Effective capability mask.
38      *
39      * @hide
40      */
41     @SystemApi(client = MODULE_LIBRARIES)
42     public final int effective; /* __u32 */
43 
44     /**
45      * Permitted capability mask.
46      *
47      * @hide
48      */
49     @SystemApi(client = MODULE_LIBRARIES)
50     public final int permitted; /* __u32 */
51 
52     /**
53      * Inheritable capability mask.
54      *
55      * @hide
56      */
57     @SystemApi(client = MODULE_LIBRARIES)
58     public final int inheritable; /* __u32 */
59 
60     /**
61      * Constructs an instance with the given field values.
62      *
63      * @param effective   effective capability mask
64      * @param permitted   permitted capability mask
65      * @param inheritable inheritable capability mask
66      *
67      * @hide
68      */
69     @SystemApi(client = MODULE_LIBRARIES)
StructCapUserData(int effective, int permitted, int inheritable)70     public StructCapUserData(int effective, int permitted, int inheritable) {
71         this.effective = effective;
72         this.permitted = permitted;
73         this.inheritable = inheritable;
74     }
75 
76     /**
77      * @hide
78      */
toString()79     @Override public String toString() {
80         return Objects.toString(this);
81     }
82 }
83