summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnil Dahiya <anil_dahiya@infosys.com>2016-07-28 15:56:00 +0530
committerAnil Dahiya <anil_dahiya@infosys.com>2016-07-28 15:56:00 +0530
commite57550022596435a5e53523b5cb879ba2b031ea3 (patch)
tree869cc7945c096ffde72fed9effbc6d041e7cd7b6
parent4666c663b6383316aa250e7785396e8061b3ce34 (diff)
parentb9d21a277be57ffcf2c015ea054bbcb45f5e57ba (diff)
downloadsdl_android-e57550022596435a5e53523b5cb879ba2b031ea3.tar.gz
Merge branch 'feature/external_security_support' into feature/unit_tests
-rw-r--r--HelloSdl/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--HelloSdl/AndroidManifest.xml50
-rw-r--r--HelloSdl/ic_launcher-web.pngbin37133 -> 0 bytes
-rw-r--r--HelloSdl/libs/android-support-v4.jarbin995624 -> 0 bytes
-rw-r--r--HelloSdl/lint.xml3
-rw-r--r--HelloSdl/proguard-project.txt20
-rw-r--r--HelloSdl/project.properties15
-rw-r--r--HelloSdl/res/drawable-hdpi/ic_launcher.pngbin5729 -> 0 bytes
-rw-r--r--HelloSdl/res/drawable-mdpi/ic_launcher.pngbin3022 -> 0 bytes
-rw-r--r--HelloSdl/res/drawable-xhdpi/ic_launcher.pngbin9073 -> 0 bytes
-rw-r--r--HelloSdl/res/drawable-xxhdpi/ic_launcher.pngbin17609 -> 0 bytes
-rw-r--r--HelloSdl/res/layout/activity_main.xml16
-rw-r--r--HelloSdl/res/menu/main.xml11
-rw-r--r--HelloSdl/res/values-w820dp/dimens.xml10
-rw-r--r--HelloSdl/res/values/dimens.xml7
-rw-r--r--HelloSdl/res/values/strings.xml8
-rw-r--r--HelloSdl/res/values/styles.xml20
-rw-r--r--HelloSdl/src/com/hellosdl/MainActivity.java42
-rw-r--r--HelloSdl/src/com/hellosdl/sdl/SdlReceiver.java24
-rw-r--r--HelloSdl/src/com/hellosdl/sdl/SdlRouterService.java8
-rw-r--r--HelloSdl/src/com/hellosdl/sdl/SdlService.java688
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java4
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java285
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java336
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java20
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/IProtocolListener.java8
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java11
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacket.java40
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacketFactory.java16
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java143
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java4
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java3
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCStruct.java12
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java509
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java342
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBuilder.java38
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java14
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java47
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/security/ISecurityInitializedListener.java5
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/security/SdlSecurityBase.java100
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java21
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java26
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java28
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java14
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java9
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java2
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java92
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamPacketizerTests.java10
-rw-r--r--sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java10
50 files changed, 1624 insertions, 1453 deletions
diff --git a/HelloSdl/.settings/org.eclipse.jdt.core.prefs b/HelloSdl/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index b080d2ddc..000000000
--- a/HelloSdl/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/HelloSdl/AndroidManifest.xml b/HelloSdl/AndroidManifest.xml
deleted file mode 100644
index d15dbe2a6..000000000
--- a/HelloSdl/AndroidManifest.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.hellosdl"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="19" />
-
- <uses-permission android:name="android.permission.BLUETOOTH" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".MainActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
-
- <service android:name=".sdl.SdlService" ></service>
-
- <service android:name=".sdl.SdlRouterService"
- android:exported="true"
- android:process="com.smartdevicelink.router"></service>
-
-
- <receiver android:name=".sdl.SdlReceiver" android:enabled="true" >
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- <action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
- <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
- <action android:name = "sdl.router.startservice"/>
- </intent-filter>
- </receiver>
-
-
- </application>
-
-</manifest>
diff --git a/HelloSdl/ic_launcher-web.png b/HelloSdl/ic_launcher-web.png
deleted file mode 100644
index 3e493438c..000000000
--- a/HelloSdl/ic_launcher-web.png
+++ /dev/null
Binary files differ
diff --git a/HelloSdl/libs/android-support-v4.jar b/HelloSdl/libs/android-support-v4.jar
deleted file mode 100644
index 4ebdaa9ed..000000000
--- a/HelloSdl/libs/android-support-v4.jar
+++ /dev/null
Binary files differ
diff --git a/HelloSdl/lint.xml b/HelloSdl/lint.xml
deleted file mode 100644
index ee0eead5b..000000000
--- a/HelloSdl/lint.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<lint>
-</lint> \ No newline at end of file
diff --git a/HelloSdl/proguard-project.txt b/HelloSdl/proguard-project.txt
deleted file mode 100644
index f2fe1559a..000000000
--- a/HelloSdl/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/HelloSdl/project.properties b/HelloSdl/project.properties
deleted file mode 100644
index f76c1b9a4..000000000
--- a/HelloSdl/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-19
-android.library.reference.1=../sdl_android_lib
diff --git a/HelloSdl/res/drawable-hdpi/ic_launcher.png b/HelloSdl/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 903e3d12d..000000000
--- a/HelloSdl/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/HelloSdl/res/drawable-mdpi/ic_launcher.png b/HelloSdl/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 8415d3068..000000000
--- a/HelloSdl/res/drawable-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/HelloSdl/res/drawable-xhdpi/ic_launcher.png b/HelloSdl/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 962976da1..000000000
--- a/HelloSdl/res/drawable-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/HelloSdl/res/drawable-xxhdpi/ic_launcher.png b/HelloSdl/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index f4c378997..000000000
--- a/HelloSdl/res/drawable-xxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/HelloSdl/res/layout/activity_main.xml b/HelloSdl/res/layout/activity_main.xml
deleted file mode 100644
index 5056c3b98..000000000
--- a/HelloSdl/res/layout/activity_main.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- tools:context="com.hellosdl.MainActivity" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/hello_world" />
-
-</RelativeLayout>
diff --git a/HelloSdl/res/menu/main.xml b/HelloSdl/res/menu/main.xml
deleted file mode 100644
index e3df24bab..000000000
--- a/HelloSdl/res/menu/main.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- tools:context="com.hellosdl.MainActivity" >
-
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:title="@string/action_settings"/>
-
-</menu>
diff --git a/HelloSdl/res/values-w820dp/dimens.xml b/HelloSdl/res/values-w820dp/dimens.xml
deleted file mode 100644
index f3e70203b..000000000
--- a/HelloSdl/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<resources>
-
- <!--
- Example customization of dimensions originally defined in res/values/dimens.xml
- (such as screen margins) for screens with more than 820dp of available width. This
- would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
- -->
- <dimen name="activity_horizontal_margin">64dp</dimen>
-
-</resources>
diff --git a/HelloSdl/res/values/dimens.xml b/HelloSdl/res/values/dimens.xml
deleted file mode 100644
index 55c1e5908..000000000
--- a/HelloSdl/res/values/dimens.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<resources>
-
- <!-- Default screen margins, per the Android Design guidelines. -->
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
-
-</resources>
diff --git a/HelloSdl/res/values/strings.xml b/HelloSdl/res/values/strings.xml
deleted file mode 100644
index a7f78e961..000000000
--- a/HelloSdl/res/values/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">HelloSdl</string>
- <string name="hello_world">Hello Car!</string>
- <string name="action_settings">Settings</string>
-
-</resources>
diff --git a/HelloSdl/res/values/styles.xml b/HelloSdl/res/values/styles.xml
deleted file mode 100644
index 4d175139d..000000000
--- a/HelloSdl/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="AppBaseTheme">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
-</resources>
diff --git a/HelloSdl/src/com/hellosdl/MainActivity.java b/HelloSdl/src/com/hellosdl/MainActivity.java
deleted file mode 100644
index da6b8ecaf..000000000
--- a/HelloSdl/src/com/hellosdl/MainActivity.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.hellosdl;
-
-import com.hellosdl.sdl.SdlReceiver;
-import com.hellosdl.sdl.SdlService;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-
-public class MainActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- if(SdlReceiver.isTransportConnected(getBaseContext())){
- Intent startIntent = new Intent(getBaseContext(), SdlService.class);
- startService(startIntent);
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-}
diff --git a/HelloSdl/src/com/hellosdl/sdl/SdlReceiver.java b/HelloSdl/src/com/hellosdl/sdl/SdlReceiver.java
deleted file mode 100644
index 2162516f5..000000000
--- a/HelloSdl/src/com/hellosdl/sdl/SdlReceiver.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.hellosdl.sdl;
-
-
-
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-
-public class SdlReceiver extends com.smartdevicelink.transport.SdlBroadcastReceiver {
- private static final String TAG = "BCast Receiver";
-
- @Override
- public Class defineLocalSdlRouterClass() {
- return SdlRouterService.class;
- }
-
- @Override
- public void onSdlEnabled(Context context, Intent intent) {
- Log.e(TAG, "SDL Enabled");
- intent.setClass(context, SdlService.class);
- context.startService(intent);
- }
-}
diff --git a/HelloSdl/src/com/hellosdl/sdl/SdlRouterService.java b/HelloSdl/src/com/hellosdl/sdl/SdlRouterService.java
deleted file mode 100644
index b80d30c4e..000000000
--- a/HelloSdl/src/com/hellosdl/sdl/SdlRouterService.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.hellosdl.sdl;
-
-
-public class SdlRouterService extends com.smartdevicelink.transport.SdlRouterService {
-
-
-
-}
diff --git a/HelloSdl/src/com/hellosdl/sdl/SdlService.java b/HelloSdl/src/com/hellosdl/sdl/SdlService.java
deleted file mode 100644
index eba5bc780..000000000
--- a/HelloSdl/src/com/hellosdl/sdl/SdlService.java
+++ /dev/null
@@ -1,688 +0,0 @@
-package com.hellosdl.sdl;
-
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-import android.util.Log;
-
-import com.hellosdl.MainActivity;
-import com.hellosdl.R;
-import com.smartdevicelink.exception.SdlException;
-import com.smartdevicelink.proxy.SdlProxyALM;
-import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
-import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
-import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
-import com.smartdevicelink.proxy.rpc.AddCommandResponse;
-import com.smartdevicelink.proxy.rpc.AddSubMenuResponse;
-import com.smartdevicelink.proxy.rpc.AlertManeuverResponse;
-import com.smartdevicelink.proxy.rpc.AlertResponse;
-import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse;
-import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse;
-import com.smartdevicelink.proxy.rpc.DeleteCommandResponse;
-import com.smartdevicelink.proxy.rpc.DeleteFileResponse;
-import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSetResponse;
-import com.smartdevicelink.proxy.rpc.DeleteSubMenuResponse;
-import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse;
-import com.smartdevicelink.proxy.rpc.DialNumberResponse;
-import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse;
-import com.smartdevicelink.proxy.rpc.GenericResponse;
-import com.smartdevicelink.proxy.rpc.GetDTCsResponse;
-import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse;
-import com.smartdevicelink.proxy.rpc.ListFilesResponse;
-import com.smartdevicelink.proxy.rpc.OnAudioPassThru;
-import com.smartdevicelink.proxy.rpc.OnButtonEvent;
-import com.smartdevicelink.proxy.rpc.OnButtonPress;
-import com.smartdevicelink.proxy.rpc.OnCommand;
-import com.smartdevicelink.proxy.rpc.OnDriverDistraction;
-import com.smartdevicelink.proxy.rpc.OnHMIStatus;
-import com.smartdevicelink.proxy.rpc.OnHashChange;
-import com.smartdevicelink.proxy.rpc.OnKeyboardInput;
-import com.smartdevicelink.proxy.rpc.OnLanguageChange;
-import com.smartdevicelink.proxy.rpc.OnLockScreenStatus;
-import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
-import com.smartdevicelink.proxy.rpc.OnStreamRPC;
-import com.smartdevicelink.proxy.rpc.OnSystemRequest;
-import com.smartdevicelink.proxy.rpc.OnTBTClientState;
-import com.smartdevicelink.proxy.rpc.OnTouchEvent;
-import com.smartdevicelink.proxy.rpc.OnVehicleData;
-import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse;
-import com.smartdevicelink.proxy.rpc.PerformInteractionResponse;
-import com.smartdevicelink.proxy.rpc.PutFile;
-import com.smartdevicelink.proxy.rpc.PutFileResponse;
-import com.smartdevicelink.proxy.rpc.ReadDIDResponse;
-import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse;
-import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse;
-import com.smartdevicelink.proxy.rpc.SendLocationResponse;
-import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
-import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
-import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse;
-import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse;
-import com.smartdevicelink.proxy.rpc.ShowConstantTbtResponse;
-import com.smartdevicelink.proxy.rpc.ShowResponse;
-import com.smartdevicelink.proxy.rpc.SliderResponse;
-import com.smartdevicelink.proxy.rpc.SpeakResponse;
-import com.smartdevicelink.proxy.rpc.StreamRPCResponse;
-import com.smartdevicelink.proxy.rpc.SubscribeButtonResponse;
-import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse;
-import com.smartdevicelink.proxy.rpc.SystemRequestResponse;
-import com.smartdevicelink.proxy.rpc.UnsubscribeButtonResponse;
-import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleDataResponse;
-import com.smartdevicelink.proxy.rpc.UpdateTurnListResponse;
-import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
-import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
-import com.smartdevicelink.transport.MultiplexTransportConfig;
-import com.smartdevicelink.transport.TransportConstants;
-
-/**
- * While this class is just an extension off the base Android Service class, we hope in the future we can offer something
- * better that takes care of a lot of life cycle stuff.
- * <p>
- * For now this shows the most basic of operations to take when connecting via SDL
- * Here's what it covers
- * 1. Basic Sdl proxy life cycle
- * 2. Sending app icon
- * 3. When to launch activity and dealing with different HMI_STATUS's
- *
- *
- * @author Joey Grover
- *
- */
-public class SdlService extends Service implements IProxyListenerALM{
- private static final String TAG = "SdlService";
- private static final String APP_NAME = "Hello Car"; //TODO enter your own app name here
- private static final String APP_ID = "7331"; //TODO enter your own app id here
- private static final String ICON_SYNC_FILENAME = "icon.png";
- private static final String ICON_FILENAME_SUFFIX = ".png";
-
-
- // variable to create and call functions of the SdlProxy
- private SdlProxyALM proxy = null;
-
- // variable used to increment correlation ID for every request sent to a SDL system
- public int autoIncCorrId = 0;
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
-
-
- @Override
- public void onCreate() {
- super.onCreate();
- startProxy();
- }
-
-
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if(proxy == null){
- startProxy();
- }else if (intent != null && intent.hasExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED)){
- proxy.forceOnConnected();
- }
- return START_STICKY;
- }
-
- @Override
- public void onDestroy() {
- disposeSyncProxy();
- super.onDestroy();
- }
-
-
- /* ***********************************************************************************************************************************************************************
- * ******************************************************* Methods for SdlProxy Management *******************************************************************************
- *************************************************************************************************************************************************************************/
-
- public void startProxy() {
- if (proxy == null) {
- try {
- proxy = new SdlProxyALM(this, APP_NAME,
- true, APP_ID,
- new MultiplexTransportConfig(getBaseContext(), APP_ID));
-
- } catch (SdlException e) {
- e.printStackTrace();
- // error creating proxy, returned proxy = null
- if (proxy == null) {
- stopSelf();
- }
- }
- }
- }
-
- public void disposeSyncProxy() {
- if (proxy != null) {
- try {
- proxy.dispose();
- } catch (SdlException e) {
- e.printStackTrace();
- }
- proxy = null;
- }
- }
-
- /**
- * This will send the app icon over to the SDL system
- * @throws SdlException
- */
- private void sendIcon() throws SdlException {
- PutFile putFile = new PutFile();
- putFile.setFileType(FileType.GRAPHIC_PNG);
- putFile.setSdlFileName(ICON_SYNC_FILENAME);
- putFile.setCorrelationID(autoIncCorrId++);
- putFile.setBulkData(contentsOfResource(R.drawable.ic_launcher));
-
- proxy.sendRPCRequest(putFile);
- }
-
- /**
- * This is a convience method that will grab all the binary data from a resource
- * to be able to be sent to the SDL sytem
- * @param resource
- * @return
- */
- private byte[] contentsOfResource(int resource) {
- InputStream is = null;
- try {
- is = getResources().openRawResource(resource);
- ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());
- final int buffersize = 4096;
- final byte[] buffer = new byte[buffersize];
- int available = 0;
- while ((available = is.read(buffer)) >= 0) {
- os.write(buffer, 0, available);
- }
- return os.toByteArray();
- } catch (IOException e) {
- Log.w("SDL Service", "Can't read icon file", e);
- return null;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- /* ***********************************************************************************************************************************************************************
- * ******************************************************* Methods for IProxyListenerALM *******************************************************************************
- *************************************************************************************************************************************************************************/
-
- @Override
- public void onOnHMIStatus(OnHMIStatus notification) {
-
- switch(notification.getHmiLevel()) {
- case HMI_FULL:
- Log.i(TAG, "HMI_FULL");
- //When we get this notification it means we have main access to the SDL System
- Intent start = new Intent(this,MainActivity.class);
- start.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP + Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(start);
-
- if (notification.getFirstRun()) {
- // send welcome message if applicable
- try {
- proxy.show(APP_NAME + " this is the first", "show command", TextAlignment.CENTERED, autoIncCorrId++);
- }catch (SdlException e) {
- e.printStackTrace();
- }
-
- // TODO this is where the developer should send addcommands and subsribe to buttons
- }else { //If this isn't our first time receiving HMI_FULL
- try {
- proxy.show("SdlProxy is", "Alive", TextAlignment.CENTERED, autoIncCorrId++);
- } catch (SdlException e) {
- e.printStackTrace();
- }
- }
- break;
- case HMI_LIMITED:
- Log.i(TAG, "HMI_LIMITED");
- break;
- case HMI_BACKGROUND:
- Log.i(TAG, "HMI_BACKGROUND");
- break;
- case HMI_NONE:
- Log.i(TAG, "HMI_NONE");
- //Since the first HMI status sent to an app is HMI_NONE we take this as we have just established a connection and we want to send our icon
- if(notification.getFirstRun()){
- try {
- sendIcon();
- } catch (SdlException e) {
- e.printStackTrace();
- }
- }
- break;
- default:
- return;
- }
-
- }
-
-
- @Override
- public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason) {
- //After we are asked to close the proxy we should shut down our service
- stopSelf();
- }
-
-
- @Override
- public void onError(String info, Exception e) {
-
-
- }
-
-
- @Override
- public void onGenericResponse(GenericResponse response) {
-
-
- }
-
-
- @Override
- public void onOnCommand(OnCommand notification) {
-
-
- }
-
-
- @Override
- public void onAddCommandResponse(AddCommandResponse response) {
-
-
- }
-
-
- @Override
- public void onAddSubMenuResponse(AddSubMenuResponse response) {
-
-
- }
-
-
- @Override
- public void onCreateInteractionChoiceSetResponse(
- CreateInteractionChoiceSetResponse response) {
-
-
- }
-
-
- @Override
- public void onAlertResponse(AlertResponse response) {
-
-
- }
-
-
- @Override
- public void onDeleteCommandResponse(DeleteCommandResponse response) {
-
-
- }
-
-
- @Override
- public void onDeleteInteractionChoiceSetResponse(
- DeleteInteractionChoiceSetResponse response) {
-
-
- }
-
-
- @Override
- public void onDeleteSubMenuResponse(DeleteSubMenuResponse response) {
-
-
- }
-
-
- @Override
- public void onPerformInteractionResponse(PerformInteractionResponse response) {
-
-
- }
-
-
- @Override
- public void onResetGlobalPropertiesResponse(
- ResetGlobalPropertiesResponse response) {
-
-
- }
-
-
- @Override
- public void onSetGlobalPropertiesResponse(
- SetGlobalPropertiesResponse response) {
-
-
- }
-
-
- @Override
- public void onSetMediaClockTimerResponse(SetMediaClockTimerResponse response) {
-
-
- }
-
-
- @Override
- public void onShowResponse(ShowResponse response) {
-
-
- }
-
-
- @Override
- public void onSpeakResponse(SpeakResponse response) {
-
-
- }
-
-
- @Override
- public void onOnButtonEvent(OnButtonEvent notification) {
-
-
- }
-
-
- @Override
- public void onOnButtonPress(OnButtonPress notification) {
-
-
- }
-
-
- @Override
- public void onSubscribeButtonResponse(SubscribeButtonResponse response) {
-
-
- }
-
-
- @Override
- public void onUnsubscribeButtonResponse(UnsubscribeButtonResponse response) {
-
-
- }
-
-
- @Override
- public void onOnPermissionsChange(OnPermissionsChange notification) {
-
-
- }
-
-
- @Override
- public void onSubscribeVehicleDataResponse(
- SubscribeVehicleDataResponse response) {
-
-
- }
-
-
- @Override
- public void onUnsubscribeVehicleDataResponse(
- UnsubscribeVehicleDataResponse response) {
-
-
- }
-
-
- @Override
- public void onGetVehicleDataResponse(GetVehicleDataResponse response) {
-
-
- }
-
-
- @Override
- public void onOnVehicleData(OnVehicleData notification) {
-
-
- }
-
-
- @Override
- public void onPerformAudioPassThruResponse(
- PerformAudioPassThruResponse response) {
-
-
- }
-
-
- @Override
- public void onEndAudioPassThruResponse(EndAudioPassThruResponse response) {
-
-
- }
-
-
- @Override
- public void onOnAudioPassThru(OnAudioPassThru notification) {
-
-
- }
-
-
- @Override
- public void onPutFileResponse(PutFileResponse response) {
-
-
- }
-
-
- @Override
- public void onDeleteFileResponse(DeleteFileResponse response) {
-
-
- }
-
-
- @Override
- public void onListFilesResponse(ListFilesResponse response) {
-
-
- }
-
-
- @Override
- public void onSetAppIconResponse(SetAppIconResponse response) {
-
-
- }
-
-
- @Override
- public void onScrollableMessageResponse(ScrollableMessageResponse response) {
-
-
- }
-
-
- @Override
- public void onChangeRegistrationResponse(ChangeRegistrationResponse response) {
-
-
- }
-
-
- @Override
- public void onSetDisplayLayoutResponse(SetDisplayLayoutResponse response) {
-
-
- }
-
-
- @Override
- public void onOnLanguageChange(OnLanguageChange notification) {
-
-
- }
-
-
- @Override
- public void onOnHashChange(OnHashChange notification) {
-
-
- }
-
-
- @Override
- public void onSliderResponse(SliderResponse response) {
-
-
- }
-
-
- @Override
- public void onOnDriverDistraction(OnDriverDistraction notification) {
-
-
- }
-
-
- @Override
- public void onOnTBTClientState(OnTBTClientState notification) {
-
-
- }
-
-
- @Override
- public void onOnSystemRequest(OnSystemRequest notification) {
-
-
- }
-
-
- @Override
- public void onSystemRequestResponse(SystemRequestResponse response) {
-
- }
-
-
- @Override
- public void onOnKeyboardInput(OnKeyboardInput notification) {
-
- }
-
-
- @Override
- public void onOnTouchEvent(OnTouchEvent notification) {
-
- }
-
-
- @Override
- public void onDiagnosticMessageResponse(DiagnosticMessageResponse response) {
-
- }
-
-
- @Override
- public void onReadDIDResponse(ReadDIDResponse response) {
-
- }
-
-
- @Override
- public void onGetDTCsResponse(GetDTCsResponse response) {
-
- }
-
-
- @Override
- public void onOnLockScreenNotification(OnLockScreenStatus notification) {
-
- }
-
-
- @Override
- public void onOnStreamRPC(OnStreamRPC notification) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onStreamRPCResponse(StreamRPCResponse response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onDialNumberResponse(DialNumberResponse response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onSendLocationResponse(SendLocationResponse response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onServiceEnded(OnServiceEnded serviceEnded) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onServiceNACKed(OnServiceNACKed serviceNACKed) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onShowConstantTbtResponse(ShowConstantTbtResponse response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onAlertManeuverResponse(AlertManeuverResponse response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onUpdateTurnListResponse(UpdateTurnListResponse response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void onServiceDataACK() {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
index 2f9eff800..f4b4c43d9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
@@ -15,7 +15,7 @@ public interface ISdlConnectionListener {
byte sessionID, byte version, String correlationID);
public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID);
+ byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted);
public void onProtocolSessionEnded(SessionType sessionType,
byte sessionID, String correlationID);
@@ -27,5 +27,5 @@ public interface ISdlConnectionListener {
public void onHeartbeatTimedOut(byte sessionID);
- public void onProtocolServiceDataACK(SessionType sessionType, byte sessionID);
+ public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID);
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
index 60d6e5362..fc90336bc 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
@@ -1,20 +1,11 @@
package com.smartdevicelink.SdlConnection;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
import java.util.concurrent.CopyOnWriteArrayList;
-import android.annotation.SuppressLint;
import android.content.ComponentName;
-import android.os.Build;
-import android.util.Log;
-import android.view.Surface;
+import android.util.Log;
-import com.smartdevicelink.encoder.SdlEncoder;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.AbstractProtocol;
import com.smartdevicelink.protocol.IProtocolListener;
@@ -22,14 +13,22 @@ import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.SdlPacket;
import com.smartdevicelink.protocol.WiProProtocol;
import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.streaming.IStreamListener;
-import com.smartdevicelink.streaming.StreamPacketizer;
-import com.smartdevicelink.streaming.StreamRPCPacketizer;
-import com.smartdevicelink.transport.*;
+import com.smartdevicelink.transport.BTTransport;
+import com.smartdevicelink.transport.BTTransportConfig;
+import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.transport.ITransportListener;
+import com.smartdevicelink.transport.MultiplexTransport;
+import com.smartdevicelink.transport.MultiplexTransportConfig;
+import com.smartdevicelink.transport.RouterServiceValidator;
+import com.smartdevicelink.transport.SdlBroadcastReceiver;
+import com.smartdevicelink.transport.SdlTransport;
+import com.smartdevicelink.transport.TCPTransport;
+import com.smartdevicelink.transport.TCPTransportConfig;
+import com.smartdevicelink.transport.USBTransport;
+import com.smartdevicelink.transport.USBTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
-public class SdlConnection implements IProtocolListener, ITransportListener, IStreamListener {
+public class SdlConnection implements IProtocolListener, ITransportListener {
private static final String TAG = "SdlConnection";
@@ -37,10 +36,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
AbstractProtocol _protocol = null;
ISdlConnectionListener _connectionListener = null;
- StreamRPCPacketizer mRPCPacketizer = null;
- StreamPacketizer mVideoPacketizer = null;
- StreamPacketizer mAudioPacketizer = null;
- SdlEncoder mSdlEncoder = null;
+
// Thread safety locks
static Object TRANSPORT_REFERENCE_LOCK = new Object();
@@ -261,8 +257,8 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
@Override
public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID) {
- _connectionListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID);
+ byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
+ _connectionListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID, isEncrypted);
}
@Override
@@ -292,201 +288,11 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
public TransportType getCurrentTransportType() {
return _transport.getTransportType();
}
- public void startStream(InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
- if (sType.equals(SessionType.NAV))
- {
- mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID);
- mVideoPacketizer.sdlConnection = this;
- mVideoPacketizer.start();
- }
- else if (sType.equals(SessionType.PCM))
- {
- mAudioPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID);
- mAudioPacketizer.sdlConnection = this;
- mAudioPacketizer.start();
- }
- }
-
- @SuppressLint("NewApi") public OutputStream startStream(SessionType sType, byte rpcSessionID) throws IOException {
- OutputStream os = new PipedOutputStream();
- InputStream is = null;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
- is = new PipedInputStream((PipedOutputStream) os, BUFF_READ_SIZE);
- } else {
- is = new PipedInputStream((PipedOutputStream) os);
- }
- if (sType.equals(SessionType.NAV))
- {
- mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID);
- mVideoPacketizer.sdlConnection = this;
- mVideoPacketizer.start();
- }
- else if (sType.equals(SessionType.PCM))
- {
- mAudioPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID);
- mAudioPacketizer.sdlConnection = this;
- mAudioPacketizer.start();
- }
- else
- {
- os.close();
- is.close();
- return null;
- }
- return os;
- }
-
- public void startRPCStream(InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) {
- try {
- mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0);
- mRPCPacketizer.start();
- } catch (Exception e) {
- Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
- }
- }
-
- public OutputStream startRPCStream(RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) {
- try {
- OutputStream os = new PipedOutputStream();
- InputStream is = new PipedInputStream((PipedOutputStream) os);
- mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0);
- mRPCPacketizer.start();
- return os;
- } catch (Exception e) {
- Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
- }
- return null;
- }
-
- public void pauseRPCStream()
- {
- if (mRPCPacketizer != null)
- {
- mRPCPacketizer.pause();
- }
- }
-
- public void resumeRPCStream()
- {
- if (mRPCPacketizer != null)
- {
- mRPCPacketizer.resume();
- }
- }
-
- public void stopRPCStream()
- {
- if (mRPCPacketizer != null)
- {
- mRPCPacketizer.stop();
- }
- }
-
- public boolean stopAudioStream()
- {
- if (mAudioPacketizer != null)
- {
- mAudioPacketizer.stop();
- return true;
- }
- return false;
- }
- public boolean stopVideoStream()
- {
- if (mVideoPacketizer != null)
- {
- mVideoPacketizer.stop();
- return true;
- }
- return false;
- }
-
- public boolean pauseAudioStream()
- {
- if (mAudioPacketizer != null)
- {
- mAudioPacketizer.pause();
- return true;
- }
- return false;
- }
-
- public boolean pauseVideoStream()
- {
- if (mVideoPacketizer != null)
- {
- mVideoPacketizer.pause();
- return true;
- }
- return false;
- }
-
- public boolean resumeAudioStream()
- {
- if (mAudioPacketizer != null)
- {
- mAudioPacketizer.resume();
- return true;
- }
- return false;
- }
-
- public boolean resumeVideoStream()
- {
- if (mVideoPacketizer != null)
- {
- mVideoPacketizer.resume();
- return true;
- }
- return false;
- }
-
- public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width,
- int height, int bitrate, SessionType sType, byte rpcSessionID) {
- try {
- PipedOutputStream stream = (PipedOutputStream) startStream(sType, rpcSessionID);
- if (stream == null) return null;
- mSdlEncoder = new SdlEncoder();
- mSdlEncoder.setFrameRate(frameRate);
- mSdlEncoder.setFrameInterval(iFrameInterval);
- mSdlEncoder.setFrameWidth(width);
- mSdlEncoder.setFrameHeight(height);
- mSdlEncoder.setBitrate(bitrate);
- mSdlEncoder.setOutputStream(stream);
- } catch (IOException e) {
- return null;
- }
- return mSdlEncoder.prepareEncoder();
- }
-
- public void startEncoder () {
- if(mSdlEncoder != null) {
- mSdlEncoder.startEncoder();
- }
- }
-
- public void releaseEncoder() {
- if(mSdlEncoder != null) {
- mSdlEncoder.releaseEncoder();
- }
- }
-
- public void drainEncoder(boolean endOfStream) {
- if(mSdlEncoder != null) {
- mSdlEncoder.drainEncoder(endOfStream);
- }
- }
-
- @Override
- public void sendStreamPacket(ProtocolMessage pm) {
- sendMessage(pm);
- }
-
- public void startService (SessionType sessionType, byte sessionID) {
+ public void startService (SessionType sessionType, byte sessionID, boolean isEncrypted) {
synchronized(PROTOCOL_REFERENCE_LOCK){
if(_protocol != null){
- _protocol.StartProtocolService(sessionType, sessionID);
+ _protocol.StartProtocolService(sessionType, sessionID, isEncrypted);
}
}
}
@@ -524,7 +330,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
- private SdlSession findSessionById(byte id) {
+ public SdlSession findSessionById(byte id) {
for (SdlSession listener : listenerList) {
if (listener.getSessionId() == id) {
return listener;
@@ -594,17 +400,18 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
@Override
public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID) {
+ byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
for (SdlSession session : listenerList) {
if (session.getSessionId() == 0) {
- session.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID);
+ session.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID, isEncrypted);
break;
}
}
- if (sessionType.equals(SessionType.NAV) || sessionType.equals(SessionType.PCM)){
+
+ if (sessionType.equals(SessionType.NAV) || sessionType.equals(SessionType.PCM) || isEncrypted){
SdlSession session = findSessionById(sessionID);
if (session != null) {
- session.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID);
+ session.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID, isEncrypted);
}
}
}
@@ -638,8 +445,8 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
public void onHeartbeatTimedOut(byte sessionID) {
SdlSession session = findSessionById(sessionID);
if (session != null) {
- session.onHeartbeatTimedOut(sessionID);
- }
+ session.onHeartbeatTimedOut(sessionID);
+ }
}
@Override
@@ -647,26 +454,17 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
SdlSession session = findSessionById(sessionID);
if (session != null) {
session.onProtocolSessionEndedNACKed(sessionType, sessionID, correlationID);
- }
+ }
}
@Override
- public void onProtocolServiceDataACK(SessionType sessionType,
- byte sessionID) {
- // TODO Auto-generated method stub
-
- }
-
- }
-
- @Override
- public void onProtocolServiceDataACK(SessionType sessionType,
- byte sessionID) {
+ public void onProtocolServiceDataACK(SessionType serviceType, int dataSize, byte sessionID) {
SdlSession session = findSessionById(sessionID);
if (session != null) {
- session.onProtocolServiceDataACK(sessionType, sessionID);
- }
- }
+ session.onProtocolServiceDataACK(serviceType, dataSize, sessionID);
+ }
+ }
+ }
public int getRegisterCount() {
return listenerList.size();
@@ -698,8 +496,8 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
}
- @Override
- public void onResetOutgoingHeartbeat(SessionType sessionType, byte sessionID){
+ @Override
+ public void onResetOutgoingHeartbeat(SessionType sessionType, byte sessionID){
SdlSession mySession = findSessionById(sessionID);
if (mySession == null) return;
@@ -790,12 +588,15 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
}
-
-
@Override
public void onProtocolSessionEndedNACKed(SessionType sessionType,
byte sessionID, String correlationID) {
_connectionListener.onProtocolSessionEndedNACKed(sessionType, sessionID, correlationID);
-
- }
+
+ }
+
+ @Override
+ public void onProtocolServiceDataACK(SessionType serviceType, int dataSize, byte sessionID) {
+ _connectionListener.onProtocolServiceDataACK(serviceType, dataSize, sessionID);
+ }
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
index 7f1359963..09f029fca 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
@@ -1,25 +1,42 @@
package com.smartdevicelink.SdlConnection;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.List;
+import java.util.ListIterator;
import java.util.concurrent.CopyOnWriteArrayList;
+import android.annotation.SuppressLint;
+import android.os.Build;
import android.util.Log;
+import android.view.Surface;
+import com.smartdevicelink.encoder.SdlEncoder;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitor;
import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitorListener;
import com.smartdevicelink.proxy.LockScreenManager;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.security.ISecurityInitializedListener;
+import com.smartdevicelink.security.SdlSecurityBase;
+import com.smartdevicelink.streaming.IStreamListener;
+import com.smartdevicelink.streaming.StreamPacketizer;
+import com.smartdevicelink.streaming.StreamRPCPacketizer;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransport;
import com.smartdevicelink.transport.enums.TransportType;
-public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorListener {
+public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorListener, IStreamListener, ISecurityInitializedListener {
private static CopyOnWriteArrayList<SdlConnection> shareConnections = new CopyOnWriteArrayList<SdlConnection>();
+ private CopyOnWriteArrayList<SessionType> encryptedServices = new CopyOnWriteArrayList<SessionType>();
SdlConnection _sdlConnection = null;
private byte sessionId;
- @SuppressWarnings("unused")
private byte wiproProcolVer;
private ISdlConnectionListener sessionListener;
private BaseTransportConfig transportConfig;
@@ -27,10 +44,15 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
IHeartbeatMonitor _incomingHeartbeatMonitor = null;
private static final String TAG = "SdlSession";
private LockScreenManager lockScreenMan = new LockScreenManager();
+ private SdlSecurityBase sdlSecurity = null;
+ StreamRPCPacketizer mRPCPacketizer = null;
+ StreamPacketizer mVideoPacketizer = null;
+ StreamPacketizer mAudioPacketizer = null;
+ SdlEncoder mSdlEncoder = null;
+ private final static int BUFF_READ_SIZE = 1024;
private int sessionHashId = 0;
-
public static SdlSession createSession(byte wiproVersion, ISdlConnectionListener listener, BaseTransportConfig btConfig) {
SdlSession session = new SdlSession();
@@ -84,6 +106,12 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
}
public void close() {
+ if (sdlSecurity != null)
+ {
+ sdlSecurity.resetParams();
+ sdlSecurity.shutDown();
+ }
+
if (_sdlConnection != null) { //sessionId == 0 means session is not started.
_sdlConnection.unregisterSession(this);
@@ -95,6 +123,259 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
}
}
+ public void startStream(InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
+ if (sType.equals(SessionType.NAV))
+ {
+ mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
+ mVideoPacketizer.sdlConnection = this.getSdlConnection();
+ mVideoPacketizer.start();
+ }
+ else if (sType.equals(SessionType.PCM))
+ {
+ mAudioPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
+ mAudioPacketizer.sdlConnection = this.getSdlConnection();
+ mAudioPacketizer.start();
+ }
+ }
+
+ @SuppressLint("NewApi")
+ public OutputStream startStream(SessionType sType, byte rpcSessionID) throws IOException {
+ OutputStream os = new PipedOutputStream();
+ InputStream is = null;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ is = new PipedInputStream((PipedOutputStream) os, BUFF_READ_SIZE);
+ } else {
+ is = new PipedInputStream((PipedOutputStream) os);
+ }
+ if (sType.equals(SessionType.NAV))
+ {
+ mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
+ mVideoPacketizer.sdlConnection = this.getSdlConnection();
+ mVideoPacketizer.start();
+ }
+ else if (sType.equals(SessionType.PCM))
+ {
+ mAudioPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
+ mAudioPacketizer.sdlConnection = this.getSdlConnection();
+ mAudioPacketizer.start();
+ }
+ else
+ {
+ os.close();
+ is.close();
+ return null;
+ }
+ return os;
+ }
+
+ public void startRPCStream(InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) {
+ try {
+ mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0, this);
+ mRPCPacketizer.start();
+ } catch (Exception e) {
+ Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
+ }
+ }
+
+ public OutputStream startRPCStream(RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) {
+ try {
+ OutputStream os = new PipedOutputStream();
+ InputStream is = new PipedInputStream((PipedOutputStream) os);
+ mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0, this);
+ mRPCPacketizer.start();
+ return os;
+ } catch (Exception e) {
+ Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
+ }
+ return null;
+ }
+
+ public void pauseRPCStream()
+ {
+ if (mRPCPacketizer != null)
+ {
+ mRPCPacketizer.pause();
+ }
+ }
+
+ public void resumeRPCStream()
+ {
+ if (mRPCPacketizer != null)
+ {
+ mRPCPacketizer.resume();
+ }
+ }
+
+ public void stopRPCStream()
+ {
+ if (mRPCPacketizer != null)
+ {
+ mRPCPacketizer.stop();
+ }
+ }
+
+ public boolean stopAudioStream()
+ {
+ if (mAudioPacketizer != null)
+ {
+ mAudioPacketizer.stop();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean stopVideoStream()
+ {
+ if (mVideoPacketizer != null)
+ {
+ mVideoPacketizer.stop();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean pauseAudioStream()
+ {
+ if (mAudioPacketizer != null)
+ {
+ mAudioPacketizer.pause();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean pauseVideoStream()
+ {
+ if (mVideoPacketizer != null)
+ {
+ mVideoPacketizer.pause();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean resumeAudioStream()
+ {
+ if (mAudioPacketizer != null)
+ {
+ mAudioPacketizer.resume();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean resumeVideoStream()
+ {
+ if (mVideoPacketizer != null)
+ {
+ mVideoPacketizer.resume();
+ return true;
+ }
+ return false;
+ }
+
+ public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width,
+ int height, int bitrate, SessionType sType, byte rpcSessionID) {
+ try {
+ PipedOutputStream stream = (PipedOutputStream) startStream(sType, rpcSessionID);
+ if (stream == null) return null;
+ mSdlEncoder = new SdlEncoder();
+ mSdlEncoder.setFrameRate(frameRate);
+ mSdlEncoder.setFrameInterval(iFrameInterval);
+ mSdlEncoder.setFrameWidth(width);
+ mSdlEncoder.setFrameHeight(height);
+ mSdlEncoder.setBitrate(bitrate);
+ mSdlEncoder.setOutputStream(stream);
+ } catch (IOException e) {
+ return null;
+ }
+ return mSdlEncoder.prepareEncoder();
+ }
+
+ public void startEncoder () {
+ if(mSdlEncoder != null) {
+ mSdlEncoder.startEncoder();
+ }
+ }
+
+ public void releaseEncoder() {
+ if(mSdlEncoder != null) {
+ mSdlEncoder.releaseEncoder();
+ }
+ }
+
+ public void drainEncoder(boolean endOfStream) {
+ if(mSdlEncoder != null) {
+ mSdlEncoder.drainEncoder(endOfStream);
+ }
+ }
+
+ @Override
+ public void sendStreamPacket(ProtocolMessage pm) {
+ sendMessage(pm);
+ }
+
+ public void setSdlSecurity(SdlSecurityBase sec) {
+ sdlSecurity = sec;
+ }
+
+ public SdlSecurityBase getSdlSecurity() {
+ return sdlSecurity;
+ }
+
+ public void startService (SessionType serviceType, byte sessionID, boolean isEncrypted) {
+ if (_sdlConnection == null)
+ return;
+
+ if (isEncrypted)
+ {
+ if (sdlSecurity != null)
+ {
+ List<SessionType> serviceList = sdlSecurity.getServiceList();
+ if (!serviceList.contains(serviceType))
+ serviceList.add(serviceType);
+
+ sdlSecurity.initialize();
+ }
+ return;
+ }
+ _sdlConnection.startService(serviceType, sessionID, isEncrypted);
+ }
+
+ public void endService (SessionType serviceType, byte sessionID) {
+ if (_sdlConnection == null)
+ return;
+ _sdlConnection.endService(serviceType, sessionID);
+ }
+
+ private void processControlService(ProtocolMessage msg) {
+ if (sdlSecurity == null)
+ return;
+ int ilen = msg.getData().length - 12;
+ byte[] data = new byte[ilen];
+ System.arraycopy(msg.getData(), 12, data, 0, ilen);
+
+ byte[] dataToRead = new byte[4096];
+
+ Integer iNumBytes = sdlSecurity.runHandshake(data, dataToRead);
+
+ if (iNumBytes == null || iNumBytes <= 0)
+ return;
+
+ byte[] returnBytes = new byte[iNumBytes];
+ System.arraycopy(dataToRead, 0, returnBytes, 0, iNumBytes);
+ ProtocolMessage protocolMessage = new ProtocolMessage();
+ protocolMessage.setSessionType(SessionType.CONTROL);
+ protocolMessage.setData(returnBytes);
+ protocolMessage.setFunctionID(0x01);
+ protocolMessage.setVersion(wiproProcolVer);
+ protocolMessage.setSessionID(getSessionId());
+
+ //sdlSecurity.hs();
+
+ sendMessage(protocolMessage);
+ }
+
public String getBroadcastComment(BaseTransportConfig myTransport) {
SdlConnection connection = null;
if (myTransport.shareConnection()) {
@@ -153,6 +434,10 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
return false;
return _sdlConnection != null && _sdlConnection.getIsConnected();
}
+
+ public boolean isServiceProtected(SessionType sType) {
+ return encryptedServices.contains(sType);
+ }
@Override
public void onTransportDisconnected(String info) {
@@ -166,6 +451,11 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
@Override
public void onProtocolMessageReceived(ProtocolMessage msg) {
+ if (msg.getSessionType().equals(SessionType.CONTROL)) {
+ processControlService(msg);
+ return;
+ }
+
this.sessionListener.onProtocolMessageReceived(msg);
}
@@ -178,10 +468,12 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
@Override
public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID) {
+ byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
this.sessionId = sessionID;
lockScreenMan.setSessionID(sessionID);
- this.sessionListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID);
+ if (isEncrypted)
+ encryptedServices.addIfAbsent(sessionType);
+ this.sessionListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID, isEncrypted);
//if (version == 3)
initialiseSession();
if (sessionType.eq(SessionType.RPC)){
@@ -191,8 +483,9 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
@Override
public void onProtocolSessionEnded(SessionType sessionType, byte sessionID,
- String correlationID) {
+ String correlationID) {
this.sessionListener.onProtocolSessionEnded(sessionType, sessionID, correlationID);
+ encryptedServices.remove(sessionType);
}
@Override
@@ -230,13 +523,13 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
return connection;
}
- @Override
+ @Override
public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
+ byte sessionID, byte version, String correlationID) {
this.sessionListener.onProtocolSessionStartedNACKed(sessionType, sessionID, version, correlationID);
}
- @Override
+ @Override
public void onProtocolSessionEndedNACKed(SessionType sessionType,
byte sessionID, String correlationID) {
this.sessionListener.onProtocolSessionEndedNACKed(sessionType, sessionID, correlationID);
@@ -244,8 +537,29 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
}
@Override
- public void onProtocolServiceDataACK(SessionType sessionType, byte sessionID) {
- this.sessionListener.onProtocolServiceDataACK(sessionType, sessionID);
+ public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID) {
+ this.sessionListener.onProtocolServiceDataACK(sessionType, dataSize, sessionID);
+ }
+
+ @Override
+ public void onSecurityInitialized() {
+
+ if (_sdlConnection != null && sdlSecurity != null)
+ {
+ List<SessionType> list = sdlSecurity.getServiceList();
+
+ SessionType service;
+ ListIterator<SessionType> iter = list.listIterator();
+
+ while (iter.hasNext()) {
+ service = iter.next();
+
+ if (service != null)
+ _sdlConnection.startService(service, getSessionId(), true);
+
+ iter.remove();
+ }
+ }
}
public void clearConnection(){
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java b/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java
index bcc2e1df5..5cdf06e95 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java
@@ -2,8 +2,6 @@ package com.smartdevicelink.protocol;
import com.smartdevicelink.protocol.WiProProtocol.MessageFrameAssembler;
import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
public abstract class AbstractProtocol {
private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@@ -40,14 +38,14 @@ public abstract class AbstractProtocol {
// session has been established.
public abstract void StartProtocolSession(SessionType sessionType);
- public abstract void StartProtocolService(SessionType sessionType, byte sessionID);
+ public abstract void StartProtocolService(SessionType sessionType, byte sessionID, boolean isEncrypted);
+ public abstract void EndProtocolService(SessionType serviceType, byte sessionID);
// This method ends a protocol session. A corresponding call to the protocol
// listener onProtocolSessionEnded() method will be made when the protocol
// session has ended.
public abstract void EndProtocolSession(SessionType sessionType, byte sessionID, int hashID);
- public abstract void EndProtocolService(SessionType serviceType, byte sessionID);
// TODO REMOVE
// This method sets the interval at which heartbeat protocol messages will be
// sent to SDL.
@@ -68,7 +66,7 @@ public abstract class AbstractProtocol {
assembler.handleFrame(packet);
}
-
+
private synchronized void resetOutgoingHeartbeat(SessionType sessionType, byte sessionID) {
if (_protocolListener != null) {
_protocolListener.onResetOutgoingHeartbeat(sessionType,sessionID);
@@ -124,8 +122,8 @@ public abstract class AbstractProtocol {
// This method handles the startup of a protocol session. A callback is sent
// to the protocol listener.
protected void handleProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID) {
- _protocolListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID);
+ byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
+ _protocolListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID, isEncrypted);
}
protected void handleProtocolSessionNACKed(SessionType sessionType,
@@ -137,16 +135,16 @@ public abstract class AbstractProtocol {
// listener.
protected void handleProtocolError(String string, Exception ex) {
_protocolListener.onProtocolError(string, ex);
- }
+ }
protected void handleProtocolHeartbeat(SessionType sessionType, byte sessionID) {
SendHeartBeatACK(sessionID);
_protocolListener.onProtocolHeartbeat(sessionType, sessionID);
}
- protected void handleProtocolHeartbeatACK(SessionType sessionType, byte sessionID) {
+ protected void handleProtocolHeartbeatACK(SessionType sessionType, byte sessionID) {
_protocolListener.onProtocolHeartbeatACK(sessionType, sessionID);
}
- protected void handleProtocolServiceDataACK(SessionType sessionType, byte sessionID) {
- _protocolListener.onProtocolServiceDataACK(sessionType, sessionID);
+ protected void handleProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID) {
+ _protocolListener.onProtocolServiceDataACK(sessionType, dataSize, sessionID);
}
protected void onResetIncomingHeartbeat(SessionType sessionType, byte sessionID) {
resetIncomingHeartbeat(sessionType, sessionID);
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/IProtocolListener.java b/sdl_android_lib/src/com/smartdevicelink/protocol/IProtocolListener.java
index 47317a086..b54ff66c8 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/IProtocolListener.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/IProtocolListener.java
@@ -12,14 +12,14 @@ public interface IProtocolListener {
void onProtocolMessageReceived(ProtocolMessage msg);
// Called to indicate that a protocol session has been started (from either side)
- void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID);
+ void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted);
void onProtocolSessionNACKed(SessionType sessionType, byte sessionID, byte version, String correlationID);
// Called to indicate that a protocol session has ended (from either side)
- void onProtocolSessionEnded(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/);
+ void onProtocolSessionEnded(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/);
- void onProtocolSessionEndedNACKed(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/);
+ void onProtocolSessionEndedNACKed(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/);
void onProtocolHeartbeat(SessionType sessionType, byte sessionID);
@@ -28,7 +28,7 @@ public interface IProtocolListener {
*/
void onProtocolHeartbeatACK(SessionType sessionType, byte sessionID);
- void onProtocolServiceDataACK(SessionType sessionType, byte sessionID);
+ void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID);
void onResetOutgoingHeartbeat(SessionType sessionType, byte sessionID);
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java b/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java
index 5d0e0fc5d..99b34aff6 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java
@@ -12,6 +12,8 @@ public class ProtocolMessage {
private int _functionID;
private int _correlationID;
private int _jsonSize;
+ private boolean payloadProtected = false;
+
int priorityCoefficient = 0;
private byte[] _data = null;
@@ -123,6 +125,15 @@ public class ProtocolMessage {
public void setJsonSize(int _jsonSize) {
this._jsonSize = _jsonSize;
}
+
+ public void setPayloadProtected(boolean bVal) {
+ payloadProtected = bVal;
+ }
+
+ public boolean getPayloadProtected() {
+ return payloadProtected;
+ }
+
/**
* Set the priority for this packet. The lower the number the higher the priority. <br>0 is the highest priority and the default.
* @param priority
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacket.java b/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacket.java
index f6a24d5e3..9c7a02852 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacket.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacket.java
@@ -13,7 +13,7 @@ public class SdlPacket implements Parcelable{
public static final int HEADER_SIZE = 12;
public static final int HEADER_SIZE_V1 = 8;//Backwards
- private static final int COMPRESSION_MASK = 0x08; //4th lowest bit
+ private static final int ENCRYPTION_MASK = 0x08; //4th lowest bit
public static final int FRAME_TYPE_CONTROL = 0x00;
public static final int FRAME_TYPE_SINGLE = 0x01;
@@ -56,7 +56,7 @@ public class SdlPacket implements Parcelable{
int version;
- boolean compression;
+ boolean encryption;
int frameType;
int serviceType;
int frameInfo;
@@ -66,11 +66,11 @@ public class SdlPacket implements Parcelable{
int priorityCoefficient;
byte[] payload = null;
- public SdlPacket(int version, boolean compression, int frameType,
+ public SdlPacket(int version, boolean encryption, int frameType,
int serviceType, int frameInfo, int sessionId,
int dataSize, int messageId, byte[] payload) {
this.version = version;
- this.compression = compression;
+ this.encryption = encryption;
this.frameType = frameType;
this.serviceType = serviceType;
this.frameInfo = frameInfo;
@@ -84,11 +84,11 @@ public class SdlPacket implements Parcelable{
}
}
- public SdlPacket(int version, boolean compression, int frameType,
+ public SdlPacket(int version, boolean encryption, int frameType,
int serviceType, int frameInfo, int sessionId,
int dataSize, int messageId, byte[] payload, int offset,int bytesToWrite) {
this.version = version;
- this.compression = compression;
+ this.encryption = encryption;
this.frameType = frameType;
this.serviceType = serviceType;
this.frameInfo = frameInfo;
@@ -114,7 +114,7 @@ public class SdlPacket implements Parcelable{
//Package only empty constructor
//TODO add defaults
this.version = 1;
- this.compression = false;
+ this.encryption = false;
this.frameType = -1; //This NEEDS to be set
this.serviceType = -1;
this.frameInfo = -1;
@@ -130,7 +130,7 @@ public class SdlPacket implements Parcelable{
*/
protected SdlPacket(SdlPacket packet){
this.version = packet.version;
- this.compression = packet.compression;
+ this.encryption = packet.encryption;
this.frameType = packet.frameType;
this.serviceType = packet.serviceType;
this.frameInfo = packet.frameInfo;
@@ -143,8 +143,8 @@ public class SdlPacket implements Parcelable{
return version;
}
- public boolean isCompression() {
- return compression;
+ public boolean isEncrypted() {
+ return encryption;
}
public FrameType getFrameType() {
@@ -186,7 +186,7 @@ public class SdlPacket implements Parcelable{
}
public byte[] constructPacket(){
- return constructPacket(version, compression, frameType,
+ return constructPacket(version, encryption, frameType,
serviceType, frameInfo, sessionId,
dataSize, messageId, payload);
}
@@ -206,7 +206,7 @@ public class SdlPacket implements Parcelable{
/**
* This method takes in the various components to the SDL packet structure and creates a new byte array that can be sent via the transport
* @param version
- * @param compression
+ * @param encryption
* @param frameType
* @param serviceType
* @param controlFrameInfo
@@ -216,7 +216,7 @@ public class SdlPacket implements Parcelable{
* @param payload
* @return
*/
- public static byte[] constructPacket(int version, boolean compression, int frameType,
+ public static byte[] constructPacket(int version, boolean encryption, int frameType,
int serviceType, int controlFrameInfo, int sessionId,
int dataSize, int messageId, byte[] payload){
ByteBuffer builder;
@@ -229,7 +229,7 @@ public class SdlPacket implements Parcelable{
break;
}
- builder.put((byte)((version<<4) + getCompressionBit(compression) + frameType));
+ builder.put((byte)((version<<4) + getEncryptionBit(encryption) + frameType));
builder.put((byte)serviceType);
builder.put((byte)controlFrameInfo);
builder.put((byte)sessionId);
@@ -254,9 +254,9 @@ public class SdlPacket implements Parcelable{
}
- public static int getCompressionBit(boolean compression){
- if(compression){
- return COMPRESSION_MASK;
+ public static int getEncryptionBit(boolean encryption){
+ if(encryption){
+ return ENCRYPTION_MASK;
}else{
return 0;
}
@@ -269,7 +269,7 @@ public class SdlPacket implements Parcelable{
StringBuilder builder = new StringBuilder();
builder.append("***** Sdl Packet ******");
builder.append( "\nVersion: " +version);
- builder.append( "\nCompression: " +compression);
+ builder.append( "\nEncryption: " +encryption);
builder.append( "\nFrameType: " +frameType);
builder.append( "\nServiceType: " +serviceType);
builder.append( "\nFrameInfo: " +frameInfo);
@@ -294,7 +294,7 @@ public class SdlPacket implements Parcelable{
//I think this is FIFO...right?
public SdlPacket(Parcel p) {
this.version = p.readInt();
- this.compression = (p.readInt() == 0) ? false : true;
+ this.encryption = (p.readInt() == 0) ? false : true;
this.frameType = p.readInt();
this.serviceType = p.readInt();
this.frameInfo = p.readInt();
@@ -318,7 +318,7 @@ public class SdlPacket implements Parcelable{
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(version);
- dest.writeInt(compression? 1 : 0);
+ dest.writeInt(encryption? 1 : 0);
dest.writeInt(frameType);
dest.writeInt(serviceType);
dest.writeInt(frameInfo);
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacketFactory.java b/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacketFactory.java
index 1fff2b1a2..5cc2807e8 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacketFactory.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/SdlPacketFactory.java
@@ -10,8 +10,8 @@ public class SdlPacketFactory {
int serviceType, int frameInfo, int sessionId,
int dataSize, int messageId, byte[] payload) {
*/
- public static SdlPacket createStartSession(SessionType serviceType, int messageID, byte version, byte sessionID) {
- SdlPacket packet = new SdlPacket(version,false,SdlPacket.FRAME_TYPE_CONTROL,
+ public static SdlPacket createStartSession(SessionType serviceType, int messageID, byte version, byte sessionID, boolean encrypted) {
+ SdlPacket packet = new SdlPacket(version,encrypted,SdlPacket.FRAME_TYPE_CONTROL,
serviceType.getValue(),SdlPacket.FRAME_INFO_START_SERVICE,sessionID,
0,messageID,null);
@@ -54,26 +54,26 @@ public class SdlPacketFactory {
}
public static SdlPacket createSingleSendData(SessionType serviceType, byte sessionID,
- int dataLength, int messageID, byte version, byte[] payload) {
+ int dataLength, int messageID, byte version, byte[] payload, boolean encrypted) {
- return new SdlPacket(version,false,SdlPacket.FRAME_TYPE_SINGLE,
+ return new SdlPacket(version,encrypted,SdlPacket.FRAME_TYPE_SINGLE,
serviceType.getValue(),0,sessionID,
payload.length,messageID,payload);
}
public static SdlPacket createMultiSendDataFirst(SessionType serviceType, byte sessionID,
- int messageID, byte version, byte[] payload) {
+ int messageID, byte version, byte[] payload, boolean encrypted) {
- return new SdlPacket(version,false,SdlPacket.FRAME_TYPE_FIRST,
+ return new SdlPacket(version,encrypted,SdlPacket.FRAME_TYPE_FIRST,
serviceType.getValue(),0,sessionID,
8,messageID,payload);
}
public static SdlPacket createMultiSendDataRest(SessionType serviceType, byte sessionID,
- int dataLength, byte frameSequenceNumber, int messageID, byte version, byte[] payload,int offset,int length) {
+ int dataLength, byte frameSequenceNumber, int messageID, byte version, byte[] payload,int offset,int length, boolean encrypted) {
- return new SdlPacket(version,false,SdlPacket.FRAME_TYPE_CONSECUTIVE,
+ return new SdlPacket(version,encrypted,SdlPacket.FRAME_TYPE_CONSECUTIVE,
serviceType.getValue(),frameSequenceNumber,sessionID,
length,messageID,payload,offset,length);
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java b/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java
index 284f04574..9fe72bcf2 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java
@@ -3,8 +3,15 @@ package com.smartdevicelink.protocol;
import java.io.ByteArrayOutputStream;
import java.util.Hashtable;
-import com.smartdevicelink.exception.*;
-import com.smartdevicelink.protocol.enums.*;
+import com.smartdevicelink.SdlConnection.SdlConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.protocol.enums.FrameDataControlFrameType;
+import com.smartdevicelink.protocol.enums.FrameType;
+import com.smartdevicelink.protocol.enums.MessageType;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.util.BitConverter;
import com.smartdevicelink.util.DebugTool;
@@ -19,7 +26,8 @@ public class WiProProtocol extends AbstractProtocol {
int hashID = 0;
int messageID = 0;
-
+ SdlConnection sdlconn = null;
+
@SuppressWarnings("unused")
private int _heartbeatSendInterval_ms = 0;
@SuppressWarnings("unused")
@@ -36,13 +44,18 @@ public class WiProProtocol extends AbstractProtocol {
public WiProProtocol(IProtocolListener protocolListener) {
super(protocolListener);
+
+ if (protocolListener instanceof SdlConnection)
+ {
+ sdlconn = (SdlConnection) protocolListener;
+ }
} // end-ctor
public byte getVersion() {
return this._version;
}
-
- public void setVersion(byte version) {
+
+ public void setVersion(byte version) {
if (version > 4) {
this._version = 4; //protect for future, proxy only supports v4 or lower
HEADER_SIZE = 12;
@@ -64,10 +77,10 @@ public class WiProProtocol extends AbstractProtocol {
HEADER_SIZE = 8;
MAX_DATA_SIZE = V1_V2_MTU_SIZE - HEADER_SIZE;
}
- }
+ }
public void StartProtocolSession(SessionType sessionType) {
- SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, _version, (byte) 0x00);
+ SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, _version, (byte) 0x00, false);
handlePacketToSend(header);
} // end-method
@@ -89,21 +102,57 @@ public class WiProProtocol extends AbstractProtocol {
byte[] data = null;
if (_version > 1 && sessionType != SessionType.NAV && sessionType != SessionType.PCM) {
- if (protocolMsg.getBulkData() != null) {
- data = new byte[12 + protocolMsg.getJsonSize() + protocolMsg.getBulkData().length];
+ if (sessionType.eq(SessionType.CONTROL)) {
+ final byte[] secureData = protocolMsg.getData().clone();
+ data = new byte[HEADER_SIZE + secureData.length];
+
+ final BinaryFrameHeader binFrameHeader =
+ SdlPacketFactory.createBinaryFrameHeader(protocolMsg.getRPCType(),protocolMsg.getFunctionID(), protocolMsg.getCorrID(), 0);
+ System.arraycopy(binFrameHeader.assembleHeaderBytes(), 0, data, 0, HEADER_SIZE);
+ System.arraycopy(secureData, 0, data,HEADER_SIZE, secureData.length);
+ }
+ else if (protocolMsg.getBulkData() != null) {
+ data = new byte[12 + protocolMsg.getJsonSize() + protocolMsg.getBulkData().length];
sessionType = SessionType.BULK_DATA;
- } else data = new byte[12 + protocolMsg.getJsonSize()];
- BinaryFrameHeader binFrameHeader = new BinaryFrameHeader();
- binFrameHeader = SdlPacketFactory.createBinaryFrameHeader(protocolMsg.getRPCType(), protocolMsg.getFunctionID(), protocolMsg.getCorrID(), protocolMsg.getJsonSize());
- System.arraycopy(binFrameHeader.assembleHeaderBytes(), 0, data, 0, 12);
- System.arraycopy(protocolMsg.getData(), 0, data, 12, protocolMsg.getJsonSize());
- if (protocolMsg.getBulkData() != null) {
- System.arraycopy(protocolMsg.getBulkData(), 0, data, 12 + protocolMsg.getJsonSize(), protocolMsg.getBulkData().length);
+ } else {
+ data = new byte[12 + protocolMsg.getJsonSize()];
}
+ if (!sessionType.eq(SessionType.CONTROL)) {
+ BinaryFrameHeader binFrameHeader = new BinaryFrameHeader();
+ binFrameHeader = SdlPacketFactory.createBinaryFrameHeader(protocolMsg.getRPCType(), protocolMsg.getFunctionID(), protocolMsg.getCorrID(), protocolMsg.getJsonSize());
+ System.arraycopy(binFrameHeader.assembleHeaderBytes(), 0, data, 0, 12);
+ System.arraycopy(protocolMsg.getData(), 0, data, 12, protocolMsg.getJsonSize());
+ if (protocolMsg.getBulkData() != null) {
+ System.arraycopy(protocolMsg.getBulkData(), 0, data, 12 + protocolMsg.getJsonSize(), protocolMsg.getBulkData().length);
+ }
+ }
} else {
data = protocolMsg.getData();
}
+ if (sdlconn != null && protocolMsg.getPayloadProtected())
+ {
+ if (data != null && data.length > 0) {
+ SdlSession session = sdlconn.findSessionById(sessionID);
+
+ if (session == null)
+ return;
+
+ byte[] dataToRead = new byte[4096];
+ SdlSecurityBase sdlSec = session.getSdlSecurity();
+ if (sdlSec == null)
+ return;
+
+ Integer iNumBytes = sdlSec.encryptData(data, dataToRead);
+ if ((iNumBytes == null) || (iNumBytes <= 0))
+ return;
+
+ byte[] encryptedData = new byte[iNumBytes];
+ System.arraycopy(dataToRead, 0, encryptedData, 0, iNumBytes);
+ data = encryptedData;
+ }
+ }
+
// Get the message lock for this protocol session
Object messageLock = _messageLocks.get(sessionID);
if (messageLock == null) {
@@ -128,7 +177,8 @@ public class WiProProtocol extends AbstractProtocol {
System.arraycopy(BitConverter.intToByteArray(data.length), 0, firstFrameData, 0, 4);
// Second four bytes are frame count.
System.arraycopy(BitConverter.intToByteArray(frameCount), 0, firstFrameData, 4, 4);
- SdlPacket firstHeader = SdlPacketFactory.createMultiSendDataFirst(sessionType, sessionID, messageID, _version,firstFrameData);
+
+ SdlPacket firstHeader = SdlPacketFactory.createMultiSendDataFirst(sessionType, sessionID, messageID, _version,firstFrameData,protocolMsg.getPayloadProtected());
firstHeader.setPriorityCoefficient(1+protocolMsg.priorityCoefficient);
//Send the first frame
handlePacketToSend(firstHeader);
@@ -153,28 +203,28 @@ public class WiProProtocol extends AbstractProtocol {
if (bytesToWrite > MAX_DATA_SIZE) {
bytesToWrite = MAX_DATA_SIZE;
}
- SdlPacket consecHeader = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, bytesToWrite, frameSequenceNumber , messageID, _version,data, currentOffset, bytesToWrite);
+ SdlPacket consecHeader = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, bytesToWrite, frameSequenceNumber , messageID, _version,data, currentOffset, bytesToWrite, protocolMsg.getPayloadProtected());
consecHeader.setPriorityCoefficient(i+2+protocolMsg.priorityCoefficient);
handlePacketToSend(consecHeader);
currentOffset += bytesToWrite;
}
} else {
messageID++;
- SdlPacket header = SdlPacketFactory.createSingleSendData(sessionType, sessionID, data.length, messageID, _version,data);
+ SdlPacket header = SdlPacketFactory.createSingleSendData(sessionType, sessionID, data.length, messageID, _version,data, protocolMsg.getPayloadProtected());
header.setPriorityCoefficient(protocolMsg.priorityCoefficient);
handlePacketToSend(header);
}
}
}
- public void handlePacketReceived(SdlPacket packet){
+ public void handlePacketReceived(SdlPacket packet){
//Check for a version difference
if (_version == 1) {
setVersion((byte)packet.version);
}
-
+
MessageFrameAssembler assembler = getFrameAssemblerForFrame(packet);
- assembler.handleFrame(packet);
+ assembler.handleFrame(packet);
onResetIncomingHeartbeat(SessionType.valueOf((byte)packet.getServiceType()), (byte)packet.getSessionId());
@@ -222,6 +272,7 @@ public class WiProProtocol extends AbstractProtocol {
if (packet.getFrameType() == FrameType.Consecutive && packet.getFrameInfo() == 0x0)
{
ProtocolMessage message = new ProtocolMessage();
+ message.setPayloadProtected(packet.isEncrypted());
message.setSessionType(SessionType.valueOf((byte)packet.getServiceType()));
message.setSessionID((byte)packet.getSessionId());
//If it is WiPro 2.0 it must have binary header
@@ -262,6 +313,29 @@ public class WiProProtocol extends AbstractProtocol {
} // end-method
protected void handleFrame(SdlPacket packet) {
+
+ if (packet.getPayload() != null && packet.getDataSize() > 0 && packet.isEncrypted() )
+ {
+ if (sdlconn != null)
+ {
+ SdlSession session = sdlconn.findSessionById((byte)packet.getSessionId());
+
+ if (session == null)
+ return;
+
+ SdlSecurityBase sdlSec = session.getSdlSecurity();
+ byte[] dataToRead = new byte[4096];
+
+ Integer iNumBytes = sdlSec.decryptData(packet.getPayload(), dataToRead);
+ if ((iNumBytes == null) || (iNumBytes <= 0))
+ return;
+
+ byte[] decryptedData = new byte[iNumBytes];
+ System.arraycopy(dataToRead, 0, decryptedData, 0, iNumBytes);
+ packet.payload = decryptedData;
+ }
+ }
+
if (packet.getFrameType().equals(FrameType.Control)) {
handleControlFrame(packet);
} else {
@@ -295,7 +369,7 @@ public class WiProProtocol extends AbstractProtocol {
}
else if (frameInfo == FrameDataControlFrameType.StartSession.getValue()) {
sendStartProtocolSessionACK(serviceType, (byte)packet.getSessionId());
- } else if (frameInfo == FrameDataControlFrameType.StartSessionACK.getValue()) {
+ } else if (frameInfo == FrameDataControlFrameType.StartSessionACK.getValue()) {
// Use this sessionID to create a message lock
Object messageLock = _messageLocks.get(packet.getSessionId());
if (messageLock == null) {
@@ -308,7 +382,7 @@ public class WiProProtocol extends AbstractProtocol {
hashID = BitConverter.intFromByteArray(packet.payload, 0);
}
}
- handleProtocolSessionStarted(serviceType,(byte) packet.getSessionId(), _version, "", hashID);
+ handleProtocolSessionStarted(serviceType,(byte) packet.getSessionId(), _version, "", hashID, packet.isEncrypted());
} else if (frameInfo == FrameDataControlFrameType.StartSessionNACK.getValue()) {
if (serviceType.eq(SessionType.NAV) || serviceType.eq(SessionType.PCM)) {
handleProtocolSessionNACKed(serviceType, (byte)packet.getSessionId(), _version, "");
@@ -326,23 +400,29 @@ public class WiProProtocol extends AbstractProtocol {
} else if (frameInfo == FrameDataControlFrameType.EndSessionNACK.getValue()) {
handleProtocolSessionEndedNACK(serviceType, (byte)packet.getSessionId(), "");
} else if (frameInfo == FrameDataControlFrameType.ServiceDataACK.getValue()) {
- handleProtocolServiceDataACK(serviceType, (byte)packet.getSessionId ());
+ if (packet.getPayload() != null && packet.getDataSize() == 4) //service data ack will be 4 bytes in length
+ {
+ int serviceDataAckSize = BitConverter.intFromByteArray(packet.getPayload(), 0);
+ handleProtocolServiceDataACK(serviceType, serviceDataAckSize,(byte)packet.getSessionId ());
+ }
}
} // end-method
private void handleSingleFrameMessageFrame(SdlPacket packet) {
ProtocolMessage message = new ProtocolMessage();
+ message.setPayloadProtected(packet.isEncrypted());
SessionType serviceType = SessionType.valueOf((byte)packet.getServiceType());
if (serviceType == SessionType.RPC) {
- message.setMessageType(MessageType.RPC);
+ message.setMessageType(MessageType.RPC);
} else if (serviceType == SessionType.BULK_DATA) {
message.setMessageType(MessageType.BULK);
} // end-if
message.setSessionType(serviceType);
message.setSessionID((byte)packet.getSessionId());
//If it is WiPro 2.0 it must have binary header
- if (_version > 1) {
+ boolean isControlService = message.getSessionType().equals(SessionType.CONTROL);
+ if (_version > 1&& !isControlService) {
BinaryFrameHeader binFrameHeader = BinaryFrameHeader.
parseBinaryHeader(packet.payload);
message.setVersion(_version);
@@ -371,8 +451,8 @@ public class WiProProtocol extends AbstractProtocol {
} // end-class
@Override
- public void StartProtocolService(SessionType sessionType, byte sessionID) {
- SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, _version, sessionID);
+ public void StartProtocolService(SessionType sessionType, byte sessionID, boolean isEncrypted) {
+ SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, _version, sessionID, isEncrypted);
handlePacketToSend(header);
}
@@ -392,7 +472,7 @@ public class WiProProtocol extends AbstractProtocol {
@Override
public void SendHeartBeat(byte sessionID) {
final SdlPacket heartbeat = SdlPacketFactory.createHeartbeat(SessionType.CONTROL, sessionID, _version);
- handlePacketToSend(heartbeat);
+ handlePacketToSend(heartbeat);
}
@Override
@@ -407,4 +487,5 @@ public class WiProProtocol extends AbstractProtocol {
handlePacketToSend(header);
}
-} // end-class \ No newline at end of file
+
+} // end-class
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java
index dc2d44ee1..9f3fbfbd9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java
@@ -2,7 +2,6 @@ package com.smartdevicelink.proxy;
import java.util.Hashtable;
-
public class RPCMessage extends RPCStruct {
public static final String KEY_REQUEST = "request";
public static final String KEY_RESPONSE = "response";
@@ -46,6 +45,9 @@ public class RPCMessage extends RPCStruct {
if (hasKey(hash.keySet(), RPCStruct.KEY_BULK_DATA)) {
setBulkData((byte[]) hash.get(RPCStruct.KEY_BULK_DATA));
}
+ if (hasKey(hash.keySet(), RPCStruct.KEY_PROTECTED)) {
+ setPayloadProtected((Boolean) hash.get(RPCStruct.KEY_PROTECTED));
+ }
}
protected String messageType;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java
index dd8c49a23..e249839d5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java
@@ -562,7 +562,7 @@ public class RPCRequestFactory {
return putFile;
}
- public static PutFile buildPutFile(String sdlFileName, Long iOffset, Long iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) {
+ public static PutFile buildPutFile(String sdlFileName, Long iOffset, Long iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Boolean isPayloadProtected, Integer iCorrelationID) {
PutFile putFile = new PutFile();
putFile.setCorrelationID(iCorrelationID);
putFile.setSdlFileName(sdlFileName);
@@ -571,6 +571,7 @@ public class RPCRequestFactory {
putFile.setSystemFile(bSystemFile);
putFile.setOffset(iOffset);
putFile.setLength(iLength);
+ putFile.setPayloadProtected(isPayloadProtected);
return putFile;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStruct.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStruct.java
index 477bbdde4..7632cf6d3 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStruct.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStruct.java
@@ -10,8 +10,10 @@ import com.smartdevicelink.marshal.JsonRPCMarshaller;
public class RPCStruct {
public static final String KEY_BULK_DATA = "bulkData";
-
+ public static final String KEY_PROTECTED = "protected";
+
private byte[] _bulkData = null;
+ private Boolean protectedPayload = false;
protected Hashtable<String, Object> store = null;
@@ -76,6 +78,14 @@ public class RPCStruct {
}
}
+ public void setPayloadProtected(Boolean bVal) {
+ protectedPayload = bVal;
+ }
+
+ public Boolean getPayloadProtected() {
+ return protectedPayload;
+ }
+
protected String getMessageTypeName(Set<String> keys) {
for (String key : keys) {
if (key == null) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
index fa3f9e68c..8ca6bea70 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
@@ -37,11 +37,41 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@SuppressWarnings("unused")
private static final String SDL_LIB_PRIVATE_TOKEN = "{DAE1A88C-6C16-4768-ACA5-6F1247EA01C2}";
+ /**
+ * @deprecated
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL
+ *
+ * Takes advantage of the advanced lifecycle management.
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param isMediaApp - Indicates if the app is a media application.
+ */
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*TTS Name*/null,
+ /*ngn media app*/null,
+ /*vr synonyms*/null,
+ /*is media app*/isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*language desired*/languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ /*callbackToUIThread*/ false,
+ new BTTransportConfig());
+ }
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL
*
* Takes advantage of the advanced lifecycle management.
+ * @param context - Used to create a multiplexing transport config
* @param listener - Reference to the object in the App listening to callbacks from SDL.
* @param appName - Name of the application displayed on SDL.
* @param isMediaApp - Indicates if the app is a media application.
@@ -67,12 +97,55 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY);
}
-
+ /**
+ * @deprecated
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param isMediaApp - Indicates if the app is a media application.
+ * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * @param languageDesired - Indicates the language desired for the SDL interface.
+ * @param autoActivateID - ID used to re-register previously registered application.
+ * @throws SdlException
+ */
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*TTS Name*/null,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ autoActivateID,
+ /*callbackToUIThread*/ false,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
+ "vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
+ }
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
*
* Takes advantage of the advanced lifecycle management.
*
+ * @param context - Used to create a multiplexing transport config
* @param listener - Reference to the object in the App listening to callbacks from SDL.
* @param appName - Name of the application displayed on SDL.
* @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
@@ -109,8 +182,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
"vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
-
/**
+ * @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
*
* Takes advantage of the advanced lifecycle management.
@@ -127,6 +200,49 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param autoActivateID - ID used to re-register previously registered application.
* @throws SdlException
*/
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
+ Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
+ Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*TTS Name*/null,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ autoActivateID,
+ /*callbackToUIThread*/ false,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
+ "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
+ }
+ /**
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param context - Used to create a multiplexing transport config
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param isMediaApp - Indicates if the app is a media application.
+ * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * @param languageDesired - Indicates the language desired for the SDL interface.
+ * @param autoActivateID - ID used to re-register previously registered application.
+ * @throws SdlException
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
@@ -151,8 +267,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
-
/**
+ * @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
*
* Takes advantage of the advanced lifecycle management.
@@ -170,6 +286,51 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
* @throws SdlException
*/
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID, boolean callbackToUIThread) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*TTS Name*/null,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ autoActivateID,
+ callbackToUIThread,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
+ "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
+ "and callbackToUIThread", SDL_LIB_TRACE_KEY);
+ }
+ /**
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param context - Used to create a multiplexing transport config
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param isMediaApp - Indicates if the app is a media application.
+ * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * @param languageDesired - Indicates the language desired for the SDL interface.
+ * @param autoActivateID - ID used to re-register previously registered application.
+ * @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
+ * @throws SdlException
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
@@ -195,8 +356,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
}
-
/**
+ * @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
*
* Takes advantage of the advanced lifecycle management.
@@ -214,6 +375,52 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
* @throws SdlException
*/
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID,
+ boolean callbackToUIThread) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*TTS Name*/null,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ autoActivateID,
+ callbackToUIThread,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
+ "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
+ "and callbackToUIThread", SDL_LIB_TRACE_KEY);
+ }
+ /**
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param context - Used to create a multiplexing transport config
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param isMediaApp - Indicates if the app is a media application.
+ * @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * @param languageDesired - Indicates the language desired for the SDL interface.
+ * @param autoActivateID - ID used to re-register previously registered application.
+ * @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
+ * @throws SdlException
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
@@ -241,6 +448,34 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
}
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*TTS Name*/null,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ autoActivateID,
+ callbackToUIThread,
+ preRegister,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
+ "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
+ "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ }
+
public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
@@ -535,10 +770,52 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
}
/**
+ * @deprecated
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param isMediaApp Indicates if the app is a media application.
+ * @param languageDesired Indicates the language desired for the SDL interface.
+ * @param hmiDisplayLanguageDesired Desired language in HMI.
+ * @param appID Identifier of the client application.
+ * @param callbackToUIThread If true, all callbacks will occur on the UI thread.
+ * @param preRegister Flag that indicates that client should be pre-registred or not
+ * @throws SdlException
+ */
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException
+ {
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
+ isMediaApp,
+ /*sdlMsgVersion*/null,
+ languageDesired,
+ hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ callbackToUIThread,
+ preRegister,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
+ "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ }
+ /**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
*
* Takes advantage of the advanced lifecycle management.
*
+ * @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
@@ -575,10 +852,47 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
}
/**
+ * @deprecated
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param isMediaApp Indicates if the app is a media application.
+ * @param appID Identifier of the client application.
+ * @throws SdlException
+ */
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID) throws SdlException {
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
+ isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ false,
+ false,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
+ "appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
+ }
+
+ /**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
*
* Takes advantage of the advanced lifecycle management.
*
+ * @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
@@ -609,6 +923,7 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
}
/**
+ * @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
*
* Takes advantage of the advanced lifecycle management.
@@ -619,7 +934,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param isMediaApp Indicates if the app is a media application.
* @param appID Identifier of the client application.
* @throws SdlException
- */
+ */
+ @Deprecated
public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, String appName, Boolean isMediaApp,String appID) throws SdlException {
super( listener,
sdlProxyConfigurationResources,
@@ -643,6 +959,42 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
"sdlProxyConfigurationResources, appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
+ /**
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param context - Used to create a multiplexing transport config
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param sdlProxyConfigurationResources Proxy configuration resources.
+ * @param appName Name of the application displayed on SDL.
+ * @param isMediaApp Indicates if the app is a media application.
+ * @param appID Identifier of the client application.
+ * @throws SdlException
+ */
+ public SdlProxyALM(Context context, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, String appName, Boolean isMediaApp,String appID) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
+ isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ false,
+ false,
+ new MultiplexTransportConfig(context,appID));
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
+ "sdlProxyConfigurationResources, appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
+ }
+
public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,BaseTransportConfig transportConfig) throws SdlException {
super( listener,
/*sdlProxyConfigurationResources*/null,
@@ -665,8 +1017,9 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
-
+
/**
+ * @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
*
* Takes advantage of the advanced lifecycle management.
@@ -679,6 +1032,44 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
*/
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,
+ boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
+ isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ callbackToUIThread,
+ preRegister,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
+ "appName, isMediaApp, " + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ }
+ /**
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param context - Used to create a multiplexing transport config
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param isMediaApp Indicates if the app is a media application.
+ * @param appID Identifier of the client application.
+ * @param callbackToUIThread If true, all callbacks will occur on the UI thread.
+ * @param preRegister Flag that indicates that client should be pre-registred or not
+ * @throws SdlException
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,
boolean callbackToUIThread, boolean preRegister) throws SdlException {
super( listener,
@@ -787,6 +1178,7 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
}
/**
+ * @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
*
* Takes advantage of the advanced lifecycle management.
@@ -809,6 +1201,57 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
*/
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ ttsName,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ autoActivateID,
+ callbackToUIThread,
+ preRegister,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
+ "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
+ "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ }
+ /**
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param context - Used to create a multiplexing transport config
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param sdlProxyConfigurationResources Proxy configuration resources.
+ * @param appName Name of the application displayed on SDL.
+ * @param ttsName TTS name.
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms A vector of strings, all of which can be used as voice commands too
+ * @param isMediaApp Indicates if the app is a media application.
+ * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * @param languageDesired Indicates the language desired for the SDL interface.
+ * @param hmiDisplayLanguageDesired Desired language in HMI.
+ * @param appID Identifier of the client application.
+ * @param autoActivateID ID used to re-register previously registered application.
+ * @param callbackToUIThread If true, all callbacks will occur on the UI thread.
+ * @param preRegister Flag that indicates that client should be pre-registred or not
+ * @throws SdlException
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
@@ -887,12 +1330,64 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
+ /**
+ * @deprecated
+ * Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param sdlProxyConfigurationResources Proxy configuration resources.
+ * @param appName Name of the application displayed on SDL.
+ * @param ttsName TTS name.
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms A vector of strings, all of which can be used as voice commands too
+ * @param isMediaApp Indicates if the app is a media application.
+ * @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * @param languageDesired Indicates the language desired for the SDL interface.
+ * @param hmiDisplayLanguageDesired Desired language in HMI.
+ * @param appType Type of application.
+ * @param appID Identifier of the client application.
+ * @param autoActivateID ID used to re-register previously registered application.
+ * @param callbackToUIThread If true, all callbacks will occur on the UI thread.
+ * @param preRegister Flag that indicates that client should be pre-registred or not
+ * @throws SdlException
+ */
+ @Deprecated
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ Vector<AppHMIType> appType, String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ ttsName,
+ ngnMediaScreenAppName,
+ vrSynonyms,
+ isMediaApp,
+ sdlMsgVersion,
+ languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
+ autoActivateID,
+ callbackToUIThread,
+ preRegister,
+ new BTTransportConfig());
+
+ SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
+ "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
+ "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ }
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
*
* Takes advantage of the advanced lifecycle management.
*
+ * @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
index b8a7a17f4..74376b7ed 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -87,6 +87,7 @@ import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
+import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.trace.TraceDeviceInfo;
@@ -124,7 +125,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private Object APP_INTERFACE_REGISTERED_LOCK = new Object();
private int iFileCount = 0;
-
+
private boolean navServiceStartResponseReceived = false;
private boolean navServiceStartResponse = false;
private boolean pcmServiceStartResponseReceived = false;
@@ -133,6 +134,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private boolean navServiceEndResponse = false;
private boolean pcmServiceEndResponseReceived = false;
private boolean pcmServiceEndResponse = false;
+ private boolean rpcProtectedResponseReceived = false;
+ private boolean rpcProtectedStartResponse = false;
// Device Info for logging
private TraceDeviceInfo _traceDeviceInterrogator = null;
@@ -166,10 +169,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private SdlMsgVersion _sdlMsgVersionRequest = null;
private Vector<String> _vrSynonyms = null;
private boolean _bAppResumeEnabled = false;
- private OnSystemRequest lockScreenIconRequest = null;
+ private OnSystemRequest lockScreenIconRequest = null;
private TelephonyManager telephonyManager = null;
private DeviceInfo deviceInfo = null;
-
+
/**
* Contains current configuration for the transport that was selected during
* construction of this object
@@ -209,11 +212,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
protected String _systemSoftwareVersion = null;
protected List<Integer> _diagModes = null;
protected Boolean firstTimeFull = true;
- protected String _proxyVersionInfo = null;
- protected Boolean _bResumeSuccess = false;
+ protected String _proxyVersionInfo = null;
+ protected Boolean _bResumeSuccess = false;
+ protected List<Class<? extends SdlSecurityBase>> _secList = null;
private CopyOnWriteArrayList<IPutFileResponseListener> _putFileListenerList = new CopyOnWriteArrayList<IPutFileResponseListener>();
-
+
protected byte _wiproVersion = 1;
protected SparseArray<OnRPCResponseListener> rpcResponseListeners = null;
@@ -295,30 +299,38 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
@Override
public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID) {
+ byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
Intent sendIntent = createBroadcastIntent();
updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "onProtocolSessionStarted");
updateBroadcastIntent(sendIntent, "COMMENT1", "SessionID: " + sessionID);
updateBroadcastIntent(sendIntent, "COMMENT2", " ServiceType: " + sessionType.getName());
+ updateBroadcastIntent(sendIntent, "COMMENT3", " Encrypted: " + isEncrypted);
sendBroadcastIntent(sendIntent);
setWiProVersion(version);
if (sessionType.eq(SessionType.RPC)) {
- if ( (_transportConfig.getHeartBeatTimeout() != Integer.MAX_VALUE) && (version > 2))
- {
- HeartbeatMonitor outgoingHeartbeatMonitor = new HeartbeatMonitor();
- outgoingHeartbeatMonitor.setInterval(_transportConfig.getHeartBeatTimeout());
- sdlSession.setOutgoingHeartbeatMonitor(outgoingHeartbeatMonitor);
-
- HeartbeatMonitor incomingHeartbeatMonitor = new HeartbeatMonitor();
- incomingHeartbeatMonitor.setInterval(_transportConfig.getHeartBeatTimeout());
- sdlSession.setIncomingHeartbeatMonitor(incomingHeartbeatMonitor);
- }
-
- startRPCProtocolSession(sessionID, correlationID);
+ if (!isEncrypted)
+ {
+ if ( (_transportConfig.getHeartBeatTimeout() != Integer.MAX_VALUE) && (version > 2))
+ {
+ HeartbeatMonitor outgoingHeartbeatMonitor = new HeartbeatMonitor();
+ outgoingHeartbeatMonitor.setInterval(_transportConfig.getHeartBeatTimeout());
+ sdlSession.setOutgoingHeartbeatMonitor(outgoingHeartbeatMonitor);
+
+ HeartbeatMonitor incomingHeartbeatMonitor = new HeartbeatMonitor();
+ incomingHeartbeatMonitor.setInterval(_transportConfig.getHeartBeatTimeout());
+ sdlSession.setIncomingHeartbeatMonitor(incomingHeartbeatMonitor);
+ }
+
+ startRPCProtocolSession(sessionID, correlationID);
+ }
+ else
+ {
+ RPCProtectedServiceStarted();
+ }
} else if (sessionType.eq(SessionType.NAV)) {
NavServiceStarted();
} else if (sessionType.eq(SessionType.PCM)) {
@@ -408,7 +420,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
- @Override
+ @Override
public void onProtocolSessionEndedNACKed(SessionType sessionType,
byte sessionID, String correlationID) {
if (sessionType.eq(SessionType.NAV)) {
@@ -431,21 +443,21 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
AudioServiceEndedNACK();
}
- }
- public void onProtocolServiceDataACK(SessionType sessionType,
+ }
+ public void onProtocolServiceDataACK(SessionType sessionType, final int dataSize,
byte sessionID) {
if (_callbackToUIThread) {
// Run in UI thread
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onServiceDataACK();
+ _proxyListener.onServiceDataACK(dataSize);
}
});
} else {
- _proxyListener.onServiceDataACK();
+ _proxyListener.onServiceDataACK(dataSize);
}
- }
+ }
}
/**
@@ -750,6 +762,32 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sendIntent.putExtra(sKey, iValue);
}
+ private Service getService()
+ {
+ Service myService = null;
+ if (_proxyListener != null && _proxyListener instanceof Service)
+ {
+ myService = (Service) _proxyListener;
+ }
+ else if (_appService != null)
+ {
+ myService = _appService;
+ }
+ if (myService != null)
+ {
+ try
+ {
+ return myService;
+ }
+ catch(Exception ex)
+ {
+ return null;
+ }
+
+ }
+ return null;
+ }
+
private void sendBroadcastIntent(Intent sendIntent)
{
Service myService = null;
@@ -1426,6 +1464,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
hash.put(RPCMessage.KEY_NOTIFICATION, hashTemp);
}
if (message.getBulkData() != null) hash.put(RPCStruct.KEY_BULK_DATA, message.getBulkData());
+ if (message.getPayloadProtected()) hash.put(RPCStruct.KEY_PROTECTED, true);
} else {
final Hashtable<String, Object> mhash = JsonRPCMarshaller.unmarshall(message.getData());
hash = mhash;
@@ -1609,6 +1648,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
pm.setMessageType(MessageType.RPC);
pm.setSessionType(SessionType.RPC);
pm.setFunctionID(FunctionID.getFunctionId(request.getFunctionName()));
+ pm.setPayloadProtected(request.getPayloadProtected());
if (request.getCorrelationID() == null)
{
//Log error here
@@ -1733,6 +1773,50 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
+ private void processRaiResponse(RegisterAppInterfaceResponse rai)
+ {
+ if (rai == null) return;
+
+ VehicleType vt = rai.getVehicleType();
+ if (vt == null) return;
+
+ String make = vt.getMake();
+ if (make == null) return;
+
+ if (_secList == null) return;
+
+ SdlSecurityBase sec = null;
+ Service svc = getService();
+ SdlSecurityBase.setAppService(svc);
+
+ for (Class<? extends SdlSecurityBase> cls : _secList)
+ {
+ try
+ {
+ sec = cls.newInstance();
+ }
+ catch (Exception e)
+ {
+ continue;
+ }
+
+ if ( (sec != null) && (sec.getMakeList() != null) )
+ {
+ if (sec.getMakeList().contains(make))
+ {
+ setSdlSecurity(sec);
+ if (sec != null)
+ {
+ sec.setAppId(_appID);
+ if (sdlSession != null)
+ sec.handleSdlSession(sdlSession);
+ }
+ return;
+ }
+ }
+ }
+ }
+
private void handleRPCMessage(Hashtable<String, Object> hash) {
RPCMessage rpcMsg = new RPCMessage(hash);
String functionName = rpcMsg.getFunctionName();
@@ -1752,6 +1836,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (msg.getSuccess()) {
_appInterfaceRegisterd = true;
}
+ processRaiResponse(msg);
Intent sendIntent = createBroadcastIntent();
updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE.toString());
@@ -1780,7 +1865,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_audioPassThruCapabilities = msg.getAudioPassThruCapabilities();
_hmiCapabilities = msg.getHmiCapabilities();
_systemSoftwareVersion = msg.getSystemSoftwareVersion();
- _proxyVersionInfo = msg.getProxyVersionInfo();
+ _proxyVersionInfo = msg.getProxyVersionInfo();
+
+
if (_bAppResumeEnabled)
{
@@ -1915,7 +2002,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (msg.getSuccess()) {
_appInterfaceRegisterd = true;
}
-
+ processRaiResponse(msg);
+
//_autoActivateIdReturned = msg.getAutoActivateID();
/*Place holder for legacy support*/ _autoActivateIdReturned = "8675309";
_buttonCapabilities = msg.getButtonCapabilities();
@@ -3245,25 +3333,23 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private RPCStreamController startRPCStream(String sLocalFile, PutFile request, SessionType sType, byte rpcSessionID, byte wiproVersion)
{
if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
FileInputStream is = getFileInputStream(sLocalFile);
if (is == null) return null;
- Integer iSize = Integer.valueOf(getFileInputStreamSize(is).intValue());
- if (iSize == null)
+ Long lSize = getFileInputStreamSize(is);
+ if (lSize == null)
{
closeFileInputStream(is);
return null;
}
try {
- StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlConn, is, request, sType, rpcSessionID, wiproVersion, iSize);
+ StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlSession, is, request, sType, rpcSessionID, wiproVersion, lSize, sdlSession);
rpcPacketizer.start();
RPCStreamController streamController = new RPCStreamController(rpcPacketizer, request.getCorrelationID());
return streamController;
- } catch (Exception e) {
+ } catch (Exception e) {
Log.e("SyncConnection", "Unable to start streaming:" + e.toString());
return null;
}
@@ -3272,18 +3358,16 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
@SuppressWarnings("unchecked")
private RPCStreamController startRPCStream(InputStream is, PutFile request, SessionType sType, byte rpcSessionID, byte wiproVersion)
{
- if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
- Long iSize = request.getLength();
+ if (sdlSession == null) return null;
+ Long lSize = request.getLength();
- if (request.getLength() == null)
+ if (lSize == null)
{
return null;
}
try {
- StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlConn, is, request, sType, rpcSessionID, wiproVersion, iSize);
+ StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlSession, is, request, sType, rpcSessionID, wiproVersion, lSize, sdlSession);
rpcPacketizer.start();
RPCStreamController streamController = new RPCStreamController(rpcPacketizer, request.getCorrelationID());
return streamController;
@@ -3295,15 +3379,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private RPCStreamController startPutFileStream(String sPath, PutFile msg) {
if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
return startRPCStream(sPath, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
}
private RPCStreamController startPutFileStream(InputStream is, PutFile msg) {
if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
if (is == null) return null;
startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
return null;
@@ -3311,24 +3391,18 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public boolean startRPCStream(InputStream is, RPCRequest msg) {
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
- sdlConn.startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
+ sdlSession.startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
return true;
}
public OutputStream startRPCStream(RPCRequest msg) {
if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
- return sdlConn.startRPCStream(msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
+ return sdlSession.startRPCStream(msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
}
public void endRPCStream() {
if (sdlSession == null) return;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return;
- sdlConn.stopRPCStream();
+ sdlSession.stopRPCStream();
}
private class CallableMethod implements Callable<Void> {
@@ -3348,7 +3422,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
public FutureTask<Void> createFutureTask(CallableMethod callMethod){
- return new FutureTask<Void>(callMethod);
+ return new FutureTask<Void>(callMethod);
}
public ScheduledExecutorService createScheduler(){
return Executors.newSingleThreadScheduledExecutor();
@@ -3358,20 +3432,18 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Opens the video service (serviceType 11) and subsequently streams raw H264 video from an InputStream provided by the app
*@return true if service is opened successfully and stream is started, return false otherwise
*/
-
- public boolean startH264(InputStream is) {
+ public boolean startH264(InputStream is, boolean isEncrypted) {
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
-
+
navServiceStartResponseReceived = false;
navServiceStartResponse = false;
- sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
+ sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
ScheduledExecutorService scheduler = createScheduler();
- scheduler.execute(fTask);
+ scheduler.execute(fTask);
while (!navServiceStartResponseReceived && !fTask.isDone());
scheduler.shutdown();
@@ -3380,7 +3452,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (navServiceStartResponse) {
try {
- sdlConn.startStream(is, SessionType.NAV, sdlSession.getSessionId());
+ sdlSession.startStream(is, SessionType.NAV, sdlSession.getSessionId());
return true;
} catch (Exception e) {
return false;
@@ -3388,23 +3460,21 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
} else {
return false;
}
- }
+ }
/**
*Opens the video service (serviceType 11) and subsequently provides an OutputStream to the app to use for a raw H264 video stream
*@return OutputStream if service is opened successfully and stream is started, return null otherwise
- */
- public OutputStream startH264() {
+ */
+ public OutputStream startH264(boolean isEncrypted) {
if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
navServiceStartResponseReceived = false;
navServiceStartResponse = false;
- sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
+ sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
@@ -3415,7 +3485,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (navServiceStartResponse) {
try {
- return sdlConn.startStream(SessionType.NAV, sdlSession.getSessionId());
+ return sdlSession.startStream(SessionType.NAV, sdlSession.getSessionId());
} catch (Exception e) {
return null;
}
@@ -3430,14 +3500,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*/
public boolean endH264() {
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
navServiceEndResponseReceived = false;
navServiceEndResponse = false;
- sdlConn.stopVideoStream();
+ sdlSession.stopVideoStream();
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
@@ -3452,7 +3520,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
return false;
}
}
-
/**
*Pauses the stream for the opened audio service (serviceType 10)
*@return true if the audio service stream is paused successfully, return false otherwise
@@ -3460,9 +3527,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public boolean pausePCM()
{
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
- return sdlConn.pauseAudioStream();
+ return sdlSession.pauseAudioStream();
}
/**
@@ -3472,9 +3537,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public boolean pauseH264()
{
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
- return sdlConn.pauseVideoStream();
+ return sdlSession.pauseVideoStream();
}
/**
@@ -3484,9 +3547,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public boolean resumePCM()
{
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
- return sdlConn.resumeAudioStream();
+ return sdlSession.resumeAudioStream();
}
/**
@@ -3496,9 +3557,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public boolean resumeH264()
{
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
- return sdlConn.resumeVideoStream();
+ return sdlSession.resumeVideoStream();
}
@@ -3506,18 +3565,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Opens the audio service (serviceType 10) and subsequently streams raw PCM audio from an InputStream provided by the app
*@return true if service is opened successfully and stream is started, return false otherwise
*/
-
- public boolean startPCM(InputStream is) {
+ public boolean startPCM(InputStream is, boolean isEncrypted) {
if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
-
+
pcmServiceStartResponseReceived = false;
pcmServiceStartResponse = false;
- sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
+ sdlSession.startService(SessionType.PCM, sdlSession.getSessionId(), isEncrypted);
- sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
@@ -3528,7 +3583,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (pcmServiceStartResponse) {
try {
- sdlConn.startStream(is, SessionType.PCM, sdlSession.getSessionId());
+ sdlSession.startStream(is, SessionType.PCM, sdlSession.getSessionId());
return true;
} catch (Exception e) {
return false;
@@ -3542,15 +3597,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Opens the audio service (serviceType 10) and subsequently provides an OutputStream to the app
*@return OutputStream if service is opened successfully and stream is started, return null otherwise
*/
- public OutputStream startPCM() {
+ public OutputStream startPCM(boolean isEncrypted) {
if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
pcmServiceStartResponseReceived = false;
pcmServiceStartResponse = false;
- sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
+ sdlSession.startService(SessionType.PCM, sdlSession.getSessionId(), isEncrypted);
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
@@ -3561,7 +3615,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (pcmServiceStartResponse) {
try {
- return sdlConn.startStream(SessionType.PCM, sdlSession.getSessionId());
+ return sdlSession.startStream(SessionType.PCM, sdlSession.getSessionId());
} catch (Exception e) {
return null;
}
@@ -3581,9 +3635,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
pcmServiceEndResponseReceived = false;
pcmServiceEndResponse = false;
- sdlConn.stopAudioStream();
+ sdlSession.stopAudioStream();
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
@@ -3609,7 +3663,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@return Surface if service is opened successfully and stream is started, return null otherwise
*/
public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width,
- int height, int bitrate) {
+ int height, int bitrate, boolean isEncrypted) {
if (sdlSession == null) return null;
SdlConnection sdlConn = sdlSession.getSdlConnection();
@@ -3617,7 +3671,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
navServiceStartResponseReceived = false;
navServiceStartResponse = false;
- sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
+ sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
FutureTask<Void> fTask = createFutureTask(new CallableMethod(2000));
ScheduledExecutorService scheduler = createScheduler();
@@ -3629,7 +3683,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
fTask = null;
if (navServiceStartResponse) {
- return sdlConn.createOpenGLInputSurface(frameRate, iFrameInterval, width,
+ return sdlSession.createOpenGLInputSurface(frameRate, iFrameInterval, width,
height, bitrate, SessionType.NAV, sdlSession.getSessionId());
} else {
return null;
@@ -3644,7 +3698,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return;
- sdlConn.startEncoder();
+ sdlSession.startEncoder();
}
/**
@@ -3655,7 +3709,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return;
- sdlConn.releaseEncoder();
+ sdlSession.releaseEncoder();
}
/**
@@ -3666,8 +3720,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return;
- sdlConn.drainEncoder(endOfStream);
- }
+ sdlSession.drainEncoder(endOfStream);
+ }
private void NavServiceStarted() {
navServiceStartResponseReceived = true;
@@ -3683,7 +3737,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
pcmServiceStartResponseReceived = true;
pcmServiceStartResponse = true;
}
-
+
+ private void RPCProtectedServiceStarted() {
+ rpcProtectedResponseReceived = true;
+ rpcProtectedStartResponse = true;
+ }
private void AudioServiceStartedNACK() {
pcmServiceStartResponseReceived = true;
pcmServiceStartResponse = false;
@@ -3714,6 +3772,27 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_appService = mService;
}
+ public boolean startProtectedRPCService() {
+ rpcProtectedResponseReceived = false;
+ rpcProtectedStartResponse = false;
+ sdlSession.startService(SessionType.RPC, sdlSession.getSessionId(), true);
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(10000));
+ ScheduledExecutorService scheduler = createScheduler();
+ scheduler.execute(fTask);
+
+ while (!rpcProtectedResponseReceived && !fTask.isDone());
+ scheduler.shutdown();
+ scheduler = null;
+ fTask = null;
+
+ if (rpcProtectedStartResponse) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public void getLockScreenIcon(final OnLockScreenIconDownloadedListener l){
if(lockScreenIconRequest == null){
l.onLockScreenIconDownloadError(new SdlException("This version of SDL core may not support lock screen icons.",
@@ -5070,8 +5149,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @throws SdlException
* @see {@link#putFileStream(String, Long, Long)}
*/
- @Deprecated
- public OutputStream putFileStream(String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
+ @Deprecated
+ public OutputStream putFileStream(String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
{
PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
return startRPCStream(msg);
@@ -5108,7 +5187,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @throws SdlException
* @see {@link#putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean)}
*/
- @Deprecated
+ @Deprecated
public void putFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException
{
PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
@@ -5154,7 +5233,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @throws SdlException
* @see {@link#putFileStream(String, Long, Long, FileType, Boolean, Boolean)}
*/
- @Deprecated
+ @Deprecated
public OutputStream putFileStream(String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException
{
PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
@@ -5200,7 +5279,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @throws SdlException
* @see {@link#putFileStream(String, String, Long, FileType, Boolean, Boolean, Integer)}
*/
- @Deprecated
+ @Deprecated
public RPCStreamController putFileStream(String sPath, String sdlFileName, Integer iOffset, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) throws SdlException
{
PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, 0, fileType, bPersistentFile, bSystemFile, iCorrelationID);
@@ -5229,8 +5308,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* returned .
* @throws SdlException
*/
- public RPCStreamController putFileStream(String path, String fileName, Long offset, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Integer correlationId,OnPutFileUpdateListener cb ) throws SdlException {
- PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, 0L, fileType, isPersistentFile, isSystemFile, correlationId);
+ public RPCStreamController putFileStream(String path, String fileName, Long offset, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId, OnPutFileUpdateListener cb ) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, 0L, fileType, isPersistentFile, isSystemFile, isPayloadProtected, correlationId);
msg.setOnPutFileUpdateListener(cb);
return startPutFileStream(path,msg);
}
@@ -5251,7 +5330,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @throws SdlException
* @see {@link#putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean, Integer)}
*/
- @Deprecated
+ @Deprecated
public RPCStreamController putFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) throws SdlException
{
PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile, iCorrelationID);
@@ -5278,8 +5357,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* RPCResponse.
* @throws SdlException
*/
- public RPCStreamController putFileStream(InputStream inputStream, String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Integer correlationId) throws SdlException {
- PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length, fileType, isPersistentFile, isSystemFile, correlationId);
+ public RPCStreamController putFileStream(InputStream inputStream, String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length, fileType, isPersistentFile, isSystemFile, isPayloadProtected, correlationId);
return startPutFileStream(inputStream, msg);
}
@@ -5383,6 +5462,25 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
return sdlSession.getCurrentTransportType();
}
+ public void setSdlSecurityClassList(List<Class<? extends SdlSecurityBase>> list) {
+ _secList = list;
+ }
+
+ private void setSdlSecurity(SdlSecurityBase sec) {
+ if (sdlSession != null)
+ {
+ sdlSession.setSdlSecurity(sec);
+ }
+ }
+
+ public boolean isServiceTypeProtected(SessionType sType)
+ {
+ if (sdlSession == null)
+ return false;
+
+ return sdlSession.isServiceProtected(sType);
+ }
+
public IProxyListenerBase getProxyListener()
{
return _proxyListener;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBuilder.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBuilder.java
index 478b59db6..9e6921a61 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBuilder.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBuilder.java
@@ -1,5 +1,6 @@
package com.smartdevicelink.proxy;
+import java.util.List;
import java.util.Vector;
import com.smartdevicelink.exception.SdlException;
@@ -8,9 +9,13 @@ import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.TTSChunk;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.Language;
+import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.transport.BTTransportConfig;
import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.transport.MultiplexTransportConfig;
+
import android.app.Service;
+import android.content.Context;
public class SdlProxyBuilder
{
@@ -34,7 +39,8 @@ public class SdlProxyBuilder
private boolean preRegister;
private String sAppResumeHash;
private BaseTransportConfig mTransport;
-
+ private List<Class<? extends SdlSecurityBase>> sdlSecList;
+
public static class Builder
{
// Required parameters
@@ -42,6 +48,7 @@ public class SdlProxyBuilder
private String appId;
private String appName;
private Boolean isMediaApp;
+ private Context context;
// Optional parameters - initialized to default values
private Service service = null;
@@ -57,16 +64,32 @@ public class SdlProxyBuilder
private boolean callbackToUIThread = false;
private boolean preRegister = false;
private String sAppResumeHash = null;
- private BaseTransportConfig mTransport = new BTTransportConfig();
-
+ private List<Class<? extends SdlSecurityBase>> sdlSecList = null;
+ private BaseTransportConfig mTransport; //Initialized in constructor
+
+ /**
+ * @deprecated Use Builder(IProxyListenerALM, String, String, Boolean, Context) instead
+ */
+ @Deprecated
public Builder(IProxyListenerALM listener, String appId, String appName, Boolean isMediaApp)
{
this.listener = listener;
this.appId = appId;
this.appName = appName;
this.isMediaApp = isMediaApp;
+ this.mTransport = new BTTransportConfig();
}
-
+
+ public Builder(IProxyListenerALM listener, String appId, String appName, Boolean isMediaApp, Context context)
+ {
+ this.listener = listener;
+ this.appId = appId;
+ this.appName = appName;
+ this.isMediaApp = isMediaApp;
+ this.context = context;
+ this.mTransport = new MultiplexTransportConfig(context, appId);
+ }
+
public Builder setService(Service val)
{ service = val; return this; }
public Builder setSdlProxyConfigurationResources(SdlProxyConfigurationResources val)
@@ -95,11 +118,15 @@ public class SdlProxyBuilder
{ sAppResumeHash = val; return this; }
public Builder setTransportType(BaseTransportConfig val)
{ mTransport = val; return this; }
+ public Builder setSdlSecurity(List<Class<? extends SdlSecurityBase>> val)
+ { sdlSecList = val; return this; }
public SdlProxyALM build() throws SdlException
{
SdlProxyBuilder obj = new SdlProxyBuilder(this);
- return new SdlProxyALM(obj.service,obj.listener,obj.sdlProxyConfigurationResources,obj.appName,obj.ttsChunks,obj.sShortAppName,obj.vrSynonyms,obj.isMediaApp,obj.sdlMessageVersion,obj.lang,obj.hmiLang,obj.vrAppHMITypes,obj.appId,obj.autoActivateID,obj.callbackToUIThread,obj.preRegister,obj.sAppResumeHash,obj.mTransport);
+ SdlProxyALM proxy = new SdlProxyALM(obj.service,obj.listener,obj.sdlProxyConfigurationResources,obj.appName,obj.ttsChunks,obj.sShortAppName,obj.vrSynonyms,obj.isMediaApp,obj.sdlMessageVersion,obj.lang,obj.hmiLang,obj.vrAppHMITypes,obj.appId,obj.autoActivateID,obj.callbackToUIThread,obj.preRegister,obj.sAppResumeHash,obj.mTransport);
+ proxy.setSdlSecurityClassList(obj.sdlSecList);
+ return proxy;
}
}
@@ -124,6 +151,7 @@ public class SdlProxyBuilder
preRegister = builder.preRegister;
sAppResumeHash = builder.sAppResumeHash;
mTransport = builder.mTransport;
+ sdlSecList = builder.sdlSecList;
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
index 2f148ad30..1861b266b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
@@ -84,14 +84,14 @@ public interface IProxyListenerBase {
*/
public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason);
- public void onServiceEnded(OnServiceEnded serviceEnded);
-
+ public void onServiceEnded(OnServiceEnded serviceEnded);
+
public void onServiceNACKed(OnServiceNACKed serviceNACKed);
-
+
public void onOnStreamRPC(OnStreamRPC notification);
public void onStreamRPCResponse(StreamRPCResponse response);
-
+
/**
* onProxyError() being called indicates that the SDL Proxy experenced an error.
*
@@ -317,12 +317,12 @@ public interface IProxyListenerBase {
public void onDialNumberResponse(DialNumberResponse response);
public void onSendLocationResponse(SendLocationResponse response);
-
+
public void onShowConstantTbtResponse(ShowConstantTbtResponse response);
public void onAlertManeuverResponse(AlertManeuverResponse response);
public void onUpdateTurnListResponse(UpdateTurnListResponse response);
-
- public void onServiceDataACK();
+
+ public void onServiceDataACK(int dataSize);
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java
index 8d13baa21..76e3c4207 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java
@@ -84,8 +84,18 @@ public class TouchEvent extends RPCStruct {
return (Integer) store.get(KEY_ID);
}
- @SuppressWarnings("unchecked")
+ /**
+ * Use getTimestamps
+ * @deprecated 4.0.2
+ * @return
+ */
+ @Deprecated
public List<Long> getTs() {
+ return getTimestamps();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Long> getTimestamps() {
if(store.get(KEY_TS) instanceof List<?>){
List<?> list = (List<?>)store.get(KEY_TS);
if(list != null && list.size()>0){
@@ -106,16 +116,35 @@ public class TouchEvent extends RPCStruct {
return null;
}
- public void setTs(List<Long> ts) {
- if (ts != null) {
+ public void setTimestamps(List<Long> ts){
+ if (ts != null) {
store.put(KEY_TS, ts);
} else {
store.remove(KEY_TS);
}
}
- @SuppressWarnings("unchecked")
+ /**
+ * Use setTimestamps.
+ * @deprecated 4.0.2
+ * @param ts
+ */
+ @Deprecated
+ public void setTs(List<Long> ts) {
+ setTimestamps(ts);
+ }
+
+ /**
+ * Use getTouchCoordinates
+ * @deprecated 4.0.2
+ * @return
+ */
+ @Deprecated
public List<TouchCoord> getC() {
+ return getTouchCoordinates();
+ }
+ @SuppressWarnings("unchecked")
+ public List<TouchCoord> getTouchCoordinates() {
if (store.get(KEY_C) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_C);
if (list != null && list.size() > 0) {
@@ -134,7 +163,17 @@ public class TouchEvent extends RPCStruct {
return null;
}
+ /**
+ * Use setTouchCoordinates
+ * @deprecated 4.0.2
+ * @return
+ */
+ @Deprecated
public void setC( List<TouchCoord> c ) {
+ setTouchCoordinates(c);
+ }
+
+ public void setTouchCoordinates( List<TouchCoord> c ) {
if (c != null) {
store.put(KEY_C, c );
} else {
diff --git a/sdl_android_lib/src/com/smartdevicelink/security/ISecurityInitializedListener.java b/sdl_android_lib/src/com/smartdevicelink/security/ISecurityInitializedListener.java
new file mode 100644
index 000000000..f18152ed0
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/security/ISecurityInitializedListener.java
@@ -0,0 +1,5 @@
+package com.smartdevicelink.security;
+
+public interface ISecurityInitializedListener {
+ public void onSecurityInitialized();
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/security/SdlSecurityBase.java b/sdl_android_lib/src/com/smartdevicelink/security/SdlSecurityBase.java
new file mode 100644
index 000000000..6aab36635
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/security/SdlSecurityBase.java
@@ -0,0 +1,100 @@
+package com.smartdevicelink.security;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.app.Service;
+
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.enums.SessionType;
+
+public abstract class SdlSecurityBase {
+
+ private SdlSession session = null;
+ private String appId = null;
+ private List<String> makeList = null;
+ private boolean isInitSuccess = false;
+ private byte sessionId = 0;
+ private static Service appService = null;
+ private List<SessionType> startServiceList = new ArrayList<SessionType>();
+
+ public SdlSecurityBase() {
+ }
+
+ public abstract void initialize();
+
+ public abstract Integer runHandshake(byte[] inputData,byte[] outputData);
+
+ public abstract Integer encryptData(byte[] inputData,byte[] outputData);
+
+ public abstract Integer decryptData(byte[] inputData,byte[] outputData);
+
+ public abstract void shutDown();
+
+ public void resetParams() {
+ session = null;
+ appId = null;
+ isInitSuccess = false;
+ startServiceList.clear();
+ }
+
+ public List<SessionType> getServiceList() {
+ return startServiceList;
+ }
+
+ public void handleInitResult(boolean val) {
+ setInitSuccess(val);
+ session.onSecurityInitialized();
+ }
+
+ public void handleSdlSession(SdlSession val) {
+ if (val == null) return;
+
+ setSessionId(val.getSessionId());
+ setSdlSession(val);
+ }
+
+ private void setInitSuccess(boolean val) {
+ isInitSuccess = val;
+ }
+
+ public boolean getInitSuccess() {
+ return isInitSuccess;
+ }
+
+ private void setSessionId(byte val) {
+ sessionId = val;
+ }
+
+ public byte getSessionId() {
+ return sessionId;
+ }
+
+ private void setSdlSession(SdlSession val) {
+ session = val;
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public void setAppId(String val) {
+ appId = val;
+ }
+
+ public static Service getAppService() {
+ return appService;
+ }
+
+ public static void setAppService(Service val) {
+ appService = val;
+ }
+
+ public List<String> getMakeList() {
+ return makeList;
+ }
+
+ public void setMakeList(List<String> val) {
+ makeList = val;
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java
index 88a1dea81..b4ee3ed1f 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java
@@ -3,6 +3,7 @@ package com.smartdevicelink.streaming;
import java.io.IOException;
import java.io.InputStream;
+import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCRequest;
@@ -12,9 +13,10 @@ abstract public class AbstractPacketizer {
private final static int BUFF_READ_SIZE = 1000000;
protected byte _rpcSessionID = 0;
- protected SessionType _session = null;
- protected InputStream is = null;
- protected byte[] buffer = new byte[BUFF_READ_SIZE];
+ protected SessionType _serviceType = null;
+ protected SdlSession _session = null;
+ protected InputStream is = null;
+ protected byte[] buffer = new byte[BUFF_READ_SIZE];
protected boolean upts = false;
protected RPCRequest _request = null;
protected byte _wiproVersion = 1;
@@ -22,20 +24,22 @@ abstract public class AbstractPacketizer {
//protected long ts = 0, intervalBetweenReports = 5000, delta = 0;
protected long intervalBetweenReports = 5000, delta = 0;
- public AbstractPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
+ public AbstractPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException {
this._streamListener = streamListener;
this.is = is;
_rpcSessionID = rpcSessionID;
- _session = sType;
+ _serviceType = sType;
+ this._session = session;
}
- public AbstractPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) throws IOException {
+ public AbstractPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, SdlSession session) throws IOException {
this._streamListener = streamListener;
this.is = is;
_rpcSessionID = rpcSessionID;
- _session = sType;
+ _serviceType = sType;
_request = request;
_wiproVersion = wiproVersion;
+ this._session = session;
}
public abstract void start() throws IOException;
@@ -45,5 +49,4 @@ abstract public class AbstractPacketizer {
public abstract void pause();
public abstract void resume();
-
-}
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
index cd807fd8e..a05fb9c52 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
@@ -4,22 +4,28 @@ import java.io.IOException;
import java.io.InputStream;
import com.smartdevicelink.SdlConnection.SdlConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
public class StreamPacketizer extends AbstractPacketizer implements Runnable{
- public final static String TAG = "StreamPacketizer";
- private Thread t = null;
+ public final static String TAG = "StreamPacketizer";
+
+ private Thread t = null;
+
+ private final static int BUFF_READ_SIZE = 1024;
public SdlConnection sdlConnection = null;
private Object mPauseLock;
private boolean mPaused;
-
- public StreamPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
- super(streamListener, is, sType, rpcSessionID);
+ private boolean isServiceProtected = false;
+
+ public StreamPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException {
+ super(streamListener, is, sType, rpcSessionID, session);
mPauseLock = new Object();
mPaused = false;
+ isServiceProtected = _session.isServiceProtected(_serviceType);
}
public void start() throws IOException {
@@ -41,11 +47,10 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
public void run() {
int length;
-
try
{
while (t != null && !t.isInterrupted())
- {
+ {
synchronized(mPauseLock)
{
while (mPaused)
@@ -58,16 +63,17 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
}
}
- length = is.read(buffer, 0, 1488);
+ length = is.read(buffer, 0, BUFF_READ_SIZE);
if (length >= 0)
{
ProtocolMessage pm = new ProtocolMessage();
pm.setSessionID(_rpcSessionID);
- pm.setSessionType(_session);
+ pm.setSessionType(_serviceType);
pm.setFunctionID(0);
pm.setCorrID(0);
pm.setData(buffer, length);
+ pm.setPayloadProtected(isServiceProtected);
if (t != null && !t.isInterrupted())
_streamListener.sendStreamPacket(pm);
@@ -81,7 +87,7 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
{
if (sdlConnection != null)
{
- sdlConnection.endService(_session, _rpcSessionID);
+ sdlConnection.endService(_serviceType, _rpcSessionID);
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java
index ac9ebb379..0e00ecad7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java
@@ -4,6 +4,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
+import com.smartdevicelink.SdlConnection.SdlSession;
+
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.FunctionID;
@@ -31,18 +33,19 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
private String sFileName;
private SdlProxyBase<IProxyListenerBase> _proxy;
private IProxyListenerBase _proxyListener;
-
+
private Object mPauseLock;
private boolean mPaused;
-
- private OnPutFileUpdateListener callBack;
-
- public StreamRPCPacketizer(SdlProxyBase<IProxyListenerBase> proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, long iLength) throws IOException {
- super(streamListener, is, request, sType, rpcSessionID, wiproVersion);
- lFileSize = iLength;
+ private boolean isRPCProtected = false;
+ private OnPutFileUpdateListener callBack;
+
+ public StreamRPCPacketizer(SdlProxyBase<IProxyListenerBase> proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, long lLength, SdlSession session) throws IOException {
+ super(streamListener, is, request, sType, rpcSessionID, wiproVersion, session);
+ lFileSize = lLength;
iInitialCorrID = request.getCorrelationID();
mPauseLock = new Object();
mPaused = false;
+ isRPCProtected = request.getPayloadProtected();
if (proxy != null)
{
_proxy = proxy;
@@ -51,7 +54,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
}
if(_request.getFunctionName().equalsIgnoreCase(FunctionID.PUT_FILE.toString())){
callBack = ((PutFile)_request).getOnPutFileUpdateListener();
- }
+ }
}
@Override
@@ -142,6 +145,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
byte[] msgBytes;
ProtocolMessage pm;
OnStreamRPC notification;
+
// Moves the current Thread into the background
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
@@ -149,8 +153,9 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
int iCorrID = 0;
PutFile msg = (PutFile) _request;
- long iOffsetCounter = msg.getOffset();
sFileName = msg.getSdlFileName();
+ long iOffsetCounter = msg.getOffset();
+
int priorityCoefficient = 1;
if (lFileSize != 0)
@@ -203,7 +208,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
pm.setSessionID(_rpcSessionID);
pm.setMessageType(MessageType.RPC);
- pm.setSessionType(_session);
+ pm.setSessionType(_serviceType);
pm.setFunctionID(FunctionID.getFunctionId(msg.getFunctionName()));
if (buffer.length != length)
@@ -212,6 +217,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
pm.setBulkDataNoCopy(buffer);
pm.setCorrID(msg.getCorrelationID());
+ pm.setPayloadProtected(isRPCProtected);
priorityCoefficient++;
pm.setPriorityCoefficient(priorityCoefficient);
@@ -225,7 +231,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR
msg.setOffset(iOffsetCounter);
iCorrID = msg.getCorrelationID() + 1;
msg.setCorrelationID(iCorrID);
-
+
_streamListener.sendStreamPacket(pm);
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java b/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
index 93f8ca246..2d997b1c4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
+++ b/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
@@ -274,7 +274,7 @@ public class SdlTrace {
sb.append("<ver>");
sb.append(hdr.getVersion());
sb.append("</ver><cmp>");
- sb.append(hdr.isCompression());
+ sb.append(hdr.isEncrypted());
sb.append("</cmp><ft>");
sb.append(getProtocolFrameType(hdr.getFrameType()));
sb.append("</ft><st>");
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java
index 70589bc4a..2d268edf0 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java
@@ -176,7 +176,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
return false;
}
Log.d(TAG, "Looking for Service: "+ SDL_ROUTER_SERVICE_CLASS_NAME);
- ActivityManager manager = (ActivityManager) context.getSystemService("activity");
+ ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
//We will check to see if it contains this name, should be pretty specific
//Log.d(TAG, "Found Service: "+ service.service.getClassName());
@@ -198,11 +198,14 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
/**
* If a Router Service is running, this method determines if that service is connected to a device over some form of transport.
- * @param context A context to access Android system services through.
+ * @param context A context to access Android system services through. If null is passed, this will always return false
* @return True if a transport connection is established, false otherwise.
*/
public static boolean isTransportConnected(Context context){
Log.d(TAG, "Checking to see if router service is transport connected");
+ if(context == null){
+ return false;
+ }
if(isRouterServiceRunning(context,false)){ //So there is a service up, let's see if it's connected
Context con;
try {
@@ -244,13 +247,12 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
}
/**
- * We need to define this for local copy of the Sdl Bluetooth Service class.
- * It will be the main point of connection for Sdl Connected apps
+ * We need to define this for local copy of the Sdl Router Service class.
+ * It will be the main point of connection for Sdl enabled apps
* @return Return the local copy of SdlRouterService.class
* {@inheritDoc}
*/
- @SuppressWarnings("rawtypes")
- public abstract Class defineLocalSdlRouterClass();
+ public abstract Class<? extends SdlRouterService> defineLocalSdlRouterClass();
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java
index 1bb7f3d72..5dffb1e44 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlRouterService.java
@@ -20,6 +20,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Notification;
@@ -40,6 +41,7 @@ import android.os.DeadObjectException;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
+import android.os.Build;
import android.os.Message;
import android.os.Messenger;
import android.os.Parcel;
@@ -1086,8 +1088,8 @@ public class SdlRouterService extends Service{
case MultiplexBluetoothTransport.STATE_NONE:
// We've just lost the connection
storeConnectedStatus(false);
- if(!connectAsClient && !closing){
- if(!legacyModeEnabled){
+ if(!connectAsClient ){
+ if(!legacyModeEnabled && !closing){
initBluetoothSerialService();
}
onTransportDisconnected(TransportType.BLUETOOTH);
@@ -1258,7 +1260,7 @@ public class SdlRouterService extends Service{
//Log.w(TAG, "Packet too big for IPC buffer. Breaking apart and then sending to client.");
//We need to churn through the packet payload and send it in chunks
byte[] bytes = packet.getPayload();
- SdlPacket copyPacket = new SdlPacket(packet.getVersion(),packet.isCompression(),
+ SdlPacket copyPacket = new SdlPacket(packet.getVersion(),packet.isEncrypted(),
(int)packet.getFrameType().getValue(),
packet.getServiceType(),packet.getFrameInfo(), session,
(int)packet.getDataSize(),packet.getMessageId(),null);
@@ -1573,6 +1575,7 @@ public class SdlRouterService extends Service{
}
}
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean removeAllSessionsWithAppId(long appId){
synchronized(SESSION_LOCK){
if(sessionMap!=null){
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java b/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java
index 613c857d9..90e066baf 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/TransportBroker.java
@@ -397,7 +397,7 @@ public class TransportBroker {
return false;
}
- ActivityManager manager = (ActivityManager) context.getSystemService("activity");
+ ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
//We will check to see if it contains this name, should be pretty specific
if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SdlBroadcastReceiver.SDL_ROUTER_SERVICE_CLASS_NAME)) {
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java b/sdl_android_tests/src/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java
index 0b9ce6cd2..1de98acbd 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java
@@ -8,12 +8,17 @@ import java.net.URLConnection;
import junit.framework.TestCase;
+import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
+import com.smartdevicelink.SdlConnection.SdlConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.streaming.AbstractPacketizer;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.test.Test;
+import com.smartdevicelink.transport.BTTransportConfig;
+import com.smartdevicelink.transport.BaseTransportConfig;
/**
* This is a unit test class for the SmartDeviceLink library project class :
@@ -33,6 +38,7 @@ public class AbstractPacketizerTests extends TestCase {
byte testWiproVersion = (byte) 0x0B;
RPCRequest testRpcRequest = new RPCRequest("test");
SessionType testSessionType = SessionType.RPC;
+ SdlSession testSdlSession = null;
InputStream testInputStream = null;
MockPacketizer testPacketizer1 = null;
MockPacketizer testPacketizer2 = null;
@@ -46,10 +52,15 @@ public class AbstractPacketizerTests extends TestCase {
URLConnection urlConnection = url.openConnection();
testInputStream = new BufferedInputStream(urlConnection.getInputStream());
- testPacketizer1 = new MockPacketizer(testListener, testInputStream, testSessionType, testSessionId);
- testPacketizer2 = new MockPacketizer(null, null, null, testSessionId);
- testPacketizer3 = new MockPacketizer(testListener, testInputStream, testRpcRequest, testSessionType, testSessionId, testWiproVersion);
- testPacketizer4 = new MockPacketizer(null, null, null, null, testSessionId, testWiproVersion);
+ MockInterfaceBroker _interfaceBroker = new MockInterfaceBroker();
+ BaseTransportConfig _transportConfig = new BTTransportConfig(true);
+
+ testSdlSession = SdlSession.createSession(testWiproVersion,_interfaceBroker, _transportConfig);
+
+ testPacketizer1 = new MockPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession);
+ testPacketizer2 = new MockPacketizer(null, null, null, testSessionId, testSdlSession);
+ testPacketizer3 = new MockPacketizer(testListener, testInputStream, testRpcRequest, testSessionType, testSessionId, testWiproVersion, testSdlSession);
+ testPacketizer4 = new MockPacketizer(null, null, null, null, testSessionId, testWiproVersion, null);
// Valid Tests
assertNotNull(Test.NOT_NULL, testPacketizer1);
@@ -67,6 +78,7 @@ public class AbstractPacketizerTests extends TestCase {
assertEquals(Test.MATCH, testSessionId, testPacketizer3.getSessionId());
assertEquals(Test.MATCH, testWiproVersion, testPacketizer3.getWiproVersion());
assertEquals(Test.MATCH, testRpcRequest.getFunctionName(), testPacketizer3.getRPCRequest().getFunctionName());
+ assertEquals(Test.MATCH, testSdlSession, testPacketizer3.getSdlSession());
// Invalid/Null Tests
assertNull(Test.NULL, testPacketizer2.getListener());
@@ -76,6 +88,7 @@ public class AbstractPacketizerTests extends TestCase {
assertNull(Test.NULL, testPacketizer4.getInputStream());
assertNull(Test.NULL, testPacketizer4.getSessionType());
assertNull(Test.NULL, testPacketizer4.getRPCRequest());
+ assertNull(Test.NULL, testPacketizer4.getSdlSession());
} catch (IOException e) {
fail("IOException was thrown.");
@@ -96,16 +109,81 @@ class MockStreamListener implements IStreamListener {
* This is a mock class for testing the following :
* {@link com.smartdevicelink.streaming.AbstractPacketizer}
*/
+class MockInterfaceBroker implements ISdlConnectionListener {
+ public MockInterfaceBroker () { }
+ @Override
+ public void onTransportDisconnected(String info) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onTransportError(String info, Exception e) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolMessageReceived(ProtocolMessage msg) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolSessionStartedNACKed(SessionType sessionType,
+ byte sessionID, byte version, String correlationID) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolSessionStarted(SessionType sessionType,
+ byte sessionID, byte version, String correlationID, int hashID,
+ boolean isEncrypted) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolSessionEnded(SessionType sessionType, byte sessionID,
+ String correlationID) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolSessionEndedNACKed(SessionType sessionType,
+ byte sessionID, String correlationID) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolError(String info, Exception e) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onHeartbeatTimedOut(byte sessionID) {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ public void onProtocolServiceDataACK(SessionType sessionType, int dataSize,
+ byte sessionID) {
+ // TODO Auto-generated method stub
+
+ }
+}
+
+/**
+ * This is a mock class for testing the following :
+ * {@link com.smartdevicelink.streaming.AbstractPacketizer}
+ */
class MockPacketizer extends AbstractPacketizer {
- public MockPacketizer (IStreamListener l, InputStream i, SessionType s, byte sid) throws IOException { super (l, i, s, sid); }
- public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, byte w) throws IOException { super (l, i, r, s, sid, w); }
+ public MockPacketizer (IStreamListener l, InputStream i, SessionType s, byte sid, SdlSession sdlsession) throws IOException { super (l, i, s, sid, sdlsession); }
+ public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, byte w, SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, w, sdlsession); }
@Override public void start() throws IOException { }
@Override public void stop() { }
public IStreamListener getListener () { return _streamListener; }
public InputStream getInputStream () { return is; }
- public SessionType getSessionType () { return _session; }
+ public SessionType getSessionType () { return _serviceType; }
+ public SdlSession getSdlSession () { return _session; }
public byte getSessionId () { return _rpcSessionID; }
public RPCRequest getRPCRequest () { return _request; }
public byte getWiproVersion () { return _wiproVersion; }
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamPacketizerTests.java b/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamPacketizerTests.java
index e4019a77f..2f4661aa8 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamPacketizerTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamPacketizerTests.java
@@ -6,10 +6,13 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.streaming.StreamPacketizer;
import com.smartdevicelink.test.Test;
+import com.smartdevicelink.transport.BTTransportConfig;
+import com.smartdevicelink.transport.BaseTransportConfig;
import junit.framework.TestCase;
@@ -29,14 +32,19 @@ public class StreamPacketizerTests extends TestCase {
byte testSessionId = (byte) 0x0A;
SessionType testSessionType = SessionType.RPC;
InputStream testInputStream = null;
+ byte testWiproVersion = (byte) 0x0B;
IStreamListener testListener = new MockStreamListener();
+ MockInterfaceBroker _interfaceBroker = new MockInterfaceBroker();
+ BaseTransportConfig _transportConfig = new BTTransportConfig(true);
+
+ SdlSession testSdlSession = SdlSession.createSession(testWiproVersion,_interfaceBroker, _transportConfig);
try {
URL url = new URL("ftp://mirror.csclub.uwaterloo.ca/index.html");
URLConnection urlConnection = url.openConnection();
testInputStream = new BufferedInputStream(urlConnection.getInputStream());
- StreamPacketizer testStreamPacketizer = new StreamPacketizer(testListener, testInputStream, testSessionType, testSessionId);
+ StreamPacketizer testStreamPacketizer = new StreamPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession);
assertNotNull(Test.NOT_NULL, testStreamPacketizer);
// NOTE: Cannot test thread handling methods currently.
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java b/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
index 2c4904989..63fb437f7 100644
--- a/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
+++ b/sdl_android_tests/src/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
@@ -6,11 +6,14 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
import com.smartdevicelink.test.Test;
+import com.smartdevicelink.transport.BTTransportConfig;
+import com.smartdevicelink.transport.BaseTransportConfig;
import junit.framework.TestCase;
@@ -34,12 +37,17 @@ public class StreamRPCPacketizerTests extends TestCase {
InputStream testInputStream = null;
IStreamListener testListener = new MockStreamListener();
+ byte testWiproVersion = (byte) 0x0B;
+ MockInterfaceBroker _interfaceBroker = new MockInterfaceBroker();
+ BaseTransportConfig _transportConfig = new BTTransportConfig(true);
+ SdlSession testSdlSession = SdlSession.createSession(testWiproVersion,_interfaceBroker, _transportConfig);
+
try {
URL url = new URL("ftp://mirror.csclub.uwaterloo.ca/index.html");
URLConnection urlConnection = url.openConnection();
testInputStream = new BufferedInputStream(urlConnection.getInputStream());
- StreamRPCPacketizer testStreamRpcPacketizer = new StreamRPCPacketizer(null, testListener, testInputStream, testRequest, testSessionType, testSessionId, testWV, testWV);
+ StreamRPCPacketizer testStreamRpcPacketizer = new StreamRPCPacketizer(null, testListener, testInputStream, testRequest, testSessionType, testSessionId, testWV, testWV, testSdlSession);
assertNotNull(Test.NOT_NULL, testStreamRpcPacketizer);
// NOTE: Cannot test thread handling methods currently.