OSDN Git Service

Fix issue #2483335: android.content.res.cts.ConfigurationTest test's are failing
authorDianne Hackborn <hackbod@google.com>
Fri, 12 Mar 2010 18:52:22 +0000 (10:52 -0800)
committerDianne Hackborn <hackbod@google.com>
Fri, 12 Mar 2010 19:01:06 +0000 (11:01 -0800)
Change-Id: Ic2d10809c88f24d84e58d9f2edfd95912af29038

core/java/android/content/res/Configuration.java

index 54fc044..6598264 100644 (file)
@@ -597,12 +597,18 @@ public final class Configuration implements Parcelable, Comparable<Configuration
         if (n != 0) return n;
         n = this.mnc - that.mnc;
         if (n != 0) return n;
-        n = this.locale.getLanguage().compareTo(that.locale.getLanguage());
-        if (n != 0) return n;
-        n = this.locale.getCountry().compareTo(that.locale.getCountry());
-        if (n != 0) return n;
-        n = this.locale.getVariant().compareTo(that.locale.getVariant());
-        if (n != 0) return n;
+        if (this.locale == null) {
+            if (that.locale != null) return 1;
+        } else if (that.locale == null) {
+            return -1;
+        } else {
+            n = this.locale.getLanguage().compareTo(that.locale.getLanguage());
+            if (n != 0) return n;
+            n = this.locale.getCountry().compareTo(that.locale.getCountry());
+            if (n != 0) return n;
+            n = this.locale.getVariant().compareTo(that.locale.getVariant());
+            if (n != 0) return n;
+        }
         n = this.touchscreen - that.touchscreen;
         if (n != 0) return n;
         n = this.keyboard - that.keyboard;
@@ -640,7 +646,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     
     public int hashCode() {
         return ((int)this.fontScale) + this.mcc + this.mnc
-                + this.locale.hashCode() + this.touchscreen
+                + (this.locale != null ? this.locale.hashCode() : 0)
+                + this.touchscreen
                 + this.keyboard + this.keyboardHidden + this.hardKeyboardHidden
                 + this.navigation + this.navigationHidden
                 + this.orientation + this.screenLayout + this.uiMode;