diff options
author | Bretty White <geekman3454@protonmail.com> | 2018-07-12 15:50:53 -0400 |
---|---|---|
committer | Bretty White <geekman3454@protonmail.com> | 2018-07-12 15:50:53 -0400 |
commit | e3b4e9eb7e65c0bc71bacd826d7aae094655990e (patch) | |
tree | a8638dadd68cb41e85b7673628b976493277d7d2 | |
parent | 0b0f8dac06035b80b6becf3ce760f7d0da7fb422 (diff) | |
download | sdl_android-e3b4e9eb7e65c0bc71bacd826d7aae094655990e.tar.gz |
update sdlmanager and basesubmanager per review comments
-rw-r--r-- | sdl_android/src/main/java/com/smartdevicelink/api/BaseSubManager.java | 18 | ||||
-rw-r--r-- | sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java | 35 |
2 files changed, 20 insertions, 33 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/api/BaseSubManager.java b/sdl_android/src/main/java/com/smartdevicelink/api/BaseSubManager.java index 3a99dde82..0096621e0 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/api/BaseSubManager.java +++ b/sdl_android/src/main/java/com/smartdevicelink/api/BaseSubManager.java @@ -16,33 +16,27 @@ import com.smartdevicelink.proxy.interfaces.ISdl; public abstract class BaseSubManager { // states - if this gets more complicated we can move elsewhere - public enum ManagerState { - SETTING_UP, - READY, - SHUTDOWN, - ; - } + public int state, SETTING_UP = 0x00, READY = 0x30, SHUTDOWN = 0x60; - protected ISdl internalInterface; - protected ManagerState state; + protected final ISdl internalInterface; public BaseSubManager(@NonNull ISdl internalInterface){ this.internalInterface = internalInterface; - this.state = ManagerState.SETTING_UP; + this.state = SETTING_UP; } /** * <p>Called when manager is being torn down</p> */ public void dispose(){ - this.state = ManagerState.SHUTDOWN; + this.state = SHUTDOWN; } - protected void transitionToState(ManagerState state) { + protected void transitionToState(int state) { this.state = state; } - protected ManagerState getState() { + protected int getState() { return state; } } diff --git a/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java b/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java index 0cf46b612..be51ebb41 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java +++ b/sdl_android/src/main/java/com/smartdevicelink/api/SdlManager.java @@ -62,7 +62,7 @@ public class SdlManager implements ProxyBridge.LifecycleListener { private Vector<TTSChunk> ttsChunks; private TemplateColorScheme dayColorScheme, nightColorScheme; - private ProxyBridge proxyBridge; + private final ProxyBridge proxyBridge= new ProxyBridge(this); //public LockScreenConfig lockScreenConfig; // Managers @@ -75,11 +75,7 @@ public class SdlManager implements ProxyBridge.LifecycleListener { private PermissionManager permissionManager; */ - private SdlManager() {} - private void initialize(){ - // proxy bridge - this.proxyBridge = new ProxyBridge(this); // instantiate managers /* @@ -182,19 +178,16 @@ public class SdlManager implements ProxyBridge.LifecycleListener { }*/ /** - * Sets the vector of AppHMIType + * Sets the vector of AppHMIType <br> + * <strong>Note: This should be an ordered list from most -> least relevant</strong> * @param hmiTypes */ public Builder setAppTypes(final Vector<AppHMIType> hmiTypes){ + sdlManager.hmiTypes = hmiTypes; + if (hmiTypes != null) { - sdlManager.hmiTypes = hmiTypes; sdlManager.isMediaApp = hmiTypes.contains(AppHMIType.MEDIA); - }else { - Vector<AppHMIType> hmiTypesDefault = new Vector<>(); - hmiTypesDefault.add(AppHMIType.DEFAULT); - sdlManager.hmiTypes = hmiTypesDefault; - sdlManager.isMediaApp = false; } return this; @@ -240,7 +233,14 @@ public class SdlManager implements ProxyBridge.LifecycleListener { @SuppressWarnings("unchecked") public SdlManager build() { try { - sdlManager.initialize(); + + if (sdlManager.appName == null) { + throw new IllegalArgumentException("You must specify an app name by calling setAppName"); + } + + if (sdlManager.appId == null) { + throw new IllegalArgumentException("You must specify an app ID by calling setAppId"); + } if (sdlManager.hmiTypes == null) { Vector<AppHMIType> hmiTypesDefault = new Vector<>(); @@ -253,14 +253,7 @@ public class SdlManager implements ProxyBridge.LifecycleListener { sdlManager.hmiLanguage = Language.EN_US; } - if (sdlManager.appName == null) { - throw new IllegalArgumentException("You must specify an app name by calling setAppName"); - } - - if (sdlManager.appId == null) { - throw new IllegalArgumentException("You must specify an app ID by calling setAppId"); - } - + sdlManager.initialize(); sdlManager.proxy = new SdlProxyBase(sdlManager.proxyBridge, sdlManager.appName, sdlManager.shortAppName, sdlManager.isMediaApp, sdlManager.hmiLanguage, sdlManager.hmiLanguage, sdlManager.hmiTypes, sdlManager.appId, sdlManager.transport, sdlManager.vrSynonyms, sdlManager.ttsChunks, sdlManager.dayColorScheme, sdlManager.nightColorScheme) {}; } catch (SdlException e) { e.printStackTrace(); |