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

Commit 43b2ac0b authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Add Connectivity Engine (CnE) WQE support"

parents 0e1a5d55 f1e62eef
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012, 2013. The Linux Foundation. All rights reserved.
 * Not a Contribution.
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -429,6 +431,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {

    TelephonyManager mTelephonyManager;

    protected ConnectivityService() { }

    public ConnectivityService(Context context, INetworkManagementService netd,
            INetworkStatsService statsService, INetworkPolicyManager policyManager) {
        // Currently, omitting a NetworkFactory will create one internally
@@ -3695,7 +3699,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
     * be done whenever a better abstraction is developed.
     */
    public class VpnCallback {
        private VpnCallback() {
        protected VpnCallback() {
        }

        public void onStateChanged(NetworkInfo info) {
@@ -4831,4 +4835,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        long wakeupTime = SystemClock.elapsedRealtime() + timeoutInMilliseconds;
        mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, wakeupTime, intent);
    }

    protected void updateBlockedUids(int uid, boolean isBlocked) {
    }
}
+52 −40
Original line number Diff line number Diff line
@@ -30,10 +30,13 @@ import android.content.res.Configuration;
import android.media.AudioService;
import android.net.wifi.p2p.WifiP2pService;
import android.os.Environment;
import android.net.INetworkPolicyManager;
import android.net.INetworkStatsService;
import android.os.IBinder;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.INetworkManagementService;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
@@ -50,6 +53,7 @@ import android.view.WindowManager;
import com.android.internal.R;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.SamplingProfilerIntegration;
import com.android.internal.util.MemInfoReader;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.accounts.AccountManagerService;
import com.android.server.am.ActivityManagerService;
@@ -143,7 +147,7 @@ class ServerThread {
        NetworkStatsService networkStats = null;
        NetworkPolicyManagerService networkPolicy = null;
        ConnectivityService connectivity = null;
        Object cneObj = null;
        Object qcCon = null;
        WifiP2pService wifiP2p = null;
        WifiService wifi = null;
        NsdService serviceDiscovery= null;
@@ -523,43 +527,40 @@ class ServerThread {
                }

               try {
                    Slog.i(TAG, "Connectivity Service");
                    connectivity = new ConnectivityService(
                   int enableCne = 1;
                   if (!deviceHasSufficientMemory()) {
                       enableCne = SystemProperties.getInt("persist.cne.override.memlimit", 0);
                   }
                   int cneFeature = (enableCne == 1) ?
                       SystemProperties.getInt("persist.cne.feature", 0) : 0;

                   if ( cneFeature > 0 && cneFeature < 7 ) {
                       Slog.i(TAG, "QcConnectivity Service");
                       PathClassLoader qcsClassLoader =
                           new PathClassLoader("/system/framework/services-ext.jar",
                                   ClassLoader.getSystemClassLoader());
                       Class qcsClass =
                           qcsClassLoader.loadClass("com.android.server.QcConnectivityService");
                       Constructor qcsConstructor = qcsClass.getConstructor
                           (new Class[] {Context.class, INetworkManagementService.class,
                            INetworkStatsService.class, INetworkPolicyManager.class});
                       qcCon = qcsConstructor.newInstance(
                               context, networkManagement, networkStats, networkPolicy);
                       connectivity = (ConnectivityService) qcCon;
                   } else {
                       Slog.i(TAG, "Connectivity Service");
                       connectivity = new ConnectivityService( context, networkManagement,
                               networkStats, networkPolicy);
                   }
                   if (connectivity != null) {
                       ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
                       networkStats.bindConnectivityManager(connectivity);
                       networkPolicy.bindConnectivityManager(connectivity);

                    wifiP2p.connectivityServiceReady();
                       wifi.checkAndStartWifi();
                } catch (Throwable e) {
                    reportWtf("starting Connectivity Service", e);
                }

                try {
                    int value = SystemProperties.getInt("persist.cne.feature", 0);
                    if(value > 0) {
                        try {
                            PathClassLoader cneClassLoader =
                                new PathClassLoader("/system/framework/com.quicinc.cne.jar",
                                        ClassLoader.getSystemClassLoader());
                            Class cneClass = cneClassLoader.loadClass("com.quicinc.cne.CNE");
                            Constructor cneConstructor = cneClass.getConstructor
                                (new Class[] {Context.class, Handler.class});
                            cneObj = cneConstructor.newInstance(context, null);
                        } catch (Exception e) {
                            Slog.e(TAG,"Failed to load CNE class", e);
                            cneObj = null;
                            reportWtf("Creating Connectivity Engine Service", e);
                        }
                        if (cneObj != null && (cneObj instanceof IBinder)) {
                            ServiceManager.addService("cneservice", (IBinder)cneObj);
                            Slog.i(TAG, "starting cneservice");
                        }
                       wifiP2p.connectivityServiceReady();
                   }
               } catch (Throwable e) {
                    Slog.e(TAG,"Loading CNEService failed: ", e);
                    reportWtf("starting Connectivity Engine Service", e);
                   reportWtf("starting Connectivity Service", e);
               }

                try {
@@ -1129,6 +1130,17 @@ class ServerThread {
        //Slog.d(TAG, "Starting service: " + intent);
        context.startServiceAsUser(intent, UserHandle.OWNER);
    }

    private static final boolean deviceHasSufficientMemory() {
        final long MEMORY_SIZE_MIN = 512 * 1024 * 1024;

        MemInfoReader minfo = new MemInfoReader();
        minfo.readMemInfo();
        if (minfo.getTotalSize() <= MEMORY_SIZE_MIN) {
            return false;
        }
        return true;
    }
}

public class SystemServer {