summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2019-04-03 17:03:15 -0400
committerJoey Grover <joeygrover@gmail.com>2019-04-03 17:03:15 -0400
commit4a6b6444696d938331c2652f78567a85df3363ef (patch)
treef4f92fb70e1cfae6485de0963043907ef26bf3fd
parentadad228414714cb259cc0b94c72bde46eb8bdc85 (diff)
downloadsdl_android-4a6b6444696d938331c2652f78567a85df3363ef.tar.gz
Fix logic, add convince mthds, more javadoc for AS
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java8
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java47
2 files changed, 48 insertions, 7 deletions
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java
index 73120d2ca..e582162f4 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceCapability.java
@@ -108,9 +108,11 @@ public class AppServiceCapability extends RPCStruct {
AppServiceRecord otherASR = capability.getUpdatedAppServiceRecord();
if(appServiceRecord != null && otherASR != null) {
- //Check service IDs, if they are the same we can assume these are the same
- if (appServiceRecord.getServiceID() != null && appServiceRecord.getServiceID().equalsIgnoreCase(otherASR.getServiceID())) {
- return true;
+ // If both service IDs exists we can compare them. If either is null we can't use
+ // only this check.
+ if(appServiceRecord.getServiceID() != null && otherASR.getServiceID() != null){
+ //return whether the app service IDs are equal or not
+ return appServiceRecord.getServiceID().equalsIgnoreCase(otherASR.getServiceID());
}else{
AppServiceManifest manifest = appServiceRecord.getServiceManifest();
AppServiceManifest otherManifest = otherASR.getServiceManifest();
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java
index 08df3d388..db0106e3d 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/AppServiceManifest.java
@@ -33,8 +33,11 @@ package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
+import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.AppServiceType;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -61,10 +64,24 @@ public class AppServiceManifest extends RPCStruct {
super(hash);
}
+ /**
+ * Constructor that takes in the mandatory parameters.
+ * @param serviceType the type of service this is, use {@link com.smartdevicelink.proxy.rpc.enums.AppServiceType}
+ * @see com.smartdevicelink.proxy.rpc.enums.AppServiceType
+ */
public AppServiceManifest(@NonNull String serviceType) {
this();
setServiceType(serviceType);
}
+ /**
+ * Constructor that takes in the mandatory parameters.
+ * @param serviceType the type of service this is
+ * @see com.smartdevicelink.proxy.rpc.enums.AppServiceType
+ */
+ public AppServiceManifest(@NonNull AppServiceType serviceType) {
+ this();
+ setServiceType(serviceType.name());
+ }
// Setters and Getters
/**
@@ -85,7 +102,8 @@ public class AppServiceManifest extends RPCStruct {
/**
* The type of service that is to be offered by this app
- * @param serviceType - the serviceType
+ * @param serviceType - the serviceType use {@link com.smartdevicelink.proxy.rpc.enums.AppServiceType}
+ * @see com.smartdevicelink.proxy.rpc.enums.AppServiceType
*/
public void setServiceType(@NonNull String serviceType){
setValue(KEY_SERVICE_TYPE, serviceType);
@@ -94,6 +112,7 @@ public class AppServiceManifest extends RPCStruct {
/**
* The type of service that is to be offered by this app
* @return the AppServiceType
+ * @see com.smartdevicelink.proxy.rpc.enums.AppServiceType
*/
public String getServiceType(){
return getString(KEY_SERVICE_TYPE);
@@ -154,16 +173,36 @@ public class AppServiceManifest extends RPCStruct {
/**
* This field contains the Function IDs for the RPCs that this service intends to handle correctly.
* This means the service will provide meaningful responses.
- * @param handledRPCs - The List of Handled RPCs
+ * @param handledRPCs - The List of Handled RPCs using their ID value from the FunctionID enum
+ * @see com.smartdevicelink.protocol.enums.FunctionID
+ * @see #setHandledRpcsUsingFunctionIDs(List)
*/
public void setHandledRpcs(List<Integer> handledRPCs){
setValue(KEY_HANDLED_RPCS, handledRPCs);
}
-
/**
* This field contains the Function IDs for the RPCs that this service intends to handle correctly.
* This means the service will provide meaningful responses.
- * @return handledRPCs - The List of Handled RPCs
+ * @param handledRPCs - The List of Handled RPCs using the FunctionID enum
+ * @see #setHandledRpcs(List)
+ */
+ public void setHandledRpcsUsingFunctionIDs(List<FunctionID> handledRPCs){
+ if(handledRPCs != null){
+ List<Integer> rpcIds = new ArrayList<>();
+ for(FunctionID functionID : handledRPCs){
+ rpcIds.add(functionID.getId());
+ }
+ setHandledRpcs(rpcIds);
+ }else{
+ setValue(KEY_HANDLED_RPCS, null);
+ }
+ }
+
+ /**
+ * This field contains the FunctionID integer ID values for the RPCs that this service intends to handle correctly.
+ * This means the service will provide meaningful responses.
+ * @return handledRPCs - The List of Handled RPC IDs obtained through the FunctionID enum
+ * @see com.smartdevicelink.protocol.enums.FunctionID
*/
@SuppressWarnings("unchecked")
public List<Integer> getHandledRpcs(){