From 5ca206ffdf1a26086d8cd7397a46d82de9aca435 Mon Sep 17 00:00:00 2001 From: iusmac Date: Tue, 20 Aug 2024 19:33:23 +0200 Subject: [PATCH] fix: address highly critical errorprone issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Task :compileDebugJavaWithJavac • 1 src/com/github/iusmac/sevensim/scheduler/SubscriptionScheduleEntity.java:104: error: [EqualsHashCode] Classes that override equals should also override hashCode. public boolean equals(final Object o) { ^ (see https://errorprone.info/bugpattern/EqualsHashCode) • 2 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:71: error: [GuardedBy] Invalid @GuardedBy expression: static member guarded by instance private static Locale sDefaultLocaleCache; ^ (see https://errorprone.info/bugpattern/GuardedBy) • 3 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:73: error: [GuardedBy] Invalid @GuardedBy expression: static member guarded by instance private static String[] sDaysOfWeekNarrowStrings; ^ (see https://errorprone.info/bugpattern/GuardedBy) • 4 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:269: error: [GuardedBy] This access should be guarded by 'DaysOfWeek'; instead found: 'this' if (sDaysOfWeekNarrowStrings == null || !loc.equals(sDefaultLocaleCache)) { ^ (see https://errorprone.info/bugpattern/GuardedBy) • 5 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:269: error: [GuardedBy] This access should be guarded by 'DaysOfWeek'; instead found: 'this' if (sDaysOfWeekNarrowStrings == null || !loc.equals(sDefaultLocaleCache)) { ^ (see https://errorprone.info/bugpattern/GuardedBy) • 6 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:270: error: [GuardedBy] This access should be guarded by 'DaysOfWeek'; instead found: 'this' sDaysOfWeekNarrowStrings = DateFormatSymbols.getInstance(loc) ^ (see https://errorprone.info/bugpattern/GuardedBy) • 7 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:272: error: [GuardedBy] This access should be guarded by 'DaysOfWeek'; instead found: 'this' sDefaultLocaleCache = loc; ^ (see https://errorprone.info/bugpattern/GuardedBy) • 8 src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java:274: error: [GuardedBy] This access should be guarded by 'DaysOfWeek'; instead found: 'this' return sDaysOfWeekNarrowStrings[dayOfWeek]; ^ (see https://errorprone.info/bugpattern/GuardedBy) • 9 src/com/github/iusmac/sevensim/telephony/Subscription.java:143: error: [BoxedPrimitiveEquality] Comparison using reference equality instead of value equality. Reference equality of boxed primitive types is usually not useful, as they are value objects, and it is bug-prone, as instances are cached for some values but not others. && mKeepDisabledAcrossBoots == subToCompare.mKeepDisabledAcrossBoots; ^ (see https://errorprone.info/bugpattern/BoxedPrimitiveEquality) Did you mean '&& Objects.equals(mKeepDisabledAcrossBoots, subToCompare.mKeepDisabledAcrossBoots);' or '&& mKeepDisabledAcrossBoots.equals(subToCompare.mKeepDisabledAcrossBoots);'? • 10 src/com/github/iusmac/sevensim/telephony/TelephonyController.java:369: error: [GuardedBy] This access should be guarded by 'TelephonyController.this', which is not currently held final Subscription sub = BundleCompat.getParcelable(mRequestMetadata, KEY_SUBSCRIPTION, ^ (see https://errorprone.info/bugpattern/GuardedBy) • 11 src/com/github/iusmac/sevensim/telephony/PinStorage.java:55: error: [GuardedBy] Invalid @GuardedBy expression: static member guarded by instance private static long sLastKeystoreAuthTimestamp; ^ (see https://errorprone.info/bugpattern/GuardedBy) • 12 src/com/github/iusmac/sevensim/telephony/PinStorage.java:381: error: [GuardedBy] This access should be guarded by 'PinStorage'; instead found: 'this' final long authTimeout = sLastKeystoreAuthTimestamp == 0 ? 0 : sLastKeystoreAuthTimestamp + ^ (see https://errorprone.info/bugpattern/GuardedBy) • 13 src/com/github/iusmac/sevensim/telephony/PinStorage.java:381: error: [GuardedBy] This access should be guarded by 'PinStorage'; instead found: 'this' final long authTimeout = sLastKeystoreAuthTimestamp == 0 ? 0 : sLastKeystoreAuthTimestamp + ^ (see https://errorprone.info/bugpattern/GuardedBy) • 14 src/com/github/iusmac/sevensim/telephony/PinStorage.java:394: error: [GuardedBy] This access should be guarded by 'PinStorage'; instead found: 'PinStorage.class' sLastKeystoreAuthTimestamp = timestamp; ^ (see https://errorprone.info/bugpattern/GuardedBy) • 15 src/com/github/iusmac/sevensim/ui/components/ItemAdapter.java:456: error: [EqualsHashCode] Classes that override equals should also override hashCode. public boolean equals(final Object o) { ^ (see https://errorprone.info/bugpattern/EqualsHashCode) Signed-off-by: iusmac --- .../iusmac/sevensim/scheduler/DaysOfWeek.java | 7 ++-- .../scheduler/SubscriptionScheduleEntity.java | 7 ++++ .../iusmac/sevensim/telephony/PinStorage.java | 14 ++++--- .../sevensim/telephony/SimPinFeeder.java | 36 +++++++++------- .../sevensim/telephony/Subscription.java | 2 +- .../telephony/TelephonyController.java | 41 ++++++++++++------- .../sevensim/ui/components/ItemAdapter.java | 6 +++ 7 files changed, 73 insertions(+), 40 deletions(-) diff --git a/src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java b/src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java index a37ca96..2f2b0f2 100644 --- a/src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java +++ b/src/com/github/iusmac/sevensim/scheduler/DaysOfWeek.java @@ -67,9 +67,10 @@ public final class DaysOfWeek implements Iterable, Comparable