• 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 componentst. Components are one of
41      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
42      */
43     private final @NonNull int[] mEnabledComponents;
44 
45     /**
46      * List of disabled componentst. 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     //
75     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
76     //   Settings > Editor > Code Style > Formatter Control
77     //@formatter:off
78 
79 
80     /**
81      * Creates a new CarPowerPolicy.
82      *
83      * @param policyId
84      *   ID of power policy.
85      * @param enabledComponents
86      *   List of enabled componentst. Components are one of
87      *   {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
88      * @param disabledComponents
89      *   List of disabled componentst. Components are one of
90      *   {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
91      * @hide
92      */
93     @DataClass.Generated.Member
CarPowerPolicy( @onNull String policyId, @NonNull int[] enabledComponents, @NonNull int[] disabledComponents)94     public CarPowerPolicy(
95             @NonNull String policyId,
96             @NonNull int[] enabledComponents,
97             @NonNull int[] disabledComponents) {
98         this.mPolicyId = policyId;
99         AnnotationValidations.validate(
100                 NonNull.class, null, mPolicyId);
101         this.mEnabledComponents = enabledComponents;
102         AnnotationValidations.validate(
103                 NonNull.class, null, mEnabledComponents);
104         this.mDisabledComponents = disabledComponents;
105         AnnotationValidations.validate(
106                 NonNull.class, null, mDisabledComponents);
107 
108         // onConstructed(); // You can define this method to get a callback
109     }
110 
111     /**
112      * ID of power policy.
113      */
114     @DataClass.Generated.Member
115     @AddedInOrBefore(majorVersion = 33)
getPolicyId()116     public @NonNull String getPolicyId() {
117         return mPolicyId;
118     }
119 
120     /**
121      * List of enabled componentst. Components are one of
122      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
123      */
124     @DataClass.Generated.Member
125     @AddedInOrBefore(majorVersion = 33)
getEnabledComponents()126     public @NonNull int[] getEnabledComponents() {
127         return mEnabledComponents;
128     }
129 
130     /**
131      * List of disabled componentst. Components are one of
132      * {@code android.frameworks.automotive.powerpolicy.PowerComponent}.
133      */
134     @DataClass.Generated.Member
135     @AddedInOrBefore(majorVersion = 33)
getDisabledComponents()136     public @NonNull int[] getDisabledComponents() {
137         return mDisabledComponents;
138     }
139 
140     @Override
141     @DataClass.Generated.Member
142     @AddedInOrBefore(majorVersion = 33)
writeToParcel(@onNull android.os.Parcel dest, int flags)143     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
144         // You can override field parcelling by defining methods like:
145         // void parcelFieldName(Parcel dest, int flags) { ... }
146 
147         dest.writeString(mPolicyId);
148         dest.writeIntArray(mEnabledComponents);
149         dest.writeIntArray(mDisabledComponents);
150     }
151 
152     @Override
153     @DataClass.Generated.Member
154     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
155     @AddedInOrBefore(majorVersion = 33)
describeContents()156     public int describeContents() { return 0; }
157 
158     /** @hide */
159     @SuppressWarnings({"unchecked", "RedundantCast"})
160     @DataClass.Generated.Member
CarPowerPolicy(@onNull android.os.Parcel in)161     /* package-private */ CarPowerPolicy(@NonNull android.os.Parcel in) {
162         // You can override field unparcelling by defining methods like:
163         // static FieldType unparcelFieldName(Parcel in) { ... }
164 
165         String policyId = in.readString();
166         int[] enabledComponents = in.createIntArray();
167         int[] disabledComponents = in.createIntArray();
168 
169         this.mPolicyId = policyId;
170         AnnotationValidations.validate(
171                 NonNull.class, null, mPolicyId);
172         this.mEnabledComponents = enabledComponents;
173         AnnotationValidations.validate(
174                 NonNull.class, null, mEnabledComponents);
175         this.mDisabledComponents = disabledComponents;
176         AnnotationValidations.validate(
177                 NonNull.class, null, mDisabledComponents);
178 
179         // onConstructed(); // You can define this method to get a callback
180     }
181 
182     @DataClass.Generated.Member
183     @AddedInOrBefore(majorVersion = 33)
184     public static final @NonNull Parcelable.Creator<CarPowerPolicy> CREATOR
185             = new Parcelable.Creator<CarPowerPolicy>() {
186         @Override
187         public CarPowerPolicy[] newArray(int size) {
188             return new CarPowerPolicy[size];
189         }
190 
191         @Override
192         public CarPowerPolicy createFromParcel(@NonNull android.os.Parcel in) {
193             return new CarPowerPolicy(in);
194         }
195     };
196 
197     @DataClass.Generated(
198             time = 1628098490687L,
199             codegenVersion = "1.0.23",
200             sourceFile = "packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicy.java",
201             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)")
202     @Deprecated
203     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()204     private void __metadata() {}
205 
206 
207     //@formatter:on
208     // End of generated code
209 
210 }
211