From 41eab2c20329316b3263df1a88b1671302b4e807 Mon Sep 17 00:00:00 2001 From: hughchen Date: Wed, 14 Aug 2019 16:27:12 +0800 Subject: [PATCH] Fix flaky test error Before this CL, we didn't consider the case of two preferences timestamp are the same. If 2 preferences timestamp are the same, the second preference will first out. it will cause test case will fail some times. In this CL, if two BluetoothDevicePreference's timestamp are the same, The first BluetoothDevicePreference is first out. Bug: 138547532 Test: make -j42 RunSettingsRoboTests Change-Id: I7366275e8edf615c582481a570ea0c25b8d37a66 --- .../android/settings/bluetooth/BluetoothDevicePreference.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java index c56c50e45d3..a8b1c97f2e8 100644 --- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java +++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java @@ -221,7 +221,7 @@ public final class BluetoothDevicePreference extends GearPreference implements return mCachedDevice .compareTo(((BluetoothDevicePreference) another).mCachedDevice); case SortType.TYPE_FIFO: - return (int)(mCurrentTime - ((BluetoothDevicePreference) another).mCurrentTime); + return mCurrentTime > ((BluetoothDevicePreference) another).mCurrentTime ? 1 : -1; default: return super.compareTo(another); }