• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.service.trust;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.SystemApi;
22 import android.os.Parcelable;
23 
24 import com.android.internal.util.DataClass;
25 
26 import java.lang.annotation.Retention;
27 import java.lang.annotation.RetentionPolicy;
28 
29 /**
30  * Result type for a callback in a call to
31  * {@link TrustAgentService#grantTrust(CharSequence, long, int)}.
32  *
33  * @hide
34  */
35 @DataClass
36 @SystemApi
37 public final class GrantTrustResult implements Parcelable {
38 
39     /** Result status is unknown to this version of the SDK. */
40     public static final int STATUS_UNKNOWN = 0;
41 
42     /** The device went from locked to unlocked as a result of the call. */
43     public static final int STATUS_UNLOCKED_BY_GRANT = 1;
44 
45     /** The status code of the result. */
46     @Status
47     private int mStatus;
48 
49 
50 
51     // Code below generated by codegen v1.0.23.
52     //
53     // DO NOT MODIFY!
54     // CHECKSTYLE:OFF Generated code
55     //
56     // To regenerate run:
57     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/trust/GrantTrustResult.java
58     //
59     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
60     //   Settings > Editor > Code Style > Formatter Control
61     //@formatter:off
62 
63 
64     /** @hide */
65     @IntDef(prefix = "STATUS_", value = {
66         STATUS_UNKNOWN,
67         STATUS_UNLOCKED_BY_GRANT
68     })
69     @Retention(RetentionPolicy.SOURCE)
70     @DataClass.Generated.Member
71     public @interface Status {}
72 
73     @NonNull
74     @DataClass.Generated.Member
statusToString(@tatus int value)75     public static String statusToString(@Status int value) {
76         switch (value) {
77             case STATUS_UNKNOWN:
78                     return "STATUS_UNKNOWN";
79             case STATUS_UNLOCKED_BY_GRANT:
80                     return "STATUS_UNLOCKED_BY_GRANT";
81             default: return Integer.toHexString(value);
82         }
83     }
84 
85     /**
86      * Creates a new GrantTrustResult.
87      *
88      * @param status
89      *   The status code of the result.
90      */
91     @DataClass.Generated.Member
GrantTrustResult( @tatus int status)92     public GrantTrustResult(
93             @Status int status) {
94         this.mStatus = status;
95 
96         if (!(mStatus == STATUS_UNKNOWN)
97                 && !(mStatus == STATUS_UNLOCKED_BY_GRANT)) {
98             throw new java.lang.IllegalArgumentException(
99                     "status was " + mStatus + " but must be one of: "
100                             + "STATUS_UNKNOWN(" + STATUS_UNKNOWN + "), "
101                             + "STATUS_UNLOCKED_BY_GRANT(" + STATUS_UNLOCKED_BY_GRANT + ")");
102         }
103 
104 
105         // onConstructed(); // You can define this method to get a callback
106     }
107 
108     /**
109      * The status code of the result.
110      */
111     @DataClass.Generated.Member
getStatus()112     public @Status int getStatus() {
113         return mStatus;
114     }
115 
116     @Override
117     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)118     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
119         // You can override field parcelling by defining methods like:
120         // void parcelFieldName(Parcel dest, int flags) { ... }
121 
122         dest.writeInt(mStatus);
123     }
124 
125     @Override
126     @DataClass.Generated.Member
describeContents()127     public int describeContents() { return 0; }
128 
129     /** @hide */
130     @SuppressWarnings({"unchecked", "RedundantCast"})
131     @DataClass.Generated.Member
GrantTrustResult(@onNull android.os.Parcel in)132     /* package-private */ GrantTrustResult(@NonNull android.os.Parcel in) {
133         // You can override field unparcelling by defining methods like:
134         // static FieldType unparcelFieldName(Parcel in) { ... }
135 
136         int status = in.readInt();
137 
138         this.mStatus = status;
139 
140         if (!(mStatus == STATUS_UNKNOWN)
141                 && !(mStatus == STATUS_UNLOCKED_BY_GRANT)) {
142             throw new java.lang.IllegalArgumentException(
143                     "status was " + mStatus + " but must be one of: "
144                             + "STATUS_UNKNOWN(" + STATUS_UNKNOWN + "), "
145                             + "STATUS_UNLOCKED_BY_GRANT(" + STATUS_UNLOCKED_BY_GRANT + ")");
146         }
147 
148 
149         // onConstructed(); // You can define this method to get a callback
150     }
151 
152     @DataClass.Generated.Member
153     public static final @NonNull Parcelable.Creator<GrantTrustResult> CREATOR
154             = new Parcelable.Creator<GrantTrustResult>() {
155         @Override
156         public GrantTrustResult[] newArray(int size) {
157             return new GrantTrustResult[size];
158         }
159 
160         @Override
161         public GrantTrustResult createFromParcel(@NonNull android.os.Parcel in) {
162             return new GrantTrustResult(in);
163         }
164     };
165 
166     @DataClass.Generated(
167             time = 1648138312806L,
168             codegenVersion = "1.0.23",
169             sourceFile = "frameworks/base/core/java/android/service/trust/GrantTrustResult.java",
170             inputSignatures = "public static final  int STATUS_UNKNOWN\npublic static final  int STATUS_UNLOCKED_BY_GRANT\nprivate @android.service.trust.GrantTrustResult.Status int mStatus\nclass GrantTrustResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass")
171     @Deprecated
__metadata()172     private void __metadata() {}
173 
174 
175     //@formatter:on
176     // End of generated code
177 
178 }
179