Music-Player-GO icon indicating copy to clipboard operation
Music-Player-GO copied to clipboard

[Bug]:

Open PSDroid2022 opened this issue 2 years ago β€’ 4 comments

What happened?

We confirm a compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''PlayerTileService", you invoke the framework API "<android.service.quicksettings.TileService: void startActivityAndCollapse(android.content.Intent)>" in "onClick" method as shown in following. But actually, this method is added in API level 24 (https://developer.android.google.cn/reference/android/service/quicksettings/TileService?hl=en#startActivityAndCollapse(android.content.Intent)).

class PlayerTileService : TileService() {

    override fun onClick() {
        super.onClick()
        with(Intent(this, MainActivity::class.java)) {
            putExtra(GoConstants.LAUNCHED_BY_TILE, GoConstants.LAUNCHED_BY_TILE)
            flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP
            startActivityAndCollapse(this)
        }
    }
}}

So when the app try to initial related funtion on devices level 21 ~ 23, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT>23)" or change your app miniSDK from 21 to 24 to fix this potential issue.

Version

4.4.20

Device and Android version

API 21~23

Relevant log output

No response

More info

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

PSDroid2022 avatar Aug 24 '22 13:08 PSDroid2022

RequiresApi + intent filter (android.service.quicksettings.action.QS_TILE) should already do the trick

"Denotes that the annotated element should only be called on the given API level or higher"

You can't add tiles on 21~23 API 😁

Also, can't see any report of unpredictable in Google play dev console since the introduction of this feat.

But, yeah, gonna add that check if it helps to improve my app. Thanks

enricocid avatar Aug 24 '22 13:08 enricocid

Actually, this annotation only suppresses the compiler's warning (i.e., Lint). It will be deleted in the apk package. And when this API is called before API 24, the app will still meet a crash. So we suggest add a SDK version check before invoke the API. (https://stackoverflow.com/questions/40007365/requiresapi-vs-targetapi-android-annotations)

PSDroid2022 avatar Aug 24 '22 14:08 PSDroid2022

TileService was added in API 24

https://developer.android.com/reference/android/service/quicksettings/TileService

I can't really understand how older devices can experience a crash if no tile is available.

@OxygenCobalt what's your take on this issue?

enricocid avatar Aug 27 '22 18:08 enricocid

It won't run below API 24, as previous devices will not parse it from the manifest. I would recommend just adding @RequiresApi(24) to the whole TileService class to let other code know about it's nature.

OxygenCobalt avatar Aug 27 '22 18:08 OxygenCobalt