title: System application in Android
body: <p>How exactly Android determines if an application is a <code>system application</code> with root privilege?</p>
  
  <p>I know that for such applications, <code>ApplicationInfo.FLAG_SYSTEM</code> will be enabled, and those applications must declare shared user id as <code>"android.uid.system"</code> in their <code>Manifest</code> file.
  Along with that there is another criteria, where an application located in <code>/system/app</code> should also be treated as System application.</p>
  
  <p>I searched the source code for PackageMangerService.java in AOSP where I observed that if shared user id is <code>android.uid.system</code> then the application is assigned the flag as <code>FLAG_SYSTEM</code>.</p>
  
  <p>But I guess, the applications which are available in <code>/system/app</code> do not contain the shared user id as <code>android.uid.system</code> then how do they get this flag <code>FLAG_SYSTEM</code> enabled for them?</p>