title: What is the difference between system apps and privileged apps on Android?
body: <p>So in 4.3 there was a concept of System applications. APKs that were placed in <code>/system/app</code> were given system privileges. As of 4.4, there is a new concept of &quot;privileged app&quot;. Privileged apps are stored in <code>/system/priv-app</code> directory and seem to be treated differently. If you look in the AOSP Source code, under <code>PackageManagerService</code>, you will see new methods such as</p>
  <pre><code>static boolean locationIsPrivileged(File path) {
      try {
          final String privilegedAppDir = new File(Environment.getRootDirectory(), &quot;priv-app&quot;)
                  .getCanonicalPath();
          return path.getCanonicalPath().startsWith(privilegedAppDir);
      } catch (IOException e) {
          Slog.e(TAG, &quot;Unable to access code path &quot; + path);
      }
      return false;
  }
  </code></pre>
  <p>So here is an example of a situation where these differ.</p>
  <pre><code>public final void addActivity(PackageParser.Activity a, String type) {
  ...
  if (!systemApp &amp;&amp; intent.getPriority() &gt; 0 &amp;&amp; &quot;activity&quot;.equals(type)) {
                  intent.setPriority(0);
                  Log.w(TAG, &quot;Package &quot; + a.info.applicationInfo.packageName + &quot; has activity &quot;
                          + a.className + &quot; with priority &gt; 0, forcing to 0&quot;);
              }
  ...
  </code></pre>
  <p>This affects the priority of any activities that are not defined as system applications. This seems to imply you can not add an activity to the package manager whose priority is higher than 0, unless you are a system app. This does <strong>not</strong> preclude privileged apps as far as I can tell (there is a lot of logic here, I may be wrong.).</p>
  <p>My question is what exactly does this imply? If my app is privileged, but not system, what difference will that make? In <code>PackageManagerService</code> you can find various things that differ between system and privileged apps, they are not exactly the same. There should be some kind of ideology behind privileged apps, otherwise they would have just said:</p>
  <pre><code>if locationIsPrivileged: app.flags |= FLAG_SYSTEM
  </code></pre>
  <p>and been done with it. This is a new concept, and I think it would be important to know the difference between these kinds of apps for anyone who is doing AOSP development as of 4.4.</p>