Fix a bug where device index is not skipped correct.

When checking language/build fingerprint to skip reindex, language check
was comparing Locale object and String object, so they would never be
equal, so we accidentally reindex every time.

- Switched Objects.equal to TextUtils.equal, this catches the error at
compiler level.

Bug: 80065409
Test: compile/robotest
Change-Id: I2b3c68bb1c2fd876338f42321605567d7e64d64b
This commit is contained in:
Fan Zhang
2018-05-25 16:05:58 -07:00
parent 2357c1cd84
commit 548485336f
2 changed files with 12 additions and 8 deletions

View File

@@ -24,6 +24,7 @@ import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.android.settings.R;
@@ -32,7 +33,6 @@ import com.android.settings.slices.SettingsSliceProvider;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
public interface DeviceIndexFeatureProvider {
@@ -96,10 +96,11 @@ public interface DeviceIndexFeatureProvider {
}
static boolean skipIndex(Context context) {
final boolean isSameVersion = Objects.equals(
final boolean isSameVersion = TextUtils.equals(
Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION);
final boolean isSameLanguage = Objects.equals(
Settings.Secure.getString(context.getContentResolver(), INDEX_LANGUAGE), LANGUAGE);
final boolean isSameLanguage = TextUtils.equals(
Settings.Secure.getString(context.getContentResolver(), INDEX_LANGUAGE),
LANGUAGE.toString());
return isSameLanguage && isSameVersion;
}