package com.smartdevicelink.transport;

import com.smartdevicelink.transport.enums.TransportType;

import android.content.ComponentName;
import android.content.Context;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MultiplexTransportConfig extends BaseTransportConfig{

    /**
     * Multiplexing security will be turned off. All router services will be trusted.
     */
    public static final int FLAG_MULTI_SECURITY_OFF         = 0x00;
    /**
     *  Multiplexing security will be minimal. Only trusted router services will be used. Trusted router list will be obtain from 
     *  server. List will be refreshed every <b>30 days</b> or during next connection session if an SDL enabled app has been
     *  installed or uninstalled. 
     */
    public static final int FLAG_MULTI_SECURITY_LOW         = 0x10;
    /**
     *  Multiplexing security will be on at a normal level. Only trusted router services will be used. Trusted router list will be obtain from 
     *  server. List will be refreshed every <b>7 days</b> or during next connection session if an SDL enabled app has been
     *  installed or uninstalled. 
     */
    public static final int FLAG_MULTI_SECURITY_MED         = 0x20;
    /**
     *  Multiplexing security will be very strict. Only trusted router services installed from trusted app stores will 
     *  be used. Trusted router list will be obtain from server. List will be refreshed every <b>7 days</b> 
     *  or during next connection session if an SDL enabled app has been installed or uninstalled. 
     */
    public static final int FLAG_MULTI_SECURITY_HIGH        = 0x30;
	
	Context context;
	String appId;
	ComponentName service;
	int securityLevel;

	List<TransportType> primaryTransports, secondaryTransports;
	boolean requiresHighBandwidth = false;


	
	public MultiplexTransportConfig(Context context, String appId) {
		this.context = context;
		this.appId = appId;
		this.securityLevel = FLAG_MULTI_SECURITY_MED;
		this.primaryTransports = Arrays.asList(new TransportType[]{TransportType.USB, TransportType.BLUETOOTH});
		this.secondaryTransports = Arrays.asList(new TransportType[]{TransportType.TCP, TransportType.USB, TransportType.BLUETOOTH});

	}

	public MultiplexTransportConfig(Context context, String appId, int securityLevel) {
		this.context = context;
		this.appId = appId;
		this.securityLevel = securityLevel;
		this.primaryTransports = Arrays.asList(new TransportType[]{TransportType.USB, TransportType.BLUETOOTH});
		this.secondaryTransports = Arrays.asList(new TransportType[]{TransportType.TCP, TransportType.USB, TransportType.BLUETOOTH});


	}	

	/**
	 * Overridden abstract method which returns specific type of this transport configuration.
	 * 
	 * @return Constant value TransportType.MULTIPLEX. 
	 * 
	 * @see TransportType
	 */
	public TransportType getTransportType() {
		return TransportType.MULTIPLEX;
	}
	
	public Context getContext(){
		return this.context;
	}


	public ComponentName getService() {
		return service;
	}


	public void setService(ComponentName service) {
		this.service = service;
	}
	
	public void setSecurityLevel(int securityLevel){
		this.securityLevel = securityLevel;
	}
	
	public int getSecurityLevel(){
		return securityLevel;
	}

	public void setRequiresHighBandwidth(boolean requiresHighBandwidth){
		this.requiresHighBandwidth = requiresHighBandwidth;
	}

	public boolean requiresHighBandwidth(){
		return this.requiresHighBandwidth;
	}

	/**
	 * This will set the order in which a primary transport is determined to be accepted or not.
	 * In the case of previous protocol versions ( < 5.1)
	 * @param transports
	 */
	public void setPrimaryTransports(List<TransportType> transports){
		if(transports != null){
			//Sanitize
			transports.remove(TransportType.MULTIPLEX);
			this.primaryTransports = transports;
		}
	}

	public List<TransportType> getPrimaryTransports(){
		return this.primaryTransports;
	}

	/**
	 * This will set the order in which a primary transport is determined to be accepted or not.
	 * In the case of previous protocol versions ( < 5.1)
	 * @param transports
	 **/
	public void setSecondaryTransports(List<TransportType> transports){
		if(transports != null){
			//Sanitize
			transports.remove(TransportType.MULTIPLEX);
			this.secondaryTransports = transports;
		}
	}

	public List<TransportType> getSecondaryTransports(){
		return this.secondaryTransports;
	}


}

@@ -185,20 +185,17 @@
 il.Array
-List
+s
 ;%0Aimport
@@ -209,39 +209,48 @@
 til.
-Arrays;%0Aimport java.util.List;%0A
+List;%0A%0A@SuppressWarnings(%22WeakerAccess%22)
 %0Apub
@@ -2047,36 +2047,16 @@
 .asList(
-new TransportType%5B%5D%7B
 Transpor
@@ -2081,33 +2081,32 @@
 rtType.BLUETOOTH
-%7D
 );%0A%09%09this.second
@@ -2135,36 +2135,16 @@
 .asList(
-new TransportType%5B%5D%7B
 Transpor
@@ -2192,25 +2192,24 @@
 pe.BLUETOOTH
-%7D
 );%0A%0A%09%7D%0A%0A%09pub
@@ -2416,36 +2416,16 @@
 .asList(
-new TransportType%5B%5D%7B
 Transpor
@@ -2458,17 +2458,16 @@
 LUETOOTH
-%7D
 );%0A%09%09thi
@@ -2508,28 +2508,8 @@
 ist(
-new TransportType%5B%5D%7B
 Tran
@@ -2565,17 +2565,16 @@
 LUETOOTH
-%7D
 );%0A%0A%0A%09%7D%09
@@ -3577,24 +3577,71 @@
 m transports
+ list of transports that can be used as primary
 %0A%09 */%0A%09publi
@@ -4100,16 +4100,65 @@
 ansports
+ list of transports that can be used as secondary
 %0A%09 **/%0A%09

Fix lint warning is MultiplexTransportConfig