Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70d2082f authored by Adnan Begovic's avatar Adnan Begovic Committed by Gerrit Code Review
Browse files

services: Kick off to CMSystemServer for external service init.

Change-Id: I2dfe51a4cadfe02f0295be36fb30a304219047ff
parent 9a23f2e7
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -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...