ws-scrcpy icon indicating copy to clipboard operation
ws-scrcpy copied to clipboard

Android 13. Only default display used.

Open drauggres opened this issue 1 year ago • 11 comments

From https://github.com/NetrisTV/ws-scrcpy/issues/208:

07-23 15:29:13.572 6186 6215 D scrcpy : /// START ws-scrcpy/issues/208 07-23 15:29:13.573 6186 6215 D scrcpy : Failed to get display ids 07-23 15:29:13.574 6186 6215 D scrcpy : getDisplayIds parameters: 07-23 15:29:13.575 6186 6215 D scrcpy : boolean 07-23 15:29:13.575 6186 6215 D scrcpy : Return type: [I 07-23 15:29:13.575 6186 6215 D scrcpy : /// END ws-scrcpy/issues/208

Yep. Google has added a boolean parameter, before Android 13 this method had no parameters.

I am going to leave it as is: on Android 13 return only default display id. Until I can properly investigate what this new integer argument is responsible for.

This method is undocumented and the source code is not available yet (and also I don't have a physical device with Android 13 to play with).

drauggres avatar Aug 03 '22 11:08 drauggres

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/hardware/display/IDisplayManager.aidl#39

int[] getDisplayIds(boolean includeDisabled);

drauggres avatar Aug 27 '22 11:08 drauggres

This works for me (Tested on Android 13 emulator):

    public int[] getDisplayIds() {
        Method method;
        String methodName = "getDisplayIds";
        try {
            if (Build.VERSION.SDK_INT < 33) {
                method = manager.getClass().getMethod(methodName);
                return (int[]) method.invoke(manager);
            } else {
                method = manager.getClass().getMethod(methodName, Boolean.TYPE);
                return (int[]) method.invoke(manager, false);
            }
        } catch (Exception e) {
            throw new AssertionError(e);
        }
    }

stoefln avatar Oct 05 '22 16:10 stoefln

My latest attempt looks like this: https://github.com/drauggres/scrcpy/commit/f931585932673911b5d603581cd59a9fa4a336d1.

I don't work at @NetrisTV and can't add features and fix bugs (maybe only critical). But if you will send a PR I will try to review and merge it (to this repo and to https://github.com/NetrisTV/scrcpy).

drauggres avatar Oct 05 '22 17:10 drauggres

tried on real device and not working. Build server from branch wip/websocket-v1.24.x and renamed to "scrcpy-server.jar" and replaced with current ws-scrcpy and not working.

krishtoautomate avatar Oct 05 '22 18:10 krishtoautomate

tried on real device and not working. Build server from branch wip/websocket-v1.24.x and renamed to "scrcpy-server.jar" and replaced with current ws-scrcpy and not working.

@krishtoautomate Did you also update version? https://github.com/NetrisTV/ws-scrcpy/blob/e53e0aa24e9ec6277126e0f712055ff4af7bc1b0/src/common/Constants.ts#L3

It should match this https://github.com/drauggres/scrcpy/blob/f931585932673911b5d603581cd59a9fa4a336d1/server/build.gradle#L10

drauggres avatar Oct 05 '22 18:10 drauggres

worked after version set to '1.24-ws0'. thanks

krishtoautomate avatar Oct 05 '22 19:10 krishtoautomate

worked after version set to '1.24-ws0'. thanks

Keep in mind, this version was not finished. It may (and probably does) have problems. But this issue with default display should be fixed.

drauggres avatar Oct 06 '22 04:10 drauggres

@drauggres ay idea how scrcpy is using it?

krishtoautomate avatar Oct 06 '22 13:10 krishtoautomate

@drauggres ay idea how scrcpy is using it?

What do you mean (version string/display id/something else)?

drauggres avatar Oct 06 '22 15:10 drauggres

@drauggres yes, how scrcpy is handling display id?

krishtoautomate avatar Oct 06 '22 18:10 krishtoautomate

@drauggres yes, how scrcpy is handling display id?

Original scrcpy expects that you will provide display id in command line as an argument: https://github.com/Genymobile/scrcpy/blob/72ba913324d65cded8672dca7a57415cb82da095/server/src/main/java/com/genymobile/scrcpy/Server.java#L214-L216

It will check available displays only if it can't receive info for provided display id: https://github.com/Genymobile/scrcpy/blob/72ba913324d65cded8672dca7a57415cb82da095/server/src/main/java/com/genymobile/scrcpy/Device.java#L68-L73

Ws-scrcpy on the other hand asks for available displays (i.e. calls public int[] getDisplayIds()) every time you click Configure stream.

drauggres avatar Oct 06 '22 18:10 drauggres