summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/LauncherProvider.java76
-rw-r--r--src/com/android/launcher3/Utilities.java10
2 files changed, 85 insertions, 1 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index dd2f48b18..753f6e746 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -56,12 +56,13 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Set;
public class LauncherProvider extends ContentProvider {
private static final String TAG = "Launcher.LauncherProvider";
private static final boolean LOGD = false;
- private static final int DATABASE_VERSION = 21;
+ private static final int DATABASE_VERSION = 22;
static final String OLD_AUTHORITY = "com.android.launcher2.settings";
static final String AUTHORITY = ProviderConfig.AUTHORITY;
@@ -936,6 +937,11 @@ public class LauncherProvider extends ContentProvider {
version = 21;
}
+ if (oldVersion < 22) {
+ updateDialtactsLauncher(db);
+ version = 22;
+ }
+
if (version != DATABASE_VERSION) {
Log.w(TAG, "Destroying all old data.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_FAVORITES);
@@ -986,6 +992,74 @@ public class LauncherProvider extends ContentProvider {
return true;
}
+ private void updateDialtactsLauncher(SQLiteDatabase db) {
+ if (!Utilities.isPackageInstalled(mContext, "com.cyngn.dialer")) {
+ return;
+ }
+
+ final String cyngnDialer = "com.cyngn.dialer";
+ final String aospDialer = "com.android.dialer";
+ final String dialtactsClass = "com.android.dialer.DialtactsActivity";
+
+ final String selectWhere = buildOrWhereString(Favorites.ITEM_TYPE,
+ new int[]{Favorites.ITEM_TYPE_SHORTCUT, Favorites.ITEM_TYPE_APPLICATION});
+ Cursor c = null;
+ db.beginTransaction();
+
+ try {
+ // Select and iterate through each matching widget
+ c = db.query(TABLE_FAVORITES,
+ new String[] { Favorites._ID, Favorites.INTENT },
+ selectWhere, null, null, null, null);
+ if (c == null) return;
+
+ while (c.moveToNext()) {
+ long favoriteId = c.getLong(0);
+ final String intentUri = c.getString(1);
+ if (intentUri != null) {
+ try {
+ final Intent intent = Intent.parseUri(intentUri, 0);
+ final ComponentName componentName = intent.getComponent();
+ final Set<String> categories = intent.getCategories();
+
+ if (Intent.ACTION_MAIN.equals(intent.getAction()) &&
+ componentName != null &&
+ aospDialer.equals(componentName.getPackageName()) &&
+ dialtactsClass.equals(componentName.getClassName()) &&
+ categories != null &&
+ categories.contains(Intent.CATEGORY_LAUNCHER)) {
+
+ final ComponentName newName = new ComponentName(cyngnDialer,
+ componentName.getClassName());
+ intent.setComponent(newName);
+ final ContentValues values = new ContentValues();
+ values.put(Favorites.INTENT, intent.toUri(0));
+
+ String updateWhere = Favorites._ID + "=" + favoriteId;
+ db.update(TABLE_FAVORITES, values, updateWhere, null);
+ if (Log.isLoggable(TAG, Log.INFO)) {
+ Log.i(TAG, "Updated " + componentName + " to " + newName);
+ }
+ }
+ } catch (RuntimeException ex) {
+ Log.e(TAG, "Problem moving Dialtacts activity", ex);
+ } catch (URISyntaxException e) {
+ Log.e(TAG, "Problem moving Dialtacts activity", e);
+ }
+ }
+ }
+
+ db.setTransactionSuccessful();
+ } catch (SQLException ex) {
+ Log.w(TAG, "Problem while upgrading dialtacts icon", ex);
+ } finally {
+ db.endTransaction();
+ if (c != null) {
+ c.close();
+ }
+ }
+ }
+
private boolean updateContactsShortcuts(SQLiteDatabase db) {
final String selectWhere = buildOrWhereString(Favorites.ITEM_TYPE,
new int[] { Favorites.ITEM_TYPE_SHORTCUT });
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index cfadeaa5c..8fe2e841b 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -617,4 +617,14 @@ public final class Utilities {
}
return defaultWidgetForSearchPackage;
}
+
+ public static boolean isPackageInstalled(Context context, String pkg) {
+ PackageManager packageManager = context.getPackageManager();
+ try {
+ PackageInfo pi = packageManager.getPackageInfo(pkg, 0);
+ return pi.applicationInfo.enabled;
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
}