Loading core/java/android/app/ForegroundServiceTypePolicy.java +36 −1 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import android.os.UserHandle; import android.permission.PermissionCheckerManager; import android.permission.PermissionManager; import android.provider.DeviceConfig; import android.telecom.TelecomManager; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; Loading Loading @@ -350,8 +351,13 @@ public abstract class ForegroundServiceTypePolicy { new RegularPermission(Manifest.permission.FOREGROUND_SERVICE_PHONE_CALL) }, true), new ForegroundServiceTypePermissions(new ForegroundServiceTypePermission[] { // For VoIP applications using the Telecom APIs. new RegularPermission(Manifest.permission.MANAGE_OWN_CALLS), new RolePermission(RoleManager.ROLE_DIALER) // For the user's chosen dialer app. new RolePermission(RoleManager.ROLE_DIALER), // For the OEM's preloaded Dialer (used for emergency calls even when the user has // chosen a different dialer app as their default). new SystemDialerPermission() }, false), FGS_TYPE_PERM_ENFORCEMENT_FLAG_PHONE_CALL /* permissionEnforcementFlag */, true /* permissionEnforcementFlagDefaultValue */, Loading Loading @@ -1304,6 +1310,35 @@ public abstract class ForegroundServiceTypePolicy { } } /** * Represents the pre-loaded system dialer which is preloaded on a device. Used in the * {@link #FGS_TYPE_POLICY_PHONE_CALL} to also allow the system dialer to be allowed to use a * phone call FGS. * <p> * When the user places an emergency call, Telecom will always bind to the pre-loaded system * dialer instead of the one filling the {@link RoleManager#ROLE_DIALER} role. If the user has * chosen a different app to fill that role, the system dialer will not be able to start its * phone call FGS. */ static class SystemDialerPermission extends ForegroundServiceTypePermission { SystemDialerPermission() { super("System Dialer"); } @Override @PackageManager.PermissionResult public int checkPermission(@NonNull Context context, int callerUid, int callerPid, @NonNull String packageName, boolean allowWhileInUse) { if (!android.app.Flags.systemDialerPhoneCallFgsGrant()) { return PERMISSION_DENIED; } final TelecomManager tm = context.getSystemService(TelecomManager.class); final String systemDialerPackage = tm.getSystemDialerPackage(); return systemDialerPackage != null && systemDialerPackage.equals(packageName) ? PERMISSION_GRANTED : PERMISSION_DENIED; } } /** * This represents a special Android permission to be required for accessing usb devices. */ Loading core/java/android/app/activity_manager.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -161,3 +161,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { namespace: "telecom" name: "system_dialer_phone_call_fgs_grant" description: "Ensures that the system dialer app can use a phone call fgs." bug: "425971621" metadata { purpose: PURPOSE_BUGFIX } } Loading
core/java/android/app/ForegroundServiceTypePolicy.java +36 −1 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import android.os.UserHandle; import android.permission.PermissionCheckerManager; import android.permission.PermissionManager; import android.provider.DeviceConfig; import android.telecom.TelecomManager; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; Loading Loading @@ -350,8 +351,13 @@ public abstract class ForegroundServiceTypePolicy { new RegularPermission(Manifest.permission.FOREGROUND_SERVICE_PHONE_CALL) }, true), new ForegroundServiceTypePermissions(new ForegroundServiceTypePermission[] { // For VoIP applications using the Telecom APIs. new RegularPermission(Manifest.permission.MANAGE_OWN_CALLS), new RolePermission(RoleManager.ROLE_DIALER) // For the user's chosen dialer app. new RolePermission(RoleManager.ROLE_DIALER), // For the OEM's preloaded Dialer (used for emergency calls even when the user has // chosen a different dialer app as their default). new SystemDialerPermission() }, false), FGS_TYPE_PERM_ENFORCEMENT_FLAG_PHONE_CALL /* permissionEnforcementFlag */, true /* permissionEnforcementFlagDefaultValue */, Loading Loading @@ -1304,6 +1310,35 @@ public abstract class ForegroundServiceTypePolicy { } } /** * Represents the pre-loaded system dialer which is preloaded on a device. Used in the * {@link #FGS_TYPE_POLICY_PHONE_CALL} to also allow the system dialer to be allowed to use a * phone call FGS. * <p> * When the user places an emergency call, Telecom will always bind to the pre-loaded system * dialer instead of the one filling the {@link RoleManager#ROLE_DIALER} role. If the user has * chosen a different app to fill that role, the system dialer will not be able to start its * phone call FGS. */ static class SystemDialerPermission extends ForegroundServiceTypePermission { SystemDialerPermission() { super("System Dialer"); } @Override @PackageManager.PermissionResult public int checkPermission(@NonNull Context context, int callerUid, int callerPid, @NonNull String packageName, boolean allowWhileInUse) { if (!android.app.Flags.systemDialerPhoneCallFgsGrant()) { return PERMISSION_DENIED; } final TelecomManager tm = context.getSystemService(TelecomManager.class); final String systemDialerPackage = tm.getSystemDialerPackage(); return systemDialerPackage != null && systemDialerPackage.equals(packageName) ? PERMISSION_GRANTED : PERMISSION_DENIED; } } /** * This represents a special Android permission to be required for accessing usb devices. */ Loading
core/java/android/app/activity_manager.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -161,3 +161,13 @@ flag { purpose: PURPOSE_BUGFIX } } flag { namespace: "telecom" name: "system_dialer_phone_call_fgs_grant" description: "Ensures that the system dialer app can use a phone call fgs." bug: "425971621" metadata { purpose: PURPOSE_BUGFIX } }