Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63a0f70a authored by Hai Zhang's avatar Hai Zhang
Browse files

Add RoleControllerManager.isApplicationVisibleForRole().

Settings doesn't actually need to know whether an application
qualifies for a role, but only whether the default app setting should
be visible for an application. Qualification and visibility differs in
cases such as FallbackHome inside Settings which is a qualifying home
activity but should never be shown in default apps UI.

Fixes: 138636320
Test: manual
Change-Id: I55a4c40560bad853494680c970f798337b80b582
parent e64bb2f9
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -409,6 +409,27 @@ public class RoleControllerServiceImpl extends RoleControllerService {
        return role.isPackageQualified(packageName, this);
    }

    @Override
    public boolean onIsApplicationVisibleForRole(@NonNull String roleName,
            @NonNull String packageName) {
        Role role = Roles.get(this).get(roleName);
        if (role == null) {
            return false;
        }
        if (!role.isAvailable(this)) {
            return false;
        }
        if (!role.isPackageQualified(packageName, this)) {
            return false;
        }
        ApplicationInfo applicationInfo = PackageUtils.getApplicationInfo(packageName, this);
        if (applicationInfo == null || !role.isApplicationVisibleAsUser(applicationInfo,
                Process.myUserHandle(), this)) {
            return false;
        }
        return true;
    }

    @Override
    public boolean onIsRoleVisible(@NonNull String roleName) {
        Role role = Roles.get(this).get(roleName);