Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: get default display via displaymanager #585

Merged
merged 2 commits into from
Dec 28, 2023
Merged

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Dec 27, 2023

#490 (comment)

Tested on Android 14 by calling mobile:deviceInfo:

Before

{"androidId"=>"6d1ee9298ac43e90", "apiVersion"=>"34", "bluetooth"=>{"state"=>"ON"}, "brand"=>"google", "carrierName"=>"", "displayDensity"=>420, "locale"=>"en_US", "manufacturer"=>"Google", "model"=>"Pixel 7", "networks"=>[{"capabilities"=>{"SSID"=>nil, "linkDownBandwidthKbps"=>55349, "linkUpstreamBandwidthKbps"=>12000, "networkCapabilities"=>"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_CONGESTED,NET_CAPABILITY_NOT_SUSPENDED", "signalStrength"=>-41, "transportTypes"=>"TRANSPORT_WIFI"}, "detailedState"=>"CONNECTED", "extraInfo"=>"", "isAvailable"=>true, "isConnected"=>true, "isFailover"=>false, "isRoaming"=>false, "state"=>"CONNECTED", "subtype"=>-1, "subtypeName"=>"", "type"=>1, "typeName"=>"WIFI"}], "platformVersion"=>"14", "realDisplaySize"=>"1080x2400", "timeZone"=>"America/Los_Angeles"}

After (with this change)

{"androidId"=>"6d1ee9298ac43e90", "apiVersion"=>"34", "bluetooth"=>{"state"=>"ON"}, "brand"=>"google", "carrierName"=>"", "displayDensity"=>420, "locale"=>"en_US", "manufacturer"=>"Google", "model"=>"Pixel 7", "networks"=>[{"capabilities"=>{"SSID"=>nil, "linkDownBandwidthKbps"=>55349, "linkUpstreamBandwidthKbps"=>12000, "networkCapabilities"=>"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_CONGESTED,NET_CAPABILITY_NOT_SUSPENDED", "signalStrength"=>-41, "transportTypes"=>"TRANSPORT_WIFI"}, "detailedState"=>"CONNECTED", "extraInfo"=>"", "isAvailable"=>true, "isConnected"=>true, "isFailover"=>false, "isRoaming"=>false, "state"=>"CONNECTED", "subtype"=>-1, "subtypeName"=>"", "type"=>1, "typeName"=>"WIFI"}], "platformVersion"=>"14", "realDisplaySize"=>"1080x2400", "timeZone"=>"America/Los_Angeles"}

Both had the same displayDensity and realDisplaySize, thus this should be ok.

Btw, below one is an error message I got when I called getDisplay via instrumentation.getContext().getDisplay()

[AndroidUiautomator2Driver@d969 (da8c073e)] Got response with status 500: {"sessionId":"6a55ea0a-409c-4a90-b988-ad28632953c2","value":{"error":"unknown error","message":"java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.","stacktrace":"java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.\n\tat android.app.ContextImpl.getDisplay(ContextImpl.java:3025)\n\tat io.appium.uiautomator2.core.UiAutomatorBridge.getDefaultDisplay(UiAutomatorBridge....
[W3C] Matched W3C error code 'unknown error' to UnknownError
[AndroidUiautomator2Driver@d969 (da8c073e)] Encountered internal error running command: An unknown server-side error occurred while processing the command. Original error: java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.
[AndroidUiautomator2Driver@d969 (da8c073e)] java.lang.UnsupportedOperationException: Tried to obtain display from a Context not associated with one. Only visual Contexts (such as Activity or one created with Context#createWindowContext) or ones created with Context#createDisplayContext are associated with displays. Other types of Contexts are typically related to background entities and may return an arbitrary display.
[AndroidUiautomator2Driver@d969 (da8c073e)] 	at android.app.ContextImpl.getDisplay(ContextImpl.java:3025)

@KazuCocoa KazuCocoa merged commit 5c731ce into master Dec 28, 2023
17 checks passed
@KazuCocoa KazuCocoa deleted the use-displaymanager branch December 28, 2023 00:23
github-actions bot pushed a commit that referenced this pull request Dec 28, 2023
## [5.14.0](v5.13.0...v5.14.0) (2023-12-28)

### Features

* get default display via displaymanager ([#585](#585)) ([5c731ce](5c731ce))
Copy link

🎉 This PR is included in version 5.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants