diff options
author | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2020-08-19 13:00:57 -0400 |
---|---|---|
committer | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2020-08-19 13:00:57 -0400 |
commit | c620999bd749b256657ad0370c02b6468ba95402 (patch) | |
tree | 01a7aec64dcbe6d58e47ee999abaf9d98b3f8736 | |
parent | 61e4c894b0ac15bb601094c37dcee7c7e4adcf35 (diff) | |
download | sdl_android-feature/remove_on_put_file_update_listener.tar.gz |
Remove OnPutFileUpdateListener usagesfeature/remove_on_put_file_update_listener
3 files changed, 42 insertions, 88 deletions
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java index 332cb696f..7a6e34b94 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -105,7 +105,6 @@ import com.smartdevicelink.proxy.rpc.enums.TextAlignment; import com.smartdevicelink.proxy.rpc.enums.TouchType;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
-import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
@@ -2206,23 +2205,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
/**
- * Only call this method for a PutFile response. It will cause a class cast exception if not.
- * @param correlationId correlation id of the packet being updated
- * @param bytesWritten how many bytes were written
- * @param totalSize the total size in bytes
- */
- @SuppressWarnings("unused")
- public void onPacketProgress(int correlationId, long bytesWritten, long totalSize){
- synchronized(ON_UPDATE_LISTENER_LOCK){
- if(rpcResponseListeners !=null
- && rpcResponseListeners.indexOfKey(correlationId)>=0){
- ((OnPutFileUpdateListener)rpcResponseListeners.get(correlationId)).onUpdate(correlationId, bytesWritten, totalSize);
- }
- }
-
- }
-
- /**
* Will provide callback to the listener either onFinish or onError depending on the RPCResponses result code,
* <p>Will automatically remove the listener for the list of listeners on completion.
* @param msg The RPCResponse message that was received
@@ -2257,9 +2239,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> synchronized(ON_UPDATE_LISTENER_LOCK){
if(rpcResponseListeners!=null
&& listener !=null){
- if(listener.getListenerType() == OnRPCResponseListener.UPDATE_LISTENER_TYPE_PUT_FILE){
- ((OnPutFileUpdateListener)listener).setTotalSize(totalSize);
- }
listener.onStart(correlationId);
rpcResponseListeners.put(correlationId, listener);
}
@@ -7602,17 +7581,17 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> * core to elsewhere in the system.
* @throws SdlException if an unrecoverable error is encountered
*/
- @SuppressWarnings("unused")
- public void putFileStream(InputStream inputStream, @NonNull String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException {
- PutFile msg = new PutFile(fileName, FileType.BINARY);
- msg.setCorrelationID(10000);
- msg.setSystemFile(true);
- msg.setOffset(offset);
- msg.setLength(length);
- //msg.setOnPutFileUpdateListener(cb);
- startRPCStream(inputStream, msg);
- }
-
+// @SuppressWarnings("unused")
+// public void putFileStream(InputStream inputStream, @NonNull String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException {
+// PutFile msg = new PutFile(fileName, FileType.BINARY);
+// msg.setCorrelationID(10000);
+// msg.setSystemFile(true);
+// msg.setOffset(offset);
+// msg.setLength(length);
+// //msg.setOnPutFileUpdateListener(cb);
+// startRPCStream(inputStream, msg);
+// }
+//
/**
* Used to push a binary stream of file data onto the module from a mobile device.
* Responses are captured through callback on IProxyListener.
@@ -7659,17 +7638,17 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> * core to elsewhere in the system.
* @throws SdlException if an unrecoverable error is encountered
*/
- @SuppressWarnings("unused")
- public OutputStream putFileStream(@NonNull String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException {
- PutFile msg = new PutFile(fileName, FileType.BINARY);
- msg.setCorrelationID(10000);
- msg.setSystemFile(true);
- msg.setOffset(offset);
- msg.setLength(length);
- //msg.setOnPutFileUpdateListener(cb);
-
- return startRPCStream(msg);
- }
+// @SuppressWarnings("unused")
+// public OutputStream putFileStream(@NonNull String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException {
+// PutFile msg = new PutFile(fileName, FileType.BINARY);
+// msg.setCorrelationID(10000);
+// msg.setSystemFile(true);
+// msg.setOffset(offset);
+// msg.setLength(length);
+// //msg.setOnPutFileUpdateListener(cb);
+//
+// return startRPCStream(msg);
+// }
/**
* Used to push a stream of putfile RPC's containing binary data from a mobile device to the module.
@@ -7685,7 +7664,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> * @param iCorrelationID - A unique ID that correlates each RPCRequest and RPCResponse.
* @return RPCStreamController - If the putFileStream was not started successfully null is returned, otherwise a valid object reference is returned
* @throws SdlException if an unrecoverable error is encountered
- * @see #putFileStream(String, String, Long, FileType, Boolean, Boolean, Boolean, Integer, OnPutFileUpdateListener)
+// * @see #putFileStream(String, String, Long, FileType, Boolean, Boolean, Boolean, Integer, OnPutFileUpdateListener)
*/
@SuppressWarnings("unused")
@Deprecated
@@ -7723,19 +7702,19 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> * returned .
* @throws SdlException if an unrecoverable error is encountered
*/
- @SuppressWarnings("unused")
- public RPCStreamController putFileStream(String path, @NonNull String fileName, Long offset, @NonNull FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId, OnPutFileUpdateListener cb ) throws SdlException {
- PutFile msg = new PutFile(fileName, fileType);
- msg.setCorrelationID(correlationId);
- msg.setPersistentFile(isPersistentFile);
- msg.setSystemFile(isSystemFile);
- msg.setOffset(offset);
- msg.setLength(0L);
- msg.setPayloadProtected(isPayloadProtected);
- //msg.setOnPutFileUpdateListener(cb);
-
- return startPutFileStream(path,msg);
- }
+// @SuppressWarnings("unused")
+// public RPCStreamController putFileStream(String path, @NonNull String fileName, Long offset, @NonNull FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId, OnPutFileUpdateListener cb ) throws SdlException {
+// PutFile msg = new PutFile(fileName, fileType);
+// msg.setCorrelationID(correlationId);
+// msg.setPersistentFile(isPersistentFile);
+// msg.setSystemFile(isSystemFile);
+// msg.setOffset(offset);
+// msg.setLength(0L);
+// msg.setPayloadProtected(isPayloadProtected);
+// //msg.setOnPutFileUpdateListener(cb);
+//
+// return startPutFileStream(path,msg);
+// }
/**
* Used to push a stream of putfile RPC's containing binary data from a mobile device to the module.
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java index 5d32aa391..91623dd9d 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamRPCPacketizer.java @@ -44,8 +44,6 @@ import com.smartdevicelink.proxy.interfaces.IProxyListenerBase; import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener;
import com.smartdevicelink.proxy.rpc.PutFile;
import com.smartdevicelink.proxy.rpc.PutFileResponse;
-import com.smartdevicelink.proxy.rpc.enums.Result;
-import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener;
import com.smartdevicelink.util.Version;
import java.io.IOException;
@@ -65,7 +63,7 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR private Object mPauseLock;
private boolean mPaused;
private boolean isRPCProtected = false;
- private OnPutFileUpdateListener callBack;
+ //private OnPutFileUpdateListener callBack;
private Version rpcSpecVersion;
@@ -223,9 +221,9 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileR {
handleStreamException(null,null," Error, PutFile offset invalid for file: " + sFileName);
}
- if(callBack!=null){
- callBack.onStart(_request.getCorrelationID(), lFileSize);
- }
+// if(callBack!=null){
+// callBack.onStart(_request.getCorrelationID(), lFileSize);
+// }
while (!Thread.interrupted()) {
synchronized (mPauseLock)
diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java index 75afd665d..024d9d601 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java @@ -81,7 +81,6 @@ import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType; import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; -import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener; @@ -530,24 +529,6 @@ abstract class BaseLifecycleManager { } /** - * Only call this method for a PutFile response. It will cause a class cast exception if not. - * - * @param correlationId correlation id of the packet being updated - * @param bytesWritten how many bytes were written - * @param totalSize the total size in bytes - */ - @SuppressWarnings("unused") - private void onPacketProgress(int correlationId, long bytesWritten, long totalSize) { - synchronized (ON_UPDATE_LISTENER_LOCK) { - if (rpcResponseListeners != null - && rpcResponseListeners.containsKey(correlationId)) { - ((OnPutFileUpdateListener) rpcResponseListeners.get(correlationId)).onUpdate(correlationId, bytesWritten, totalSize); - } - } - - } - - /** * Will provide callback to the listener either onFinish or onError depending on the RPCResponses result code, * <p>Will automatically remove the listener for the list of listeners on completion. * @@ -578,15 +559,11 @@ abstract class BaseLifecycleManager { * * @param listener that will get called back when a response is received * @param correlationId of the RPCRequest that was sent - * @param totalSize only include if this is an OnPutFileUpdateListener. Otherwise it will be ignored. */ - private void addOnRPCResponseListener(OnRPCResponseListener listener, int correlationId, int totalSize) { + private void addOnRPCResponseListener(OnRPCResponseListener listener, int correlationId) { synchronized (ON_UPDATE_LISTENER_LOCK) { if (rpcResponseListeners != null && listener != null) { - if (listener.getListenerType() == OnRPCResponseListener.UPDATE_LISTENER_TYPE_PUT_FILE) { - ((OnPutFileUpdateListener) listener).setTotalSize(totalSize); - } listener.onStart(correlationId); rpcResponseListeners.put(correlationId, listener); } @@ -821,7 +798,7 @@ abstract class BaseLifecycleManager { OnRPCResponseListener listener = ((RPCRequest) message).getOnRPCResponseListener(); if (listener != null) { - addOnRPCResponseListener(listener, corrId, msgBytes.length); + addOnRPCResponseListener(listener, corrId); } } } else if (RPCMessage.KEY_RESPONSE.equals(message.getMessageType())) { // Response Specifics |