Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b9a7be0 authored by Miranda Kephart's avatar Miranda Kephart Committed by Automerger Merge Worker
Browse files

Merge "Add a timeout when loading and releasing screenshot shutter sound" into...

Merge "Add a timeout when loading and releasing screenshot shutter sound" into udc-dev am: f7c510fe

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22163029



Change-Id: I680feb463902bd6be71eb3a004d19688aedb1b29
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0e62bc02 f7c510fe
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.function.Supplier;

@@ -613,11 +615,13 @@ public class ScreenshotController {
        // Note that this may block if the sound is still being loaded (very unlikely) but we can't
        // reliably release in the background because the service is being destroyed.
        try {
            MediaPlayer player = mCameraSound.get();
            MediaPlayer player = mCameraSound.get(1, TimeUnit.SECONDS);
            if (player != null) {
                player.release();
            }
        } catch (InterruptedException | ExecutionException e) {
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            mCameraSound.cancel(true);
            Log.w(TAG, "Error releasing shutter sound", e);
        }
    }