openboard-team / openboard

GNU General Public License v3.0
2.56k stars 253 forks source link

compatibility issue when calling method #568

Open PSDroid2022 opened 2 years ago

PSDroid2022 commented 2 years ago

Hi, nice day! This time we confirm a callback compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''org.dslul.openboard.inputmethod.compat.ViewOutlineProviderCompatUtilsLXX", you call the framework API "<android.view.View: void invalidateOutline()>" in "InsetsOutlineProvider" method as shown in following. But actually, this method is added in API level 21 (https://developer.android.google.cn/reference/android/view/View?hl=en#invalidateOutline()).

private class InsetsOutlineProvider(private val mView: View) : ViewOutlineProvider(), InsetsUpdater {
        private var mLastVisibleTopInsets = NO_DATA
        override fun setInsets(insets: InputMethodService.Insets) {
            val visibleTopInsets = insets.visibleTopInsets
            if (mLastVisibleTopInsets != visibleTopInsets) {
                mLastVisibleTopInsets = visibleTopInsets
                mView.invalidateOutline()
            }
        }

So when the app try to call this API on devices level 19~20, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT>=21)", " @TargetApi(Build.VERSION_CODES.Lollipop)" or change your app miniSDK from 19 to 21 to fix this potential issue. By the way, "@TargetApi(Build.VERSION_CODES.Lollipop)" will be deleted by Android compiler when extracting APKs, so it seems like a not good way to solve those issues.

Helium314 commented 2 years ago

So when the app try to call this API on devices level 19~20, your app will run with an unpredictable results

Where is this ever called for such devices? I only can find it in https://github.com/openboard-team/openboard/blob/e9393dfab01dcdfb0872f360b1afe8092777f5ec/app/src/main/java/org/dslul/openboard/inputmethod/compat/ViewOutlineProviderCompatUtils.kt#L14-L17

PSDroid2022 commented 2 years ago

OK, it seems like "InsetsOutlineProvider()" is a dead code in ViewOutlineProviderCompatUtilsLXX.