OSDN Git Service

Fix ImeSubtypeListItem#compareTo()
authorYohei Yukawa <yukawa@google.com>
Tue, 24 Jan 2017 08:29:07 +0000 (00:29 -0800)
committerYohei Yukawa <yukawa@google.com>
Tue, 24 Jan 2017 08:29:07 +0000 (00:29 -0800)
commit410cc501b2066bc2fddbe58a67260673df642aae
tree719a08c01f12f8258f7288bc908eb4fc20538d51
parent4ea4f63d28efe745051f0887c8a1e70f916fe500
Fix ImeSubtypeListItem#compareTo()

It turns out that ImeSubtypeListItem#compareTo() does not satisfy the
contract of Comparable#compareTo(), which can trigger
IllegalArgumentException from Collections.sort() depending on the
runtime condition.

This CL makes it clear that two instances of ImeSubtypeListItem will be
compared with with those fileds in the following order.

  1. ImeSubtypeListItem#mImeName
  2. ImeSubtypeListItem#mSubtypeName
  3. ImeSubtypeListItem#mIsSystemLocale
  4. ImeSubtypeListItem#mIsSystemLanguage

Bug: 34255739
Test: adb shell am instrument -w -e class com.android.internal.inputmethod.InputMethodSubtypeSwitchingControllerTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I47f902cc8f5873926d238c30e462d08d7dbebcf7
core/java/com/android/internal/inputmethod/InputMethodSubtypeSwitchingController.java
core/tests/coretests/src/com/android/internal/inputmethod/InputMethodSubtypeSwitchingControllerTest.java