<commit_before>package com.smartdevicelink.api;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;

import com.smartdevicelink.api.lockscreen.LockScreenConfig;
import com.smartdevicelink.api.lockscreen.LockScreenManager;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.SdlProxyBase;
import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.TTSChunk;
import com.smartdevicelink.proxy.rpc.TemplateColorScheme;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.streaming.audio.AudioStreamingCodec;
import com.smartdevicelink.streaming.audio.AudioStreamingParams;
import com.smartdevicelink.streaming.video.VideoStreamingParameters;
import com.smartdevicelink.transport.BaseTransportConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * <strong>SDLManager</strong> <br>
 *
 * This is the main point of contact between an application and SDL <br>
 *
 * It is broken down to these areas: <br>
 *
 * 1. SDLManagerBuilder <br>
 * 2. ISdl Interface along with its overridden methods - This can be passed into attached managers <br>
 * 3. Sending Requests <br>
 * 4. Helper methods
 */
public class SdlManager {

	private static String TAG = "Sdl Manager";
	private SdlProxyBase proxy;

	// Required parameters for builder
	private String appId, appName, shortAppName;
	private boolean isMediaApp;
	private Language hmiLanguage;
	private Vector<AppHMIType> hmiTypes;
	private BaseTransportConfig transport;
	private Context context;
	private Vector<String> vrSynonyms;
	private Vector<TTSChunk> ttsChunks;
	private TemplateColorScheme dayColorScheme, nightColorScheme;

	private CompletionListener initListener;
	private int state = -1;
	private LockScreenConfig lockScreenConfig;

	// Managers
	private LockScreenManager lockscreenManager;
    /*
    private FileManager fileManager;
    private VideoStreamingManager videoStreamingManager;
    private AudioStreamManager audioStreamManager;
    private LockscreenManager lockscreenManager;
    private ScreenManager screenManager;
    private PermissionManager permissionManager;
    */

	// Initialize proxyBridge with anonymous lifecycleListener
	private final ProxyBridge proxyBridge= new ProxyBridge(new ProxyBridge.LifecycleListener() {
		@Override
		public void onProxyConnected() {
			Log.d(TAG, "Proxy is connected. Now initializing.");
			initialize();
		}

		@Override
		public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason){
			dispose();
		}

		@Override
		public void onServiceEnded(OnServiceEnded serviceEnded){

		}

		@Override
		public void onServiceNACKed(OnServiceNACKed serviceNACKed){

		}

		@Override
		public void onError(String info, Exception e){

		}
	});

	// Sub manager listener
	private final CompletionListener subManagerListener = new CompletionListener() {
		@Override
		public synchronized void onComplete(boolean success) {
			if(!success){
				Log.d(TAG, "Sub manager failed to initialize");
			}
			if(
					lockscreenManager.getState() != BaseSubManager.SETTING_UP
					/*
					fileManager.getState() != BaseSubManager.SETTING_UP &&
					videoStreamingManager.getState() != BaseSubManager.SETTING_UP &&
					audioStreamManager.getState() != BaseSubManager.SETTING_UP &&
					screenManager.getState() != BaseSubManager.SETTING_UP
					permissionManager.getState() != BaseSubManager.SETTING_UP
					*/  ){
				state = BaseSubManager.READY;
				if(initListener != null){
					initListener.onComplete(true);
					initListener = null;
				}
			}
		}
	};

	private void initialize(){
		// instantiate managers
		this.lockscreenManager = new LockScreenManager(lockScreenConfig, context, _internalInterface);
		this.lockscreenManager.start(subManagerListener);
		/*
		this.fileManager = new FileManager(_internalInterface, context);
		this.fileManager.start(subManagerListener);
		this.screenManager = new ScreenManager(_internalInterface, this.fileManager);
		this.screenManager.start(subManagerListener);
		this.permissionManager = new PermissionManager(_internalInterface);
		this.permissionManager.start(subManagerListener);
		this.videoStreamingManager = new VideoStreamingManager(context, _internalInterface);
		this.videoStreamingManager.start(subManagerListener);
		this.audioStreamManager = new AudioStreamManager(_internalInterface);
		this.audioStreamManager.start(subManagerListener);
		*/

		// If no managers, just call subManagerListener's onComplete
		subManagerListener.onComplete(true);
	}

	private void dispose() {
		this.lockscreenManager.dispose();
		/*
		this.fileManager.dispose();
		this.audioStreamManager.dispose();
		this.screenManager.dispose();
		this.permissionManager.dispose();
		this.videoStreamingManager.dispose();
		this.audioStreamManager.dispose();
		*/
	}
<commit_msg>only start manager if it is enabled<commit_after>package com.smartdevicelink.api;

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.Log;

