Remove instances of identical operands in binary expression
These are almost certainly all bugs. Removing them and enabling the
errorprone warning as an error going forward will hopefully avoid
further instances creeping in to the code base.
Bug: 217923092
Test: atest AdbDebuggingManagerTest AppTransitionControllerTest
errorprone build
Change-Id: I51fb57024eb19f1b4c96b2033bbafdb610ef2ebb
diff --git a/services/Android.bp b/services/Android.bp
index 4dcf7d4..1bb283e 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -24,6 +24,7 @@
"-Xep:ArrayHashCode:ERROR",
"-Xep:SelfAssignment:ERROR",
"-Xep:ArrayEquals:ERROR",
+ "-Xep:IdentityBinaryExpression:ERROR",
// NOTE: only enable to generate local patchfiles
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
// "-XepPatchLocation:/tmp/refaster/",
diff --git a/services/core/java/com/android/server/wm/AppTransitionController.java b/services/core/java/com/android/server/wm/AppTransitionController.java
index 475a9fb..457ea13 100644
--- a/services/core/java/com/android/server/wm/AppTransitionController.java
+++ b/services/core/java/com/android/server/wm/AppTransitionController.java
@@ -249,7 +249,7 @@
overrideWithRemoteAnimationIfSet(animLpActivity, transit, activityTypes);
}
- final boolean voiceInteraction = containsVoiceInteraction(mDisplayContent.mOpeningApps)
+ final boolean voiceInteraction = containsVoiceInteraction(mDisplayContent.mClosingApps)
|| containsVoiceInteraction(mDisplayContent.mOpeningApps);
final int layoutRedo;
diff --git a/services/tests/servicestests/src/com/android/server/adb/AdbDebuggingManagerTest.java b/services/tests/servicestests/src/com/android/server/adb/AdbDebuggingManagerTest.java
index 02cf971..b36aa06 100644
--- a/services/tests/servicestests/src/com/android/server/adb/AdbDebuggingManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/adb/AdbDebuggingManagerTest.java
@@ -635,7 +635,7 @@
long time = System.currentTimeMillis();
for (String key : testKeys) {
long connectionTime = adbKeyStore.getLastConnectionTime(key);
- if (Math.abs(connectionTime - connectionTime) > epsilon) {
+ if (Math.abs(time - connectionTime) > epsilon) {
fail("The connection time for a previously untracked key, " + connectionTime
+ ", is beyond the current time of " + time);
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
index ea7804d..d99fbb1 100644
--- a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
@@ -2048,8 +2048,7 @@
protected List<ShortcutInfo> getShortcutAsLauncher(int targetUserId) {
final ShortcutQuery q = new ShortcutQuery();
- q.setQueryFlags(ShortcutQuery.FLAG_MATCH_DYNAMIC | ShortcutQuery.FLAG_MATCH_DYNAMIC
- | ShortcutQuery.FLAG_MATCH_PINNED);
+ q.setQueryFlags(ShortcutQuery.FLAG_MATCH_DYNAMIC | ShortcutQuery.FLAG_MATCH_PINNED);
return mLauncherApps.getShortcuts(q, UserHandle.of(targetUserId));
}