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

Commit 922ef107 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Skip system dialer FGS grant if no dialer role is present.

Ensure we don't try to do the grant if there is no dialer role on the
device.

Test: updated test assumptions to match grant behavior.
Flag: android.app.system_dialer_phone_call_fgs_grant
Bug: 435713951
Bug: 425971621
Change-Id: I40174ff112ea5373fddb6573ccbdd84ee76e500a
parent 651dc956
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1328,6 +1328,13 @@ public abstract class ForegroundServiceTypePolicy {
            if (!android.app.Flags.systemDialerPhoneCallFgsGrant()) {
                return PERMISSION_DENIED;
            }

            final RoleManager roleManager = context.getSystemService(RoleManager.class);
            if (!roleManager.isRoleAvailable(RoleManager.ROLE_DIALER)) {
                // If the Dialer role does not exist on the device, then there will not be a system
                // dialer which can use the phone call FGS type.
                return PERMISSION_DENIED;
            }
            final TelecomManager tm = context.getSystemService(TelecomManager.class);
            final String systemDialerPackage = tm.getSystemDialerPackage();
            return systemDialerPackage != null && systemDialerPackage.equals(packageName)