Skip to content

Commit 4626dca

Browse files
Extract isRPCVersionBetween5And7() into a seaparate method
1 parent 4cb8e19 commit 4626dca

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/screen/menu/MenuReplaceUtilities.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,8 @@ static Set<SdlArtwork> findAllArtworksToBeUploadedFromCells(ISdl internalInterfa
146146

147147
static boolean windowCapabilitySupportsPrimaryImage(ISdl internalInterface, WindowCapability windowCapability, MenuCell cell) {
148148
boolean supportsImage;
149-
if (cell.isSubMenuCell() && internalInterface != null && internalInterface.getSdlMsgVersion() != null) {
150-
Version headUnitRPCVersion = new Version(internalInterface.getSdlMsgVersion());
151-
Version minRPCVersion = new Version(5, 0, 0);
152-
Version maxRPCVersion = new Version(7, 1, 0);
153-
// If RPC version is >= 5.0 && < 7.1
154-
if (headUnitRPCVersion.isNewerThan(minRPCVersion) == 0 || headUnitRPCVersion.isBetween(minRPCVersion, maxRPCVersion) == 1) {
149+
if (cell.isSubMenuCell()) {
150+
if (isRPCVersionBetween5And7(internalInterface)) {
155151
supportsImage = true;
156152
} else {
157153
supportsImage = hasImageFieldOfName(windowCapability, ImageFieldName.subMenuIcon);
@@ -162,6 +158,17 @@ static boolean windowCapabilitySupportsPrimaryImage(ISdl internalInterface, Wind
162158
return supportsImage;
163159
}
164160

161+
static boolean isRPCVersionBetween5And7(ISdl internalInterface) {
162+
if (internalInterface != null && internalInterface.getSdlMsgVersion() != null) {
163+
Version headUnitRPCVersion = new Version(internalInterface.getSdlMsgVersion());
164+
Version minRPCVersion = new Version(5, 0, 0);
165+
Version maxRPCVersion = new Version(7, 0, 0);
166+
// If RPC version is >= 5.0 && < 7.0
167+
return (headUnitRPCVersion.isNewerThan(minRPCVersion) == 0 || headUnitRPCVersion.isBetween(minRPCVersion, maxRPCVersion) == 1);
168+
}
169+
return false;
170+
}
171+
165172
static boolean windowCapabilitySupportsSecondaryImage(WindowCapability windowCapability, MenuCell cell) {
166173
return cell.isSubMenuCell() ? hasImageFieldOfName(windowCapability, ImageFieldName.menuSubMenuSecondaryImage) : hasImageFieldOfName(windowCapability, ImageFieldName.menuCommandSecondaryImage);
167174
}

0 commit comments

Comments
 (0)