AOSP Privileged vs System app

http://stackoverflow.com/questions/19868138/aosp-privileged-vs-system-app




So in 4.3 there was a concept of System applications. Apks that were placed in System/app were given system privellages. As of 4.4, there is a new concept of Privellaged app. Privellaged apps are stored in system/priv-app and seem to be treated differently. If you look in the AOSP Source code, under PackageManagerService, you will see new methods such as

static boolean locationIsPrivileged(File path) {
    try {
        final String privilegedAppDir = new File(Environment.getRootDirectory(), "priv-app")
                .getCanonicalPath();
        return path.getCanonicalPath().startsWith(privilegedAppDir);
    } catch (IOException e) {
        Slog.e(TAG, "Unable to access code path " + path);
    }
    return false;
}

So here is an example of a situation where these differ.

public final void addActivity(PackageParser.Activity a, String type) {
...
if (!systemApp && intent.getPriority() > 0 && "activity".equals(type)) {
                intent.setPriority(0);
                Log.w(TAG, "Package " + a.info.applicationInfo.packageName + " has activity "
                        + a.className + " with priority > 0, forcing to 0");
            }
...

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 who's priority is higher than 0, unless you are a system app. This does NOT preclude privileged apps as far as I can tell (theres a lot of logic here, i may be wrong.)

My question is what exactly does this imply? If my app is privellaged, but not system, what difference will that make? In PackageManagerService 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:

if locationIsPrivilleged: app.flags |= FLAG_SYSTEM

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.

share | improve this question
  add comment

2 Answers

up vote 6 down vote accepted

So after some digging, it's clear that apps in priv-app get system privileges, the same way that old apps used to get system privileges by being in system-app. The only official Google documentation I could find on this came in the form of a commit message:

Commit hash: ccbf84f44c9e6a5ed3c08673614826bb237afc54

Some system apps are more system than others

"signatureOrSystem" permissions are no longer available to all apps residing en the /system partition. Instead, there is a new /system/priv-app directory, and only apps whose APKs are in that directory are allowed to use signatureOrSystem permissions without sharing the platform cert. This will reduce the surface area for possible exploits of system- bundled applications to try to gain access to permission-guarded operations.

The ApplicationInfo.FLAG_SYSTEM flag continues to mean what it is says in the documentation: it indicates that the application apk was bundled on the /system partition. A new hidden flag FLAG_PRIVILEGED has been introduced that reflects the actual right to access these permissions.

share | improve this answer
 
 
stackoverflow.com/a/19813031/1306452 –   Andrew T.  Jan 28 at 20:22
 
So if from 4.4, only /system/priv-app applications can get SignatureOrSystem permissions, what's the implication for privileges of apps that are kept in /system/app/ ? Thanks. –   Jake Feb 22 at 12:12 
 
More specifically, what's the purpose of /system/app/ folder in 4.4 ? Thanks. –   Jake  Feb 22 at 12:18 
1  
@Jake Apps put in system/app are typically things that you might want to have less permissions. for instance, you probably don't want your email client or random vendor bloatware to be able to change your system security settings. –   Andrew T.  Feb 22 at 18:19
2  
Apps in system/app have no special permissions. They don't differ from 3rd party apps unless they are signed with the system key (hence SigOrSystem check). As for the methods that helped, theres a variety. I started grepping for priv-app, and then followed that to PackageManagerService which now refers to Privilleged packages. –   Andrew T.  Feb 23 at 5:10


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值