Search code examples
wear-ossamsung-galaxysamsung-galaxy-gear

How to add bezel to WearOS simulator


Samsung started using WearOS in their latest smartwatches, e.g. in Galaxy 4 watch, and I need to test bezel functionality since the latter model does have it. However I didn't find any WearOS devices in AVD supporting bezel.

I've also tried creating a new h/w profile, but didn't find a bezel option there either. All navigation options they have are below. None of them is related to bezel.

enter image description here

I've also tried to find a skin for Galaxy 4, but with no luck so far. The code that doesn't work according to a Galaxy4 owner is below. You can suggest how to fix the code of course, but I still want to know how to test it without buying a watch

    view.setOnGenericMotionListener { v, ev ->
        if (ev.action == MotionEvent.ACTION_SCROLL &&
                ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)
        ) {
            
            val delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL) *
                    ViewConfigurationCompat.getScaledVerticalScrollFactor(
                            ViewConfiguration.get(this), this
                    )

            if (Math.abs(delta) > 2f) {
                val np = if (delta > 0) Util.nextAccount(mAccount) else Util.prevAccount(mAccount)
                Util.d(TAG, mAccount + np.toString())
                switchAccount(np)

            }
            true
        } else {
            false
        }
    }

nextAccount and prevAccount are some custom functions that switch the view. None of them is called according to a user.

Here is a Tizen Studio emulator with a bezel that can be rotated by dragging the white dot:

enter image description here


Solution

  • I've finally fixed the problem. In a view's layout that is supposed to process the rotary event I've added requestFocus tag:

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="vertical"
        android:fadeScrollbars="false"
        android:id="@+id/token_scroll"
        >
        <requestFocus />
        ...
    

    To test the bezel, I've used menu on the right of the emulator as shown on the picture below. Bezel events are processed correctly at least in the emulator. I'll let you know if it works in real Galaxy 4 smartwatch when hear from the user.

    UPDATE A Galaxy 4 smartwatch user has just confirmed that bezel works after the fix. It confirms that both the fix and the testing method were correct and achieved their goals.

    enter image description here