Add boot message when upgrading databases.
Change-Id: Ieb3b68e4c28641b86b20b0cbb567be4d333ec788
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7e6968b..18ee2c6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -21,6 +21,9 @@
<!-- Label to show to user for this package. -->
<string name="app_label">Media Storage</string>
+ <!-- [CHAR LIMIT=NONE] Boot message while upgrading media provider. -->
+ <string name="upgrade_msg">Upgrading Media database.</string>
+
<!-- Description line for music artists in the search/suggestion results -->
<string name="artist_label">Artist</string>
</resources>
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index fc70b73..fd5effe 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -4414,7 +4414,8 @@
private static String TAG = "MediaProvider";
private static final boolean LOCAL_LOGV = false;
- private static final int DATABASE_VERSION = 407;
+
+ static final int DATABASE_VERSION = 407;
private static final String INTERNAL_DATABASE_NAME = "internal.db";
private static final String EXTERNAL_DATABASE_NAME = "external.db";
diff --git a/src/com/android/providers/media/MediaUpgradeReceiver.java b/src/com/android/providers/media/MediaUpgradeReceiver.java
index 0e5a45c..f9eb5ba 100644
--- a/src/com/android/providers/media/MediaUpgradeReceiver.java
+++ b/src/com/android/providers/media/MediaUpgradeReceiver.java
@@ -18,10 +18,13 @@
import java.io.File;
+import android.app.ActivityManagerNative;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
+import android.os.RemoteException;
import android.util.Log;
import android.util.Slog;
@@ -44,12 +47,26 @@
// We are now running with the system up, but no apps started,
// so can do whatever cleanup after an upgrade that we want.
+ // Lookup the last known database version
+ SharedPreferences prefs = context.getSharedPreferences(TAG, Context.MODE_PRIVATE);
+ int prefVersion = prefs.getInt(PREF_DB_VERSION, 0);
+ if (prefVersion == MediaProvider.DATABASE_VERSION) {
+ return;
+ }
+ prefs.edit().putInt(PREF_DB_VERSION, MediaProvider.DATABASE_VERSION).commit();
+
try {
File dbDir = context.getDatabasePath("foo").getParentFile();
String[] files = dbDir.list();
for (int i=0; i<files.length; i++) {
String file = files[i];
if (MediaProvider.isMediaDatabaseName(file)) {
+ try {
+ ActivityManagerNative.getDefault().showBootMessage(
+ context.getText(R.string.upgrade_msg), true);
+ } catch (RemoteException e) {
+ }
+
long startTime = System.currentTimeMillis();
Slog.i(TAG, "---> Start upgrade of media database " + file);
SQLiteDatabase db = null;