OSDN Git Service

Localization: do not use private ICU APIs
authorAlexander Martinz <amartinz@shiftphones.com>
Wed, 30 Jan 2019 22:05:12 +0000 (23:05 +0100)
committerAlexander Martinz <amartinz@shiftphones.com>
Thu, 31 Jan 2019 17:56:14 +0000 (18:56 +0100)
Instead of using private ICU APIs for checking, if the ICU's version
has been updated, use the android sdk version.

It is safe to assume, that ICU version does not change randomly and if
then only on major Android version upgrades.

Change-Id: Ia348a5597aa472d44b766b869a31a3935723f210
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
src/org/lineageos/eleven/locale/LocaleSetManager.java
src/org/lineageos/eleven/provider/LocalizedStore.java

index 6e49f9e..18b9e86 100644 (file)
@@ -18,6 +18,7 @@ package org.lineageos.eleven.locale;
 
 import android.content.Context;
 import android.support.annotation.VisibleForTesting;
+import android.os.Build;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -25,8 +26,6 @@ import org.lineageos.eleven.provider.PropertiesStore;
 
 import java.util.Locale;
 
-import libcore.icu.ICU;
-
 public class LocaleSetManager {
     private static final String TAG = LocaleSetManager.class.getSimpleName();
 
@@ -57,9 +56,9 @@ public class LocaleSetManager {
         // if our icu version has changed, return true
         final String storedICUversion = PropertiesStore.getInstance(mContext)
                 .getProperty(PropertiesStore.DbProperties.ICU_VERSION);
-        if (!ICU.getIcuVersion().equals(storedICUversion)) {
+        if (!String.valueOf(Build.VERSION.SDK_INT).equals(storedICUversion)) {
             Log.d(TAG, "ICU version has changed from: " + storedICUversion + " to "
-                    + ICU.getIcuVersion());
+                    + String.valueOf(Build.VERSION.SDK_INT));
             return true;
         }
 
index 363ae20..76c7ea3 100644 (file)
@@ -19,6 +19,7 @@ import android.content.ContentValues;
 import android.content.Context;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
+import android.os.Build;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.Message;
@@ -38,8 +39,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import libcore.icu.ICU;
-
 /**
  * Because sqlite localized collator isn't sufficient, we need to store more specialized logic
  * into our own db similar to contacts db.  This is most noticeable in languages like Chinese,
@@ -178,8 +177,10 @@ public class LocalizedStore {
 
             // Update the ICU version used to generate the locale derived data
             // so we can tell when we need to rebuild with new ICU versions.
+            // But assume that ICU versions are only able to change on Android version upgrades and
+            // use SDK INT as identifier.
             PropertiesStore.getInstance(mContext).storeProperty(
-                    PropertiesStore.DbProperties.ICU_VERSION, ICU.getIcuVersion());
+                    PropertiesStore.DbProperties.ICU_VERSION, String.valueOf(Build.VERSION.SDK_INT));
             PropertiesStore.getInstance(mContext).storeProperty(PropertiesStore.DbProperties.LOCALE,
                     locales.toString());