Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
improve getting ios screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
shamanec committed Dec 29, 2023
1 parent 9850e8e commit c269ec0
Show file tree
Hide file tree
Showing 3 changed files with 451 additions and 89 deletions.
7 changes: 4 additions & 3 deletions device/dev_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ func (device *LocalDevice) setupIOSDevice() {
device.resetLocalDevice()
return
}
// Update hardware model got from plist
// Update hardware model got from plist, os version and product type
device.Device.HardwareModel = plistValues["HardwareModel"].(string)
device.Device.OSVersion = plistValues["ProductVersion"].(string)
device.Device.IOSProductType = plistValues["ProductType"].(string)

// Update the screen dimensions of the device using data from the IOSDeviceDimensions map
err = device.updateScreenSize()
Expand Down Expand Up @@ -550,7 +551,7 @@ func (device *LocalDevice) startGridNode() {

func (device *LocalDevice) updateScreenSize() error {
if device.Device.OS == "ios" {
if dimensions, ok := util.IOSDeviceInfoMap[device.Device.HardwareModel]; ok {
if dimensions, ok := util.IOSDeviceInfoMap[device.Device.IOSProductType]; ok {
device.Device.ScreenHeight = dimensions.Height
device.Device.ScreenWidth = dimensions.Width
} else {
Expand All @@ -568,7 +569,7 @@ func (device *LocalDevice) updateScreenSize() error {

func (device *LocalDevice) updateModel() {
if device.Device.OS == "ios" {
if info, ok := util.IOSDeviceInfoMap[device.Device.HardwareModel]; ok {
if info, ok := util.IOSDeviceInfoMap[device.Device.IOSProductType]; ok {
device.Device.Model = info.Model
} else {
device.Device.Model = "Unknown iOS device"
Expand Down
1 change: 1 addition & 0 deletions models/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ type Device struct {
ScreenHeight string `json:"screen_height" bson:"screen_height"`
HardwareModel string `json:"hardware_model,omitempty" bson:"hardware_model,omitempty"`
InstalledApps []string `json:"installed_apps" bson:"-"`
IOSProductType string `json:"ios_product_type,omitempty" bson:"ios_product_type,omitempty"`
}
Loading

0 comments on commit c269ec0

Please sign in to comment.