import com.smartdevicelink.api.lockscreen.LockScreenConfig;
import com.smartdevicelink.api.lockscreen.LockScreenManager;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.SdlProxyBase;
import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
import com.smartdevicelink.proxy.interfaces.ISdl;
import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.TTSChunk;
import com.smartdevicelink.proxy.rpc.TemplateColorScheme;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.streaming.audio.AudioStreamingCodec;
import com.smartdevicelink.streaming.audio.AudioStreamingParams;
import com.smartdevicelink.streaming.video.VideoStreamingParameters;
import com.smartdevicelink.transport.BaseTransportConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * <strong>SDLManager</strong> <br>
 *
 * This is the main point of contact between an application and SDL <br>
 *
 * It is broken down to these areas: <br>
 *
 * 1. SDLManagerBuilder <br>
 * 2. ISdl Interface along with its overridden methods - This can be passed into attached managers <br>
 * 3. Sending Requests <br>
 * 4. Helper methods
 */
public class SdlManager {

	private static String TAG = "Sdl Manager";
	private SdlProxyBase proxy;

	// Required parameters for builder
	private String appId, appName, shortAppName;
	private boolean isMediaApp;
	private Language hmiLanguage;
	private Vector<AppHMIType> hmiTypes;
	private BaseTransportConfig transport;
	private Context context;
	private Vector<String> vrSynonyms;
	private Vector<TTSChunk> ttsChunks;
	private TemplateColorScheme dayColorScheme, nightColorScheme;

	private CompletionListener initListener;
	private int state = -1;
	private LockScreenConfig lockScreenConfig;

	// Managers
	private LockScreenManager lockscreenManager;
    /*
    private FileManager fileManager;
    private VideoStreamingManager videoStreamingManager;
    private AudioStreamManager audioStreamManager;
    private LockscreenManager lockscreenManager;
    private ScreenManager screenManager;
    private PermissionManager permissionManager;
    */

	// Initialize proxyBridge with anonymous lifecycleListener
	private final ProxyBridge proxyBridge= new ProxyBridge(new ProxyBridge.LifecycleListener() {
		@Override
		public void onProxyConnected() {
			Log.d(TAG, "Proxy is connected. Now initializing.");
			initialize();
		}

		@Override
		public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason){
			dispose();
		}

		@Override
		public void onServiceEnded(OnServiceEnded serviceEnded){

		}

		@Override
		public void onServiceNACKed(OnServiceNACKed serviceNACKed){

		}

		@Override
		public void onError(String info, Exception e){

		}
	});

	// Sub manager listener
	private final CompletionListener subManagerListener = new CompletionListener() {
		@Override
		public synchronized void onComplete(boolean success) {
			if(!success){
				Log.d(TAG, "Sub manager failed to initialize");
			}
			if(lockscreenManager == null || lockscreenManager.getState() != BaseSubManager.SETTING_UP){
				state = BaseSubManager.READY;
				if(initListener != null){
					initListener.onComplete(true);
					initListener = null;
				}
			}
		}
	};

	private void initialize(){
		// instantiate managers
		if (lockScreenConfig.isEnabled()) {
			this.lockscreenManager = new LockScreenManager(lockScreenConfig, context, _internalInterface);
			this.lockscreenManager.start(subManagerListener);
		}
		/*
		this.fileManager = new FileManager(_internalInterface, context);
		this.fileManager.start(subManagerListener);
		this.screenManager = new ScreenManager(_internalInterface, this.fileManager);
		this.screenManager.start(subManagerListener);
		this.permissionManager = new PermissionManager(_internalInterface);
		this.permissionManager.start(subManagerListener);
		this.videoStreamingManager = new VideoStreamingManager(context, _internalInterface);
		this.videoStreamingManager.start(subManagerListener);
		this.audioStreamManager = new AudioStreamManager(_internalInterface);
		this.audioStreamManager.start(subManagerListener);
		*/

		// If no managers, just call subManagerListener's onComplete
		subManagerListener.onComplete(true);
	}

	private void dispose() {
		if (this.lockscreenManager != null) {
			this.lockscreenManager.dispose();
		}
		/*
		this.fileManager.dispose();
		this.audioStreamManager.dispose();
		this.screenManager.dispose();
		this.permissionManager.dispose();
		this.videoStreamingManager.dispose();
		this.audioStreamManager.dispose();
		*/
	}

{'fraction_non_alphanumeric': 0.08811031133466309, 'fraction_numerical': 0.000867227473766369, 'mean_word_length': 5.6697513013302485, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7249633', 'n_tokens_mistral': 3604, 'n_tokens_neox': 3353, 'n_words': 684}