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 @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
36 public final class StructCapUserData {
37     /**
38      * Effective capability mask.
39      *
40      * @hide
41      */
42     @SystemApi(client = MODULE_LIBRARIES)
43     @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
44     public final int effective; /* __u32 */
45 
46     /**
47      * Permitted capability mask.
48      *
49      * @hide
50      */
51     @SystemApi(client = MODULE_LIBRARIES)
52     @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
53     public final int permitted; /* __u32 */
54 
55     /**
56      * Inheritable capability mask.
57      *
58      * @hide
59      */
60     @SystemApi(client = MODULE_LIBRARIES)
61     @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
62     public final int inheritable; /* __u32 */
63 
64     /**
65      * Constructs an instance with the given field values.
66      *
67      * @param effective   effective capability mask
68      * @param permitted   permitted capability mask
69      * @param inheritable inheritable capability mask
70      *
71      * @hide
72      */
73     @SystemApi(client = MODULE_LIBRARIES)
74     @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
StructCapUserData(int effective, int permitted, int inheritable)75     public StructCapUserData(int effective, int permitted, int inheritable) {
76         this.effective = effective;
77         this.permitted = permitted;
78         this.inheritable = inheritable;
79     }
80 
81     /**
82      * @hide
83      */
toString()84     @Override public String toString() {
85         return Objects.toString(this);
86     }
87 }
88