Android Framework: System service does not get permission(s)
<p>I added a system service (<strong>not</strong> an app) into the Android framework (hence running in the system_process). Via Binder.getCallingUid() I can determine the calling process/app. So far so good.
But if my service tries to use other system services (e.g. the LocationManager) a SecurityException is thrown because LocationManager thinks it is called by the original app that called my service.</p>

<p>From what I understood, system services have all permissions by default, so this should not be the case, should it?</p>

<blockquote>
  <p>From programming4.us/Mobile/1304.aspx:
  Binder services are free to make other
  binder calls, but these calls always
  occur with the service’s own identity
  (UID and PID) and not the identity of
  the caller.</p>
</blockquote>

<p>Here some code to illustrate the problem:</p>

<pre><code>public class MyService implements IInterface {

    public IBinder asBinder() {
        return mBinder;
    }

    private final IMyService.Stub mBinder = new IMyService.Stub() {

        public void doSomething() {
          int uid = Binder.getCallingUid(); // uid of the calling app
          int myUid = Process.myUid(); // my uid == 1000
          ...
          try {
           ILocationManager lm = ILocationManager.Stub.asInterface(ServiceManager.getService("location"));
           Location myLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
          } catch (Exception e) {
             SecurityException is thrown. Requires ACCESS_FINE_LOCATION
          }
        }

    };
}
</code></pre>

<p>Thanks in advance for any help or comments!</p>
