Skip to content

Commit

Permalink
Fix L2 and old Trebuchet migration
Browse files Browse the repository at this point in the history
There can only be one original-package tag. Go with com.android.launcher3
for now, and move Trebuchet back to com.cyanogenmod.trebuchet. This will
allow for workspace migrations from both CM10.2 Trebuchet and from CM11
Launcher3

Change-Id: I7743954bffc55f503851038f800607947e20015e
  • Loading branch information
rmcc authored and Adnan committed Nov 19, 2014
1 parent 12ed20f commit 916ba22
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Android.mk
Expand Up @@ -38,10 +38,10 @@ LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/

# LOCAL_SDK_VERSION := 21

LOCAL_PACKAGE_NAME := Launcher3
LOCAL_PACKAGE_NAME := Trebuchet
#LOCAL_CERTIFICATE := shared

LOCAL_AAPT_FLAGS := --rename-manifest-package org.cyanogenmod.trebuchet
LOCAL_AAPT_FLAGS += --rename-manifest-package com.cyanogenmod.trebuchet

LOCAL_OVERRIDES_PACKAGES := Launcher3

Expand Down
12 changes: 7 additions & 5 deletions AndroidManifest.xml
Expand Up @@ -19,8 +19,13 @@
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.launcher3">
<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="16"/>
package="com.android.launcher3"
android:versionName="@string/application_version"
android:versionCode="1000">

<original-package android:name="com.android.launcher3" />

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="16" />

<permission
android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
Expand Down Expand Up @@ -54,9 +59,6 @@
android:name="com.android.launcher3.permission.RECEIVE_FIRST_LOAD_BROADCAST"
android:protectionLevel="signatureOrSystem" />

<original-package android:name="com.cyanogenmod.trebuchet" />
<original-package android:name="com.android.launcher3" />

<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
Expand Down
58 changes: 57 additions & 1 deletion src/com/android/launcher3/LauncherProvider.java
Expand Up @@ -853,7 +853,6 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}


if (version < 16) {
db.beginTransaction();
try {
Expand All @@ -869,6 +868,63 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.endTransaction();
}
}
// This was the old L2-based Trebuchet's version. Do steps that come after version 12
// (Launcher2's original version) so the new things get added, but skip the intermediate
// workspaceScreens updates (addWorkspacesTable() takes care of that)

if (version == 16) {
Log.w(TAG, "Found pre-11 Trebuchet, preparing update");

// With the new shrink-wrapped and re-orderable workspaces, it makes sense
// to persist workspace screens and their relative order.
mMaxScreenId = 0;

// This will never happen in the wild, but when we switch to using workspace
// screen ids, redo the import from old launcher.
sJustLoadedFromOldDb = true;

addWorkspacesTable(db);

Cursor c = null;
long screenId = -1;
try {
c = db.rawQuery("SELECT max(screen) FROM favorites", null);
if (c != null && c.moveToNext()) {
screenId = c.getLong(0);
}
if (c != null) {
c.close();
}
} catch (SQLException ex) {
Log.e(TAG, ex.getMessage(), ex);
}


db.beginTransaction();
try {
// Insert new column for holding widget provider name
db.execSQL("ALTER TABLE favorites " +
"ADD COLUMN appWidgetProvider TEXT;");
db.execSQL("ALTER TABLE favorites " +
"ADD COLUMN modified INTEGER NOT NULL DEFAULT 0;");
// Create workspaces for the migrated things
if (screenId > 0) {
for (int sId = 0; sId <= screenId; sId++) {
db.execSQL("INSERT INTO workspaceScreens (_id, screenRank) " +
"VALUES (" + (sId+1) + ", " + sId + ")");
}
}
// Adjust hotseat format
db.execSQL("UPDATE favorites SET screen=cellX WHERE container=-101;");
db.setTransactionSuccessful();
version = 17;
} catch (SQLException ex) {
// Old version remains, which means we wipe old data
Log.e(TAG, ex.getMessage(), ex);
} finally {
db.endTransaction();
}
}

if (version < 17) {
// We use the db version upgrade here to identify users who may not have seen
Expand Down

0 comments on commit 916ba22

Please sign in to comment.