blob: 6537fbc373986deeeb78b5c2f72ad7e243f2af90 [file] [log] [blame]
Anthony Hugh6f5eadc2019-08-22 15:35:48 -07001/*
2 * Copyright (C) 2019 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
17package android.content.pm.permission;
18
19import android.annotation.IntRange;
20import android.annotation.NonNull;
21import android.os.Parcel;
22import android.os.Parcelable;
23
24import com.android.internal.util.Preconditions;
25
26import java.util.List;
27import java.util.Objects;
28
29/**
30 * Parcelable version of {@link android.permission.PermissionManager.SplitPermissionInfo}
31 * @hide
32 */
33public class SplitPermissionInfoParcelable implements Parcelable {
34
35 /**
36 * The permission that is split.
37 */
38 @NonNull
39 private final String mSplitPermission;
40
41 /**
42 * The permissions that are added.
43 */
44 @NonNull
45 private final List<String> mNewPermissions;
46
47 /**
48 * The target API level when the permission was split.
49 */
50 @IntRange(from = 0)
51 private final int mTargetSdk;
52
53 private void onConstructed() {
54 Preconditions.checkCollectionElementsNotNull(mNewPermissions, "newPermissions");
55 }
56
57
58
59 // Code below generated by codegen v1.0.0.
60 //
61 // DO NOT MODIFY!
62 //
63 // To regenerate run:
64 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/SplitPermissionInfoParcelable.java
65 //
66 // CHECKSTYLE:OFF Generated code
67
68 /**
69 * Creates a new SplitPermissionInfoParcelable.
70 *
71 * @param splitPermission
72 * The permission that is split.
73 * @param newPermissions
74 * The permissions that are added.
75 * @param targetSdk
76 * The target API level when the permission was split.
77 */
78 public SplitPermissionInfoParcelable(
79 @NonNull String splitPermission,
80 @NonNull List<String> newPermissions,
81 @IntRange(from = 0) int targetSdk) {
82 this.mSplitPermission = splitPermission;
83 Preconditions.checkNotNull(mSplitPermission);
84 this.mNewPermissions = newPermissions;
85 Preconditions.checkNotNull(mNewPermissions);
86 this.mTargetSdk = targetSdk;
87 Preconditions.checkArgumentNonnegative(mTargetSdk);
88
89 onConstructed();
90 }
91
92 /**
93 * The permission that is split.
94 */
95 public @NonNull String getSplitPermission() {
96 return mSplitPermission;
97 }
98
99 /**
100 * The permissions that are added.
101 */
102 public @NonNull List<String> getNewPermissions() {
103 return mNewPermissions;
104 }
105
106 /**
107 * The target API level when the permission was split.
108 */
109 public @IntRange(from = 0) int getTargetSdk() {
110 return mTargetSdk;
111 }
112
113 @Override
114 public boolean equals(Object o) {
115 // You can override field equality logic by defining either of the methods like:
116 // boolean fieldNameEquals(SplitPermissionInfoParcelable other) { ... }
117 // boolean fieldNameEquals(FieldType otherValue) { ... }
118
119 if (this == o) return true;
120 if (o == null || getClass() != o.getClass()) return false;
121 @SuppressWarnings("unchecked")
122 SplitPermissionInfoParcelable that = (SplitPermissionInfoParcelable) o;
123 //noinspection PointlessBooleanExpression
124 return true
125 && Objects.equals(mSplitPermission, that.mSplitPermission)
126 && Objects.equals(mNewPermissions, that.mNewPermissions)
127 && mTargetSdk == that.mTargetSdk;
128 }
129
130 @Override
131 public int hashCode() {
132 // You can override field hashCode logic by defining methods like:
133 // int fieldNameHashCode() { ... }
134
135 int _hash = 1;
136 _hash = 31 * _hash + Objects.hashCode(mSplitPermission);
137 _hash = 31 * _hash + Objects.hashCode(mNewPermissions);
138 _hash = 31 * _hash + mTargetSdk;
139 return _hash;
140 }
141
142 @Override
143 public void writeToParcel(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(mSplitPermission);
148 dest.writeStringList(mNewPermissions);
149 dest.writeInt(mTargetSdk);
150 }
151
152 @Override
153 public int describeContents() { return 0; }
154
155 public static final @NonNull Parcelable.Creator<SplitPermissionInfoParcelable> CREATOR
156 = new Parcelable.Creator<SplitPermissionInfoParcelable>() {
157 @Override
158 public SplitPermissionInfoParcelable[] newArray(int size) {
159 return new SplitPermissionInfoParcelable[size];
160 }
161
162 @Override
163 @SuppressWarnings({"unchecked", "RedundantCast"})
164 public SplitPermissionInfoParcelable createFromParcel(Parcel in) {
165 // You can override field unparcelling by defining methods like:
166 // static FieldType unparcelFieldName(Parcel in) { ... }
167
168 String splitPermission = in.readString();
169 List<String> newPermissions = new java.util.ArrayList<>();
170 in.readStringList(newPermissions);
171 int targetSdk = in.readInt();
172 return new SplitPermissionInfoParcelable(
173 splitPermission,
174 newPermissions,
175 targetSdk);
176 }
177 };
178}