summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-03-11 22:05:32 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-03-12 16:01:16 (GMT)
commit6c29892fc83a43a7f363f56950ac6e7a8423ac91 (patch)
treefa822f579149c92f7562969f728eb0d7ed401622 /src
parentcc0e0e1f3d19109cfe2a6ff2e2b616d5b97e90f6 (diff)
downloadandroid_packages_providers_ThemesProvider-6c29892fc83a43a7f363f56950ac6e7a8423ac91.zip
android_packages_providers_ThemesProvider-6c29892fc83a43a7f363f56950ac6e7a8423ac91.tar.gz
android_packages_providers_ThemesProvider-6c29892fc83a43a7f363f56950ac6e7a8423ac91.tar.bz2
Themes: Process theme resources after package scanned [2/2]staging/cm-12.1
The provider now assumes that the theme service will process all themes and icons packs, and then sends the appropriate broadcast once processing is done for that package. The preview generator now queries for the theme 's capabilities rather than rely on that info to be passed in. This is partly due to the new flow of installing a theme as well as the fact that legacy icon packs were not having previews generated. Change-Id: I418debb6f91296107476016367131fac2c3a32ce
Diffstat (limited to 'src')
-rw-r--r--src/org/cyanogenmod/themes/provider/AppReceiver.java11
-rw-r--r--src/org/cyanogenmod/themes/provider/PreviewGenerationService.java36
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java12
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesProvider.java43
4 files changed, 39 insertions, 63 deletions
diff --git a/src/org/cyanogenmod/themes/provider/AppReceiver.java b/src/org/cyanogenmod/themes/provider/AppReceiver.java
index 2a6f85a..1db9dde 100644
--- a/src/org/cyanogenmod/themes/provider/AppReceiver.java
+++ b/src/org/cyanogenmod/themes/provider/AppReceiver.java
@@ -33,20 +33,19 @@ public class AppReceiver extends BroadcastReceiver {
final String pkgName = uri != null ? uri.getSchemeSpecificPart() : null;
final boolean isReplacing = intent.getExtras().getBoolean(Intent.EXTRA_REPLACING, false);
final String action = intent.getAction();
- final boolean themeProcessing;
try {
+ // All themes/icon packs go to the theme service for processing now so assume
+ // isProcessing is always true when installing/replacing
if (Intent.ACTION_PACKAGE_ADDED.equals(action) && !isReplacing) {
- themeProcessing = ProviderUtils.isThemeBeingProcessed(context, pkgName);
- ThemePackageHelper.insertPackage(context, pkgName, themeProcessing);
+ ThemePackageHelper.insertPackage(context, pkgName, true);
} else if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
ThemePackageHelper.removePackage(context, pkgName);
} else if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) {
- themeProcessing = ProviderUtils.isThemeBeingProcessed(context, pkgName);
if (ProviderUtils.themeExistsInProvider(context, pkgName)) {
- ThemePackageHelper.updatePackage(context, pkgName, themeProcessing);
+ ThemePackageHelper.updatePackage(context, pkgName, true);
} else {
// Edge case where app was not a theme in previous install
- ThemePackageHelper.insertPackage(context, pkgName, themeProcessing);
+ ThemePackageHelper.insertPackage(context, pkgName, true);
}
} else if (Intent.ACTION_THEME_RESOURCES_CACHED.equals(action)) {
final String themePkgName = intent.getStringExtra(Intent.EXTRA_THEME_PACKAGE_NAME);
diff --git a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
index 0db60f6..ed86994 100644
--- a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
+++ b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
@@ -18,6 +18,7 @@ package org.cyanogenmod.themes.provider;
import android.app.IntentService;
import android.content.ContentResolver;
import android.content.ContentValues;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -48,11 +49,6 @@ public class PreviewGenerationService extends IntentService {
public static final String ACTION_INSERT = "org.cyanogenmod.themes.provider.action.insert";
public static final String ACTION_UPDATE = "org.cyanogenmod.themes.provider.action.update";
public static final String EXTRA_PKG_NAME = "extra_pkg_name";
- public static final String EXTRA_HAS_SYSTEMUI = "extra_has_system_ui";
- public static final String EXTRA_HAS_ICONS = "extra_has_icons";
- public static final String EXTRA_HAS_WALLPAPER = "extra_has_wallpaper";
- public static final String EXTRA_HAS_STYLES = "extra_has_styles";
- public static final String EXTRA_HAS_BOOTANIMATION = "extra_has_bootanimation";
private static final String TAG = PreviewGenerationService.class.getName();
@@ -69,12 +65,25 @@ public class PreviewGenerationService extends IntentService {
final Bundle extras = intent.getExtras();
String pkgName = extras.getString(EXTRA_PKG_NAME);
- boolean hasSystemUi = extras.getBoolean(EXTRA_HAS_SYSTEMUI, false);
- boolean hasIcons = extras.getBoolean(EXTRA_HAS_ICONS, false);
- boolean hasWallpaper = extras.getBoolean(EXTRA_HAS_WALLPAPER, false);
- boolean hasStyles = extras.getBoolean(EXTRA_HAS_STYLES, false);
- boolean hasBootanimation = extras.getBoolean(EXTRA_HAS_BOOTANIMATION, false);
+ boolean hasSystemUi = false;
+ boolean hasIcons = false;
+ boolean hasWallpaper = false;
+ boolean hasStyles = false;
+ boolean hasBootanimation = false;
boolean isSystemTheme = ThemeConfig.SYSTEM_DEFAULT.equals(pkgName);
+ Cursor c = queryTheme(this, pkgName);
+ if (c != null) {
+ if (c.moveToFirst()) {
+ hasSystemUi = c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_STATUS_BAR)) == 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;
+ hasStyles = c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_OVERLAYS)) == 1;
+ hasBootanimation =
+ c.getInt(c.getColumnIndex(ThemesColumns.MODIFIES_BOOT_ANIM)) == 1;
+ }
+ c.close();
+ }
final String action = intent.getAction();
if (ACTION_INSERT.equals(action) || ACTION_UPDATE.equals(action)) {
PackageInfo info = null;
@@ -228,4 +237,11 @@ public class PreviewGenerationService extends IntentService {
bmp.compress(format, quality, out);
return out.toByteArray();
}
+
+ private static Cursor queryTheme(Context context, String pkgName) {
+ String selection = ThemesColumns.PKG_NAME + "=?";
+ String[] selectionArgs = { pkgName };
+ return context.getContentResolver().query(ThemesColumns.CONTENT_URI, null,
+ selection, selectionArgs, null);
+ }
}
diff --git a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
index b0835de..d81b7a4 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
@@ -194,11 +194,6 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
Intent intent = new Intent(mContext, PreviewGenerationService.class);
intent.setAction(PreviewGenerationService.ACTION_INSERT);
intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME, c.getString(0));
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_SYSTEMUI, c.getInt(1) == 1);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_ICONS, c.getInt(2) == 1);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_STYLES, c.getInt(3) == 1);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_WALLPAPER, c.getInt(4) == 1);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_BOOTANIMATION, c.getInt(5) == 1);
mContext.startService(intent);
}
c.close();
@@ -245,7 +240,6 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
Intent intent = new Intent(mContext, PreviewGenerationService.class);
intent.setAction(PreviewGenerationService.ACTION_INSERT);
intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME, pkgName);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_SYSTEMUI, true);
mContext.startService(intent);
}
}
@@ -286,7 +280,6 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
Intent intent = new Intent(mContext, PreviewGenerationService.class);
intent.setAction(PreviewGenerationService.ACTION_INSERT);
intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME, pkgName);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_SYSTEMUI, true);
mContext.startService(intent);
}
}
@@ -573,11 +566,6 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
Intent intent = new Intent(context, PreviewGenerationService.class);
intent.setAction(PreviewGenerationService.ACTION_INSERT);
intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME, SYSTEM_THEME_PKG_NAME);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_SYSTEMUI, true);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_ICONS, true);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_STYLES, true);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_WALLPAPER, true);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_BOOTANIMATION, true);
context.startService(intent);
}
}
diff --git a/src/org/cyanogenmod/themes/provider/ThemesProvider.java b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
index ed9025c..2d57f73 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesProvider.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
@@ -153,10 +153,10 @@ public class ThemesProvider extends ContentProvider {
long id = 0;
switch (uriType) {
case THEMES:
- boolean processPreviews = true;
+ boolean processPreviews = false;
if (values.containsKey(ThemesColumns.INSTALL_STATE)) {
int state = values.getAsInteger(ThemesColumns.INSTALL_STATE);
- processPreviews = state == ThemesColumns.InstallState.INSTALLING;
+ processPreviews = state == ThemesColumns.InstallState.INSTALLED;
}
id = sqlDB.insert(ThemesOpenHelper.ThemesTable.TABLE_NAME, null, values);
if (processPreviews) {
@@ -164,21 +164,6 @@ public class ThemesProvider extends ContentProvider {
intent.setAction(PreviewGenerationService.ACTION_INSERT);
intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME,
values.getAsString(ThemesColumns.PKG_NAME));
- Boolean hasSystemUi = values.getAsBoolean(ThemesColumns.MODIFIES_STATUS_BAR);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_SYSTEMUI,
- hasSystemUi != null && hasSystemUi);
- Boolean hasIcons = values.getAsBoolean(ThemesColumns.MODIFIES_ICONS);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_ICONS,
- hasIcons != null && hasIcons);
- Boolean hasStyles = values.getAsBoolean(ThemesColumns.MODIFIES_OVERLAYS);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_STYLES,
- hasStyles != null && hasStyles);
- Boolean hasWallpaper = values.getAsBoolean(ThemesColumns.MODIFIES_LAUNCHER);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_WALLPAPER,
- hasWallpaper != null && hasWallpaper);
- Boolean hasBootAni = values.getAsBoolean(ThemesColumns.MODIFIES_BOOT_ANIM);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_BOOTANIMATION,
- hasBootAni != null && hasBootAni);
getContext().startService(intent);
}
break;
@@ -278,28 +263,16 @@ public class ThemesProvider extends ContentProvider {
case THEMES:
case THEMES_ID:
String pkgName = values.getAsString(ThemesColumns.PKG_NAME);
- final boolean updatePreviews = getShouldUpdatePreviews(sqlDB, pkgName);
+ boolean updatePreviews = false;
+ if (values.containsKey(ThemesColumns.INSTALL_STATE)) {
+ int state = values.getAsInteger(ThemesColumns.INSTALL_STATE);
+ updatePreviews = state == ThemesColumns.InstallState.INSTALLED;
+ }
rowsUpdated = sqlDB.update(ThemesTable.TABLE_NAME, values, selection, selectionArgs);
if (updateNotTriggeredByContentProvider(values) && updatePreviews) {
Intent intent = new Intent(getContext(), PreviewGenerationService.class);
intent.setAction(PreviewGenerationService.ACTION_UPDATE);
- intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME,
- values.getAsString(ThemesColumns.PKG_NAME));
- Boolean hasSystemUi = values.getAsBoolean(ThemesColumns.MODIFIES_STATUS_BAR);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_SYSTEMUI,
- hasSystemUi != null && hasSystemUi);
- Boolean hasIcons = values.getAsBoolean(ThemesColumns.MODIFIES_ICONS);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_ICONS,
- hasIcons != null && hasIcons);
- Boolean hasStyles = values.getAsBoolean(ThemesColumns.MODIFIES_OVERLAYS);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_STYLES,
- hasStyles != null && hasStyles);
- Boolean hasWallpaper = values.getAsBoolean(ThemesColumns.MODIFIES_LAUNCHER);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_WALLPAPER,
- hasWallpaper != null && hasWallpaper);
- Boolean hasBootAni = values.getAsBoolean(ThemesColumns.MODIFIES_BOOT_ANIM);
- intent.putExtra(PreviewGenerationService.EXTRA_HAS_BOOTANIMATION,
- hasBootAni != null && hasBootAni);
+ intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME, pkgName);
getContext().startService(intent);
}
getContext().getContentResolver().notifyChange(uri, null);