@@ -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,42 +105,66 @@ 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+ final Boolean isConsole = getWurflIsConsole ();
114+ if (isConsole ) {
115+ return 6 ;
116+ }
121117
122- if (wurflDevice . getCapabilityAsBool ( "is_phone" )) {
123- return 4 ;
124- }
118+ if ("out_of_home_device" . equals ( getWurflPhysicalFormFactor () )) {
119+ return 8 ;
120+ }
125121
126- if (wurflDevice .getCapabilityAsBool ("is_tablet" )) {
127- return 5 ;
128- }
122+ final String formFactor = getWurflFormFactor ();
123+ return switch (formFactor ) {
124+ case "Desktop" -> 2 ;
125+ case "Smartphone" , "Feature Phone" -> 4 ;
126+ case "Tablet" -> 5 ;
127+ case "Smart-TV" -> 3 ;
128+ case "Other Non-Mobile" -> 6 ;
129+ case "Other Mobile" -> 1 ;
130+ default -> null ;
131+ };
132+ }
129133
130- if (wurflDevice .getCapabilityAsBool ("is_ott" )) {
131- return 7 ;
132- }
134+ private Boolean getWurflIsOtt () {
135+ try {
136+ return wurflDevice .getCapabilityAsBool ("is_ott" );
137+ } catch (CapabilityNotDefinedException e ) {
138+ logger .warn ("Failed to get is_ott from WURFL device capabilities" , e );
139+ return Boolean .FALSE ;
140+ }
141+ }
133142
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 );
143+ private String getWurflFormFactor () {
144+ try {
145+ return wurflDevice .getVirtualCapability ("form_factor" );
146+ } catch (VirtualCapabilityNotDefinedException e ) {
147+ logger .warn ("Failed to get form_factor from WURFL device capabilities" , e );
148+ return "" ;
149+ }
150+ }
151+
152+ private String getWurflPhysicalFormFactor () {
153+ try {
154+ return wurflDevice .getCapability ("physical_form_factor" );
155+ } catch (CapabilityNotDefinedException e ) {
156+ logger .warn ("Failed to get physical_form_factor from WURFL device capabilities" , e );
157+ return "" ;
158+ }
159+ }
160+
161+ private Boolean getWurflIsConsole () {
162+ try {
163+ return wurflDevice .getCapabilityAsBool ("is_console" );
164+ } catch (CapabilityNotDefinedException e ) {
165+ logger .warn ("Failed to get is_console from WURFL device capabilities" , e );
166+ return Boolean .FALSE ;
140167 }
141- return null ;
142168 }
143169
144170 private String getWurflOs () {
0 commit comments