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

Unverified Commit 9497ae26 authored by Adnan Begovic's avatar Adnan Begovic Committed by Michael Bestas
Browse files

services: Kick off to CMSystemServer for external service init.

Change-Id: I2dfe51a4cadfe02f0295be36fb30a304219047ff
parent b6657ca0
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ import java.lang.reflect.Method;

import java.io.File;
import java.io.IOException;
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;
@@ -579,6 +582,9 @@ public final class SystemServer {
        boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1");
        boolean enableWigig = SystemProperties.getBoolean("persist.wigig.enable", false);

        String externalServer = context.getResources().getString(
                org.cyanogenmod.platform.internal.R.string.config_externalSystemServer);

        try {
            Slog.i(TAG, "Reading configuration...");
            SystemConfig.getInstance();
@@ -1245,6 +1251,24 @@ public final class SystemServer {
        // MMS service broker
        mmsService = mSystemServiceManager.startService(MmsServiceBroker.class);

        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);
        }

        if (Settings.Global.getInt(mContentResolver, Settings.Global.DEVICE_PROVISIONED, 0) == 0 ||
                UserManager.isDeviceInDemoMode(mSystemContext)) {
            mSystemServiceManager.startService(RetailDemoModeService.class);