1 /*
2  * Copyright 2024 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 androidx.core.backported.fixes
18 
19 /** List of all known issue reportable by [BackportedFixManager] */
20 internal class KnownIssue
21 private constructor(
22 
23     /**
24      * The public id of this issue in the [Google Issue Tracker](https://issuetracker.google.com)
25      */
26     val id: Long,
27     /**
28      * The alias for this issue, if one exists.
29      *
30      * Known issues can have at most one alias.
31      *
32      * The value 0 indicates there is no alias for this issue. Non-zero alias values are unique
33      * across all known issues.
34      */
35     val alias: Int
36 ) {
37     // TODO b/381266031 - Make public
38     // TODO b/381267367 - Add link to public list issues
39 
40     /**
41      * The url to the [Google Issue Tracker](https://issuetracker.google.com) for this known issue.
42      */
43     internal val url = "https://issuetracker.google.com/issues/$id"
44 
equalsnull45     override fun equals(other: Any?) = other is KnownIssue && id == other.id
46 
47     override fun hashCode() = id.hashCode()
48 
49     override fun toString(): String {
50         return if (alias == 0) {
51             "$id without alias"
52         } else {
53             "$id with alias $alias"
54         }
55     }
56 
57     companion object {
58         // keep-sorted start newline_separated=yes sticky_prefixes=/*
59         /** Sample known issue that is always fixed on a device. */
60         @JvmField val KI_350037023 = KnownIssue(350037023L, 1)
61 
62         /** Sample known issue that is never fixed on a device. */
63         @JvmField val KI_350037348 = KnownIssue(350037348L, 3)
64 
65         /** Sample known issue that is only applies to robolectric devices */
66         @JvmField val KI_372917199 = KnownIssue(372917199L, 2)
67 
68         // keep-sorted end
69 
<lambda>null70         private val values by lazy {
71             listOf(
72                 // keep-sorted start
73                 KI_350037023,
74                 KI_350037348,
75                 KI_372917199,
76                 // keep-sorted end
77             )
78         }
79 
80         /** List of all known issues */
81         @JvmStatic
valuesnull82         internal fun values(): List<KnownIssue> {
83             return values
84         }
85     }
86 }
87