Fix issue #2483335: android.content.res.cts.ConfigurationTest test's are failing
Change-Id: Ic2d10809c88f24d84e58d9f2edfd95912af29038
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 54fc044..6598264 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -597,12 +597,18 @@
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 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;