diff options
author | d34d <clark@cyngn.com> | 2015-03-28 12:58:27 -0700 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2015-04-17 03:56:18 +0300 |
commit | d6c69145c554db81855d7c72f69d2008b7f21417 (patch) | |
tree | 052109086dfc3b06a3caefc729ad69e68dff3d2f /src | |
parent | 8e2b36126617748c20dad975d0c1f8facaa3d11e (diff) | |
download | android_packages_providers_ThemesProvider-d6c69145c554db81855d7c72f69d2008b7f21417.tar.gz android_packages_providers_ThemesProvider-d6c69145c554db81855d7c72f69d2008b7f21417.tar.bz2 android_packages_providers_ThemesProvider-d6c69145c554db81855d7c72f69d2008b7f21417.zip |
Fix version upgrades where "holo" may still be used
The stock theme was renamed from holo to system for CM12 but there
are old upgrades that still need to check for "holo" when updating
columns in the database. The name change occurerd in the upgrade
to version 11, all upgrades before that now explicitly call out
"holo" instead of "system" to ensure the upgrade process completes
as expected.
This patch also fixes up the preview generation during the upgrade
to version 6.
Change-Id: I246d417f10c264c44a1741019589e50b968096e4
Diffstat (limited to 'src')
-rw-r--r-- | src/org/cyanogenmod/themes/provider/PreviewGenerationService.java | 5 | ||||
-rw-r--r-- | src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java | 22 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java index ed86994..3281038 100644 --- a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java +++ b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java @@ -74,7 +74,10 @@ public class PreviewGenerationService extends IntentService { Cursor c = queryTheme(this, pkgName); if (c != null) { if (c.moveToFirst()) { - hasSystemUi = c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_STATUS_BAR)) == 1; + // mods_status_bar was added in version 7 of the database so we need to make sure + // it exists when trying to get the int value from the row. + final int sysUiIndex = c.getColumnIndex(ThemesColumns.MODIFIES_STATUS_BAR); + hasSystemUi = sysUiIndex >= 0 && c.getInt(sysUiIndex) == 1; hasIcons = c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_ICONS)) == 1; hasWallpaper = c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_LAUNCHER)) == 1 || c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_LOCKSCREEN)) == 1; diff --git a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java index d81b7a4..c3a966c 100644 --- a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java +++ b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java @@ -39,6 +39,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 14; private static final String DATABASE_NAME = "themes.db"; private static final String SYSTEM_THEME_PKG_NAME = ThemeConfig.SYSTEM_DEFAULT; + private static final String OLD_SYSTEM_THEME_PKG_NAME = "holo"; private Context mContext; @@ -138,7 +139,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { // Add default value to mixnmatch for KEY_ALARM ContentValues values = new ContentValues(); values.put(MixnMatchColumns.COL_KEY, ThemesContract.MixnMatchColumns.KEY_ALARM); - values.put(MixnMatchColumns.COL_VALUE, SYSTEM_THEME_PKG_NAME); + values.put(MixnMatchColumns.COL_VALUE, OLD_SYSTEM_THEME_PKG_NAME); db.insert(MixnMatchTable.TABLE_NAME, null, values); } @@ -157,20 +158,20 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { // change default package name to holo String changeDefaultToSystem = String.format("UPDATE %s SET %s='%s' WHERE" + " %s='%s'", ThemesTable.TABLE_NAME, ThemesColumns.PKG_NAME, - SYSTEM_THEME_PKG_NAME, ThemesColumns.PKG_NAME, "default"); + OLD_SYSTEM_THEME_PKG_NAME, ThemesColumns.PKG_NAME, "default"); db.execSQL(changeDefaultToSystem); if (isSystemDefault(mContext)) { // flag holo as default if String makeHoloDefault = String.format("UPDATE %s SET %s=%d WHERE" + " %s='%s'", ThemesTable.TABLE_NAME, ThemesColumns.IS_DEFAULT_THEME, 1, - ThemesColumns.PKG_NAME, SYSTEM_THEME_PKG_NAME); + ThemesColumns.PKG_NAME, OLD_SYSTEM_THEME_PKG_NAME); db.execSQL(makeHoloDefault); } // change any existing mixnmatch values set to "default" to "holo" db.execSQL(String.format("UPDATE %s SET %s='%s' WHERE %s='%s'", - MixnMatchTable.TABLE_NAME, MixnMatchColumns.COL_VALUE, SYSTEM_THEME_PKG_NAME, + MixnMatchTable.TABLE_NAME, MixnMatchColumns.COL_VALUE, OLD_SYSTEM_THEME_PKG_NAME, MixnMatchColumns.COL_VALUE, "default")); } @@ -182,9 +183,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { ThemesColumns.TITLE, "Holo", ThemesColumns.PKG_NAME, "holo")); // we need to update any existing themes - final String[] projection = { ThemesColumns.PKG_NAME, ThemesColumns.MODIFIES_STATUS_BAR, - ThemesColumns.MODIFIES_ICONS, ThemesColumns.MODIFIES_OVERLAYS, - ThemesColumns.MODIFIES_LAUNCHER, ThemesColumns.MODIFIES_BOOT_ANIM }; + final String[] projection = { ThemesColumns.PKG_NAME }; final String selection = ThemesColumns.MODIFIES_OVERLAYS + "=?"; final String[] selectionArgs = { "1" }; final Cursor c = db.query(ThemesTable.TABLE_NAME, projection, selection, selectionArgs, @@ -220,7 +219,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { final String pkgName = c.getString(0); final boolean isLegacyTheme = c.getInt(1) == 1; boolean hasSystemUi = false; - if (SYSTEM_THEME_PKG_NAME.equals(pkgName) || isLegacyTheme) { + if (OLD_SYSTEM_THEME_PKG_NAME.equals(pkgName) || isLegacyTheme) { hasSystemUi = true; } else { try { @@ -264,7 +263,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { final String pkgName = c.getString(0); final boolean isLegacyTheme = c.getInt(1) == 1; boolean hasSystemUi = false; - if (SYSTEM_THEME_PKG_NAME.equals(pkgName) || isLegacyTheme) { + if (OLD_SYSTEM_THEME_PKG_NAME.equals(pkgName) || isLegacyTheme) { hasSystemUi = true; } else { try { @@ -324,7 +323,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { while(c.moveToNext()) { final String pkgName = c.getString(0); int targetSdk = -1; - if (SYSTEM_THEME_PKG_NAME.equals(pkgName)) { + if (OLD_SYSTEM_THEME_PKG_NAME.equals(pkgName)) { // 0 is a special value used for the system theme, not to be confused with the // default theme which may not be the same as the system theme. targetSdk = 0; @@ -349,14 +348,13 @@ public class ThemesOpenHelper extends SQLiteOpenHelper { private void upgradeToVersion11(SQLiteDatabase db) { // Update holo theme to be called "system" final String NEW_THEME_TITLE = "System"; - final String PREV_SYSTEM_PKG_NAME = "holo"; String holoToSystem = String.format("UPDATE TABLE %s " + "SET title=%s, pkg_name=%s " + "WHERE %s='%s'", ThemesTable.TABLE_NAME, NEW_THEME_TITLE, SYSTEM_THEME_PKG_NAME, - ThemesColumns.PKG_NAME, PREV_SYSTEM_PKG_NAME); + ThemesColumns.PKG_NAME, OLD_SYSTEM_THEME_PKG_NAME); db.execSQL(holoToSystem); } |