Need help in getting virtual keyboard height in native code of cocos creator?

Hello team,
I have added one edit box that will be placed on bottom part of the screen, on clicking the edit box keyboard opens and I want the edit box to appear just above the virtual keyboard in android.,
Now i added function on edit began and calling the native method where I can get the keyboard height and place edit box on top of keyboard.

calling the java method in cocos function that is attached to on edit began event

      callNative() {

        if (sys.isNative) {
            const calltoandroid = native.reflection.callStaticMethod("com/cocos/game/AppActivity", "getKeyboardHeight", "()V");
            native.fileUtils;
        }
    
    }

I am facing issue with key board height calculation
I have added below code that is used to calculate the same un android AppActivity.java

    static void getKeyboardHeight(){
        obj.calculateHeight();
    }

    void calculateHeight(){
        View rootView = getWindow().getDecorView().getRootView();

        rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                Rect r = new Rect();
                rootView.getWindowVisibleDisplayFrame(r);
    
                int screenHeight = rootView.getHeight();
      
                int keypadHeight = screenHeight - r.bottom;

                CocosHelper.runOnGameThread(new Runnable() {
                    @Override
                    public void run() {
                        // Call a JavaScript function in Cocos Creator 
                    }
                });
            }
        });
    }

but the listener is called once on before the keyboard gets opened and once after the keyboard closed. So the height keypadHeight which i am getting is always 0.
I even tried adding the native callback on edit began event but the result is same.
So is the method is correct or there any method on How to get virtual keyboard height in android build of cocos creator?
I am using cocos creator 3.6.v

Edits: I am getting the correct screenHeight and I doubt the issue with rootView.getWindowVisibleDisplayFrame(r);

Any help is really appreciated, Thank you

@slackmoehrle @mr.kylin @FocusCreative any idea on the same?

This value looks like the height of virtual keyboard.