Skip to content

Commit f18454b

Browse files
Merge branch 'develop' into feature/use_taskmaster
2 parents 61afaf4 + a4cb87c commit f18454b

6 files changed

Lines changed: 36 additions & 50 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import com.smartdevicelink.managers.screen.ScreenManager;
5050
import com.smartdevicelink.managers.video.VideoStreamManager;
5151
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
52-
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
5352
import com.smartdevicelink.transport.BaseTransportConfig;
5453
import com.smartdevicelink.transport.MultiplexTransportConfig;
5554
import com.smartdevicelink.transport.enums.TransportType;
@@ -211,18 +210,6 @@ public void run() {
211210
}
212211
}
213212

214-
@Override
215-
void onProxyClosed(SdlDisconnectedReason reason) {
216-
Log.i(TAG, "Proxy is closed.");
217-
if (managerListener != null) {
218-
managerListener.onDestroy();
219-
}
220-
221-
if (reason == null || !reason.equals(SdlDisconnectedReason.LANGUAGE_CHANGE)) {
222-
dispose();
223-
}
224-
}
225-
226213
/**
227214
* Dispose SdlManager and clean its resources
228215
* <strong>Note: new instance of SdlManager should be created on every connection. SdlManager cannot be reused after getting disposed.</strong>

android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,20 @@ void initializeProxy() {
112112
}
113113
}
114114

115-
private void cycleProxy(SdlDisconnectedReason disconnectedReason) {
115+
@Override
116+
void cycleProxy(SdlDisconnectedReason disconnectedReason) {
116117
cleanProxy();
117118
initializeProxy();
118119
if (!SdlDisconnectedReason.LEGACY_BLUETOOTH_MODE_ENABLED.equals(disconnectedReason) && !SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST.equals(disconnectedReason)) {
119120
//We don't want to alert higher if we are just cycling for legacy bluetooth
120-
onClose("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED));
121+
onClose("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED), disconnectedReason);
121122
}
122-
try {
123-
session.startSession();
124-
} catch (SdlException e) {
125-
e.printStackTrace();
123+
if (session != null) {
124+
try {
125+
session.startSession();
126+
} catch (SdlException e) {
127+
e.printStackTrace();
128+
}
126129
}
127130
}
128131

@@ -160,7 +163,7 @@ void onTransportDisconnected(String info, boolean availablePrimary, BaseTranspor
160163
Log.d(TAG, "notifying RPC session ended, but potential primary transport available");
161164
cycleProxy(SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST);
162165
} else {
163-
onClose(info, null);
166+
onClose(info, null, null);
164167
}
165168
}
166169

base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ public void onServiceEnded(SessionType sessionType) {
142142

143143
@Override
144144
public void onProxyClosed(LifecycleManager lifeCycleManager, String info, Exception e, SdlDisconnectedReason reason) {
145-
BaseSdlManager.this.onProxyClosed(reason);
145+
Log.i(TAG, "Proxy is closed.");
146+
if (reason == null || !reason.equals(SdlDisconnectedReason.LANGUAGE_CHANGE)) {
147+
dispose();
148+
}
146149
}
147150

148151
@Override
@@ -165,8 +168,6 @@ public synchronized void onComplete(boolean success) {
165168
// ABSTRACT METHODS
166169
abstract void retryChangeRegistration();
167170

168-
abstract void onProxyClosed(SdlDisconnectedReason reason);
169-
170171
abstract void checkState();
171172

172173
abstract void initialize();

base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ public OnHMIStatus getCurrentHMIStatus() {
342342
return currentHMIStatus;
343343
}
344344

345-
void onClose(String info, Exception e) {
345+
void onClose(String info, Exception e, SdlDisconnectedReason reason) {
346346
Log.i(TAG, "onClose");
347347
if (lifecycleListener != null) {
348-
lifecycleListener.onProxyClosed((LifecycleManager) this, info, e, null);
348+
lifecycleListener.onProxyClosed((LifecycleManager) this, info, e, reason);
349349
}
350350
}
351351

@@ -462,7 +462,7 @@ public void run() {
462462
cleanProxy();
463463
} else {
464464
Log.v(TAG, "re-registering for language change");
465-
processLanguageChange();
465+
cycleProxy(SdlDisconnectedReason.LANGUAGE_CHANGE);
466466
}
467467
break;
468468
case UNREGISTER_APP_INTERFACE:
@@ -476,19 +476,6 @@ public void run() {
476476

477477
};
478478

479-
private void processLanguageChange() {
480-
if (session != null) {
481-
if (session.getIsConnected()) {
482-
session.close();
483-
}
484-
try {
485-
session.startSession();
486-
} catch (SdlException e) {
487-
e.printStackTrace();
488-
}
489-
}
490-
}
491-
492479
/* *******************************************************************************************************
493480
********************************** INTERNAL - RPC LISTENERS !! END !! *********************************
494481
*********************************************************************************************************/
@@ -872,7 +859,7 @@ private void sendRPCMessagePrivate(RPCMessage message, boolean isInternalMessage
872859
final ISdlConnectionListener sdlConnectionListener = new ISdlConnectionListener() {
873860
@Override
874861
public void onTransportDisconnected(String info) {
875-
onClose(info, null);
862+
onClose(info, null, null);
876863

877864
}
878865

@@ -884,7 +871,7 @@ public void onTransportDisconnected(String info, boolean availablePrimary, BaseT
884871

885872
@Override
886873
public void onTransportError(String info, Exception e) {
887-
onClose(info, e);
874+
onClose(info, e, null);
888875

889876
}
890877

@@ -1530,6 +1517,8 @@ void onProtocolSessionStarted(SessionType sessionType) {
15301517
}
15311518
}
15321519

1520+
abstract void cycleProxy(SdlDisconnectedReason disconnectedReason);
1521+
15331522
void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) {
15341523
}
15351524

javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ void retryChangeRegistration() {
141141
// Do nothing
142142
}
143143

144-
@Override
145-
void onProxyClosed(SdlDisconnectedReason reason) {
146-
Log.i(TAG, "Proxy is closed.");
147-
if (managerListener != null) {
148-
managerListener.onDestroy(SdlManager.this);
149-
}
150-
}
151-
152144
@Override
153145
public void dispose() {
154146
if (this.permissionManager != null) {

javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import android.support.annotation.RestrictTo;
3636

3737
import com.smartdevicelink.SdlConnection.SdlSession;
38+
import com.smartdevicelink.exception.SdlException;
39+
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
3840
import com.smartdevicelink.transport.BaseTransportConfig;
3941

4042
/**
@@ -53,11 +55,23 @@ void initializeProxy() {
5355
this.session = new SdlSession(sdlConnectionListener, _transportConfig);
5456
}
5557

58+
@Override
59+
void cycleProxy(SdlDisconnectedReason disconnectedReason) {
60+
cleanProxy();
61+
if (session != null) {
62+
try {
63+
session.startSession();
64+
} catch (SdlException e) {
65+
e.printStackTrace();
66+
}
67+
}
68+
}
69+
5670
@Override
5771
void onTransportDisconnected(String info, boolean availablePrimary, BaseTransportConfig transportConfig) {
5872
super.onTransportDisconnected(info, availablePrimary, transportConfig);
5973
if (!availablePrimary) {
60-
onClose(info, null);
74+
onClose(info, null, null);
6175
}
6276
}
6377
}

0 commit comments

Comments
 (0)