Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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.om; |
| 18 | |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 20 | import android.annotation.NonNull; |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 25 | import java.lang.annotation.Retention; |
| 26 | import java.lang.annotation.RetentionPolicy; |
| 27 | |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 28 | /** |
| 29 | * Immutable overlay information about a package. All PackageInfos that |
| 30 | * represent an overlay package will have a corresponding OverlayInfo. |
| 31 | * |
| 32 | * @hide |
| 33 | */ |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 34 | @SystemApi |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 35 | public final class OverlayInfo implements Parcelable { |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 36 | |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 37 | /** @hide */ |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 38 | @IntDef(prefix = "STATE_", value = { |
| 39 | STATE_UNKNOWN, |
| 40 | STATE_MISSING_TARGET, |
| 41 | STATE_NO_IDMAP, |
| 42 | STATE_DISABLED, |
| 43 | STATE_ENABLED, |
Mårten Kongstad | a525e22 | 2018-04-10 16:57:33 +0200 | [diff] [blame] | 44 | STATE_ENABLED_STATIC, |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 45 | STATE_TARGET_UPGRADING, |
| 46 | STATE_OVERLAY_UPGRADING, |
| 47 | }) |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 48 | /** @hide */ |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 49 | @Retention(RetentionPolicy.SOURCE) |
| 50 | public @interface State {} |
| 51 | |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 52 | /** |
| 53 | * An internal state used as the initial state of an overlay. OverlayInfo |
| 54 | * objects exposed outside the {@link |
| 55 | * com.android.server.om.OverlayManagerService} should never have this |
| 56 | * state. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 57 | * |
| 58 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 59 | */ |
| 60 | public static final int STATE_UNKNOWN = -1; |
| 61 | |
| 62 | /** |
| 63 | * The target package of the overlay is not installed. The overlay cannot be enabled. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 64 | * |
| 65 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 66 | */ |
| 67 | public static final int STATE_MISSING_TARGET = 0; |
| 68 | |
| 69 | /** |
| 70 | * Creation of idmap file failed (e.g. no matching resources). The overlay |
| 71 | * cannot be enabled. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 72 | * |
| 73 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 74 | */ |
| 75 | public static final int STATE_NO_IDMAP = 1; |
| 76 | |
| 77 | /** |
| 78 | * The overlay is currently disabled. It can be enabled. |
| 79 | * |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 80 | * @see IOverlayManager#setEnabled |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 81 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 82 | */ |
| 83 | public static final int STATE_DISABLED = 2; |
| 84 | |
| 85 | /** |
| 86 | * The overlay is currently enabled. It can be disabled. |
| 87 | * |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 88 | * @see IOverlayManager#setEnabled |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 89 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 90 | */ |
| 91 | public static final int STATE_ENABLED = 3; |
| 92 | |
| 93 | /** |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 94 | * The target package is currently being upgraded; the state will change |
| 95 | * once the package installation has finished. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 96 | * @hide |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 97 | */ |
| 98 | public static final int STATE_TARGET_UPGRADING = 4; |
| 99 | |
| 100 | /** |
| 101 | * The overlay package is currently being upgraded; the state will change |
| 102 | * once the package installation has finished. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 103 | * @hide |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 104 | */ |
| 105 | public static final int STATE_OVERLAY_UPGRADING = 5; |
| 106 | |
| 107 | /** |
Mårten Kongstad | a525e22 | 2018-04-10 16:57:33 +0200 | [diff] [blame] | 108 | * The overlay package is currently enabled because it is marked as |
| 109 | * 'static'. It cannot be disabled but will change state if for instance |
| 110 | * its target is uninstalled. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 111 | * @hide |
Mårten Kongstad | a525e22 | 2018-04-10 16:57:33 +0200 | [diff] [blame] | 112 | */ |
| 113 | public static final int STATE_ENABLED_STATIC = 6; |
| 114 | |
| 115 | /** |
| 116 | * Overlay category: theme. |
| 117 | * <p> |
| 118 | * Change how Android (including the status bar, dialogs, ...) looks. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 119 | * |
| 120 | * @hide |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 121 | */ |
| 122 | public static final String CATEGORY_THEME = "android.theme"; |
| 123 | |
| 124 | /** |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 125 | * Package name of the overlay package |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 126 | * |
| 127 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 128 | */ |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 129 | @SystemApi |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 130 | public final String packageName; |
| 131 | |
| 132 | /** |
| 133 | * Package name of the target package |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 134 | * |
| 135 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 136 | */ |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 137 | @SystemApi |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 138 | public final String targetPackageName; |
| 139 | |
| 140 | /** |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 141 | * Category of the overlay package |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 142 | * |
| 143 | * @hide |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 144 | */ |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 145 | @SystemApi |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 146 | public final String category; |
| 147 | |
| 148 | /** |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 149 | * Full path to the base APK for this overlay package |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 150 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 151 | */ |
| 152 | public final String baseCodePath; |
| 153 | |
| 154 | /** |
| 155 | * The state of this OverlayInfo as defined by the STATE_* constants in this class. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 156 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 157 | */ |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 158 | public final @State int state; |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * User handle for which this overlay applies |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 162 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 163 | */ |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 164 | @SystemApi |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 165 | public final int userId; |
| 166 | |
| 167 | /** |
Mårten Kongstad | 2f1944b | 2018-04-10 17:44:42 +0200 | [diff] [blame] | 168 | * Priority as read from the manifest. Used if isStatic is true. Not |
| 169 | * intended to be exposed to 3rd party. |
| 170 | * |
| 171 | * @hide |
| 172 | */ |
| 173 | public final int priority; |
| 174 | |
| 175 | /** |
| 176 | * isStatic as read from the manifest. If true, the overlay is |
| 177 | * unconditionally loaded and cannot be unloaded. Not intended to be |
| 178 | * exposed to 3rd party. |
| 179 | * |
| 180 | * @hide |
| 181 | */ |
| 182 | public final boolean isStatic; |
| 183 | |
| 184 | /** |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 185 | * Create a new OverlayInfo based on source with an updated state. |
| 186 | * |
| 187 | * @param source the source OverlayInfo to base the new instance on |
| 188 | * @param state the new state for the source OverlayInfo |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 189 | * |
| 190 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 191 | */ |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 192 | public OverlayInfo(@NonNull OverlayInfo source, @State int state) { |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 193 | this(source.packageName, source.targetPackageName, source.category, source.baseCodePath, |
Mårten Kongstad | 2f1944b | 2018-04-10 17:44:42 +0200 | [diff] [blame] | 194 | state, source.userId, source.priority, source.isStatic); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 195 | } |
| 196 | |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 197 | /** @hide */ |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 198 | public OverlayInfo(@NonNull String packageName, @NonNull String targetPackageName, |
Mårten Kongstad | 2f1944b | 2018-04-10 17:44:42 +0200 | [diff] [blame] | 199 | @NonNull String category, @NonNull String baseCodePath, int state, int userId, |
| 200 | int priority, boolean isStatic) { |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 201 | this.packageName = packageName; |
| 202 | this.targetPackageName = targetPackageName; |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 203 | this.category = category; |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 204 | this.baseCodePath = baseCodePath; |
| 205 | this.state = state; |
| 206 | this.userId = userId; |
Mårten Kongstad | 2f1944b | 2018-04-10 17:44:42 +0200 | [diff] [blame] | 207 | this.priority = priority; |
| 208 | this.isStatic = isStatic; |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 209 | ensureValidState(); |
| 210 | } |
| 211 | |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 212 | /** @hide */ |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 213 | public OverlayInfo(Parcel source) { |
| 214 | packageName = source.readString(); |
| 215 | targetPackageName = source.readString(); |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 216 | category = source.readString(); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 217 | baseCodePath = source.readString(); |
| 218 | state = source.readInt(); |
| 219 | userId = source.readInt(); |
Mårten Kongstad | 2f1944b | 2018-04-10 17:44:42 +0200 | [diff] [blame] | 220 | priority = source.readInt(); |
| 221 | isStatic = source.readBoolean(); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 222 | ensureValidState(); |
| 223 | } |
| 224 | |
| 225 | private void ensureValidState() { |
| 226 | if (packageName == null) { |
| 227 | throw new IllegalArgumentException("packageName must not be null"); |
| 228 | } |
| 229 | if (targetPackageName == null) { |
| 230 | throw new IllegalArgumentException("targetPackageName must not be null"); |
| 231 | } |
| 232 | if (baseCodePath == null) { |
| 233 | throw new IllegalArgumentException("baseCodePath must not be null"); |
| 234 | } |
| 235 | switch (state) { |
| 236 | case STATE_UNKNOWN: |
| 237 | case STATE_MISSING_TARGET: |
| 238 | case STATE_NO_IDMAP: |
| 239 | case STATE_DISABLED: |
| 240 | case STATE_ENABLED: |
Mårten Kongstad | a525e22 | 2018-04-10 16:57:33 +0200 | [diff] [blame] | 241 | case STATE_ENABLED_STATIC: |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 242 | case STATE_TARGET_UPGRADING: |
| 243 | case STATE_OVERLAY_UPGRADING: |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 244 | break; |
| 245 | default: |
| 246 | throw new IllegalArgumentException("State " + state + " is not a valid state"); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public int describeContents() { |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | @Override |
| 256 | public void writeToParcel(Parcel dest, int flags) { |
| 257 | dest.writeString(packageName); |
| 258 | dest.writeString(targetPackageName); |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 259 | dest.writeString(category); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 260 | dest.writeString(baseCodePath); |
| 261 | dest.writeInt(state); |
| 262 | dest.writeInt(userId); |
Mårten Kongstad | 2f1944b | 2018-04-10 17:44:42 +0200 | [diff] [blame] | 263 | dest.writeInt(priority); |
| 264 | dest.writeBoolean(isStatic); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 265 | } |
| 266 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 267 | public static final @android.annotation.NonNull Parcelable.Creator<OverlayInfo> CREATOR = |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 268 | new Parcelable.Creator<OverlayInfo>() { |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 269 | @Override |
| 270 | public OverlayInfo createFromParcel(Parcel source) { |
| 271 | return new OverlayInfo(source); |
| 272 | } |
| 273 | |
| 274 | @Override |
| 275 | public OverlayInfo[] newArray(int size) { |
| 276 | return new OverlayInfo[size]; |
| 277 | } |
| 278 | }; |
| 279 | |
| 280 | /** |
| 281 | * Return true if this overlay is enabled, i.e. should be used to overlay |
| 282 | * the resources in the target package. |
| 283 | * |
| 284 | * Disabled overlay packages are installed but are currently not in use. |
| 285 | * |
| 286 | * @return true if the overlay is enabled, else false. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 287 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 288 | */ |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 289 | @SystemApi |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 290 | public boolean isEnabled() { |
| 291 | switch (state) { |
| 292 | case STATE_ENABLED: |
Mårten Kongstad | a525e22 | 2018-04-10 16:57:33 +0200 | [diff] [blame] | 293 | case STATE_ENABLED_STATIC: |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 294 | return true; |
| 295 | default: |
| 296 | return false; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Translate a state to a human readable string. Only intended for |
| 302 | * debugging purposes. |
| 303 | * |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 304 | * @return a human readable String representing the state. |
Hyunyoung Song | 880a951 | 2018-12-20 11:24:48 -0800 | [diff] [blame] | 305 | * @hide |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 306 | */ |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 307 | public static String stateToString(@State int state) { |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 308 | switch (state) { |
| 309 | case STATE_UNKNOWN: |
| 310 | return "STATE_UNKNOWN"; |
| 311 | case STATE_MISSING_TARGET: |
| 312 | return "STATE_MISSING_TARGET"; |
| 313 | case STATE_NO_IDMAP: |
| 314 | return "STATE_NO_IDMAP"; |
| 315 | case STATE_DISABLED: |
| 316 | return "STATE_DISABLED"; |
| 317 | case STATE_ENABLED: |
| 318 | return "STATE_ENABLED"; |
Mårten Kongstad | a525e22 | 2018-04-10 16:57:33 +0200 | [diff] [blame] | 319 | case STATE_ENABLED_STATIC: |
| 320 | return "STATE_ENABLED_STATIC"; |
Mårten Kongstad | db0e34e | 2018-01-10 12:05:26 +0100 | [diff] [blame] | 321 | case STATE_TARGET_UPGRADING: |
| 322 | return "STATE_TARGET_UPGRADING"; |
| 323 | case STATE_OVERLAY_UPGRADING: |
| 324 | return "STATE_OVERLAY_UPGRADING"; |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 325 | default: |
| 326 | return "<unknown state>"; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public int hashCode() { |
| 332 | final int prime = 31; |
| 333 | int result = 1; |
| 334 | result = prime * result + userId; |
| 335 | result = prime * result + state; |
| 336 | result = prime * result + ((packageName == null) ? 0 : packageName.hashCode()); |
| 337 | result = prime * result + ((targetPackageName == null) ? 0 : targetPackageName.hashCode()); |
Mårten Kongstad | 3e93311 | 2018-04-09 14:29:36 +0200 | [diff] [blame] | 338 | result = prime * result + ((category == null) ? 0 : category.hashCode()); |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 339 | result = prime * result + ((baseCodePath == null) ? 0 : baseCodePath.hashCode()); |
| 340 | return result; |
| 341 | } |
| 342 | |
| 343 | @Override |
| 344 | public boolean equals(Object obj) { |
| 345 | if (this == obj) { |
| 346 | return true; |
| 347 | } |
| 348 | if (obj == null) { |
| 349 | return false; |
| 350 | } |
| 351 | if (getClass() != obj.getClass()) { |
| 352 | return false; |
| 353 | } |
| 354 | OverlayInfo other = (OverlayInfo) obj; |
| 355 | if (userId != other.userId) { |
| 356 | return false; |
| 357 | } |
| 358 | if (state != other.state) { |
| 359 | return false; |
| 360 | } |
| 361 | if (!packageName.equals(other.packageName)) { |
| 362 | return false; |
| 363 | } |
| 364 | if (!targetPackageName.equals(other.targetPackageName)) { |
| 365 | return false; |
| 366 | } |
Adrian Roos | c84df77 | 2018-01-19 21:20:22 +0100 | [diff] [blame] | 367 | if (!category.equals(other.category)) { |
| 368 | return false; |
| 369 | } |
Mårten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 370 | if (!baseCodePath.equals(other.baseCodePath)) { |
| 371 | return false; |
| 372 | } |
| 373 | return true; |
| 374 | } |
| 375 | |
| 376 | @Override |
| 377 | public String toString() { |
| 378 | return "OverlayInfo { overlay=" + packageName + ", target=" + targetPackageName + ", state=" |
| 379 | + state + " (" + stateToString(state) + "), userId=" + userId + " }"; |
| 380 | } |
| 381 | } |