aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-04-26 16:57:38 -0700
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-05-31 17:28:48 -0700
commitb51572d697f9aa6160f0c4b5d0343e414eea4cad (patch)
treecbeecb9986f888918e3059ead83e1ff308453c2d
parent970f0b6e95bebbaf51a5087ab09adfce7332115d (diff)
downloadvendor_cmsdk-b51572d697f9aa6160f0c4b5d0343e414eea4cad.zip
vendor_cmsdk-b51572d697f9aa6160f0c4b5d0343e414eea4cad.tar.gz
vendor_cmsdk-b51572d697f9aa6160f0c4b5d0343e414eea4cad.tar.bz2
cmsdk: Create CMSystemServer to handle our platform init.
Change-Id: I7b62978e2a284a3a1ec1ffc1d8c72545d7b0c939
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java17
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMAudioService.java14
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMHardwareService.java15
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMStatusBarManagerService.java13
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java88
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java28
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServiceHelper.java66
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java15
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java7
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/IconCacheManagerService.java14
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/LiveLockScreenServiceBroker.java16
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/PartnerInterfaceService.java15
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java15
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/ProfileManagerService.java7
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerService.java14
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java16
-rw-r--r--cm/res/res/values/config.xml5
-rw-r--r--cm/res/res/values/symbols.xml3
-rw-r--r--sdk/src/java/cyanogenmod/app/CMStatusBarManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/app/CMTelephonyManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/app/LiveLockScreenManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/app/ProfileManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/hardware/CMHardwareManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/hardware/LiveDisplayManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/media/CMAudioManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/power/PerformanceManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/themes/ThemeManager.java2
-rw-r--r--sdk/src/java/cyanogenmod/weather/CMWeatherManager.java3
28 files changed, 288 insertions, 101 deletions
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 b954dfa..d2c1121 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);
@@ -63,6 +62,11 @@ public class AppSuggestManagerService extends SystemService {
}
@Override
+ public String getFeatureDeclaration() {
+ return CMContextConstants.Features.APP_SUGGEST;
+ }
+
+ @Override
public void onStart() {
mImpl = AppSuggestProviderProxy.createAndBind(mContext, TAG, ACTION,
R.bool.config_enableAppSuggestOverlay,
@@ -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 b9df047..6cebb8e 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 3622d9f..7e79de4 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 5905836..d33a453 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;
@@ -82,13 +82,12 @@ public class CMStatusBarManagerService extends SystemService {
}
@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 0000000..2b12e95
--- /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 0000000..85a306d
--- /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 0000000..5cefc22
--- /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<CMSystemService> serviceClass;
+ try {
+ serviceClass = (Class<CMSystemService>)Class.forName(className);
+ } catch (ClassNotFoundException ex) {
+ throw new RuntimeException("Failed to create service " + className
+ + ": service class not found", ex);
+ }
+
+ return getServiceFromClass(serviceClass);
+ }
+
+ public <T extends CMSystemService> T getServiceFromClass(Class<T> serviceClass) {
+ final T service;
+ try {
+ Constructor<T> 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 35e5395..917d553 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);
@@ -182,17 +182,16 @@ public class CMTelephonyManagerService extends SystemService {
}
@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 856bf2a..fb22f73 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();
@@ -222,6 +222,11 @@ public class CMWeatherManagerService extends SystemService{
}
@Override
+ public String getFeatureDeclaration() {
+ return CMContextConstants.Features.WEATHER_SERVICES;
+ }
+
+ @Override
public void onStart() {
publishBinderService(CMContextConstants.CM_WEATHER_SERVICE, mService);
registerPackageMonitor();
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 de86458..c8c6d3e 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
@@ -50,14 +50,14 @@ public class IconCacheManagerService extends SystemService {
}
@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 397a4fe..a142f1f 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;
@@ -235,16 +235,14 @@ public class LiveLockScreenServiceBroker extends SystemService {
}
@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 9f2b1f6..168ddb5 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 ba10e5e..57b0141 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";
@@ -105,14 +105,13 @@ public class PerformanceManagerService extends SystemService {
}
@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 eb39063..e969564 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
@@ -179,6 +179,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 125df02..0d9f341 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();
@@ -242,13 +242,13 @@ public class ThemeManagerService extends SystemService {
}
@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 70183f6..f724f1d 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";
@@ -147,14 +148,13 @@ public class LiveDisplayService extends SystemService {
}
@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 155d658..d822691 100644
--- a/cm/res/res/values/config.xml
+++ b/cm/res/res/values/config.xml
@@ -89,7 +89,7 @@
<!-- Default wi-fi direct name -->
<string name="config_wifiDirectName" translatable="false"></string>
- <!-- Defines external services to be started by the SystemServer at boot. The service itself
+ <!-- Defines external services to be started by the CMSystemServer at boot. The service itself
should publish as a binder services in its onStart -->
<string-array name="config_externalCMServices">
<item>org.cyanogenmod.platform.internal.CMStatusBarManagerService</item>
@@ -106,4 +106,7 @@
<item>org.cyanogenmod.platform.internal.display.LiveDisplayService</item>
<item>org.cyanogenmod.platform.internal.CMAudioService</item>
</string-array>
+
+ <!-- The CMSystemServer class that is invoked from Android's SystemServer -->
+ <string name="config_externalSystemServer" translatable="false">org.cyanogenmod.platform.internal.CMSystemServer</string>
</resources>
diff --git a/cm/res/res/values/symbols.xml b/cm/res/res/values/symbols.xml
index 767f354..0e7143c 100644
--- a/cm/res/res/values/symbols.xml
+++ b/cm/res/res/values/symbols.xml
@@ -118,4 +118,7 @@
<java-symbol type="string" name="qs_themes_label" />
<java-symbol type="string" name="qs_themes_content_description" />
<java-symbol type="drawable" name="ic_qs_themes" />
+
+ <!-- CM system server -->
+ <java-symbol type="string" name="config_externalSystemServer" />
</resources>
diff --git a/sdk/src/java/cyanogenmod/app/CMStatusBarManager.java b/sdk/src/java/cyanogenmod/app/CMStatusBarManager.java
index d696a82..ecd3106 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 4285f44..866d34a 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 c5fa4ce..bd6a515 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 c2470cb..fd74903 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 5bfb858..5205da3 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 e75c9d8..abfd158 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 801cab4..6907fbe 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 484bd9a..baf1fb9 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 5fbbde7..75aea2a 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 89b1740..a5f0dd2 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());
}