package com.xtremelabs.robolectric.shadows;

import android.os.Binder;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.ShadowBinderBridge;

import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import com.xtremelabs.robolectric.internal.RealObject;

@Implements(android.os.Binder.class)
public class ShadowBinder {
    @RealObject
    Binder realObject;

    private static Integer callingPid;

    @Implementation
    public boolean transact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
        return new ShadowBinderBridge(realObject).onTransact(code, data, reply, flags);
    }

    @Implementation
    public static final int getCallingPid() {
        if (callingPid != null) {
            return callingPid;
        }
        return android.os.Process.myPid();
    }

    public static void setCallingPid(int pid) {
        ShadowBinder.callingPid = pid;
    }

    public static void reset() {
        ShadowBinder.callingPid = null;
    }
}

@@ -439,16 +439,55 @@
 bject;%0A%0A
+    private static Integer callingUid;%0A
     priv
@@ -933,160 +933,485 @@
     
-public static void setCallingPid(int pid) %7B%0A        ShadowBinder.callingPid = pid;%0A    %7D%0A%0A    public static void reset() %7B%0A        ShadowBinder.callingP
+@Implementation%0A    public static final int getCallingUid() %7B%0A        if (callingUid != null) %7B%0A            return callingUid;%0A        %7D%0A        return android.os.Process.myUid();%0A    %7D%0A%0A    public static void setCallingPid(int pid) %7B%0A        ShadowBinder.callingPid = pid;%0A    %7D%0A%0A    public static void setCallingUid(int uid) %7B%0A        ShadowBinder.callingUid = uid;%0A    %7D%0A%0A    public static void reset() %7B%0A        ShadowBinder.callingPid = null;%0A        ShadowBinder.callingU
 id =

Implement ShadowBinder#getCallingUid