Debian Codegraph @

core/java/android/content/pm/overlay/OverlayPaths.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 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.overlay;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21
22 import com.android.internal.util.DataClass;
23
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Objects;
27
28 /** @hide */
29 @DataClass(genConstructor = false, genBuilder = false, genHiddenBuilder = false,
30 genEqualsHashCode = true, genToString = true)
31 public class OverlayPaths {
32 /**
33 * Represents {@link android.content.pm.ApplicationInfo#resourceDirs}.
34 * Only contains paths to APKs of overlays that can have their idmap resolved from their base
35 * APK path. Currently all overlay APKs can have their idmap path resolved from their idmap
36 * path.
37 */
38 @NonNull
39 private final List<String> mResourceDirs = new ArrayList<>();
40
41 /**
42 * Represents {@link android.content.pm.ApplicationInfo#overlayPaths}.
43 * Contains the contents of {@link #getResourceDirs()} and along with paths for overlays
44 * that are not APKs.
45 */
46 @NonNull
47 private final List<String> mOverlayPaths = new ArrayList<>();
48
49 public static class Builder {
50 final OverlayPaths mPaths = new OverlayPaths();
51
52 /**
53 * Adds a non-APK path to the contents of {@link OverlayPaths#getOverlayPaths()}.
54 */
55 public Builder addNonApkPath(@NonNull String idmapPath) {
56 mPaths.mOverlayPaths.add(idmapPath);
57 return this;
58 }
59
60 /**
61 * Adds a overlay APK path to the contents of {@link OverlayPaths#getResourceDirs()} and
62 * {@link OverlayPaths#getOverlayPaths()}.
63 */
64 public Builder addApkPath(@NonNull String overlayPath) {
65 addUniquePath(mPaths.mResourceDirs, overlayPath);
66 addUniquePath(mPaths.mOverlayPaths, overlayPath);
67 return this;
68 }
69
70 public Builder addAll(@Nullable OverlayPaths other) {
71 if (other != null) {
72 for (final String path : other.getResourceDirs()) {
73 addUniquePath(mPaths.mResourceDirs, path);
74 }
75 for (final String path : other.getOverlayPaths()) {
76 addUniquePath(mPaths.mOverlayPaths, path);
77 }
78 }
79 return this;
80 }
81
82 public OverlayPaths build() {
83 return mPaths;
84 }
85
86 private static void addUniquePath(@NonNull List<String> paths, @NonNull String path) {
87 if (!paths.contains(path)) {
88 paths.add(path);
89 }
90 }
91 }
92
93 /**
94 * Returns whether {@link #getOverlayPaths()} and {@link #getOverlayPaths} are empty.
95 */
96 public boolean isEmpty() {
97 return mResourceDirs.isEmpty() && mOverlayPaths.isEmpty();
98 }
99
100 private OverlayPaths() {
101 }
102
103
104
105 // Code below generated by codegen v1.0.22.
106 //
107 // DO NOT MODIFY!
108 // CHECKSTYLE:OFF Generated code
109 //
110 // To regenerate run:
111 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/overlay/OverlayPaths.java
112 //
113 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
114 // Settings > Editor > Code Style > Formatter Control
115 //@formatter:off
116
117
118 /**
119 * Represents {@link android.content.pm.ApplicationInfo#resourceDirs}.
120 * Only contains paths to APKs of overlays that can have their idmap resolved from their base
121 * APK path. Currently all overlay APKs can have their idmap path resolved from their idmap
122 * path.
123 */
124 @DataClass.Generated.Member
125 public @NonNull List<String> getResourceDirs() {
126 return mResourceDirs;
127 }
128
129 /**
130 * Represents {@link android.content.pm.ApplicationInfo#overlayPaths}.
131 * Contains the contents of {@link #getResourceDirs()} and along with paths for overlays
132 * that are not APKs.
133 */
134 @DataClass.Generated.Member
135 public @NonNull List<String> getOverlayPaths() {
136 return mOverlayPaths;
137 }
138
139 @Override
140 @DataClass.Generated.Member
141 public String toString() {
142 // You can override field toString logic by defining methods like:
143 // String fieldNameToString() { ... }
144
145 return "OverlayPaths { " +
146 "resourceDirs = " + mResourceDirs + ", " +
147 "overlayPaths = " + mOverlayPaths +
148 " }";
149 }
150
151 @Override
152 @DataClass.Generated.Member
153 public boolean equals(@android.annotation.Nullable Object o) {
154 // You can override field equality logic by defining either of the methods like:
155 // boolean fieldNameEquals(OverlayPaths other) { ... }
156 // boolean fieldNameEquals(FieldType otherValue) { ... }
157
158 if (this == o) return true;
159 if (o == null || getClass() != o.getClass()) return false;
160 @SuppressWarnings("unchecked")
161 OverlayPaths that = (OverlayPaths) o;
162 //noinspection PointlessBooleanExpression
163 return true
164 && Objects.equals(mResourceDirs, that.mResourceDirs)
165 && Objects.equals(mOverlayPaths, that.mOverlayPaths);
166 }
167
168 @Override
169 @DataClass.Generated.Member
170 public int hashCode() {
171 // You can override field hashCode logic by defining methods like:
172 // int fieldNameHashCode() { ... }
173
174 int _hash = 1;
175 _hash = 31 * _hash + Objects.hashCode(mResourceDirs);
176 _hash = 31 * _hash + Objects.hashCode(mOverlayPaths);
177 return _hash;
178 }
179
180 @DataClass.Generated(
181 time = 1612307813586L,
182 codegenVersion = "1.0.22",
183 sourceFile = "frameworks/base/core/java/android/content/pm/overlay/OverlayPaths.java",
184 inputSignatures = "private final @android.annotation.NonNull java.util.List<java.lang.String> mResourceDirs\nprivate final @android.annotation.NonNull java.util.List<java.lang.String> mOverlayPaths\npublic boolean isEmpty()\nclass OverlayPaths extends java.lang.Object implements []\nfinal android.content.pm.overlay.OverlayPaths mPaths\npublic android.content.pm.overlay.OverlayPaths.Builder addNonApkPath(java.lang.String)\npublic android.content.pm.overlay.OverlayPaths.Builder addApkPath(java.lang.String)\npublic android.content.pm.overlay.OverlayPaths.Builder addAll(android.content.pm.overlay.OverlayPaths)\npublic android.content.pm.overlay.OverlayPaths build()\nprivate static void addUniquePath(java.util.List<java.lang.String>,java.lang.String)\nclass Builder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=false, genHiddenBuilder=false, genEqualsHashCode=true, genToString=true)")
185 @Deprecated
186 private void __metadata() {}
187
188
189 //@formatter:on
190 // End of generated code
191
192 }