1 /*
2  * Copyright (C) 2020 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.content.pm;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.pm.ApplicationInfo;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.text.TextUtils;
25 import android.util.ArraySet;
26 
27 import com.android.internal.util.DataClass;
28 import com.android.internal.util.Parcelling;
29 
30 /**
31  * Information about a process an app may run.  This corresponds to information collected from the
32  * AndroidManifest.xml's <permission-group> tags.
33  * @hide
34  */
35 @DataClass(genGetters = true, genSetters = false, genParcelable = true, genAidl = false,
36         genBuilder = false)
37 public class ProcessInfo implements Parcelable {
38     /**
39      * The name of the process, fully-qualified based on the app's package name.
40      */
41     @NonNull
42     public String name;
43 
44     /**
45      * If non-null, these are permissions that are not allowed in this process.
46      */
47     @Nullable
48     @DataClass.ParcelWith(Parcelling.BuiltIn.ForInternedStringArraySet.class)
49     public ArraySet<String> deniedPermissions;
50 
51     /**
52      * Indicates if the process has requested GWP-ASan to be enabled, disabled, or left unspecified.
53      */
54     public @ApplicationInfo.GwpAsanMode int gwpAsanMode;
55 
56     /**
57      * Indicates if the process has requested Memtag to be enabled (in sync or async mode),
58      * disabled, or left unspecified.
59      */
60     public @ApplicationInfo.MemtagMode int memtagMode;
61 
62     /**
63      * Enable automatic zero-initialization of native heap memory allocations.
64      */
65     public @ApplicationInfo.NativeHeapZeroInitialized int nativeHeapZeroInitialized;
66 
67     @Deprecated
ProcessInfo(@onNull ProcessInfo orig)68     public ProcessInfo(@NonNull ProcessInfo orig) {
69         this.name = orig.name;
70         this.deniedPermissions = orig.deniedPermissions;
71         this.gwpAsanMode = orig.gwpAsanMode;
72         this.memtagMode = orig.memtagMode;
73         this.nativeHeapZeroInitialized = orig.nativeHeapZeroInitialized;
74     }
75 
76 
77 
78     // Code below generated by codegen v1.0.22.
79     //
80     // DO NOT MODIFY!
81     // CHECKSTYLE:OFF Generated code
82     //
83     // To regenerate run:
84     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/ProcessInfo.java
85     //
86     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
87     //   Settings > Editor > Code Style > Formatter Control
88     //@formatter:off
89 
90 
91     /**
92      * Creates a new ProcessInfo.
93      *
94      * @param name
95      *   The name of the process, fully-qualified based on the app's package name.
96      * @param deniedPermissions
97      *   If non-null, these are permissions that are not allowed in this process.
98      * @param gwpAsanMode
99      *   Indicates if the process has requested GWP-ASan to be enabled, disabled, or left unspecified.
100      * @param memtagMode
101      *   Indicates if the process has requested Memtag to be enabled (in sync or async mode),
102      *   disabled, or left unspecified.
103      * @param nativeHeapZeroInitialized
104      *   Enable automatic zero-initialization of native heap memory allocations.
105      */
106     @DataClass.Generated.Member
ProcessInfo( @onNull String name, @Nullable ArraySet<String> deniedPermissions, @ApplicationInfo.GwpAsanMode int gwpAsanMode, @ApplicationInfo.MemtagMode int memtagMode, @ApplicationInfo.NativeHeapZeroInitialized int nativeHeapZeroInitialized)107     public ProcessInfo(
108             @NonNull String name,
109             @Nullable ArraySet<String> deniedPermissions,
110             @ApplicationInfo.GwpAsanMode int gwpAsanMode,
111             @ApplicationInfo.MemtagMode int memtagMode,
112             @ApplicationInfo.NativeHeapZeroInitialized int nativeHeapZeroInitialized) {
113         this.name = name;
114         com.android.internal.util.AnnotationValidations.validate(
115                 NonNull.class, null, name);
116         this.deniedPermissions = deniedPermissions;
117         this.gwpAsanMode = gwpAsanMode;
118         com.android.internal.util.AnnotationValidations.validate(
119                 ApplicationInfo.GwpAsanMode.class, null, gwpAsanMode);
120         this.memtagMode = memtagMode;
121         com.android.internal.util.AnnotationValidations.validate(
122                 ApplicationInfo.MemtagMode.class, null, memtagMode);
123         this.nativeHeapZeroInitialized = nativeHeapZeroInitialized;
124         com.android.internal.util.AnnotationValidations.validate(
125                 ApplicationInfo.NativeHeapZeroInitialized.class, null, nativeHeapZeroInitialized);
126 
127         // onConstructed(); // You can define this method to get a callback
128     }
129 
130     @DataClass.Generated.Member
131     static Parcelling<ArraySet<String>> sParcellingForDeniedPermissions =
132             Parcelling.Cache.get(
133                     Parcelling.BuiltIn.ForInternedStringArraySet.class);
134     static {
135         if (sParcellingForDeniedPermissions == null) {
136             sParcellingForDeniedPermissions = Parcelling.Cache.put(
137                     new Parcelling.BuiltIn.ForInternedStringArraySet());
138         }
139     }
140 
141     @Override
142     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)143     public void writeToParcel(@NonNull Parcel dest, int flags) {
144         // You can override field parcelling by defining methods like:
145         // void parcelFieldName(Parcel dest, int flags) { ... }
146 
147         byte flg = 0;
148         if (deniedPermissions != null) flg |= 0x2;
149         dest.writeByte(flg);
150         dest.writeString(name);
151         sParcellingForDeniedPermissions.parcel(deniedPermissions, dest, flags);
152         dest.writeInt(gwpAsanMode);
153         dest.writeInt(memtagMode);
154         dest.writeInt(nativeHeapZeroInitialized);
155     }
156 
157     @Override
158     @DataClass.Generated.Member
describeContents()159     public int describeContents() { return 0; }
160 
161     /** @hide */
162     @SuppressWarnings({"unchecked", "RedundantCast"})
163     @DataClass.Generated.Member
ProcessInfo(@onNull Parcel in)164     protected ProcessInfo(@NonNull Parcel in) {
165         // You can override field unparcelling by defining methods like:
166         // static FieldType unparcelFieldName(Parcel in) { ... }
167 
168         byte flg = in.readByte();
169         String _name = in.readString();
170         ArraySet<String> _deniedPermissions = sParcellingForDeniedPermissions.unparcel(in);
171         int _gwpAsanMode = in.readInt();
172         int _memtagMode = in.readInt();
173         int _nativeHeapZeroInitialized = in.readInt();
174 
175         this.name = _name;
176         com.android.internal.util.AnnotationValidations.validate(
177                 NonNull.class, null, name);
178         this.deniedPermissions = _deniedPermissions;
179         this.gwpAsanMode = _gwpAsanMode;
180         com.android.internal.util.AnnotationValidations.validate(
181                 ApplicationInfo.GwpAsanMode.class, null, gwpAsanMode);
182         this.memtagMode = _memtagMode;
183         com.android.internal.util.AnnotationValidations.validate(
184                 ApplicationInfo.MemtagMode.class, null, memtagMode);
185         this.nativeHeapZeroInitialized = _nativeHeapZeroInitialized;
186         com.android.internal.util.AnnotationValidations.validate(
187                 ApplicationInfo.NativeHeapZeroInitialized.class, null, nativeHeapZeroInitialized);
188 
189         // onConstructed(); // You can define this method to get a callback
190     }
191 
192     @DataClass.Generated.Member
193     public static final @NonNull Parcelable.Creator<ProcessInfo> CREATOR
194             = new Parcelable.Creator<ProcessInfo>() {
195         @Override
196         public ProcessInfo[] newArray(int size) {
197             return new ProcessInfo[size];
198         }
199 
200         @Override
201         public ProcessInfo createFromParcel(@NonNull Parcel in) {
202             return new ProcessInfo(in);
203         }
204     };
205 
206     @DataClass.Generated(
207             time = 1615850184524L,
208             codegenVersion = "1.0.22",
209             sourceFile = "frameworks/base/core/java/android/content/pm/ProcessInfo.java",
210             inputSignatures = "public @android.annotation.NonNull java.lang.String name\npublic @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedStringArraySet.class) android.util.ArraySet<java.lang.String> deniedPermissions\npublic @android.content.pm.ApplicationInfo.GwpAsanMode int gwpAsanMode\npublic @android.content.pm.ApplicationInfo.MemtagMode int memtagMode\npublic @android.content.pm.ApplicationInfo.NativeHeapZeroInitialized int nativeHeapZeroInitialized\nclass ProcessInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=false, genParcelable=true, genAidl=false, genBuilder=false)")
211     @Deprecated
__metadata()212     private void __metadata() {}
213 
214 
215     //@formatter:on
216     // End of generated code
217 
218 }
219