From b51572d697f9aa6160f0c4b5d0343e414eea4cad Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Tue, 26 Apr 2016 16:57:38 -0700 Subject: [PATCH] cmsdk: Create CMSystemServer to handle our platform init. Change-Id: I7b62978e2a284a3a1ec1ffc1d8c72545d7b0c939 --- .../internal/AppSuggestManagerService.java | 17 ++-- .../platform/internal/CMAudioService.java | 14 ++- .../platform/internal/CMHardwareService.java | 15 ++-- .../internal/CMStatusBarManagerService.java | 13 ++- .../platform/internal/CMSystemServer.java | 88 +++++++++++++++++++ .../platform/internal/CMSystemService.java | 28 ++++++ .../internal/CMSystemServiceHelper.java | 66 ++++++++++++++ .../internal/CMTelephonyManagerService.java | 15 ++-- .../internal/CMWeatherManagerService.java | 7 +- .../internal/IconCacheManagerService.java | 14 +-- .../internal/LiveLockScreenServiceBroker.java | 16 ++-- .../internal/PartnerInterfaceService.java | 15 ++-- .../internal/PerformanceManagerService.java | 15 ++-- .../internal/ProfileManagerService.java | 7 +- .../internal/ThemeManagerService.java | 14 +-- .../internal/display/LiveDisplayService.java | 16 ++-- cm/res/res/values/config.xml | 5 +- cm/res/res/values/symbols.xml | 3 + .../cyanogenmod/app/CMStatusBarManager.java | 2 +- .../cyanogenmod/app/CMTelephonyManager.java | 2 +- .../app/LiveLockScreenManager.java | 2 +- .../java/cyanogenmod/app/ProfileManager.java | 2 +- .../hardware/CMHardwareManager.java | 2 +- .../hardware/LiveDisplayManager.java | 2 +- .../cyanogenmod/media/CMAudioManager.java | 2 +- .../cyanogenmod/power/PerformanceManager.java | 2 +- .../java/cyanogenmod/themes/ThemeManager.java | 2 +- .../cyanogenmod/weather/CMWeatherManager.java | 3 +- 28 files changed, 288 insertions(+), 101 deletions(-) create mode 100644 cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java create mode 100644 cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java create mode 100644 cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServiceHelper.java diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java index b954dfa9..d2c11210 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java @@ -26,13 +26,12 @@ import com.android.server.SystemService; import cyanogenmod.app.CMContextConstants; import cyanogenmod.app.suggest.ApplicationSuggestion; import cyanogenmod.app.suggest.IAppSuggestManager; -import cyanogenmod.platform.Manifest; import java.util.ArrayList; import java.util.List; /** @hide */ -public class AppSuggestManagerService extends SystemService { +public class AppSuggestManagerService extends CMSystemService { private static final String TAG = "AppSgstMgrService"; public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); @@ -62,6 +61,11 @@ public class AppSuggestManagerService extends SystemService { mContext = context; } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.APP_SUGGEST; + } + @Override public void onStart() { mImpl = AppSuggestProviderProxy.createAndBind(mContext, TAG, ACTION, @@ -73,13 +77,6 @@ public class AppSuggestManagerService extends SystemService { } else { Slog.i(TAG, "Bound to to suggest provider"); } - - if (mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.APP_SUGGEST)) { - publishBinderService(CMContextConstants.CM_APP_SUGGEST_SERVICE, mService); - } else { - Log.wtf(TAG, "CM hardware service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_APP_SUGGEST_SERVICE, mService); } } diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMAudioService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMAudioService.java index b9df047e..6cebb8ed 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMAudioService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMAudioService.java @@ -36,7 +36,7 @@ import cyanogenmod.media.CMAudioManager; import cyanogenmod.media.ICMAudioService; import cyanogenmod.platform.Manifest; -public class CMAudioService extends SystemService { +public class CMAudioService extends CMSystemService { private static final String TAG = "CMAudioService"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); @@ -55,14 +55,12 @@ public class CMAudioService extends SystemService { } @Override - public void onStart() { - if (!mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.AUDIO)) { - Log.wtf(TAG, "CM Audio service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - return; - } + public String getFeatureDeclaration() { + return CMContextConstants.Features.AUDIO; + } + @Override + public void onStart() { if (!NativeHelper.isNativeLibraryAvailable()) { Log.wtf(TAG, "CM Audio service started by system server by native library is" + "unavailable. Service will be unavailable."); diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java index 3622d9f5..7e79de41 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java @@ -54,7 +54,7 @@ import org.cyanogenmod.hardware.UniqueDeviceId; import org.cyanogenmod.hardware.VibratorHW; /** @hide */ -public class CMHardwareService extends SystemService implements ThermalUpdateCallback { +public class CMHardwareService extends CMSystemService implements ThermalUpdateCallback { private static final boolean DEBUG = true; private static final String TAG = CMHardwareService.class.getSimpleName(); @@ -344,13 +344,12 @@ public class CMHardwareService extends SystemService implements ThermalUpdateCal super(context); mContext = context; mCmHwImpl = getImpl(context); - if (context.getPackageManager().hasSystemFeature( - CMContextConstants.Features.HARDWARE_ABSTRACTION)) { - publishBinderService(CMContextConstants.CM_HARDWARE_SERVICE, mService); - } else { - Log.wtf(TAG, "CM hardware service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_HARDWARE_SERVICE, mService); + } + + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.HARDWARE_ABSTRACTION; } @Override diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java index 5905836d..d33a453b 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java @@ -58,7 +58,7 @@ import org.cyanogenmod.platform.internal.R; * Internal service which manages interactions with system ui elements * @hide */ -public class CMStatusBarManagerService extends SystemService { +public class CMStatusBarManagerService extends CMSystemService { private static final String TAG = "CMStatusBarManagerService"; private Context mContext; @@ -81,14 +81,13 @@ public class CMStatusBarManagerService extends SystemService { mContext = context; } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.STATUSBAR; + } + @Override public void onStart() { - if (!mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.STATUSBAR)) { - Log.wtf(TAG, "CM statusbar service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - return; - } Log.d(TAG, "registerCMStatusBar cmstatusbar: " + this); mCustomTileListeners = new CustomTileListeners(); publishBinderService(CMContextConstants.CM_STATUS_BAR_SERVICE, mService); diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java new file mode 100644 index 00000000..2b12e95e --- /dev/null +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cyanogenmod.platform.internal; + +import android.content.Context; +import android.util.Slog; +import com.android.server.LocalServices; +import com.android.server.SystemService; +import com.android.server.SystemServiceManager; +import cyanogenmod.app.CMContextConstants; + +import org.cyanogenmod.platform.internal.display.LiveDisplayService; + +import java.util.HashMap; +import java.util.Map; + +/** + * Base CM System Server which handles the starting and states of various CM + * specific system services. Since its part of the main looper provided by the system + * server, it will be available indefinitely (until all the things die). + */ +public class CMSystemServer { + private static final String TAG = "CMSystemServer"; + private Context mSystemContext; + private CMSystemServiceHelper mSystemServiceHelper; + + public CMSystemServer(Context systemContext) { + mSystemContext = systemContext; + mSystemServiceHelper = new CMSystemServiceHelper(mSystemContext); + } + + /** + * Invoked via reflection by the SystemServer + */ + private void run() { + // Start services. + try { + startServices(); + } catch (Throwable ex) { + Slog.e("System", "******************************************"); + Slog.e("System", "************ Failure starting cm system services", ex); + throw ex; + } + } + + private void startServices() { + final Context context = mSystemContext; + final SystemServiceManager ssm = LocalServices.getService(SystemServiceManager.class); + String[] externalServices = context.getResources().getStringArray( + org.cyanogenmod.platform.internal.R.array.config_externalCMServices); + + for (String service : externalServices) { + try { + Slog.i(TAG, "Attempting to start service " + service); + CMSystemService cmSystemService = mSystemServiceHelper.getServiceFor(service); + if (context.getPackageManager().hasSystemFeature( + cmSystemService.getFeatureDeclaration())) { + Slog.i(TAG, "Starting service " + service); + ssm.startService(cmSystemService.getClass()); + } else { + Slog.i(TAG, "Not starting service " + service + + " due to feature not declared on device"); + } + } catch (Throwable e) { + reportWtf("starting " + service , e); + } + } + } + + private void reportWtf(String msg, Throwable e) { + Slog.w(TAG, "***********************************************"); + Slog.wtf(TAG, "BOOT FAILURE " + msg, e); + } +} diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java new file mode 100644 index 00000000..85a306db --- /dev/null +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cyanogenmod.platform.internal; + +import android.content.Context; +import com.android.server.SystemService; + +public abstract class CMSystemService extends SystemService { + public CMSystemService(Context context) { + super(context); + } + + public abstract String getFeatureDeclaration(); +} diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServiceHelper.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServiceHelper.java new file mode 100644 index 00000000..5cefc222 --- /dev/null +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServiceHelper.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cyanogenmod.platform.internal; + +import android.content.Context; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * Helper methods for fetching a CMSystemService from a class declaration + */ +public class CMSystemServiceHelper { + private Context mContext; + + public CMSystemServiceHelper(Context context) { + mContext = context; + } + + public CMSystemService getServiceFor(String className) { + final Class serviceClass; + try { + serviceClass = (Class)Class.forName(className); + } catch (ClassNotFoundException ex) { + throw new RuntimeException("Failed to create service " + className + + ": service class not found", ex); + } + + return getServiceFromClass(serviceClass); + } + + public T getServiceFromClass(Class serviceClass) { + final T service; + try { + Constructor constructor = serviceClass.getConstructor(Context.class); + service = constructor.newInstance(mContext); + } catch (InstantiationException ex) { + throw new RuntimeException("Failed to create service " + serviceClass + + ": service could not be instantiated", ex); + } catch (IllegalAccessException ex) { + throw new RuntimeException("Failed to create service " + serviceClass + + ": service must have a public constructor with a Context argument", ex); + } catch (NoSuchMethodException ex) { + throw new RuntimeException("Failed to create service " + serviceClass + + ": service must have a public constructor with a Context argument", ex); + } catch (InvocationTargetException ex) { + throw new RuntimeException("Failed to create service " + serviceClass + + ": service constructor threw an exception", ex); + } + return service; + } +} diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java index 35e53956..917d553d 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java @@ -36,7 +36,7 @@ import cyanogenmod.app.ICMTelephonyManager; * * @hide */ -public class CMTelephonyManagerService extends SystemService { +public class CMTelephonyManagerService extends CMSystemService { private static final String TAG = "CMTelephonyManagerSrv"; private static boolean localLOGD = Log.isLoggable(TAG, Log.DEBUG); @@ -181,18 +181,17 @@ public class CMTelephonyManagerService extends SystemService { mContext = context; } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.TELEPHONY; + } + @Override public void onStart() { if (localLOGD) { Log.d(TAG, "CM telephony manager service start: " + this); } - if (mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.TELEPHONY)) { - publishBinderService(CMContextConstants.CM_TELEPHONY_MANAGER_SERVICE, mService); - } else { - Log.wtf(TAG, "CM telephony service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_TELEPHONY_MANAGER_SERVICE, mService); mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); } diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java index 856bf2a3..fb22f73b 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java @@ -54,7 +54,7 @@ import cyanogenmod.weatherservice.ServiceRequestResult; import java.util.ArrayList; import java.util.List; -public class CMWeatherManagerService extends SystemService{ +public class CMWeatherManagerService extends CMSystemService { private static final String TAG = CMWeatherManagerService.class.getSimpleName(); @@ -221,6 +221,11 @@ public class CMWeatherManagerService extends SystemService{ mContext = context; } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.WEATHER_SERVICES; + } + @Override public void onStart() { publishBinderService(CMContextConstants.CM_WEATHER_SERVICE, mService); 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 de864583..c8c6d3ef 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java @@ -35,7 +35,7 @@ import java.util.Arrays; import java.util.Comparator; /** @hide */ -public class IconCacheManagerService extends SystemService { +public class IconCacheManagerService extends CMSystemService { private static final String TAG = IconCacheManagerService.class.getSimpleName(); private static final long MAX_ICON_CACHE_SIZE = 33554432L; // 32MB @@ -49,15 +49,15 @@ public class IconCacheManagerService extends SystemService { mContext = context; } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.THEMES; + } + @Override public void onStart() { Log.d(TAG, "registerIconCache cmiconcache: " + this); - 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!"); - } + publishBinderService(CMContextConstants.CM_ICON_CACHE_SERVICE, mService); } private void purgeIconCache() { diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/LiveLockScreenServiceBroker.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/LiveLockScreenServiceBroker.java index 397a4fe6..a142f1f1 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/LiveLockScreenServiceBroker.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/LiveLockScreenServiceBroker.java @@ -52,7 +52,7 @@ import java.util.List; * * @hide */ -public class LiveLockScreenServiceBroker extends SystemService { +public class LiveLockScreenServiceBroker extends CMSystemService { private static final String TAG = LiveLockScreenServiceBroker.class.getSimpleName(); private static final boolean DEBUG = false; @@ -234,17 +234,15 @@ public class LiveLockScreenServiceBroker extends SystemService { mContext = context; } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.LIVE_LOCK_SCREEN; + } + @Override public void onStart() { if (DEBUG) Slog.d(TAG, "service started"); - if (mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.LIVE_LOCK_SCREEN)) { - publishBinderService(CMContextConstants.CM_LIVE_LOCK_SCREEN_SERVICE, - new BinderService()); - } else { - Slog.wtf(TAG, "CM live lock screen service started by system server but feature xml " + - "not declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_LIVE_LOCK_SCREEN_SERVICE, new BinderService()); } @Override diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java index 9f2b1f66..168ddb5a 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java @@ -48,7 +48,7 @@ import java.security.interfaces.RSAPublicKey; /** @hide */ -public class PartnerInterfaceService extends SystemService { +public class PartnerInterfaceService extends CMSystemService { private static final String TAG = "CMSettingsService"; @@ -60,13 +60,12 @@ public class PartnerInterfaceService extends SystemService { public PartnerInterfaceService(Context context) { super(context); mContext = context; - if (mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.PARTNER)) { - publishBinderService(CMContextConstants.CM_PARTNER_INTERFACE, mService); - } else { - Log.wtf(TAG, "CM partner service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_PARTNER_INTERFACE, mService); + } + + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.PARTNER; } @Override diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java index ba10e5ef..57b01418 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java @@ -41,7 +41,7 @@ import cyanogenmod.power.PerformanceManagerInternal; import cyanogenmod.providers.CMSettings; /** @hide */ -public class PerformanceManagerService extends SystemService { +public class PerformanceManagerService extends CMSystemService { private static final String TAG = "PerformanceManager"; @@ -104,15 +104,14 @@ public class PerformanceManagerService extends SystemService { mHandler = new PerformanceManagerHandler(mHandlerThread.getLooper()); } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.PERFORMANCE; + } + @Override public void onStart() { - if (mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.PERFORMANCE)) { - publishBinderService(CMContextConstants.CM_PERFORMANCE_SERVICE, mBinder); - } else { - Log.wtf(TAG, "CM performance service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_PERFORMANCE_SERVICE, mBinder); publishLocalService(PerformanceManagerInternal.class, new LocalService()); } diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/ProfileManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/ProfileManagerService.java index eb390637..e9695641 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/ProfileManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/ProfileManagerService.java @@ -62,7 +62,7 @@ import java.util.Map; import java.util.UUID; /** @hide */ -public class ProfileManagerService extends SystemService { +public class ProfileManagerService extends CMSystemService { private static final String TAG = "CMProfileService"; // Enable the below for detailed logging of this class @@ -178,6 +178,11 @@ public class ProfileManagerService extends SystemService { } } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.PROFILES; + } + @Override public void onStart() { mBackupManager = new BackupManager(mContext); 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 125df02f..0d9f341d 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java @@ -92,7 +92,7 @@ import static cyanogenmod.platform.Manifest.permission.ACCESS_THEME_MANAGER; import static org.cyanogenmod.internal.util.ThemeUtils.SYSTEM_THEME_PATH; import static org.cyanogenmod.internal.util.ThemeUtils.THEME_BOOTANIMATION_PATH; -public class ThemeManagerService extends SystemService { +public class ThemeManagerService extends CMSystemService { private static final String TAG = ThemeManagerService.class.getName(); @@ -241,14 +241,14 @@ public class ThemeManagerService extends SystemService { ThemeUtils.createIconCacheDirIfNotExists(); } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.THEMES; + } + @Override public void onStart() { - 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!"); - } + publishBinderService(CMContextConstants.CM_THEME_SERVICE, mService); // listen for wallpaper changes IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); mContext.registerReceiver(mWallpaperChangeReceiver, filter); diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java index 70183f60..f724f1da 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java @@ -54,6 +54,7 @@ import com.android.server.twilight.TwilightState; import org.cyanogenmod.internal.util.QSConstants; import org.cyanogenmod.internal.util.QSUtils; +import org.cyanogenmod.platform.internal.CMSystemService; import org.cyanogenmod.platform.internal.R; import java.io.FileDescriptor; @@ -79,7 +80,7 @@ import cyanogenmod.providers.CMSettings; * and calibration. It interacts with CMHardwareService to relay * changes down to the lower layers. */ -public class LiveDisplayService extends SystemService { +public class LiveDisplayService extends CMSystemService { private static final String TAG = "LiveDisplay"; @@ -146,15 +147,14 @@ public class LiveDisplayService extends SystemService { updateCustomTileEntries(); } + @Override + public String getFeatureDeclaration() { + return CMContextConstants.Features.LIVEDISPLAY; + } + @Override public void onStart() { - if (mContext.getPackageManager().hasSystemFeature( - CMContextConstants.Features.LIVEDISPLAY)) { - publishBinderService(CMContextConstants.CM_LIVEDISPLAY_SERVICE, mBinder); - } else { - Log.wtf(TAG, "CM LiveDisplay service started by system server but feature xml not" + - " declared. Not publishing binder service!"); - } + publishBinderService(CMContextConstants.CM_LIVEDISPLAY_SERVICE, mBinder); } @Override diff --git a/cm/res/res/values/config.xml b/cm/res/res/values/config.xml index 155d658d..d8226912 100644 --- a/cm/res/res/values/config.xml +++ b/cm/res/res/values/config.xml @@ -89,7 +89,7 @@ - org.cyanogenmod.platform.internal.CMStatusBarManagerService @@ -106,4 +106,7 @@ org.cyanogenmod.platform.internal.display.LiveDisplayService org.cyanogenmod.platform.internal.CMAudioService + + + org.cyanogenmod.platform.internal.CMSystemServer diff --git a/cm/res/res/values/symbols.xml b/cm/res/res/values/symbols.xml index 767f3540..0e7143c4 100644 --- a/cm/res/res/values/symbols.xml +++ b/cm/res/res/values/symbols.xml @@ -118,4 +118,7 @@ + + + diff --git a/sdk/src/java/cyanogenmod/app/CMStatusBarManager.java b/sdk/src/java/cyanogenmod/app/CMStatusBarManager.java index d696a822..ecd31061 100644 --- a/sdk/src/java/cyanogenmod/app/CMStatusBarManager.java +++ b/sdk/src/java/cyanogenmod/app/CMStatusBarManager.java @@ -68,7 +68,7 @@ public class CMStatusBarManager { if (context.getPackageManager().hasSystemFeature( cyanogenmod.app.CMContextConstants.Features.STATUSBAR) && sService == null) { - throw new RuntimeException("Unable to get CMStatusBarService. The service either" + + Log.wtf(TAG, "Unable to get CMStatusBarService. The service either" + " crashed, was not started, or the interface has been called to early in" + " SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/app/CMTelephonyManager.java b/sdk/src/java/cyanogenmod/app/CMTelephonyManager.java index 4285f443..866d34ad 100644 --- a/sdk/src/java/cyanogenmod/app/CMTelephonyManager.java +++ b/sdk/src/java/cyanogenmod/app/CMTelephonyManager.java @@ -60,7 +60,7 @@ public class CMTelephonyManager { if (context.getPackageManager().hasSystemFeature(CMContextConstants.Features.TELEPHONY) && sService == null) { - throw new RuntimeException("Unable to get CMTelephonyManagerService. " + + Log.wtf(TAG, "Unable to get CMTelephonyManagerService. " + "The service either crashed, was not started, or the interface has been " + "called to early in SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/app/LiveLockScreenManager.java b/sdk/src/java/cyanogenmod/app/LiveLockScreenManager.java index c5fa4ce2..bd6a515f 100644 --- a/sdk/src/java/cyanogenmod/app/LiveLockScreenManager.java +++ b/sdk/src/java/cyanogenmod/app/LiveLockScreenManager.java @@ -49,7 +49,7 @@ public class LiveLockScreenManager { sService = getService(); if (context.getPackageManager().hasSystemFeature( CMContextConstants.Features.LIVE_LOCK_SCREEN) && sService == null) { - throw new RuntimeException("Unable to get LiveLockScreenManagerService. " + + Log.wtf(TAG, "Unable to get LiveLockScreenManagerService. " + "The service either crashed, was not started, or the interface has " + "been called to early in SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/app/ProfileManager.java b/sdk/src/java/cyanogenmod/app/ProfileManager.java index c2470cb5..fd749033 100644 --- a/sdk/src/java/cyanogenmod/app/ProfileManager.java +++ b/sdk/src/java/cyanogenmod/app/ProfileManager.java @@ -224,7 +224,7 @@ public class ProfileManager { if (context.getPackageManager().hasSystemFeature( cyanogenmod.app.CMContextConstants.Features.PROFILES) && sService == null) { - throw new RuntimeException("Unable to get ProfileManagerService. The service either" + + Log.wtf(TAG, "Unable to get ProfileManagerService. The service either" + " crashed, was not started, or the interface has been called to early in" + " SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java b/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java index 5bfb8583..5205da3f 100644 --- a/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java +++ b/sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java @@ -157,7 +157,7 @@ public final class CMHardwareManager { if (context.getPackageManager().hasSystemFeature( CMContextConstants.Features.HARDWARE_ABSTRACTION) && !checkService()) { - throw new RuntimeException("Unable to get CMHardwareService. The service either" + + Log.wtf(TAG, "Unable to get CMHardwareService. The service either" + " crashed, was not started, or the interface has been called to early in" + " SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java b/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java index e75c9d85..abfd1585 100644 --- a/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java +++ b/sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java @@ -129,7 +129,7 @@ public class LiveDisplayManager { if (!context.getPackageManager().hasSystemFeature( CMContextConstants.Features.LIVEDISPLAY) || !checkService()) { - throw new RuntimeException("Unable to get LiveDisplayService. The service either" + + Log.wtf(TAG, "Unable to get LiveDisplayService. The service either" + " crashed, was not started, or the interface has been called to early in" + " SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/media/CMAudioManager.java b/sdk/src/java/cyanogenmod/media/CMAudioManager.java index 801cab41..6907fbea 100644 --- a/sdk/src/java/cyanogenmod/media/CMAudioManager.java +++ b/sdk/src/java/cyanogenmod/media/CMAudioManager.java @@ -95,7 +95,7 @@ public final class CMAudioManager { if (!context.getPackageManager().hasSystemFeature( CMContextConstants.Features.AUDIO) || !checkService()) { - throw new RuntimeException("Unable to get CMAudioService. The service either" + + Log.wtf(TAG, "Unable to get CMAudioService. The service either" + " crashed, was not started, or the interface has been called to early in" + " SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/power/PerformanceManager.java b/sdk/src/java/cyanogenmod/power/PerformanceManager.java index 484bd9aa..baf1fb96 100644 --- a/sdk/src/java/cyanogenmod/power/PerformanceManager.java +++ b/sdk/src/java/cyanogenmod/power/PerformanceManager.java @@ -91,7 +91,7 @@ public class PerformanceManager { sService = getService(); if (context.getPackageManager().hasSystemFeature( CMContextConstants.Features.PERFORMANCE) && sService == null) { - throw new RuntimeException("Unable to get PerformanceManagerService. The service" + + Log.wtf(TAG, "Unable to get PerformanceManagerService. The service" + " either crashed, was not started, or the interface has been called to early" + " in SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/themes/ThemeManager.java b/sdk/src/java/cyanogenmod/themes/ThemeManager.java index 5fbbde73..75aea2a2 100644 --- a/sdk/src/java/cyanogenmod/themes/ThemeManager.java +++ b/sdk/src/java/cyanogenmod/themes/ThemeManager.java @@ -52,7 +52,7 @@ public class ThemeManager { sService = getService(); if (context.getPackageManager().hasSystemFeature( CMContextConstants.Features.THEMES) && sService == null) { - throw new RuntimeException("Unable to get ThemeManagerService. The service either" + + Log.wtf(TAG, "Unable to get ThemeManagerService. The service either" + " crashed, was not started, or the interface has been called to early in" + " SystemServer init"); } diff --git a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java index 89b17401..a5f0dd24 100644 --- a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java +++ b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java @@ -25,6 +25,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.util.ArraySet; +import android.util.Log; import cyanogenmod.app.CMContextConstants; import cyanogenmod.providers.CMSettings; import cyanogenmod.providers.WeatherContract; @@ -90,7 +91,7 @@ public class CMWeatherManager { if (context.getPackageManager().hasSystemFeature( CMContextConstants.Features.WEATHER_SERVICES) && (sWeatherManagerService == null)) { - throw new RuntimeException("Unable to bind the CMWeatherManagerService"); + Log.wtf(TAG, "Unable to bind the CMWeatherManagerService"); } mHandler = new Handler(appContext.getMainLooper()); }