summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuriy <YChernyshov@luxoft.com>2014-07-08 11:10:36 +0300
committerYuriy <YChernyshov@luxoft.com>2014-07-08 11:10:36 +0300
commit2c8332c90a786c097bf11989a923a2930e12e1d2 (patch)
tree434dd8fe18b9ecdf5f8bf4ce0178724be028e4c7
parent131e154b8b98e055d39f76db95387a6b9a5c28f7 (diff)
downloadsdl_core-SNAPSHOT_PASA08072014.tar.gz
APPLINK-6558-Restore RPC Service during XML auto testing.SNAPSHOT_PASA08072014
-rw-r--r--mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/SyncProxyBase.java58
-rw-r--r--mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/session/Session.java15
-rw-r--r--mobile/android/SyncProxyTester/src/main/AndroidManifest.xml4
-rw-r--r--mobile/android/SyncProxyTester/src/main/assets/CHANGELOG.txt4
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java20
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/module/ModuleTest.java17
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/IProxyServiceEvent.java8
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/ProxyService.java62
8 files changed, 147 insertions, 41 deletions
diff --git a/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/SyncProxyBase.java b/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/SyncProxyBase.java
index d3b069cad3..20b839a303 100644
--- a/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/SyncProxyBase.java
+++ b/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/SyncProxyBase.java
@@ -100,6 +100,7 @@ import com.ford.syncV4.util.DeviceInfoManager;
import com.ford.syncV4.util.logger.Logger;
import java.io.OutputStream;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
@@ -616,7 +617,7 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
*/
public void updateRegisterAppInterfaceParameters(RegisterAppInterface registerAppInterface,
boolean sendAsItIs) {
- String appId = (String) registerAppInterface.getAppId();
+ String appId = String.valueOf(registerAppInterface.getAppId());
if (registerAppInterface.getDeviceInfo() != null) {
setDeviceInfo(registerAppInterface.getDeviceInfo());
DeviceInfoManager.copyDeviceInfo(getDeviceInfo(), registerAppInterface.getDeviceInfo());
@@ -626,16 +627,11 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
if (registerAppInterface.getCorrelationID() != null) {
setRegisterAppInterfaceCorrelationId(registerAppInterface.getCorrelationID());
}
- if (sendAsItIs) {
- raiTable.put(appId, registerAppInterface);
- appIds.add(appId);
- } else {
+ if (!sendAsItIs) {
RegisterAppInterface registerAppInterfaceToUpdate = raiTable.get(appId);
Logger.d(LOG_TAG + " Update RAI (public), appId:" + appId + ", RAI:" + registerAppInterface);
if (registerAppInterfaceToUpdate == null) {
registerAppInterfaceToUpdate = RPCRequestFactory.buildRegisterAppInterface();
- raiTable.put(appId, registerAppInterface);
- appIds.add(appId);
}
if (registerAppInterfaceToUpdate != null) {
registerAppInterfaceToUpdate.setTtsName(registerAppInterface.getTtsName());
@@ -658,6 +654,8 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
}
}
}
+ raiTable.put(appId, registerAppInterface);
+ appIds.add(appId);
}
/**
@@ -899,6 +897,35 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
return mSyncConnection;
}
+ /**
+ * This method is for the TEST CASES ONLY, it used for example in XML testing, when RAI request
+ * has different AppId and (or) different AppName, so we need to adjust session
+ * (if it has been started) to the new RAI request
+ */
+ public void invalidatePreviousSession(String newAppId) {
+ // In XML test assume that we have only one session started, so get the enum of the
+ // session ids
+ Enumeration<Byte> lastSessionId = syncSession.getSessionIds();
+
+ // Invalidate all previous Session(s) RAI request(s)
+ invalidateAllRAIs();
+
+ // Invalidate all previous Session(s) data
+ syncSession.invalidate();
+
+ // Assign new AppId (according to XML test)
+ appIds.add(newAppId);
+
+ // Initialize new AppId key at the Session's holder collection
+ syncSession.addAppId(newAppId);
+
+ // Again, assume that we have only one Session in XML test, assign previous Session Id
+ // to the new AppId
+ if (lastSessionId.hasMoreElements()) {
+ syncSession.updateSessionId(lastSessionId.nextElement());
+ }
+ }
+
public ProxyMessageDispatcher<ProtocolMessage> getIncomingProxyMessageDispatcher() {
return _incomingProxyMessageDispatcher;
}
@@ -1128,7 +1155,7 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
mIsProxyDisposed = true;
- Logger.i("SYNC Proxy start Dispose");
+ Logger.i("SYNC Proxy start dispose");
try {
// Clean the proxy
@@ -1162,7 +1189,7 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
mTraceDeviceInterrogator = null;
} finally {
- Logger.i("SyncProxy Disposed");
+ Logger.i("SYNC Proxy disposed");
}
}
@@ -1911,9 +1938,11 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
DeviceInfoManager.dumpDeviceInfo(getDeviceInfo());
String appId = syncSession.getAppIdBySessionId(sessionId);
- Logger.d("RestartRPCProtocolSession sesId:" + sessionId + " appId:" + appId);
-
RegisterAppInterface registerAppInterface = raiTable.get(appId);
+
+ Logger.d("RestartRPCProtocolSession sesId:" + sessionId + " appId:" + appId +
+ " RAI:" + registerAppInterface);
+
if (registerAppInterface == null) {
return;
}
@@ -2620,10 +2649,11 @@ public abstract class SyncProxyBase<ProxyListenerType extends IProxyListenerBase
languageDesired, hmiDisplayLanguageDesired, appHMIType, appId, correlationID, hashId,
deviceInfo);
- appIds.add((String) appId);
- raiTable.put((String) appId, registerAppInterface);
+ final String appIdString = String.valueOf(appId);
+ appIds.add(appIdString);
+ raiTable.put(appIdString, registerAppInterface);
- sendRPCRequestPrivate((String) appId, registerAppInterface);
+ sendRPCRequestPrivate(appIdString, registerAppInterface);
}
/**
diff --git a/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/session/Session.java b/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/session/Session.java
index d4f326e189..2f7486931f 100644
--- a/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/session/Session.java
+++ b/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/session/Session.java
@@ -5,6 +5,7 @@ import com.ford.syncV4.service.Service;
import com.ford.syncV4.util.logger.Logger;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -113,6 +114,13 @@ public class Session {
}
/**
+ * @return an enumeration of the Session Ids.
+ */
+ public Enumeration<Byte> getSessionIds() {
+ return sessionIds.elements();
+ }
+
+ /**
* @return a number of Session Id's
*/
public int getSessionIdsNumber() {
@@ -285,13 +293,12 @@ public class Session {
/**
* Invalidates provided Application Id, clear all Services associated and remove it from the list
*
- * @param appId Application Id
- *
* @return true in case of success, false - otherwise
*/
- public boolean invalidateAppId(String appId) {
+ public boolean invalidate() {
- // TODO : Implement
+ servicesList.clear();
+ sessionIds.clear();
return true;
}
diff --git a/mobile/android/SyncProxyTester/src/main/AndroidManifest.xml b/mobile/android/SyncProxyTester/src/main/AndroidManifest.xml
index 630e7bed3d..87a69f9ffb 100644
--- a/mobile/android/SyncProxyTester/src/main/AndroidManifest.xml
+++ b/mobile/android/SyncProxyTester/src/main/AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ford.syncV4.android"
- android:versionCode="94"
- android:versionName="2.0.23 (CW27)" >
+ android:versionCode="96"
+ android:versionName="2.0.24 (CW28)" >
<!-- Version 12 is minimum to support the USB Accessory mode -->
<uses-sdk android:minSdkVersion="12"/>
diff --git a/mobile/android/SyncProxyTester/src/main/assets/CHANGELOG.txt b/mobile/android/SyncProxyTester/src/main/assets/CHANGELOG.txt
index ea883041ec..fbc2ca4ec0 100644
--- a/mobile/android/SyncProxyTester/src/main/assets/CHANGELOG.txt
+++ b/mobile/android/SyncProxyTester/src/main/assets/CHANGELOG.txt
@@ -1,4 +1,8 @@
+[CW28]
+* SYNC Mobile SDK | SyncProxyTester: Add possibility to restore connection during autotest (exclude connection lost)
+
[CW27]
+* SYNC Mobile SDK: SDL should always do a notification of the mobile app about closed session
* SyncProxyTester: Log two request of UnsubscribeButton on mobile
* SyncProxyTester: Some RPC responses are not shown in the list view
* SyncProxyTester: Incorrect representation of the "key - value" pair in the RPC Request at the XML test
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java
index d0f4750fd9..7d99c3bc38 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java
@@ -480,6 +480,26 @@ public class SyncProxyTester extends ActionBarActivity implements ActionBar.TabL
}*/
}
+ /**
+ * A callback form the Test Module indicated that current AppId has been changed
+ *
+ * @param newAppId new AppId
+ */
+ @Override
+ public void onInvalidateAppId(final String newAppId) {
+ /*PlaceholderFragment currentFragment = getCurrentActiveFragment();
+ if (currentFragment == null) {
+ return;
+ }
+ currentFragment.setAppId(newAppId);*/
+ MainApp.getInstance().runInUIThread(new Runnable() {
+ @Override
+ public void run() {
+ updateActiveTabView(newAppId);
+ }
+ });
+ }
+
@Override
public void onServiceStart(ServiceType serviceType, String appId) {
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/module/ModuleTest.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/module/ModuleTest.java
index b7e1c23afe..1aebbe57df 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/module/ModuleTest.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/module/ModuleTest.java
@@ -310,8 +310,7 @@ public class ModuleTest {
if (filenames.length > 0) {
List<String> paths = new ArrayList<String>();
for (String filename : filenames) {
- mLogAdapter.logMessage("Processing "
- + filename, Log.INFO, true);
+ mLogAdapter.logMessage("Processing " + filename, Log.INFO, true);
try {
String fullPath = mFilePath + File.separator + filename;
processTestFile(fullPath);
@@ -321,13 +320,10 @@ public class ModuleTest {
paths.add(testErrorsFilename);
}
} catch (Exception e) {
- mLogAdapter
- .logMessage("Parser Failed!!",
- Log.ERROR, e);
+ mLogAdapter.logMessage("Parser Failed!!", Log.ERROR, e);
}
}
- mLogAdapter.logMessage("All tests finished",
- Log.INFO, true);
+ mLogAdapter.logMessage("All tests finished", Log.INFO, true);
if (paths.size() > 0) {
sendReportEmail(paths);
@@ -452,8 +448,9 @@ public class ModuleTest {
Logger.e(TAG + " Couldn't parse pause number: " + pauseString);
}
}
- currentTest = new Test(parser.getAttributeValue(null, TEST_NAME_ATTR),
- pause, null);
+ String testName = parser.getAttributeValue(null, TEST_NAME_ATTR);
+ Logger.d(TAG + " Test '" + testName + "' started");
+ currentTest = new Test(testName, pause, null);
expecting.clear();
sResponses.clear();
numIterations = 1;
@@ -1133,7 +1130,7 @@ public class ModuleTest {
// (generateInvalidJSON ? invalidMarshaller : defaultMarshaller);
//Logger.d("Current Marshaller:" + currentMarshaller);
- //Logger.d(TAG + " Send RPC:" + rpc + " appId:" + mAppId);
+ //Logger.d(TAG + " Send Test RPC:" + rpc.getFunctionName() + " appId:" + mAppId);
mProxyService.sendRPCRequestWithPreprocess(mAppId, rpc, currentMarshaller, true);
long pause = wrapper.getPause();
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/IProxyServiceEvent.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/IProxyServiceEvent.java
index e1fb9435bc..cbeaef9d0c 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/IProxyServiceEvent.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/IProxyServiceEvent.java
@@ -54,4 +54,12 @@ public interface IProxyServiceEvent {
* @param serviceType a type of the service
*/
public void onStartServiceNackReceived(String appId, ServiceType serviceType);
+
+ /**
+ * Dispatch when XML test need to send {@link com.ford.syncV4.proxy.rpc.RegisterAppInterface}
+ * response with different AppId and(or) AppName parameters
+ *
+ * @param newAppId new AppId
+ */
+ public void onInvalidateAppId(String newAppId);
} \ No newline at end of file
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/ProxyService.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/ProxyService.java
index 64e173262a..5d2c9b3aaa 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/ProxyService.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/service/ProxyService.java
@@ -706,6 +706,11 @@ public class ProxyService extends Service implements IProxyListenerALMTesting, I
createDebugMessageForAdapter(appId, notification);
+ if (mSyncProxy == null) {
+ Logger.w(TAG + " OnOnHMIStatus SYNC Proxy null");
+ return;
+ }
+
switch (notification.getSystemContext()) {
case SYSCTXT_MAIN:
break;
@@ -881,7 +886,7 @@ public class ProxyService extends Service implements IProxyListenerALMTesting, I
mConnectionListenersManager.dispatch();
}
- Logger.d("Is Module testing:" + isModuleTesting());
+ Logger.d("OnProxyClosed is Module testing:" + isModuleTesting());
if (!isModuleTesting()) {
if (e == null) {
@@ -898,7 +903,8 @@ public class ProxyService extends Service implements IProxyListenerALMTesting, I
}
}
} else {
- mSyncProxy = null;
+ // TODO : At the end of the XML Test the default workflow of the SDK is restoring
+ // Session, if the is no such needs then this is a place to cancel reconnect task
}
}
@@ -1821,6 +1827,10 @@ public class ProxyService extends Service implements IProxyListenerALMTesting, I
}
}
+ if (mSyncProxy == null) {
+ Logger.w(TAG + " OnRegisterAppInterfaceResponse SYNC Proxy null");
+ return;
+ }
try {
processRegisterAppInterfaceResponse(appId, response);
} catch (SyncException e) {
@@ -2396,7 +2406,7 @@ public class ProxyService extends Service implements IProxyListenerALMTesting, I
*
* @throws SyncException
*/
- private void sendRegisterRequest(RegisterAppInterface registerAppInterface,
+ private synchronized void sendRegisterRequest(RegisterAppInterface registerAppInterface,
IJsonRPCMarshaller jsonRPCMarshaller, boolean sendAsItIs)
throws SyncException {
@@ -2416,29 +2426,59 @@ public class ProxyService extends Service implements IProxyListenerALMTesting, I
mSyncProxy.setJsonRPCMarshaller(jsonRPCMarshaller);
// Assume that at this point a new instance of the SyncProxy is created
-
- // TODO it's seems stupid in order to register send onTransportConnected
mSyncProxy.updateRegisterAppInterfaceParameters(registerAppInterface, sendAsItIs);
} else {
if (mSyncProxy.getSyncConnection() == null) {
+ Logger.w("Send RAI, SyncConnection null");
return;
}
mSyncProxy.setJsonRPCMarshaller(jsonRPCMarshaller);
- // TODO it's seems stupid in order to register send onTransportConnected
- mSyncProxy.updateRegisterAppInterfaceParameters(registerAppInterface, sendAsItIs);
-
boolean hasRPCRunning = hasRPCRunning(appId);
- Logger.d("Send RegisterRequest, appId:" + appId + ", hasRPC:" + hasRPCRunning);
+ Logger.d("Send RAI, appId:" + appId + ", hasRPC:" + hasRPCRunning);
if (hasRPCRunning) {
// In case of XML Test is running and the next tag is in use:
// <action actionName="startRPCService" pause="2000"/>
// what is needed is only to run RPC Request
mSyncProxy.sendRPCRequest(appId, registerAppInterface);
} else {
- //mSyncProxy.sendRPCRequest(appId, registerAppInterface);
- mSyncProxy.getSyncConnection().onTransportConnected();
+ Logger.d("Send RAI, isModuleTesting:" + isModuleTesting());
+ if (isModuleTesting()) {
+
+ // Inter Test Module block
+
+ mSyncProxy.invalidatePreviousSession(appId);
+
+ if (mProxyServiceEvent != null) {
+ mProxyServiceEvent.onInvalidateAppId(appId);
+ }
+
+ // Wait until onInvalidateAppId callback will be completed
+ try {
+ Thread.sleep(150);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+
+ mSyncProxy.updateRegisterAppInterfaceParameters(registerAppInterface, sendAsItIs);
+
+ if (mSessionsCounter.size() == 0) {
+ // Indicates that there is no RPC service started
+ // TODO : Should not call onTransportConnected in order to register App
+ mSyncProxy.getSyncConnection().onTransportConnected();
+ } else {
+ // In case of XML testing we assume that there is only one Session
+ mSessionsCounter.clear();
+ mSessionsCounter.add(appId);
+
+ mSyncProxy.sendRPCRequest(appId, registerAppInterface);
+ }
+ } else {
+ mSyncProxy.updateRegisterAppInterfaceParameters(registerAppInterface, sendAsItIs);
+ // TODO : Should not call onTransportConnected in order to register App
+ mSyncProxy.getSyncConnection().onTransportConnected();
+ }
}
}
}