android icon indicating copy to clipboard operation
android copied to clipboard

Compatibility issue when calling method

Open PSDroid2022 opened this issue 3 years ago • 1 comments

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

In ''com.owncloud.android.ui.preview.PreviewVideoActivity", you invoke the API "<com.google.android.exoplayer2.SimpleExoPlayer$Builder: com.google.android.exoplayer2.SimpleExoPlayer build()>" in "preparePlayer" method as shown in following. But actually, this API invoke the framwork API "<android.media.AudioManager: boolean isStreamMute(int)> ", which is introduced after API level 23 (https://developer.android.google.cn/reference/kotlin/android/os/BaseBundle?hl=en#getint_1).

    // Video player internal methods
    private void preparePlayer() {

        AdaptiveTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        // Video streaming is only supported at Jelly Bean or higher Android versions (>= API 16)

        // Create the player
        player = new ExoPlayer.Builder(requireContext()).setTrackSelector(trackSelector).setLoadControl(new DefaultLoadControl()).build();

        player.addListener(this);

        // Bind the player to the view.
        exoPlayerView.setPlayer(player);

        // Prepare video player asynchronously
        new PrepareVideoPlayerAsyncTask(getActivity(), this, getFile(), mAccount).execute();
    }

So when the app try to invoke this API on devices before API level 23, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT >= 23)" to fix this potential issue.

Android device

  • Device: [e.g. Emulator]
  • OS: [e.g. API 21 22]
  • Owncloud Version: [2.20]

PSDroid2022 avatar Aug 24 '22 08:08 PSDroid2022

We will implement https://github.com/owncloud/android/issues/3245 very soon. This should fix the problem.

Thanks a lot for your suggestion!

jesmrec avatar Aug 24 '22 09:08 jesmrec