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

Commit 821a90df authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix pub issue #58043: Copy crash in Android 4.3..."

parents a7524695 f0989840
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -154,15 +154,18 @@ public class ClipboardService extends IClipboard.Stub {
            if (clip != null && clip.getItemCount() <= 0) {
                throw new IllegalArgumentException("No items");
            }
            if (mAppOps.noteOp(AppOpsManager.OP_WRITE_CLIPBOARD, Binder.getCallingUid(),
            final int callingUid = Binder.getCallingUid();
            if (mAppOps.noteOp(AppOpsManager.OP_WRITE_CLIPBOARD, callingUid,
                    callingPackage) != AppOpsManager.MODE_ALLOWED) {
                return;
            }
            checkDataOwnerLocked(clip, Binder.getCallingUid());
            checkDataOwnerLocked(clip, callingUid);
            clearActiveOwnersLocked();
            PerUserClipboard clipboard = getClipboard();
            clipboard.primaryClip = clip;
            final long ident = Binder.clearCallingIdentity();
            final int n = clipboard.primaryClipListeners.beginBroadcast();
            try {
                for (int i = 0; i < n; i++) {
                    try {
                        ListenerInfo li = (ListenerInfo)
@@ -173,12 +176,14 @@ public class ClipboardService extends IClipboard.Stub {
                                    .dispatchPrimaryClipChanged();
                        }
                    } catch (RemoteException e) {

                        // The RemoteCallbackList will take care of removing
                        // the dead object for us.
                    }
                }
            } finally {
                clipboard.primaryClipListeners.finishBroadcast();
                Binder.restoreCallingIdentity(ident);
            }
        }
    }