From 70d2082f7d7253f8cf5d578507f44fd6e28ce706 Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Tue, 26 Apr 2016 16:56:49 -0700 Subject: services: Kick off to CMSystemServer for external service init. Change-Id: I2dfe51a4cadfe02f0295be36fb30a304219047ff --- services/java/com/android/server/SystemServer.java | 30 +++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'services/java') diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 5169607..671bf89 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -99,6 +99,9 @@ import cyanogenmod.providers.CMSettings; import dalvik.system.VMRuntime; import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Locale; import java.util.Timer; import java.util.TimerTask; @@ -455,8 +458,8 @@ public final class SystemServer { boolean disableNetwork = SystemProperties.getBoolean("config.disable_network", false); boolean disableNetworkTime = SystemProperties.getBoolean("config.disable_networktime", false); boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1"); - String[] externalServices = context.getResources().getStringArray( - org.cyanogenmod.platform.internal.R.array.config_externalCMServices); + String externalServer = context.getResources().getString( + org.cyanogenmod.platform.internal.R.string.config_externalSystemServer); try { Slog.i(TAG, "Reading configuration..."); @@ -1052,13 +1055,22 @@ public final class SystemServer { // MMS service broker mmsService = mSystemServiceManager.startService(MmsServiceBroker.class); - for (String service : externalServices) { - try { - Slog.i(TAG, service); - mSystemServiceManager.startService(service); - } catch (Throwable e) { - reportWtf("starting " + service , e); - } + final Class serverClazz; + try { + serverClazz = Class.forName(externalServer); + final Constructor constructor = serverClazz.getDeclaredConstructor(Context.class); + constructor.setAccessible(true); + final Object baseObject = constructor.newInstance(mSystemContext); + final Method method = baseObject.getClass().getDeclaredMethod("run"); + method.setAccessible(true); + method.invoke(baseObject); + } catch (ClassNotFoundException + | IllegalAccessException + | InvocationTargetException + | InstantiationException + | NoSuchMethodException e) { + Slog.wtf(TAG, "Unable to start " + externalServer); + Slog.wtf(TAG, e); } // It is now time to start up the app processes... -- cgit v1.1