From 2eb67594164a6d29b8abd0628529257782aa10fa Mon Sep 17 00:00:00 2001 From: Oli Lan Date: Fri, 4 Feb 2022 12:45:34 +0000 Subject: [PATCH] Catch SecurityException when sending clip change broadcast. This fixes an issue where the system server can crash if a SecurityException occurs while a clip change broadcast is being sent. If an app is not permitted to access clipboard, then the clipboardAccessAllowed check throws a SecurityException. This is ok when the exception can propogate back to a caller, such as when setClipData has been called, but when this happens while a change broadcast is being triggered it will instead crash the system. Bug: 207333180 Test: atest ClipboardManagerTest Test: atest ClipDescriptionTest Change-Id: If18ce497a89335ed26c8996571448c2c083887e6 --- .../java/com/android/server/clipboard/ClipboardService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java index 38df5f8960000..a0c5aa364f0d1 100644 --- a/services/core/java/com/android/server/clipboard/ClipboardService.java +++ b/services/core/java/com/android/server/clipboard/ClipboardService.java @@ -639,7 +639,7 @@ public class ClipboardService extends SystemService { clipboard.primaryClipListeners.getBroadcastItem(i) .dispatchPrimaryClipChanged(); } - } catch (RemoteException e) { + } catch (RemoteException | SecurityException e) { // The RemoteCallbackList will take care of removing // the dead object for us. }