diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java index bedeb0a393..2b72663a1f 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java @@ -5,10 +5,10 @@ import android.os.Build; import android.util.Log; -import com.smartdevicelink.transport.SdlBroadcastReceiver; -import com.smartdevicelink.transport.SdlRouterService; +import com.smartdevicelink.transport.BaseBroadcastReceiver; +import com.smartdevicelink.transport.BaseRouterService; -public class SdlReceiver extends SdlBroadcastReceiver { +public class SdlReceiver extends BaseBroadcastReceiver { private static final String TAG = "SdlBroadcastReciever"; @Override diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlRouterService.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlRouterService.java index b4bec8cded..6df32a25c0 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlRouterService.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlRouterService.java @@ -1,7 +1,7 @@ package com.sdl.hellosdlandroid; -public class SdlRouterService extends com.smartdevicelink.transport.SdlRouterService { +public class SdlRouterService extends com.smartdevicelink.transport.BaseRouterService { diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java index cdf83079c0..e7a894bb36 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java @@ -5,8 +5,8 @@ import android.os.Message; import com.smartdevicelink.test.util.DeviceUtil; +import com.smartdevicelink.transport.BaseRouterService; import com.smartdevicelink.transport.MultiplexBluetoothTransport; -import com.smartdevicelink.transport.SdlRouterService; import junit.framework.TestCase; @@ -34,7 +34,7 @@ public void handleMessage(Message msg) { return; } switch(msg.what){ - case SdlRouterService.MESSAGE_STATE_CHANGE: + case BaseRouterService.MESSAGE_STATE_CHANGE: if(msg.arg1 == stateDesired){ didCorrectThing = true; break; diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java index 10aa25d75d..9da249b788 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/LocalRouterServiceTests.java @@ -21,7 +21,7 @@ public void testLocalRouterServiceParcel(){ p.writeParcelable(new ComponentName(mContext, "test"), 0); p.setDataPosition(0); - SdlRouterService.LocalRouterService local = new SdlRouterService.LocalRouterService(p); + BaseRouterService.LocalRouterService local = new BaseRouterService.LocalRouterService(p); assertNotNull(local); assertEquals(local.version,4); @@ -36,8 +36,8 @@ public void testLocalRouterServiceParcelCreator(){ p.writeParcelable(new Intent(), 0); p.writeParcelable(new ComponentName(mContext, "test"), 0); p.setDataPosition(0); - - SdlRouterService.LocalRouterService local = SdlRouterService.LocalRouterService.CREATOR.createFromParcel(p); + + BaseRouterService.LocalRouterService local = BaseRouterService.LocalRouterService.CREATOR.createFromParcel(p); assertNotNull(local); assertEquals(local.version,4); @@ -45,11 +45,11 @@ public void testLocalRouterServiceParcelCreator(){ } - public SdlRouterService.LocalRouterService getLocalRouterService(int testWith, Parcel p){ + public BaseRouterService.LocalRouterService getLocalRouterService(int testWith, Parcel p){ if(testWith == TEST_WITH_CONSTRUCTOR){ - return new SdlRouterService.LocalRouterService(p); + return new BaseRouterService.LocalRouterService(p); }else{ - return SdlRouterService.LocalRouterService.CREATOR.createFromParcel(p); + return BaseRouterService.LocalRouterService.CREATOR.createFromParcel(p); } } @@ -60,8 +60,8 @@ public void corruptParcel(int testWith){ p.writeParcelable(new ComponentName(mContext, "test"), 0); p.writeParcelable(new Intent(), 0); p.setDataPosition(0); - - SdlRouterService.LocalRouterService local = getLocalRouterService(testWith, p); + + BaseRouterService.LocalRouterService local = getLocalRouterService(testWith, p); assertNotNull(local); assertNull(local.launchIntent); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java index 89dbae3ab7..d924106d2a 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java @@ -23,8 +23,8 @@ public void testHandleMessage() { } // Instantiate SdlRouterService and Registered App class - SdlRouterService router = new SdlRouterService(); - SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + BaseRouterService router = new BaseRouterService(); + BaseRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); // Call Handle Message app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes); @@ -42,8 +42,8 @@ public void testNullBuffer() { } // Instantiate SdlRouterService and Registered App class - SdlRouterService router = new SdlRouterService(); - SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); + BaseRouterService router = new BaseRouterService(); + BaseRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger); // Force Null Buffer app.buffer = null; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java index f5265ccf00..aa9bbacb39 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/* + * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ package com.smartdevicelink.SdlConnection; @@ -44,12 +44,12 @@ import com.smartdevicelink.protocol.enums.SessionType; import com.smartdevicelink.transport.BTTransport; import com.smartdevicelink.transport.BTTransportConfig; +import com.smartdevicelink.transport.BaseBroadcastReceiver; 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; @@ -90,7 +90,7 @@ public SdlConnection(BaseTransportConfig transportConfig) { RouterServiceValidator vlad = null; //Let's check if we can even do multiplexing if(transportConfig.getTransportType() == TransportType.MULTIPLEX){ - ComponentName tempCompName = SdlBroadcastReceiver.consumeQueuedRouterService(); + ComponentName tempCompName = BaseBroadcastReceiver.consumeQueuedRouterService(); MultiplexTransportConfig multiConfig = (MultiplexTransportConfig)transportConfig; if(tempCompName!=null){ vlad =new RouterServiceValidator(multiConfig.getContext(),tempCompName); @@ -582,7 +582,7 @@ public void forceHardwareConnectEvent(TransportType type){ if(_transport!=null && (_transport.getTransportType()==TransportType.MULTIPLEX)){ //This is only valid for the multiplex connection MultiplexTransport multi = ((MultiplexTransport)_transport); MultiplexTransportConfig config = multi.getConfig(); - ComponentName tempCompName = SdlBroadcastReceiver.consumeQueuedRouterService(); + ComponentName tempCompName = BaseBroadcastReceiver.consumeQueuedRouterService(); if(config.getService() != null && config.getService().equals(tempCompName)){ //If this is the same service that just connected that we are already looking at. Attempt to reconnect if(!multi.getIsConnected() && multi.isDisconnecting() ){ //If we aren't able to force a connection it means the _transport = new MultiplexTransport(config,this); @@ -611,7 +611,7 @@ public void forceHardwareConnectEvent(TransportType type){ && !_transport.getIsConnected()){ if(cachedMultiConfig!=null){ //We are in legacy mode, but just received a force connect. The router service should never be pointing us here if we are truely in legacy mode - ComponentName tempCompName = SdlBroadcastReceiver.consumeQueuedRouterService(); + ComponentName tempCompName = BaseBroadcastReceiver.consumeQueuedRouterService(); RouterServiceValidator vlad = new RouterServiceValidator(cachedMultiConfig.getContext(),tempCompName); if(vlad.validate()){ cachedMultiConfig.setService(tempCompName); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/BaseBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BaseBroadcastReceiver.java new file mode 100644 index 0000000000..50f9c7504a --- /dev/null +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BaseBroadcastReceiver.java @@ -0,0 +1,4 @@ +package com.smartdevicelink.transport; + +public abstract class BaseBroadcastReceiver extends SdlBroadcastReceiver { +} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/BaseRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BaseRouterService.java new file mode 100644 index 0000000000..20ea3a501e --- /dev/null +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BaseRouterService.java @@ -0,0 +1,4 @@ +package com.smartdevicelink.transport; + +public class BaseRouterService extends SdlRouterService { +} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java index d1dc5cbb32..fb5b4cbfb5 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBaseTransport.java @@ -76,7 +76,7 @@ protected synchronized void setState(int state) { // Give the new state to the Handler so the UI Activity can update //Also sending the previous state so we know if we lost a connection - handler.obtainMessage(SdlRouterService.MESSAGE_STATE_CHANGE, state, previousState, getTransportRecord()).sendToTarget(); + handler.obtainMessage(BaseRouterService.MESSAGE_STATE_CHANGE, state, previousState, getTransportRecord()).sendToTarget(); } public String getAddress(){ diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java index 644cda21bc..9812fe4152 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java @@ -86,7 +86,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ public MultiplexBluetoothTransport(Handler handler) { super(handler, TransportType.BLUETOOTH); //This will keep track of which method worked last night - mBluetoothLevel = SdlRouterService.getBluetoothPrefs(SHARED_PREFS); + mBluetoothLevel = BaseRouterService.getBluetoothPrefs(SHARED_PREFS); } @@ -248,7 +248,7 @@ public synchronized void connected(BluetoothSocket socket, BluetoothDevice devic } // Send the name of the connected device back to the UI Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_DEVICE_NAME); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); if(connectedDeviceName != null) { bundle.putString(DEVICE_NAME, connectedDeviceName); @@ -310,7 +310,7 @@ public void write(byte[] out, int offset, int count) { */ private void connectionFailed() { // Send a failure message back to the Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_LOG); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_LOG); Bundle bundle = new Bundle(); bundle.putString(LOG, "Unable to connect device"); msg.setData(bundle); @@ -325,7 +325,7 @@ private void connectionFailed() { */ private void connectionLost() { // Send a failure message back to the Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_LOG); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_LOG); Bundle bundle = new Bundle(); bundle.putString(LOG, "Device connection was lost"); msg.setData(bundle); @@ -509,7 +509,7 @@ public void run() { try { // This is a blocking call and will only return on a // successful connection or an exception - mBluetoothLevel = SdlRouterService.getBluetoothPrefs(SHARED_PREFS); + mBluetoothLevel = BaseRouterService.getBluetoothPrefs(SHARED_PREFS); long waitTime = 3000; try { Thread.sleep(waitTime); @@ -525,7 +525,7 @@ public void run() { if(mBluetoothLevel<=1){ try { - SdlRouterService.setBluetoothPrefs(2,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(2,SHARED_PREFS); Method m = mmDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class}); //Log.i(TAG,"connecting using createRfcommSocket"); mmSocket = (BluetoothSocket) m.invoke(mmDevice, Integer.valueOf(1)); @@ -539,13 +539,13 @@ public void run() { Looper.myLooper().quit(); } success=true; - SdlRouterService.setBluetoothPrefs(1,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(1,SHARED_PREFS); break; } else{trySecure = true;} } catch (Exception e) { //Log.e(TAG,"createRfcommSocket exception - " + e.toString()); - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); trySecure = true; try { @@ -557,7 +557,7 @@ public void run() { }else{trySecure = true;} if(trySecure && mBluetoothLevel<=2){ try { - SdlRouterService.setBluetoothPrefs(3,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(3,SHARED_PREFS); //Log.i(TAG, "connecting using createRfcommSocketToServiceRecord "); mmSocket = mmDevice.createRfcommSocketToServiceRecord(SERVER_UUID); if(mmSocket!=null){ @@ -570,17 +570,17 @@ public void run() { Looper.myLooper().quit(); } success=true; - SdlRouterService.setBluetoothPrefs(2,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(2,SHARED_PREFS); break; }else{tryInsecure = true;} } catch (IOException io) { tryInsecure = true; Log.e(TAG,"createRfcommSocketToServiceRecord exception - " + io.toString()); - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } catch (Exception e){ Log.e(TAG,"createRfcommSocketToServiceRecord exception - " + e.toString()); - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } }else{tryInsecure = true;} @@ -588,7 +588,7 @@ public void run() { if (tryInsecure && mBluetoothLevel<=3) { // try again using insecure comm if available try { - SdlRouterService.setBluetoothPrefs(4,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(4,SHARED_PREFS); //Log.i(TAG,"connecting using createInsecureRfcommSocketToServiceRecord"); Method m = mmDevice.getClass().getMethod("createInsecureRfcommSocketToServiceRecord", new Class[] {UUID.class}); mmSocket = (BluetoothSocket) m.invoke(mmDevice, new Object[] {SERVER_UUID}); @@ -602,20 +602,20 @@ public void run() { } success=true; tryInsecure = false; - SdlRouterService.setBluetoothPrefs(3,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(3,SHARED_PREFS); break; } catch (NoSuchMethodException ie) { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } catch (IllegalAccessException ie) { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } catch (InvocationTargetException ie) { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } } if (tryInsecure && mBluetoothLevel<=4) { // try again using insecure comm if available try { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); //Log.i(TAG,"connecting using createInsecureRfcommSocket()"); Method m = mmDevice.getClass().getMethod("createInsecureRfcommSocket()", new Class[] {UUID.class}); mmSocket = (BluetoothSocket) m.invoke(mmDevice, new Object[] {SERVER_UUID}); @@ -628,14 +628,14 @@ public void run() { Looper.myLooper().quit(); } success=true; - SdlRouterService.setBluetoothPrefs(4,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(4,SHARED_PREFS); break; } catch (NoSuchMethodException ie) { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } catch (IllegalAccessException ie) { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } catch (InvocationTargetException ie) { - SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); + BaseRouterService.setBluetoothPrefs(0,SHARED_PREFS); } } } catch (IOException e) { @@ -796,7 +796,7 @@ public void run() { //Log.d(TAG, "Packet formed, sending off"); SdlPacket packet = psm.getFormedPacket(); packet.setTransportRecord(getTransportRecord()); - handler.obtainMessage(SdlRouterService.MESSAGE_READ, packet).sendToTarget(); + handler.obtainMessage(BaseRouterService.MESSAGE_READ, packet).sendToTarget(); psm.reset(); } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java index 0fa211bd96..74d74c05ec 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java @@ -107,7 +107,7 @@ public synchronized void start(){ } // Send the name of the connected device back to the UI Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_DEVICE_NAME); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); bundle.putString(DEVICE_NAME, connectedDeviceName); bundle.putString(DEVICE_ADDRESS, connectedDeviceAddress); @@ -317,7 +317,7 @@ public void run() { Log.d(TAG, "Packet formed, sending off"); SdlPacket packet = psm.getFormedPacket(); packet.setTransportRecord(getTransportRecord()); - handler.obtainMessage(SdlRouterService.MESSAGE_READ, packet).sendToTarget(); + handler.obtainMessage(BaseRouterService.MESSAGE_READ, packet).sendToTarget(); } //We put a trace statement in the message read so we can avoid all the extra bytes psm.reset(); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java index d72987a882..ef0ff0a944 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java @@ -114,7 +114,7 @@ public synchronized void start(){ writerThread.start(); // Send the name of the connected device back to the UI Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_DEVICE_NAME); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_DEVICE_NAME); Bundle bundle = new Bundle(); bundle.putString(DEVICE_NAME, connectedDeviceName); bundle.putString(DEVICE_ADDRESS, connectedDeviceAddress); @@ -176,7 +176,7 @@ public void write(byte[] out, int offset, int count) { */ private void connectionFailed() { // Send a failure message back to the Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_LOG); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_LOG); Bundle bundle = new Bundle(); bundle.putString(LOG, "Unable to connect device"); msg.setData(bundle); @@ -191,7 +191,7 @@ private void connectionFailed() { */ private void connectionLost() { // Send a failure message back to the Activity - Message msg = handler.obtainMessage(SdlRouterService.MESSAGE_LOG); + Message msg = handler.obtainMessage(BaseRouterService.MESSAGE_LOG); Bundle bundle = new Bundle(); bundle.putString(LOG, "Device connection was lost"); msg.setData(bundle); @@ -257,7 +257,7 @@ public void run() { //FIXME probably check to see what the BT does //Log.d(TAG, "Packet formed, sending off"); SdlPacket packet = psm.getFormedPacket(); packet.setTransportRecord(getTransportRecord()); - handler.obtainMessage(SdlRouterService.MESSAGE_READ, packet).sendToTarget(); + handler.obtainMessage(BaseRouterService.MESSAGE_READ, packet).sendToTarget(); } //Reset the PSM now that we have a finished packet. //We will continue to loop through the data to see if any other packet diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java index 227b0b8941..d24fa4d303 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java @@ -472,7 +472,7 @@ public ComponentName componentNameForServiceRunning(PackageManager pm){ for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { //Log.d(TAG, service.service.getClassName()); //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)){ + if ((service.service.getClassName()).toLowerCase(Locale.US).contains(BaseBroadcastReceiver.SDL_ROUTER_SERVICE_CLASS_NAME)){ //this.service = service.service; //This is great if(service.started && service.restarting==0){ //If this service has been started and is not crashed return service.service; //appPackageForComponenetName(service.service,pm); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index ba1cc80a04..48a9910250 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -65,6 +65,7 @@ import static com.smartdevicelink.transport.TransportConstants.FOREGROUND_EXTRA; +@Deprecated public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ private static final String TAG = "Sdl Broadcast Receiver"; @@ -87,7 +88,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ private static Thread.UncaughtExceptionHandler foregroundExceptionHandler = null; public int getRouterServiceVersion(){ - return SdlRouterService.ROUTER_SERVICE_VERSION_NUMBER; + return BaseRouterService.ROUTER_SERVICE_VERSION_NUMBER; } @Override @@ -158,7 +159,8 @@ public void onReceive(Context context, Intent intent) { } } - if(localRouterClass != null && localRouterClass.getName().equalsIgnoreCase(com.smartdevicelink.transport.SdlRouterService.class.getName())){ + if(localRouterClass != null && localRouterClass.getName().equalsIgnoreCase(com.smartdevicelink.transport.BaseRouterService + .class.getName())){ Log.e(TAG, "You cannot use the default SdlRouterService class, it must be extended in your project. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); } @@ -215,8 +217,8 @@ public void onListObtained(boolean successful) { //We will send it an intent with the version number of the local instance and an intent to start this instance Intent serviceIntent = new Intent(context, localRouterClass); - SdlRouterService.LocalRouterService self = SdlRouterService.getLocalRouterService(serviceIntent, serviceIntent.getComponent()); - Intent restart = new Intent(SdlRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION); + BaseRouterService.LocalRouterService self = BaseRouterService.getLocalRouterService(serviceIntent, serviceIntent.getComponent()); + Intent restart = new Intent(BaseRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION); restart.putExtra(LOCAL_ROUTER_SERVICE_EXTRA, self); restart.putExtra(LOCAL_ROUTER_SERVICE_DID_START_OWN, didStart); context.sendBroadcast(restart); @@ -259,8 +261,8 @@ public void onComplete(Vector routerServices) { } //Make sure to send this out for old apps to close down - SdlRouterService.LocalRouterService self = SdlRouterService.getLocalRouterService(serviceIntent, serviceIntent.getComponent()); - Intent restart = new Intent(SdlRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION); + BaseRouterService.LocalRouterService self = BaseRouterService.getLocalRouterService(serviceIntent, serviceIntent.getComponent()); + Intent restart = new Intent(BaseRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION); restart.putExtra(LOCAL_ROUTER_SERVICE_EXTRA, self); restart.putExtra(LOCAL_ROUTER_SERVICE_DID_START_OWN, true); context.sendBroadcast(restart); @@ -514,7 +516,7 @@ public static ComponentName consumeQueuedRouterService(){ * @return Return the local copy of SdlRouterService.class * {@inheritDoc} */ - public abstract Class defineLocalSdlRouterClass(); + public abstract Class defineLocalSdlRouterClass(); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java index 3313fd0f37..3981e0a08e 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java @@ -132,6 +132,7 @@ * @author Joey Grover * */ +@Deprecated @SuppressWarnings({"UnusedReturnValue", "WeakerAccess", "Convert2Diamond", "deprecation"}) public class SdlRouterService extends Service{ diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java index 53e1dbbed0..1036e99500 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java @@ -133,7 +133,7 @@ private boolean bindToService(){ context.startService(bindingIntent); }else { bindingIntent.putExtra(FOREGROUND_EXTRA, true); - SdlBroadcastReceiver.setForegroundExceptionHandler(); //Prevent ANR in case the OS takes too long to start the service + BaseBroadcastReceiver.setForegroundExceptionHandler(); //Prevent ANR in case the OS takes too long to start the service context.startForegroundService(bindingIntent); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java index 29e0c3aa17..cef9a9bf5b 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java @@ -91,7 +91,7 @@ public void handleMessage(Message msg) { return; } switch (msg.what) { - case SdlRouterService.MESSAGE_STATE_CHANGE: + case BaseRouterService.MESSAGE_STATE_CHANGE: switch (msg.arg1) { case MultiplexBaseTransport.STATE_CONNECTED: synchronized (service.TRANSPORT_STATUS_LOCK){ @@ -126,7 +126,7 @@ public void handleMessage(Message msg) { } break; - case SdlRouterService.MESSAGE_READ: + case BaseRouterService.MESSAGE_READ: service.transportListener.onPacketReceived((SdlPacket) msg.obj); break; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java index 710e9d610e..b9412fe756 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java @@ -561,7 +561,7 @@ private boolean isRouterServiceRunning(Context context) { 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)) { + if ((service.service.getClassName()).toLowerCase(Locale.US).contains(BaseBroadcastReceiver.SDL_ROUTER_SERVICE_CLASS_NAME)) { this.routerClassName = service.service.getClassName(); this.routerPackage = service.service.getPackageName(); return true; @@ -651,7 +651,7 @@ private boolean registerWithRouterService() { if (!sendBindingIntent()) { Log.e(TAG, "Something went wrong while trying to bind with the router service."); - SdlBroadcastReceiver.queryForConnectedService(currentContext); + BaseBroadcastReceiver.queryForConnectedService(currentContext); return false; } return true; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java index 1a09515034..7fd605603a 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java @@ -81,7 +81,7 @@ public TransportManager(MultiplexTransportConfig config, TransportEventListener this.mConfig = config; if(config.service == null) { - config.service = SdlBroadcastReceiver.consumeQueuedRouterService(); + config.service = BaseBroadcastReceiver.consumeQueuedRouterService(); } contextWeakReference = new WeakReference<>(config.context); @@ -496,7 +496,7 @@ public void handleMessage(Message msg) { return; } switch (msg.what) { - case SdlRouterService.MESSAGE_STATE_CHANGE: + case BaseRouterService.MESSAGE_STATE_CHANGE: switch (msg.arg1) { case MultiplexBaseTransport.STATE_CONNECTED: synchronized (service.TRANSPORT_STATUS_LOCK){ @@ -525,7 +525,7 @@ public void handleMessage(Message msg) { } break; - case SdlRouterService.MESSAGE_READ: + case BaseRouterService.MESSAGE_READ: service.transportListener.onPacketReceived((SdlPacket) msg.obj); break; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java index b724377ede..24ead97cf5 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java @@ -190,10 +190,10 @@ public void onComplete(Vector routerServices) { } //Make sure to send this out for old apps to close down - SdlRouterService.LocalRouterService self = SdlRouterService.getLocalRouterService(serviceIntent, serviceIntent.getComponent()); - Intent restart = new Intent(SdlRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION); - restart.putExtra(SdlBroadcastReceiver.LOCAL_ROUTER_SERVICE_EXTRA, self); - restart.putExtra(SdlBroadcastReceiver.LOCAL_ROUTER_SERVICE_DID_START_OWN, true); + BaseRouterService.LocalRouterService self = BaseRouterService.getLocalRouterService(serviceIntent, serviceIntent.getComponent()); + Intent restart = new Intent(BaseRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION); + restart.putExtra(BaseBroadcastReceiver.LOCAL_ROUTER_SERVICE_EXTRA, self); + restart.putExtra(BaseBroadcastReceiver.LOCAL_ROUTER_SERVICE_DID_START_OWN, true); context.sendBroadcast(restart); if (usbAccessory!=null) { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java index 6f1740878e..497e6448fa 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java @@ -42,7 +42,7 @@ import android.os.Looper; import android.util.Log; -import com.smartdevicelink.transport.SdlRouterService; +import com.smartdevicelink.transport.BaseRouterService; import java.util.HashMap; import java.util.Vector; @@ -162,7 +162,7 @@ private void onFinished() { private static Intent createQueryIntent(String receiverLocation) { Intent intent = new Intent(); - intent.setAction(SdlRouterService.REGISTER_WITH_ROUTER_ACTION); + intent.setAction(BaseRouterService.REGISTER_WITH_ROUTER_ACTION); intent.putExtra(SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME, receiverLocation); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);