Fix issue #11374840: adb shell am startservice not working any more

The startService() and stopServie() calls had a redundant check for
the incoming user ID being valid, but with its own custom implementation
that doesn't match the normal handleIncomingUser flow.  In fact, for
both of these we are going to do handleIncomingUser anyway when we get
to retrieveServiceLocked(), so there was just no need for this.

Change-Id: I14409a03781a14a5f1a786aceb31dcc77efb062c
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 8b7fd8e..ab9d9bd 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -12367,7 +12367,6 @@
         synchronized(this) {
             final int callingPid = Binder.getCallingPid();
             final int callingUid = Binder.getCallingUid();
-            checkValidCaller(callingUid, userId);
             final long origId = Binder.clearCallingIdentity();
             ComponentName res = mServices.startServiceLocked(caller, service,
                     resolvedType, callingPid, callingUid, userId);
@@ -12397,8 +12396,6 @@
             throw new IllegalArgumentException("File descriptors passed in Intent");
         }
 
-        checkValidCaller(Binder.getCallingUid(), userId);
-
         synchronized(this) {
             return mServices.stopServiceLocked(caller, service, resolvedType, userId);
         }
@@ -16389,13 +16386,6 @@
         return mUserManager;
     }
 
-    private void checkValidCaller(int uid, int userId) {
-        if (UserHandle.getUserId(uid) == userId || uid == Process.SYSTEM_UID || uid == 0) return;
-
-        throw new SecurityException("Caller uid=" + uid
-                + " is not privileged to communicate with user=" + userId);
-    }
-
     private int applyUserId(int uid, int userId) {
         return UserHandle.getUid(userId, uid);
     }