cmsdk: Mandate themes feature xml's for service implementation.
The feature xml plays two roles: 1) To allow sdk interface (constructor) to throw when system service is unavailable. This allows for clearer platform development debugging. 2) To allow for simpler disambiguation of what services to instrument in a modular environment. Change-Id: I67b16a0725ed89d5ddbc973b09337d6227087e4d TICKET: CYNGNOS-2295
This commit is contained in:
parent
c406211045
commit
ccdb292eec
@ -1073,7 +1073,7 @@ package cyanogenmod.themes {
|
|||||||
public class ThemeManager {
|
public class ThemeManager {
|
||||||
method public deprecated void addClient(cyanogenmod.themes.ThemeManager.ThemeChangeListener);
|
method public deprecated void addClient(cyanogenmod.themes.ThemeManager.ThemeChangeListener);
|
||||||
method public void applyDefaultTheme();
|
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 cyanogenmod.themes.ThemeChangeRequest.RequestType getLastThemeChangeRequestType();
|
||||||
method public long getLastThemeChangeTime();
|
method public long getLastThemeChangeTime();
|
||||||
method public int getProgress();
|
method public int getProgress();
|
||||||
|
@ -42,15 +42,22 @@ public class IconCacheManagerService extends SystemService {
|
|||||||
private static final long PURGED_ICON_CACHE_SIZE = 25165824L; // 24 MB
|
private static final long PURGED_ICON_CACHE_SIZE = 25165824L; // 24 MB
|
||||||
|
|
||||||
private long mIconCacheSize = 0L;
|
private long mIconCacheSize = 0L;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
public IconCacheManagerService(Context context) {
|
public IconCacheManagerService(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
Log.d(TAG, "registerIconCache cmiconcache: " + this);
|
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() {
|
private void purgeIconCache() {
|
||||||
|
@ -236,7 +236,12 @@ public class ThemeManagerService extends SystemService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
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
|
// listen for wallpaper changes
|
||||||
IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
|
IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED);
|
||||||
mContext.registerReceiver(mWallpaperChangeReceiver, filter);
|
mContext.registerReceiver(mWallpaperChangeReceiver, filter);
|
||||||
|
@ -157,5 +157,13 @@ public final class CMContextConstants {
|
|||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
|
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
|
||||||
public static final String TELEPHONY = "org.cyanogenmod.telephony";
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package cyanogenmod.themes;
|
package cyanogenmod.themes;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@ -47,14 +48,20 @@ public class ThemeManager {
|
|||||||
|
|
||||||
private Set<ThemeProcessingListener> mProcessingListeners = new ArraySet<>();
|
private Set<ThemeProcessingListener> mProcessingListeners = new ArraySet<>();
|
||||||
|
|
||||||
private ThemeManager() {
|
private ThemeManager(Context context) {
|
||||||
mHandler = new Handler(Looper.getMainLooper());
|
|
||||||
sService = getService();
|
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) {
|
if (sInstance == null) {
|
||||||
sInstance = new ThemeManager();
|
sInstance = new ThemeManager(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sInstance;
|
return sInstance;
|
||||||
|
@ -1073,7 +1073,7 @@ package cyanogenmod.themes {
|
|||||||
public class ThemeManager {
|
public class ThemeManager {
|
||||||
method public deprecated void addClient(cyanogenmod.themes.ThemeManager.ThemeChangeListener);
|
method public deprecated void addClient(cyanogenmod.themes.ThemeManager.ThemeChangeListener);
|
||||||
method public void applyDefaultTheme();
|
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 cyanogenmod.themes.ThemeChangeRequest.RequestType getLastThemeChangeRequestType();
|
||||||
method public long getLastThemeChangeTime();
|
method public long getLastThemeChangeTime();
|
||||||
method public int getProgress();
|
method public int getProgress();
|
||||||
|
Loading…
Reference in New Issue
Block a user