From 3a3b2594e55ea01d5cd31a0e3f928afd25b6ce0e Mon Sep 17 00:00:00 2001 From: Jan Altensen Date: Wed, 1 Dec 2021 12:46:45 +0100 Subject: [PATCH] Migration: Add a migration for dialer activity on upgrade from nougat to Q * The Launchable activity for nougat Dialer was `com.android.dialer/com.android.dialer.DialtactsActivity` and `com.android.dialer/com.android.dialer.main.impl.MainActivity` and on Q. * Not handling this causes the Dialer Icon to displace from its initial position before upgrading from nougat to Android Q. Change-Id: I5d1f63056423a64413ba3aafd08f52bb84dddbec --- .../blisslauncher/core/migrate/Migration.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/core/migrate/Migration.java b/app/src/main/java/foundation/e/blisslauncher/core/migrate/Migration.java index 9e65e5ba9e..937799abfe 100644 --- a/app/src/main/java/foundation/e/blisslauncher/core/migrate/Migration.java +++ b/app/src/main/java/foundation/e/blisslauncher/core/migrate/Migration.java @@ -8,6 +8,7 @@ import com.google.gson.Gson; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -35,15 +36,23 @@ public class Migration { } if (Build.VERSION.SDK_INT > 28) { - String oldComponent = "com.android.dialer/com.android.dialer.app.DialtactsActivity"; - String newComponent = "com.android.dialer/com.android.dialer.main.impl.MainActivity"; - String dialerComponent = LauncherDB.getDatabase(context).launcherDao().getComponentName("com.android.dialer"); + List dialerComponentList = Arrays.asList( + "com.android.dialer/com.android.dialer.main.impl.MainActivity", + "com.android.dialer/com.android.dialer.app.DialtactsActivity", + "com.android.dialer/com.android.dialer.DialtactsActivity" + ); - if (dialerComponent != null && dialerComponent.equals(oldComponent)) { + String currentComponent = dialerComponentList.get(0); + String dialerComponent = LauncherDB + .getDatabase(context) + .launcherDao() + .getComponentName("com.android.dialer"); + + if (dialerComponent != null && dialerComponentList.contains(dialerComponent) + && !dialerComponent.equals(currentComponent)) { Log.d(TAG, "migrateSafely: Migrating dialer component!"); DatabaseManager.getManager(context).migrateComponent( - oldComponent, newComponent - ); + dialerComponent, currentComponent); } } -- GitLab