Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/issue 738 - Support for Short and Full UUID App ID #802

Merged
merged 8 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"SOCIAL",
"MEDIA"
],
"appID":"t4weGRSWY",
"appID":"123e4567e8",
"fullAppID":"123e4567-e89b-12d3-a456-426655440000",
"languageDesired":"PT-BR",
"deviceInfo":{
"hardware":"My Hardware",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ public class Test {
public static final DriverDistractionState GENERAL_DRIVERDISTRACTIONSTATE = DriverDistractionState.DD_ON;
public static final List<LocationDetails> GENERAL_LOCATIONDETAILS_LIST = Arrays.asList(new LocationDetails[] { Test.GENERAL_LOCATIONDETAILS, Test.GENERAL_LOCATIONDETAILS});
public static final AudioStreamingIndicator GENERAL_AUDIO_STREAMING_INDICATOR = AudioStreamingIndicator.PLAY;

public static final String GENERAL_APP_ID = "123e4567e8";
public static final String GENERAL_FULL_APP_ID = "123e4567-e89b-12d3-a456-426655440000";

public static final ModuleType GENERAL_MODULETYPE = ModuleType.CLIMATE;
public static final Temperature GENERAL_TEMPERATURE = new Temperature();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* This is a unit test class for the SmartDeviceLink library project class :
* {@link com.smartdevicelink.rpc.RegisterAppInterface}
* {@link com.smartdevicelink.proxy.rpc.RegisterAppInterface}
*/
public class RegisterAppInterfaceTests extends BaseRpcTests {

Expand All @@ -37,7 +37,7 @@ protected RPCMessage createMessage() {
msg.setSdlMsgVersion(Test.GENERAL_SDLMSGVERSION);
msg.setAppName(Test.GENERAL_STRING);
msg.setNgnMediaScreenAppName(Test.GENERAL_STRING);
msg.setAppID(Test.GENERAL_STRING);
msg.setFullAppID(Test.GENERAL_FULL_APP_ID);
msg.setLanguageDesired(Test.GENERAL_LANGUAGE);
msg.setHmiDisplayLanguageDesired(Test.GENERAL_LANGUAGE);
msg.setHashID(Test.GENERAL_STRING);
Expand Down Expand Up @@ -70,7 +70,8 @@ protected JSONObject getExpectedParameters(int sdlVersion) {
result.put(RegisterAppInterface.KEY_SDL_MSG_VERSION, Test.JSON_SDLMSGVERSION);
result.put(RegisterAppInterface.KEY_APP_NAME, Test.GENERAL_STRING);
result.put(RegisterAppInterface.KEY_NGN_MEDIA_SCREEN_APP_NAME, Test.GENERAL_STRING);
result.put(RegisterAppInterface.KEY_APP_ID, Test.GENERAL_STRING);
result.put(RegisterAppInterface.KEY_APP_ID, Test.GENERAL_APP_ID);
result.put(RegisterAppInterface.KEY_FULL_APP_ID, Test.GENERAL_FULL_APP_ID);
result.put(RegisterAppInterface.KEY_LANGUAGE_DESIRED, Test.GENERAL_LANGUAGE);
result.put(RegisterAppInterface.KEY_HMI_DISPLAY_LANGUAGE_DESIRED, Test.GENERAL_LANGUAGE);
result.put(RegisterAppInterface.KEY_HASH_ID, Test.GENERAL_STRING);
Expand All @@ -97,6 +98,7 @@ public void testRpcValues () {
String testName = ( (RegisterAppInterface) msg).getAppName();
String testNgnName = ( (RegisterAppInterface) msg).getNgnMediaScreenAppName();
String testAppId = ( (RegisterAppInterface) msg).getAppID();
String testFullAppId = ( (RegisterAppInterface) msg).getFullAppID();
Language testLang = ( (RegisterAppInterface) msg).getLanguageDesired();
Language testHmiLang = ( (RegisterAppInterface) msg).getHmiDisplayLanguageDesired();
String testHashId = ( (RegisterAppInterface) msg).getHashID();
Expand All @@ -112,7 +114,8 @@ public void testRpcValues () {
assertTrue(Test.TRUE, Validator.validateSdlMsgVersion(Test.GENERAL_SDLMSGVERSION, testVersion));
assertEquals(Test.MATCH, Test.GENERAL_STRING, testName);
assertEquals(Test.MATCH, Test.GENERAL_STRING, testNgnName);
assertEquals(Test.MATCH, Test.GENERAL_STRING, testAppId);
assertEquals(Test.MATCH, Test.GENERAL_APP_ID, testAppId);
assertEquals(Test.MATCH, Test.GENERAL_FULL_APP_ID, testFullAppId);
assertEquals(Test.MATCH, Test.GENERAL_LANGUAGE, testLang);
assertEquals(Test.MATCH, Test.GENERAL_LANGUAGE, testHmiLang);
assertEquals(Test.MATCH, Test.GENERAL_STRING, testHashId);
Expand All @@ -133,6 +136,7 @@ public void testRpcValues () {
assertNull(Test.NULL, msg.getAppName());
assertNull(Test.NULL, msg.getNgnMediaScreenAppName());
assertNull(Test.NULL, msg.getAppID());
assertNull(Test.NULL, msg.getFullAppID());
assertNull(Test.NULL, msg.getLanguageDesired());
assertNull(Test.NULL, msg.getHmiDisplayLanguageDesired());
assertNull(Test.NULL, msg.getHashID());
Expand Down Expand Up @@ -179,6 +183,7 @@ public void testJsonConstructor () {
assertEquals(Test.MATCH, appHmiTypeItem, cmd.getAppHMIType().get(index) );
}
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterface.KEY_APP_ID), cmd.getAppID());
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterface.KEY_FULL_APP_ID), cmd.getFullAppID());
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterface.KEY_LANGUAGE_DESIRED), cmd.getLanguageDesired().toString());

JSONObject deviceInfoObj = JsonUtils.readJsonObjectFromJsonObject(parameters, RegisterAppInterface.KEY_DEVICE_INFO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.util.Version;

import java.util.Hashtable;
import java.util.List;
Expand Down Expand Up @@ -182,7 +183,14 @@
* <td>Maxlength: 100</td>
* <td>SmartDeviceLink 2.0 </td>
* </tr>
*
* <tr>
* <td>fullAppID</td>
* <td>String</td>
* <td>ID used to validate app with policy table entries</td>
* <td>N</td>
* <td>Maxlength: 100</td>
* <td>SmartDeviceLink 4.6</td>
* </tr>
* <tr>
* <td>hmiCapabilities</td>
* <td>HMICapabilities</td>
Expand Down Expand Up @@ -238,6 +246,7 @@ public class RegisterAppInterface extends RPCRequest {
public static final String KEY_HMI_DISPLAY_LANGUAGE_DESIRED = "hmiDisplayLanguageDesired";
public static final String KEY_APP_HMI_TYPE = "appHMIType";
public static final String KEY_APP_ID = "appID";
public static final String KEY_FULL_APP_ID = "fullAppID";
public static final String KEY_LANGUAGE_DESIRED = "languageDesired";
public static final String KEY_DEVICE_INFO = "deviceInfo";
public static final String KEY_APP_NAME = "appName";
Expand All @@ -248,6 +257,7 @@ public class RegisterAppInterface extends RPCRequest {
public static final String KEY_HASH_ID = "hashID";
public static final String KEY_DAY_COLOR_SCHEME = "dayColorScheme";
public static final String KEY_NIGHT_COLOR_SCHEME = "nightColorScheme";
private static final int APP_ID_MAX_LENGTH = 10;

/**
* Constructs a new RegisterAppInterface object
Expand Down Expand Up @@ -291,18 +301,18 @@ public RegisterAppInterface(Hashtable<String, Object> hash) {
* @param isMediaApplication a Boolean value
* @param languageDesired a Language Enumeration
* @param hmiDisplayLanguageDesired
* @param appID a String value representing a unique ID, which an app will be given when approved <br>
* @param fullAppID a String value representing a unique ID, which an app will be given when approved <br>
* <b>Notes: </b>Maxlength = 100
*/
public RegisterAppInterface(@NonNull SdlMsgVersion syncMsgVersion, @NonNull String appName, @NonNull Boolean isMediaApplication,
@NonNull Language languageDesired, @NonNull Language hmiDisplayLanguageDesired, @NonNull String appID) {
@NonNull Language languageDesired, @NonNull Language hmiDisplayLanguageDesired, @NonNull String fullAppID) {
this();
setSdlMsgVersion(syncMsgVersion);
setAppName(appName);
setIsMediaApplication(isMediaApplication);
setLanguageDesired(languageDesired);
setHmiDisplayLanguageDesired(hmiDisplayLanguageDesired);
setAppID(appID);
setFullAppID(fullAppID);
}
/**
* Gets the version of the SDL&reg; SmartDeviceLink interface
Expand Down Expand Up @@ -573,32 +583,83 @@ public String getHashID() {

public void setHashID(String hashID) {
setParameters(KEY_HASH_ID, hashID);
}
}

/**
* Gets the unique ID, which an app will be given when approved
*
*
* @return String - a String value representing the unique ID, which an app
* will be given when approved
* @since SmartDeviceLink 2.0
*/
public String getAppID() {
return getString(KEY_APP_ID);
}
public String getAppID() {
return getString(KEY_APP_ID);
}

/**
* Sets a unique ID, which an app will be given when approved
*
*
* @param appID
* a String value representing a unique ID, which an app will be
* given when approved
* <p></p>
* <b>Notes: </b>Maxlength = 100
* @since SmartDeviceLink 2.0
*/
public void setAppID(@NonNull String appID) {
setParameters(KEY_APP_ID, appID);
}
public void setAppID(@NonNull String appID) {
if (appID != null) {
setParameters(KEY_APP_ID, appID.toLowerCase());
} else {
setParameters(KEY_APP_ID, appID);
}
}

/**
* Gets the unique ID, which an app will be given when approved
*
* @return String - a String value representing the unique ID, which an app
* will be given when approved
* @since SmartDeviceLink 4.6
*/
public String getFullAppID() {
return getString(KEY_FULL_APP_ID);
}

/**
* Sets a unique ID, which an app will be given when approved <br>
* Note: this will automatically parse the fullAppID into the smaller appId and set the appId value as well
* @param fullAppID
* a String value representing a unique ID, which an app will be
* given when approved
* <p></p>
* <b>Notes: </b>Maxlength = 100
* @since SmartDeviceLink 4.6
*/
public void setFullAppID(String fullAppID) {
if (fullAppID != null) {
fullAppID = fullAppID.toLowerCase();
setParameters(KEY_FULL_APP_ID, fullAppID);
String appID;
if (fullAppID.length() <= APP_ID_MAX_LENGTH) {
appID = fullAppID;
} else {
appID = fullAppID.replace("-", "").substring(0, APP_ID_MAX_LENGTH);
}
setAppID(appID);
} else {
setParameters(KEY_FULL_APP_ID, null);
}
}

@Override
public void format(Version rpcVersion, boolean formatParams) {
if(rpcVersion == null || rpcVersion.getMajor() >= 5) {
if (getFullAppID() == null) {
setFullAppID(getAppID());
}
}
super.format(rpcVersion, formatParams);
}

/**
* Gets the color scheme that is currently used for day
Expand Down