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