aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/cm_current.txt2
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java9
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java7
-rw-r--r--src/java/cyanogenmod/app/CMContextConstants.java8
-rw-r--r--src/java/cyanogenmod/themes/ThemeManager.java15
-rw-r--r--system-api/cm_system-current.txt2
6 files changed, 35 insertions, 8 deletions
diff --git a/api/cm_current.txt b/api/cm_current.txt
index 7168d70..e906245 100644
--- a/api/cm_current.txt
+++ b/api/cm_current.txt
@@ -1073,7 +1073,7 @@ package cyanogenmod.themes {
public class ThemeManager {
method public deprecated void addClient(cyanogenmod.themes.ThemeManager.ThemeChangeListener);
method public void applyDefaultTheme();
- method public static cyanogenmod.themes.ThemeManager getInstance();
+ method public static cyanogenmod.themes.ThemeManager getInstance(android.content.Context);
method public cyanogenmod.themes.ThemeChangeRequest.RequestType getLastThemeChangeRequestType();
method public long getLastThemeChangeTime();
method public int getProgress();
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java
index 56be660..de86458 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java
@@ -42,15 +42,22 @@ public class IconCacheManagerService extends SystemService {
private static final long PURGED_ICON_CACHE_SIZE = 25165824L; // 24 MB
private long mIconCacheSize = 0L;
+ private Context mContext;
public IconCacheManagerService(Context context) {
super(context);
+ mContext = context;
}
@Override
public void onStart() {
Log.d(TAG, "registerIconCache cmiconcache: " + this);
- publishBinderService(CMContextConstants.CM_ICON_CACHE_SERVICE, mService);
+ if (mContext.getPackageManager().hasSystemFeature(CMContextConstants.Features.THEMES)) {
+ publishBinderService(CMContextConstants.CM_ICON_CACHE_SERVICE, mService);
+ } else {
+ Log.wtf(TAG, "IconCache service started by system server but feature xml not" +
+ " declared. Not publishing binder service!");
+ }
}
private void purgeIconCache() {
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java
index 24a7e26..8c0af4c 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java
@@ -236,7 +236,12 @@ public class ThemeManagerService extends SystemService {
@Override
public void onStart() {
- publishBinderService(CMContextConstants.CM_THEME_SERVICE, mService);
+ if (mContext.getPackageManager().hasSystemFeature(CMContextConstants.Features.THEMES)) {
+ publishBinderService(CMContextConstants.CM_THEME_SERVICE, mService);
+ } else {
+ Log.wtf(TAG, "Theme service started by system server but feature xml not" +
+ " declared. Not publishing binder service!");
+ }
// listen for wallpaper changes
IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
mContext.registerReceiver(mWallpaperChangeReceiver, filter);
diff --git a/src/java/cyanogenmod/app/CMContextConstants.java b/src/java/cyanogenmod/app/CMContextConstants.java
index e82c60b..83a7c2d 100644
--- a/src/java/cyanogenmod/app/CMContextConstants.java
+++ b/src/java/cyanogenmod/app/CMContextConstants.java
@@ -157,5 +157,13 @@ public final class CMContextConstants {
*/
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
public static final String TELEPHONY = "org.cyanogenmod.telephony";
+
+ /**
+ * Feature for {@link PackageManager#getSystemAvailableFeatures} and
+ * {@link PackageManager#hasSystemFeature}: The device includes the cm theme service
+ * utilized by the cmsdk.
+ */
+ @SdkConstant(SdkConstant.SdkConstantType.FEATURE)
+ public static final String THEMES = "org.cyanogenmod.theme";
}
}
diff --git a/src/java/cyanogenmod/themes/ThemeManager.java b/src/java/cyanogenmod/themes/ThemeManager.java
index 4c575ae..b580ccd 100644
--- a/src/java/cyanogenmod/themes/ThemeManager.java
+++ b/src/java/cyanogenmod/themes/ThemeManager.java
@@ -16,6 +16,7 @@
package cyanogenmod.themes;
+import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -47,14 +48,20 @@ public class ThemeManager {
private Set<ThemeProcessingListener> mProcessingListeners = new ArraySet<>();
- private ThemeManager() {
- mHandler = new Handler(Looper.getMainLooper());
+ private ThemeManager(Context context) {
sService = getService();
+ if (context.getPackageManager().hasSystemFeature(
+ CMContextConstants.Features.THEMES) && sService == null) {
+ throw new RuntimeException("Unable to get ThemeManagerService. The service either" +
+ " crashed, was not started, or the interface has been called to early in" +
+ " SystemServer init");
+ }
+ mHandler = new Handler(Looper.getMainLooper());
}
- public static ThemeManager getInstance() {
+ public static ThemeManager getInstance(Context context) {
if (sInstance == null) {
- sInstance = new ThemeManager();
+ sInstance = new ThemeManager(context);
}
return sInstance;
diff --git a/system-api/cm_system-current.txt b/system-api/cm_system-current.txt
index 7168d70..e906245 100644
--- a/system-api/cm_system-current.txt
+++ b/system-api/cm_system-current.txt
@@ -1073,7 +1073,7 @@ package cyanogenmod.themes {
public class ThemeManager {
method public deprecated void addClient(cyanogenmod.themes.ThemeManager.ThemeChangeListener);
method public void applyDefaultTheme();
- method public static cyanogenmod.themes.ThemeManager getInstance();
+ method public static cyanogenmod.themes.ThemeManager getInstance(android.content.Context);
method public cyanogenmod.themes.ThemeChangeRequest.RequestType getLastThemeChangeRequestType();
method public long getLastThemeChangeTime();
method public int getProgress();