Skip to content

Commit 07d6f95

Browse files
committed
get notification listeners in manager from LCM
1 parent 0abaa2b commit 07d6f95

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ void initializeProxy() {
114114

115115
@Override
116116
void cycleProxy(SdlDisconnectedReason disconnectedReason) {
117-
cleanProxy();
118-
initializeProxy();
119117
if (!SdlDisconnectedReason.LEGACY_BLUETOOTH_MODE_ENABLED.equals(disconnectedReason) && !SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST.equals(disconnectedReason)) {
120118
//We don't want to alert higher if we are just cycling for legacy bluetooth
121119
onClose("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED), disconnectedReason);
122120
}
121+
cleanProxy();
122+
initializeProxy();
123123
if (session != null) {
124124
try {
125125
session.startSession();

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@
7171
import org.json.JSONException;
7272

7373
import java.util.ArrayList;
74+
import java.util.HashMap;
7475
import java.util.List;
7576
import java.util.Map;
7677
import java.util.Queue;
7778
import java.util.Set;
7879
import java.util.Vector;
7980
import java.util.concurrent.ConcurrentLinkedQueue;
81+
import java.util.concurrent.CopyOnWriteArrayList;
8082

8183
abstract class BaseSdlManager {
8284

@@ -145,6 +147,19 @@ public void onProxyClosed(LifecycleManager lifeCycleManager, String info, Except
145147
Log.i(TAG, "Proxy is closed.");
146148
if (reason == null || !reason.equals(SdlDisconnectedReason.LANGUAGE_CHANGE)) {
147149
dispose();
150+
} else {
151+
onRPCNotificationListeners = new HashMap<>();
152+
HashMap<Integer, CopyOnWriteArrayList<OnRPCNotificationListener>> rpcNotificationListeners = lifeCycleManager.getOnRPCNotificationListeners();
153+
for (Integer key : rpcNotificationListeners.keySet()) {
154+
if (rpcNotificationListeners.get(key) != null) {
155+
for (OnRPCNotificationListener listener : rpcNotificationListeners.get(key)) {
156+
String functionName = FunctionID.getFunctionName(key);
157+
if (functionName != null) {
158+
onRPCNotificationListeners.put(FunctionID.getEnumForString(functionName), listener);
159+
}
160+
}
161+
}
162+
}
148163
}
149164
}
150165

@@ -311,6 +326,7 @@ void handleQueuedNotifications() {
311326
//Set variables to null that are no longer needed
312327
queuedNotifications = null;
313328
queuedNotificationListener = null;
329+
onRPCNotificationListeners = null;
314330
}
315331
}
316332

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ private void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotifi
640640
}
641641
}
642642

643+
public HashMap<Integer, CopyOnWriteArrayList<OnRPCNotificationListener>> getOnRPCNotificationListeners() {
644+
return rpcNotificationListeners;
645+
}
646+
643647
private boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {
644648
synchronized (ON_NOTIFICATION_LISTENER_LOCK) {
645649
if (rpcNotificationListeners != null

0 commit comments

Comments
 (0)