Skip to content

Commit

Permalink
Recoder: Handle SecurityException during recording deletion
Browse files Browse the repository at this point in the history
Fix crash when clicking "delete" in notification after URI was deleted
by some other app.

Change-Id: I3137084e8d2dd5a05c53812724fd9f8315146497
  • Loading branch information
OnlyTomInSecond authored and luk1337 committed Oct 25, 2023
1 parent 8c97fca commit 5e90615
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 The LineageOS Project
* Copyright (C) 2021-2023 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,10 +17,13 @@

import android.content.ContentResolver;
import android.net.Uri;
import android.util.Log;

import androidx.annotation.NonNull;

public final class DeleteRecordingTask implements Runnable {
private static final String TAG = "DeleteRecordingTask";

@NonNull
private final ContentResolver cr;
@NonNull
Expand All @@ -33,6 +36,10 @@ public DeleteRecordingTask(@NonNull ContentResolver cr, @NonNull Uri uri) {

@Override
public void run() {
cr.delete(uri, null, null);
try {
cr.delete(uri, null, null);
} catch (SecurityException e) {
Log.e(TAG, "Failed to delete recording", e);
}
}
}

0 comments on commit 5e90615

Please sign in to comment.