am a99cb5bc: (DO NOT MERGE) Fix pub issue #58043: Copy crash in Android 4.3...

* commit 'a99cb5bc41d4493db84c5ee3d9123d4a99df5c53':
  (DO NOT MERGE) Fix pub issue #58043: Copy crash in Android 4.3...
This commit is contained in:
Dianne Hackborn
2013-07-31 14:14:21 -07:00
committed by Android Git Automerger
2 changed files with 23 additions and 17 deletions

View File

@@ -16,6 +16,7 @@
package android.app; package android.app;
import android.R;
import com.android.internal.app.IUsageStats; import com.android.internal.app.IUsageStats;
import com.android.internal.os.PkgUsageStats; import com.android.internal.os.PkgUsageStats;
import com.android.internal.util.MemInfoReader; import com.android.internal.util.MemInfoReader;
@@ -369,9 +370,9 @@ public class ActivityManager {
// Really brain dead right now -- just take this from the configured // Really brain dead right now -- just take this from the configured
// vm heap size, and assume it is in megabytes and thus ends with "m". // vm heap size, and assume it is in megabytes and thus ends with "m".
String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m"); String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m");
return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1)); return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length() - 1));
} }
/** /**
* Used by persistent processes to determine if they are running on a * Used by persistent processes to determine if they are running on a
* higher-end device so should be okay using hardware drawing acceleration * higher-end device so should be okay using hardware drawing acceleration

View File

@@ -154,31 +154,36 @@ public class ClipboardService extends IClipboard.Stub {
if (clip != null && clip.getItemCount() <= 0) { if (clip != null && clip.getItemCount() <= 0) {
throw new IllegalArgumentException("No items"); 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) { callingPackage) != AppOpsManager.MODE_ALLOWED) {
return; return;
} }
checkDataOwnerLocked(clip, Binder.getCallingUid()); checkDataOwnerLocked(clip, callingUid);
clearActiveOwnersLocked(); clearActiveOwnersLocked();
PerUserClipboard clipboard = getClipboard(); PerUserClipboard clipboard = getClipboard();
clipboard.primaryClip = clip; clipboard.primaryClip = clip;
final long ident = Binder.clearCallingIdentity();
final int n = clipboard.primaryClipListeners.beginBroadcast(); final int n = clipboard.primaryClipListeners.beginBroadcast();
for (int i = 0; i < n; i++) { try {
try { for (int i = 0; i < n; i++) {
ListenerInfo li = (ListenerInfo) try {
clipboard.primaryClipListeners.getBroadcastCookie(i); ListenerInfo li = (ListenerInfo)
if (mAppOps.checkOpNoThrow(AppOpsManager.OP_READ_CLIPBOARD, li.mUid, clipboard.primaryClipListeners.getBroadcastCookie(i);
li.mPackageName) == AppOpsManager.MODE_ALLOWED) { if (mAppOps.checkOpNoThrow(AppOpsManager.OP_READ_CLIPBOARD, li.mUid,
clipboard.primaryClipListeners.getBroadcastItem(i) li.mPackageName) == AppOpsManager.MODE_ALLOWED) {
.dispatchPrimaryClipChanged(); clipboard.primaryClipListeners.getBroadcastItem(i)
.dispatchPrimaryClipChanged();
}
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
} }
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
} }
} finally {
clipboard.primaryClipListeners.finishBroadcast();
Binder.restoreCallingIdentity(ident);
} }
clipboard.primaryClipListeners.finishBroadcast();
} }
} }