@@ -55,6 +55,7 @@ public AuctionRequestPayload apply(AuctionRequestPayload auctionRequestPayload)
5555 private Device update (Device ortbDevice ) {
5656 final String make = tryUpdateField (ortbDevice .getMake (), this ::getWurflMake );
5757 final String model = tryUpdateField (ortbDevice .getModel (), this ::getWurflModel );
58+ final String hwv = tryUpdateField (ortbDevice .getHwv (), this ::getWurflModel );
5859 final Integer deviceType = tryUpdateField (
5960 Optional .ofNullable (ortbDevice .getDevicetype ())
6061 .filter (it -> it > 0 )
@@ -72,6 +73,7 @@ private Device update(Device ortbDevice) {
7273 .make (make )
7374 .model (model )
7475 .devicetype (deviceType )
76+ .hwv (hwv )
7577 .os (os )
7678 .osv (osv )
7779 .h (h )
@@ -103,49 +105,72 @@ private String getWurflModel() {
103105 }
104106
105107 private Integer getWurflDeviceType () {
106- try {
107- if (wurflDevice .getVirtualCapabilityAsBool ("is_mobile" )) {
108- // if at least one of these capabilities is not defined, the mobile device type is undefined
109- final boolean isPhone = wurflDevice .getVirtualCapabilityAsBool ("is_phone" );
110- final boolean isTablet = wurflDevice .getCapabilityAsBool ("is_tablet" );
111- return isPhone || isTablet ? 1 : 6 ;
112- }
113108
114- if (wurflDevice . getVirtualCapabilityAsBool ( "is_full_desktop" )) {
115- return 2 ;
116- }
109+ if (getWurflIsOtt ( )) {
110+ return 7 ;
111+ }
117112
118- if (wurflDevice . getCapabilityAsBool ( "is_connected_tv" )) {
119- return 3 ;
120- }
113+ if (getWurflIsConsole ( )) {
114+ return 6 ;
115+ }
121116
122- if (wurflDevice . getCapabilityAsBool ( "is_phone" )) {
123- return 4 ;
124- }
117+ if ("out_of_home_device" . equals ( getWurflPhysicalFormFactor () )) {
118+ return 8 ;
119+ }
125120
126- if (wurflDevice .getCapabilityAsBool ("is_tablet" )) {
127- return 5 ;
128- }
121+ final String formFactor = getWurflFormFactor ();
122+ return switch (formFactor ) {
123+ case "Desktop" -> 2 ;
124+ case "Smartphone" , "Feature Phone" -> 4 ;
125+ case "Tablet" -> 5 ;
126+ case "Smart-TV" -> 3 ;
127+ case "Other Non-Mobile" -> 6 ;
128+ case "Other Mobile" -> 1 ;
129+ default -> null ;
130+ };
131+ }
129132
130- if (wurflDevice .getCapabilityAsBool ("is_ott" )) {
131- return 7 ;
132- }
133+ private Boolean getWurflIsOtt () {
134+ try {
135+ return wurflDevice .getCapabilityAsBool ("is_ott" );
136+ } catch (CapabilityNotDefinedException e ) {
137+ logger .warn ("Failed to get is_ott from WURFL device capabilities" );
138+ return Boolean .FALSE ;
139+ }
140+ }
133141
134- final String physicalFormFactor = wurflDevice .getCapability ("physical_form_factor" );
135- if (physicalFormFactor != null && physicalFormFactor .equals ("out_of_home_device" )) {
136- return 8 ;
137- }
138- } catch (CapabilityNotDefinedException | VirtualCapabilityNotDefinedException | NumberFormatException e ) {
139- logger .warn ("Failed to determine device type from WURFL device capabilities" , e );
142+ private String getWurflFormFactor () {
143+ try {
144+ return wurflDevice .getVirtualCapability ("form_factor" );
145+ } catch (VirtualCapabilityNotDefinedException e ) {
146+ logger .warn ("Failed to get form_factor from WURFL device capabilities" );
147+ return "" ;
148+ }
149+ }
150+
151+ private String getWurflPhysicalFormFactor () {
152+ try {
153+ return wurflDevice .getCapability ("physical_form_factor" );
154+ } catch (CapabilityNotDefinedException e ) {
155+ logger .warn ("Failed to get physical_form_factor from WURFL device capabilities" );
156+ return "" ;
157+ }
158+ }
159+
160+ private Boolean getWurflIsConsole () {
161+ try {
162+ return wurflDevice .getCapabilityAsBool ("is_console" );
163+ } catch (CapabilityNotDefinedException e ) {
164+ logger .warn ("Failed to get is_console from WURFL device capabilities" );
165+ return Boolean .FALSE ;
140166 }
141- return null ;
142167 }
143168
144169 private String getWurflOs () {
145170 try {
146171 return wurflDevice .getVirtualCapability ("advertised_device_os" );
147172 } catch (VirtualCapabilityNotDefinedException e ) {
148- logger .warn ("Failed to evaluate advertised device OS" , e );
173+ logger .warn ("Failed to evaluate advertised device OS" );
149174 return null ;
150175 }
151176 }
@@ -154,7 +179,7 @@ private String getWurflOsv() {
154179 try {
155180 return wurflDevice .getVirtualCapability ("advertised_device_os_version" );
156181 } catch (VirtualCapabilityNotDefinedException e ) {
157- logger .warn ("Failed to evaluate advertised device OS version" , e );
182+ logger .warn ("Failed to evaluate advertised device OS version" );
158183 }
159184 return null ;
160185 }
@@ -163,7 +188,7 @@ private Integer getWurflH() {
163188 try {
164189 return wurflDevice .getCapabilityAsInt ("resolution_height" );
165190 } catch (NumberFormatException e ) {
166- logger .warn ("Failed to get resolution height from WURFL device capabilities" , e );
191+ logger .warn ("Failed to get resolution height from WURFL device capabilities" );
167192 return null ;
168193 }
169194 }
@@ -172,7 +197,7 @@ private Integer getWurflW() {
172197 try {
173198 return wurflDevice .getCapabilityAsInt ("resolution_width" );
174199 } catch (NumberFormatException e ) {
175- logger .warn ("Failed to get resolution width from WURFL device capabilities" , e );
200+ logger .warn ("Failed to get resolution width from WURFL device capabilities" );
176201 return null ;
177202 }
178203 }
@@ -181,7 +206,7 @@ private Integer getWurflPpi() {
181206 try {
182207 return wurflDevice .getVirtualCapabilityAsInt ("pixel_density" );
183208 } catch (VirtualCapabilityNotDefinedException e ) {
184- logger .warn ("Failed to get pixel density from WURFL device capabilities" , e );
209+ logger .warn ("Failed to get pixel density from WURFL device capabilities" );
185210 return null ;
186211 }
187212 }
@@ -193,7 +218,7 @@ private BigDecimal getWurflPxRatio() {
193218 ? new BigDecimal (densityAsString )
194219 : null ;
195220 } catch (CapabilityNotDefinedException | NumberFormatException e ) {
196- logger .warn ("Failed to get pixel ratio from WURFL device capabilities" , e );
221+ logger .warn ("Failed to get pixel ratio from WURFL device capabilities" );
197222 return null ;
198223 }
199224 }
@@ -202,7 +227,7 @@ private Integer getWurflJs() {
202227 try {
203228 return wurflDevice .getCapabilityAsBool ("ajax_support_javascript" ) ? 1 : 0 ;
204229 } catch (CapabilityNotDefinedException | NumberFormatException e ) {
205- logger .warn ("Failed to get JS support from WURFL device capabilities" , e );
230+ logger .warn ("Failed to get JS support from WURFL device capabilities" );
206231 return null ;
207232 }
208233 }
0 commit comments