• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.car.hardware.power;
18 
19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE;
20 
21 import android.annotation.NonNull;
22 import android.car.annotation.AddedInOrBefore;
23 import android.os.Parcelable;
24 
25 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport;
26 import com.android.car.internal.util.AnnotationValidations;
27 import com.android.car.internal.util.DataClass;
28 
29 /**
30  * Car power policy definition.
31  */
32 @DataClass(genHiddenConstructor = true)
33 public final class CarPowerPolicy implements Parcelable {
34     /**
35      * ID of power policy.
36      */
37     private final @NonNull String mPolicyId;
38 
39     /**
40      * List of enabled components. Components are one of
41      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
42      */
43     private final @NonNull int[] mEnabledComponents;
44 
45     /**
46      * List of disabled components. Components are one of
47      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
48      */
49     private final @NonNull int[] mDisabledComponents;
50 
51     /**
52      * Returns {@code true} if the given component is enabled in the power policy. Otherwise,
53      * {@code false}.
54      */
55     @AddedInOrBefore(majorVersion = 33)
isComponentEnabled(int component)56     public boolean isComponentEnabled(int component) {
57         for (int i = 0; i < mEnabledComponents.length; i++) {
58             if (component == mEnabledComponents[i]) {
59                 return true;
60             }
61         }
62         return false;
63     }
64 
65 
66 
67     // Code below generated by codegen v1.0.23.
68     //
69     // DO NOT MODIFY!
70     // CHECKSTYLE:OFF Generated code
71     //
72     // To regenerate run:
73     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicy.java
74     // Added AddedInOrBefore or ApiRequirement Annotation manually
75     //
76     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
77     //   Settings > Editor > Code Style > Formatter Control
78     //@formatter:off
79 
80 
81     /**
82      * Creates a new CarPowerPolicy.
83      *
84      * @param policyId
85      *   ID of power policy.
86      * @param enabledComponents
87      *   List of enabled componentst. Components are one of
88      *   {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
89      * @param disabledComponents
90      *   List of disabled componentst. Components are one of
91      *   {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
92      * @hide
93      */
94     @DataClass.Generated.Member
CarPowerPolicy( @onNull String policyId, @NonNull int[] enabledComponents, @NonNull int[] disabledComponents)95     public CarPowerPolicy(
96             @NonNull String policyId,
97             @NonNull int[] enabledComponents,
98             @NonNull int[] disabledComponents) {
99         this.mPolicyId = policyId;
100         AnnotationValidations.validate(
101                 NonNull.class, null, mPolicyId);
102         this.mEnabledComponents = enabledComponents;
103         AnnotationValidations.validate(
104                 NonNull.class, null, mEnabledComponents);
105         this.mDisabledComponents = disabledComponents;
106         AnnotationValidations.validate(
107                 NonNull.class, null, mDisabledComponents);
108 
109         // onConstructed(); // You can define this method to get a callback
110     }
111 
112     /**
113      * ID of power policy.
114      */
115     @DataClass.Generated.Member
116     @AddedInOrBefore(majorVersion = 33)
getPolicyId()117     public @NonNull String getPolicyId() {
118         return mPolicyId;
119     }
120 
121     /**
122      * List of enabled componentst. Components are one of
123      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
124      */
125     @DataClass.Generated.Member
126     @AddedInOrBefore(majorVersion = 33)
getEnabledComponents()127     public @NonNull int[] getEnabledComponents() {
128         return mEnabledComponents;
129     }
130 
131     /**
132      * List of disabled componentst. Components are one of
133      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
134      */
135     @DataClass.Generated.Member
136     @AddedInOrBefore(majorVersion = 33)
getDisabledComponents()137     public @NonNull int[] getDisabledComponents() {
138         return mDisabledComponents;
139     }
140 
141     @Override
142     @DataClass.Generated.Member
143     @AddedInOrBefore(majorVersion = 33)
writeToParcel(@onNull android.os.Parcel dest, int flags)144     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
145         // You can override field parcelling by defining methods like:
146         // void parcelFieldName(Parcel dest, int flags) { ... }
147 
148         dest.writeString(mPolicyId);
149         dest.writeIntArray(mEnabledComponents);
150         dest.writeIntArray(mDisabledComponents);
151     }
152 
153     @Override
154     @DataClass.Generated.Member
155     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
156     @AddedInOrBefore(majorVersion = 33)
describeContents()157     public int describeContents() { return 0; }
158 
159     /** @hide */
160     @SuppressWarnings({"unchecked", "RedundantCast"})
161     @DataClass.Generated.Member
CarPowerPolicy(@onNull android.os.Parcel in)162     /* package-private */ CarPowerPolicy(@NonNull android.os.Parcel in) {
163         // You can override field unparcelling by defining methods like:
164         // static FieldType unparcelFieldName(Parcel in) { ... }
165 
166         String policyId = in.readString();
167         int[] enabledComponents = in.createIntArray();
168         int[] disabledComponents = in.createIntArray();
169 
170         this.mPolicyId = policyId;
171         AnnotationValidations.validate(
172                 NonNull.class, null, mPolicyId);
173         this.mEnabledComponents = enabledComponents;
174         AnnotationValidations.validate(
175                 NonNull.class, null, mEnabledComponents);
176         this.mDisabledComponents = disabledComponents;
177         AnnotationValidations.validate(
178                 NonNull.class, null, mDisabledComponents);
179 
180         // onConstructed(); // You can define this method to get a callback
181     }
182 
183     @DataClass.Generated.Member
184     @AddedInOrBefore(majorVersion = 33)
185     public static final @NonNull Parcelable.Creator<CarPowerPolicy> CREATOR
186             = new Parcelable.Creator<CarPowerPolicy>() {
187         @Override
188         public CarPowerPolicy[] newArray(int size) {
189             return new CarPowerPolicy[size];
190         }
191 
192         @Override
193         public CarPowerPolicy createFromParcel(@NonNull android.os.Parcel in) {
194             return new CarPowerPolicy(in);
195         }
196     };
197 
198     @DataClass.Generated(
199             time = 1628098490687L,
200             codegenVersion = "1.0.23",
201             sourceFile = "packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicy.java",
202             inputSignatures = "private final @android.annotation.NonNull java.lang.String mPolicyId\nprivate final @android.annotation.NonNull int[] mEnabledComponents\nprivate final @android.annotation.NonNull int[] mDisabledComponents\npublic  boolean isComponentEnabled(int)\nclass CarPowerPolicy extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genHiddenConstructor=true)")
203     @Deprecated
204     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()205     private void __metadata() {}
206 
207 
208     //@formatter:on
209     // End of generated code
210 
211 }
212