Tightening migration conditions. (Bug 11973614)
Change-Id: I6d7417b705227472d035f428cbec933cc6dbf2ce
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 6e3032f..c119999 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -41,6 +41,7 @@
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
@@ -478,11 +479,18 @@
// On large interfaces, we want the screen to auto-rotate based on the current orientation
unlockScreenOrientation(true);
+ // The two first run cling paths are mutually exclusive, if the launcher is preinstalled
+ // on the device, then we always show the first run cling experience (or if there is no
+ // launcher2). Otherwise, we prompt the user upon started for migration
showFirstRunActivity();
- if (mModel.canMigrateFromOldLauncherDb()) {
- mLauncherClings.showMigrationCling();
+ if (mLauncherClings.shouldShowFirstRunOrMigrationClings()) {
+ if (mModel.canMigrateFromOldLauncherDb(this)) {
+ mLauncherClings.showMigrationCling();
+ } else {
+ mLauncherClings.showFirstRunCling();
+ }
} else {
- mLauncherClings.showFirstRunCling();
+ mLauncherClings.removeFirstRunAndMigrationClings();
}
}
@@ -4280,6 +4288,21 @@
mLauncherClings.updateSearchBarHint(hint);
}
+ protected boolean isLauncherPreinstalled() {
+ PackageManager pm = getPackageManager();
+ try {
+ ApplicationInfo ai = pm.getApplicationInfo(getComponentName().getPackageName(), 0);
+ if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
protected String getFirstRunClingSearchBarHint() {
return "";
}