BimmerGestalt / IDriveConnectAddons

Ideas for new features using the IDrive Connected Apps protocol
MIT License
64 stars 25 forks source link

Making the screen mirror size as big as the navigation map? #14

Closed DrTermi closed 1 year ago

DrTermi commented 2 years ago

Hello, First of all thanks for the app, i wanted to know is there a way to make the screen mirror size as big as the navigation map? As you can see in the pictures i will post, the screen mirror has a lot of bottom margins left without use while the navigation app is full screen and very beautiful. If there is a way, if you could just give me a hint of which part of the code i have to change for this? Thanks

IMG_20221029_094439 photo_2022-10-28_19-56-31

hufman commented 2 years ago

Very interesting, they generally have the same logic and so it should work the same. I see a faint black outline around the screen mirroring, indicating that the app knows that the screen is supposed to be wider, but the height isn't as tall as it should be. What phone do you have, what is its screen dimensions?

DrTermi commented 2 years ago

I have Xiaomi Redmi note 10 pro and the screen is 6.67inch (dimensions of the phone are 164 x 76.5 mm ) btw in the picture it's not very clear but not only there is a little black corner at the left of the screen mirror but also the whole screen mirror + black corner is still smaller than the BMW's screen size unlike the navigation map app. (the navigation map app pîcture i posted its in dark and not very clear but the map completely fill the bmw's screen)

sbour015 commented 1 year ago

Hi, I have the same issue with a Evo idrive 5 and a Samsung Galaxy S10

dvstnl commented 1 year ago

PXL_20230217_203225356 I've a pixel 6 with resolution of 2,400 x 1,080

The screen mirroring is tiny with the black borders

hmi.display-width: 800 hmi.type: MINI ID4++ hmi.version: EntryNav_3D1411_Release 3D1411-490-1428I Build 37 - Rev:127251 2014-08-08 10:14:08

galenzhao commented 1 year ago

same here,

image

the red area is pure black,

the green area is like dark gray, seems like idrive's background.

apk downloaded from releases, commit: d0a0fa3

Redmi Note 12 Pro is a 6.67" device, with a 1080x2400 120Hz OLED display

hmi.display-height: 480 hmi.display-width: 800 hmi.role: HU hmi.type: BMW ID6L hmi.version: EntryEvo_ID5_1907_Release ID5_1907-490-1907O Build 48 - Rev:205692 2019-05-24 09:15:55

galenzhao commented 1 year ago

I found some logs, not sure if it helps.

05-09 10:27:46.173  1483  1630 W DisplayManagerService: Display DisplayDeviceInfo{"IDriveVirtualDisplay": uniqueId="virtual:me.hufman.androidautoidrive,10363,IDriveVirtualDisplay,0", 885 x 540, modeId 4, defaultModeId 4, supportedModes [{id=4, width=885, height=540, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 250, 250.0 x 250.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, owner me.hufman.androidautoidrive (uid 10363), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_NEVER_BLANK, FLAG_OWN_CONTENT_ONLY} does not support input device matching.
05-09 10:27:46.173  1483  1630 W DisplayManagerService: Display DisplayDeviceInfo{"idrive-screen-mirror": uniqueId="virtual:io.bimmergestalt.idriveconnectaddons.screenmirror,10369,idrive-screen-mirror,0", 672 x 480, modeId 5, defaultModeId 5, supportedModes [{id=5, width=672, height=480, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 200, 200.0 x 200.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, owner io.bimmergestalt.idriveconnectaddons.screenmirror (uid 10369), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRESENTATION} does not support input device matching.
galenzhao commented 1 year ago

hardcode some numbers have the image size correct.

        screenMirrorProvider.setSize(980, 540)
        image.setProperty(RHMIProperty.PropertyId.WIDTH, 980)
        image.setProperty(RHMIProperty.PropertyId.HEIGHT, 540)
        image.setProperty(RHMIProperty.PropertyId.POSITION_X, -90)
        image.setProperty(RHMIProperty.PropertyId.POSITION_Y, -67)

the position still needs turning.

image

dvstnl commented 1 year ago

Cool could you post the updated APK? :)

galenzhao commented 1 year ago

Cool could you post the updated APK? :)

https://github.com/galenzhao/IDriveConnectAddons/releases/tag/v1

I'll descript how to custom settings later.

first, is impossible to make a real full-screen mirror unless your phone screen is the same aspect ratio as HU's screen.

image

I'll show the custom settings based on my phone and HU.

phone screen: 2400x1080 HU: reported 800x480, but dig into the AAIdrive it should be 980x540

custom mirror setting: rhmiwidth:974 rhmiHeight:610 marginLeft:90(useless) marginRight:5(useless) paddingLeft:181 paddingTop:67 Screenshot_2023-05-11-13-51-19-210_io bimmergestalt idriveconnectaddons screenmirror

when using the screen mirror function.

the app creates a virtual screen to capture screenshot images, you can think it's an image buffer with rhmiWidth and rhmiHeight.

then the phone screenshot image will be placed in the center of the image buffer with a fixed aspect ratio. like this:

image

around a black background color.

then the image buffer will draw on HU with a default left and top padding. so we need to set a value for them to make the image move left and up.

my phone's aspect ratio is 2400/1080, which makes the screenshot image covered a little by HU's top-right corner image( like this photo https://user-images.githubusercontent.com/3184101/237265225-524fa6a9-c99b-41e4-9dcb-2c3d7797c085.jpeg). so I need to move down the buffered image a little, but as I said the image buffer has a black background color, when I move down the image buffer the HU's screen will show it default background on the top which is not covered by the image buffer.

in this case, I need to change the image buffer's height bigger, to make sure the HU's background is still covered which I can not change the padding-top value. but with a bigger image buffer height, the actual screenshot image will move down by 1/2 height increment.

the final result is like this: image

so it is based on your phone and HU screen size and custom dimension setting to show a perfect screen mirror.

galenzhao commented 1 year ago

and here's the code: https://github.com/galenzhao/IDriveConnectAddons/tree/customsettings

it's maybe not beautiful, cuz I'm not an Android developer or understand Kotlin.

for future dev, we may calc these settings by code, cuz we can get the phone's screen size by code. then set it automatically.

galenzhao commented 1 year ago

image

hufman commented 1 year ago

Thank you @galenzhao for looking into this! I hadn't been able to think of any explanations, so thank you for experimenting and trying to figure it out! AAIdrive's map module and the screen mirroring code use the same logic to figure out the size for the output widget in the car. My only guesses are that the problem is either in code to center the image in the car's display, or the aspect mismatch that you suspect.

Now that you have code for UI settings, perhaps you could experiment with adding different stretch modes? Currently it just sets the virtual display to the same size as the car's output image should be, and the phone automatically adds black bars. Perhaps instead it should match the phone's aspect ratio and stretch the image manually. AAIdrive has an example of using Canvas operations to resize an image, and Matrix has a few different methods to create the resize matrix for different stretch modes.

galenzhao commented 1 year ago

Thank you @galenzhao for looking into this! I hadn't been able to think of any explanations, so thank you for experimenting and trying to figure it out! AAIdrive's map module and the screen mirroring code use the same logic to figure out the size for the output widget in the car. My only guesses are that the problem is either in code to center the image in the car's display, or the aspect mismatch that you suspect.

Now that you have code for UI settings, perhaps you could experiment with adding different stretch modes? Currently it just sets the virtual display to the same size as the car's output image should be, and the phone automatically adds black bars. Perhaps instead it should match the phone's aspect ratio and stretch the image manually. AAIdrive has an example of using Canvas operations to resize an image, and Matrix has a few different methods to create the resize matrix for different stretch modes.

the mirror addon set a smaller virtual display: https://github.com/BimmerGestalt/IDriveConnectAddons/blob/d0a0fa3342eba883ecc33921e31060b52b0d4610/screen_mirror/src/main/java/io/bimmergestalt/idriveconnectaddons/screenmirror/carapp/CarApp.kt#L50

maybe HU does not scale a small image to a bigger one even if you are setting a bigger width value for the image so there will be a right black bar on my HU


and for the screenshot image resizing, I think we better keep it aspect and just calc a better position to place. and make sure all the HU screen is covered by our image, so the HU's ugly default background image will be hidden.

Staffu11 commented 1 year ago

Hello. I have maybe a noob question, but how to add addones to the application?

hufman commented 1 year ago

You would install an APK from the repo's Releases page

Staffu11 commented 1 year ago

Thanks a lot 💪

wt., 23 maj 2023, 04:05 użytkownik Walter Huf @.***> napisał:

You would install an APK from the repo's Releases page https://github.com/BimmerGestalt/IDriveConnectAddons/releases

— Reply to this email directly, view it on GitHub https://github.com/BimmerGestalt/IDriveConnectAddons/issues/14#issuecomment-1558436622, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAA5HCAKLYEDNH2VG6OZ6S3XHQSN5ANCNFSM6AAAAAARTQDWJU . You are receiving this because you commented.Message ID: @.***>

Staffu11 commented 1 year ago

Thanks a lot for reply. I have a question. Is this possible to add information when dpf is regenerating?

wt., 23 maj 2023, 04:05 użytkownik Walter Huf @.***> napisał:

You would install an APK from the repo's Releases page https://github.com/BimmerGestalt/IDriveConnectAddons/releases

— Reply to this email directly, view it on GitHub https://github.com/BimmerGestalt/IDriveConnectAddons/issues/14#issuecomment-1558436622, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAA5HCAKLYEDNH2VG6OZ6S3XHQSN5ANCNFSM6AAAAAARTQDWJU . You are receiving this because you commented.Message ID: @.***>

hufman commented 1 year ago

I'm not sure what "dpf regenerating" is, in the context of screen mirroring or navigation. If it's a piece of car information, the only options are in this api: https://bimmergestalt.github.io/BMWConnectedAnalysis/cds/

Staffu11 commented 1 year ago

Dpf i mean Diesel Particulate Filter. This would be very useful to have information when is regenerating process runing.

wt., 13 cze 2023, 15:42 użytkownik Walter Huf @.***> napisał:

I'm not sure what "dpf regenerating" is, in the context of screen mirroring or navigation. If it's a piece of car information, the only options are in this api: https://bimmergestalt.github.io/BMWConnectedAnalysis/cds/

— Reply to this email directly, view it on GitHub https://github.com/BimmerGestalt/IDriveConnectAddons/issues/14#issuecomment-1589453250, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAA5HCA7FG5D6BRTCV6A27TXLB365ANCNFSM6AAAAAARTQDWJU . You are receiving this because you commented.Message ID: @.***>

hufman commented 1 year ago

Ah yes, that is not related to this bug report, about screen mirroring being smaller than navigation. I don't see any related data points in the CDS api, sorry.

DmiBro commented 1 year ago

Hello, I have i3 with NBT EVO with 940x580 resolution and Samsun Flip3 with 2400x1080. Not able to make screen mirror work on full screen. Followed instruction of @galenzhao above, but it does not help - changing any parameter on the phone does not change anything on the screen.

May be I am using wrong version of Screen mirror? https://github.com/BimmerGestalt/IDriveConnectAddons/releases is empty, where can I find latest apk?

hufman commented 1 year ago

Thank you for bringing the empty releases page to my attention! The build failed after a recent Readme update and I needed to fix it.

DmiBro commented 1 year ago

I see now https://github.com/BimmerGestalt/IDriveConnectAddons/releases/download/latest_build/screen_mirror-debug.apk

Problems I described above was with version 1.1 from https://github.com/galenzhao/IDriveConnectAddons/releases/download/v1.1/screen_mirror-debug.apk, today I downloaded version 2.1 from https://github.com/galenzhao/IDriveConnectAddons/releases/download/v1.2/screen_mirror-debug.apk

Which app version is the correct one, allowing to change screen size and position?

hufman commented 1 year ago

I imagine that's the right version, @galenzhao would know better. You should describe what problem you are having, and why the dimension adjustments don't appear to work for you.

galenzhao commented 1 year ago

I see now https://github.com/BimmerGestalt/IDriveConnectAddons/releases/download/latest_build/screen_mirror-debug.apk

Problems I described above was with version 1.1 from https://github.com/galenzhao/IDriveConnectAddons/releases/download/v1.1/screen_mirror-debug.apk, today I downloaded version 2.1 from https://github.com/galenzhao/IDriveConnectAddons/releases/download/v1.2/screen_mirror-debug.apk

Which app version is the correct one, allowing to change screen size and position?

the newer ver1.2 fixes some hardcode values, but from ver >= 1.1 should change the param permanently.

is there any difference on the screen after you change the value? btw you should change values before clicking 'grant permission'.

DmiBro commented 1 year ago

I see now https://github.com/BimmerGestalt/IDriveConnectAddons/releases/download/latest_build/screen_mirror-debug.apk Problems I described above was with version 1.1 from https://github.com/galenzhao/IDriveConnectAddons/releases/download/v1.1/screen_mirror-debug.apk, today I downloaded version 2.1 from https://github.com/galenzhao/IDriveConnectAddons/releases/download/v1.2/screen_mirror-debug.apk Which app version is the correct one, allowing to change screen size and position?

the newer ver1.2 fixes some hardcode values, but from ver >= 1.1 should change the param permanently.

is there any difference on the screen after you change the value? btw you should change values before clicking 'grant permission'.

Hello, I tried both 1.1 and 1.2 version, behaviour is the same. When I select screen mirroring in the car menu, I got this on the car screen

20230731_192100

and this on the phone

Screenshot_20230731_192032_AAIdrive

It is not possible to change values on the phone before I grant permission, only after. And this does not change anything on the car screen, is always has blank areas on the right, see below

20230731_192130

hufman commented 1 year ago

Thank you for the screenshot of your phone being mirrored to the car! What behavior would you like to see changed? Do you want AAIdrive to distort the phone's aspect ratio to fill up the screen, would you like the smaller image to be centered in the middle of the screen (and be cut off when your car is running in split screen), or any other change? Currently AAIdrive is scaling the image to fit in the screen, without changing aspect ratio.

galenzhao commented 1 year ago

It is not possible to change values on the phone before I grant permission, only after. And this does not change anything on the car screen, is always has blank areas on the right, see below

The value has changed already, but the screen mirroring image is still the wrong size and pos.

how about the map function? does it show the correct image?

change the value in the app before clicking 'grant permission' can be performed by the following, image

image

DmiBro commented 1 year ago

@hufman @galenzhao thank you for comments. I changed values in Screen Mirror app before granting permission and see now changes on the car screen. Now question is what should be right settings to fill whole screen.

I followed above calculation for my phone ZFlip3 with 2640x1080 screen:

Map function shows full screen automatically, see below 20230802_185002

Where should I put 607, and what should be remaining parameters?

galenzhao commented 1 year ago

I followed above calculation for my phone ZFlip3 with 2640x1080 screen:

  • 2640/1080=2.44
  • 980/2.44=402
  • 402+67*2=536
  • 402+(540-402)*2=678
  • (536+678)/2=607

for pos calc,

  1. scale your phone to fit HU, like: image your phone screenshot image should be 980x400

  2. then chose an 'offsetY' that you like. image

  3. calc max(offsetY,offsetYY) image

  4. then your image buffer height should be: height=max(offsetY,offsetYY)*2+phone_height(400) image

  5. custom mirror setting: rhmiwidth:980 rhmiHeight:image buffer height marginLeft:90(useless) marginRight:5(useless) paddingLeft:180 paddingTop:67

DmiBro commented 1 year ago

@galenzhao wow that's very detailed, thanks a lot. Just two questions:

hufman commented 1 year ago

Are you sure about your rhmiWidth (you can check by setting AAIdrive to show Advanced options and looking in Car Information)? Are you able to enable the sidebar? It looks like you have a widescreen car, which would be 1440x540 (which I don't think i3 came in) or 1280x480. Both of which are a wider aspect ratio than your phone, which is why your phone isn't taking up the right side of the screen in your screenshot. The map can be full screen because it is creating a disconnected virtual display and draws whatever it wants, while screen mirroring creates a virtual display that the phone mirrors its normal screen into.

hufman commented 1 year ago

I just pushed a new build that reduces the visible margin on the right side. It doesn't change any aspect ratio, so the phone image will try to fill as much as possible but may still show black bars.

DmiBro commented 1 year ago

I just pushed a new build that reduces the visible margin on the right side. It doesn't change any aspect ratio, so the phone image will try to fill as much as possible but may still show black bars.

I was not able to install new build from releases page, it says "application is not installed as it conflicts with other package". Was able before to install version 1.2 over 1.1.

Checked and you are right, looks like my screen has 1280x480 resolution. What is maximum size of the screen I can have with my phone?

hufman commented 1 year ago

Indeed, you would need to uninstall galenzhao's build to install the main build, Android disallows app updates for the same app name from different authors to prevent data from leaking or being incompatible. The code is pretty good at maximizing the height, so your 480 high screen and your 2.44 aspect ratio would give a max width of 1171. Although your screenshot shows that it didn't move up to the top of the screen like it's supposed to, not sure what that means.

DmiBro commented 1 year ago

Indeed, you would need to uninstall galenzhao's build to install the main build, Android disallows app updates for the same app name from different authors to prevent data from leaking or being incompatible. The code is pretty good at maximizing the height, so your 480 high screen and your 2.44 aspect ratio would give a max width of 1171. Although your screenshot shows that it didn't move up to the top of the screen like it's supposed to, not sure what that means.

@hufman Walter, It helped, now image is almost perfect. On the top Android status bar icons are cut roughly by half, on the right side image is also slightly bigger then screen, on the left size I still can see empty space with arrow from car UI, see below.

How can I modify image size and position in the code to make it perfect, not to disturb you further? Change any parameters in the code, recompile and try again? image

hufman commented 1 year ago

The code responsible for moving the image to the left is here. It uses some data about IDrive screen sizes, and so your screen was previously measured as being able to move the image 70 pixels to the left (paddingLeft) and having 64 pixels more on the left where the car doesn't allow the app to draw (marginLeft). You can see this in the map image you showed before. You are free to adjust the POSITION_X and recompile the app, of course, but the marginLeft will prevent the image from taking up the entire screen. @galenzhao's code makes the numbers easily editable, but it would want to be updated to use the new visibleWidth.

I'm glad the new version works better, and matches the map size!