Allow the old launcher content URI to be overrided
Move the URI used to import favorites from launcher2 to be loaded
from a string resource. This allows it to be overridden.
This will enable permissions fix for GoogleSearch.
Bug: 12058200
Change-Id: I31243fe89f545c9771d5cceffe1c9e7668a42bc5
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8ba58e5..b963edd 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -20,6 +20,10 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- General -->
<skip />
+
+ <!-- URI used to import old favorites. [DO NOT TRANSLATE] -->
+ <string name="old_launcher_provider_uri" translatable="false">content://com.android.launcher2.settings/favorites?notify=true</string>
+
<!-- Application name -->
<string name="application_name">Launcher3</string>
<!-- Accessibility-facing application name -->
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 145d225..937f02b 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -193,7 +193,7 @@
mAppsCanBeOnRemoveableStorage = Environment.isExternalStorageRemovable();
ContentProviderClient client = contentResolver.acquireContentProviderClient(
- LauncherSettings.Favorites.OLD_CONTENT_URI);
+ Uri.parse(context.getString(R.string.old_launcher_provider_uri)));
mOldContentProviderExists = (client != null);
if (client != null) {
client.release();
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 2a64525..734db65 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -329,7 +329,7 @@
public void migrateLauncher2Shortcuts() {
mOpenHelper.migrateLauncher2Shortcuts(mOpenHelper.getWritableDatabase(),
- LauncherSettings.Favorites.OLD_CONTENT_URI);
+ Uri.parse(getContext().getString(R.string.old_launcher_provider_uri)));
}
private static int getDefaultWorkspaceResourceId() {
@@ -466,7 +466,7 @@
"/old_favorites?notify=true");
if (!convertDatabase(db, uri, permuteScreensCb, true)) {
// Try and upgrade from the Launcher2 db
- uri = LauncherSettings.Favorites.OLD_CONTENT_URI;
+ uri = Uri.parse(mContext.getString(R.string.old_launcher_provider_uri));
if (!convertDatabase(db, uri, permuteScreensCb, false)) {
// If we fail, then set a flag to load the default workspace
setFlagEmptyDbCreated();