From 01709c7469b59e451f064c266bbe442e9bef0ab4 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Thu, 24 Oct 2019 18:50:51 -0700 Subject: Make AFont_getLocale work There are multiple problems here: - Java Font.equals and hashCode doesn't look at locale list. Due to this issue, the CTS tests have been passing unexpectedly. - The null pointer check in the AFont_getLoacle was inversed. Should return only when it is non-null. - Looks like we cannot get the parent's attribute which always returns null. Instead, read the "lang" attribute when we read the family tag. Bug: 139201432 Test: atest NativeSystemFontTest Test: atest TypefaceEqualsTest Change-Id: I0514847bbf46a73358afab374ccfce2db09b2ec0 --- graphics/java/android/graphics/fonts/Font.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/fonts/Font.java b/graphics/java/android/graphics/fonts/Font.java index 552088f7c478..ba96a06cc852 100644 --- a/graphics/java/android/graphics/fonts/Font.java +++ b/graphics/java/android/graphics/fonts/Font.java @@ -519,12 +519,13 @@ public final class Font { } Font f = (Font) o; return mFontStyle.equals(f.mFontStyle) && f.mTtcIndex == mTtcIndex - && Arrays.equals(f.mAxes, mAxes) && f.mBuffer.equals(mBuffer); + && Arrays.equals(f.mAxes, mAxes) && f.mBuffer.equals(mBuffer) + && Objects.equals(f.mLocaleList, mLocaleList); } @Override public int hashCode() { - return Objects.hash(mFontStyle, mTtcIndex, Arrays.hashCode(mAxes), mBuffer); + return Objects.hash(mFontStyle, mTtcIndex, Arrays.hashCode(mAxes), mBuffer, mLocaleList); } @Override -- cgit v1.2.3-59-g8ed1b