Merge "Re-scan all directories only after OTAs."
diff --git a/src/com/android/providers/contacts/ContactDirectoryManager.java b/src/com/android/providers/contacts/ContactDirectoryManager.java
index b7039a2..447ab28 100644
--- a/src/com/android/providers/contacts/ContactDirectoryManager.java
+++ b/src/com/android/providers/contacts/ContactDirectoryManager.java
@@ -175,7 +175,7 @@
*/
public void scanAllPackages(boolean rescan) {
if (rescan || !areTypeResourceIdsValid()) {
- getDbHelper().setProperty(DbProperties.DIRECTORY_SCAN_COMPLETE, "0");
+ getDbHelper().clearDirectoryScanComplete();
}
scanAllPackagesIfNeeded();
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 6bc42a4..dc301f8 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -5629,6 +5629,10 @@
PropertyUtils.setProperty(getWritableDatabase(), key, value);
}
+ public void clearDirectoryScanComplete() {
+ setProperty(DbProperties.DIRECTORY_SCAN_COMPLETE, "0");
+ }
+
/**
* Test if the given column appears in the given projection.
*/
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 3689f90..e17da20 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -1763,7 +1763,6 @@
initForDefaultLocale();
mReadAccessLatch.countDown();
mReadAccessLatch = null;
- updateDirectoriesInBackground(true);
break;
}
diff --git a/src/com/android/providers/contacts/ContactsUpgradeReceiver.java b/src/com/android/providers/contacts/ContactsUpgradeReceiver.java
index 99727bc..57c0cd0 100644
--- a/src/com/android/providers/contacts/ContactsUpgradeReceiver.java
+++ b/src/com/android/providers/contacts/ContactsUpgradeReceiver.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.os.RemoteException;
import android.util.Log;
@@ -42,6 +43,7 @@
static final String TAG = "ContactsUpgradeReceiver";
static final String PREF_DB_VERSION = "db_version";
static final String PREF_ICU_VERSION = "icu_version";
+ static final String PREF_OS_VERSION = "os_version";
@Override
public void onReceive(Context context, Intent intent) {
@@ -52,14 +54,19 @@
long startTime = System.currentTimeMillis();
// Lookup the last known database version
- SharedPreferences prefs = context.getSharedPreferences(TAG, Context.MODE_PRIVATE);
- int prefDbVersion = prefs.getInt(PREF_DB_VERSION, 0);
+ final SharedPreferences prefs = context.getSharedPreferences(TAG, Context.MODE_PRIVATE);
+ final int prefDbVersion = prefs.getInt(PREF_DB_VERSION, 0);
+
final String curIcuVersion = ICU.getIcuVersion();
+ final String curOsVersion = getOsVersionString();
+
final String prefIcuVersion = prefs.getString(PREF_ICU_VERSION, "");
+ final String prefOsVersion = prefs.getString(PREF_OS_VERSION, "");
// If the version is old go ahead and attempt to create or upgrade the database.
if (prefDbVersion != ContactsDatabaseHelper.DATABASE_VERSION ||
- !prefIcuVersion.equals(curIcuVersion)) {
+ !prefIcuVersion.equals(curIcuVersion) ||
+ !prefOsVersion.equals(curOsVersion)) {
// Store the current version so this receiver isn't run again until the database
// version number changes. This is intentionally done even before the upgrade path
// is attempted to be conservative. If the upgrade fails for some reason and we
@@ -67,6 +74,7 @@
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(PREF_DB_VERSION, ContactsDatabaseHelper.DATABASE_VERSION);
editor.putString(PREF_ICU_VERSION, curIcuVersion);
+ editor.putString(PREF_OS_VERSION, curOsVersion);
editor.commit();
// Ask for a reference to the database to force the helper to either
@@ -79,8 +87,11 @@
Log.i(TAG, "Creating or opening contacts database");
helper.getWritableDatabase();
+ helper.clearDirectoryScanComplete();
+
profileHelper.getWritableDatabase();
calllogHelper.getWritableDatabase();
+
ContactsProvider2.updateLocaleOffline(context, helper, profileHelper);
// Log the total time taken for the receiver to perform the operation
@@ -96,4 +107,8 @@
PackageManager.DONT_KILL_APP);
}
}
+
+ private static String getOsVersionString() {
+ return Build.ID;
+ }
}