From cf9b399af719e4686d47e4dd854bdee108799d4e Mon Sep 17 00:00:00 2001 From: Pranav Madapurmath Date: Fri, 28 Apr 2023 18:17:18 +0000 Subject: [PATCH] Support notion of ECBM for work profiles. When we have all sims assigned to the work profile and the profile is paused, the admin would not be able to place or receive any calls going through those sims. However, when the primary user needs to place a MO emergency call, we allow them to use the work sim for this boundary case. Consequently, this enables ECBM for that sim where any MT non-emergency calls during the 5 minute period should not be rejected. If the work profile is disabled, the call needs to be accepted by the primary profile. EmergencyCallHelper already defines a notion of determining if we're in ECBM but it's also being tracked for MT emergency calls and is simply passing it up into ConnectionRequest. Instead, I've added in logic to keep track of the last MO emergency call while keeping the old logic intact. This is being leveraged in CallsManager#processIncomingCallIntent to determine if the phone account for the incoming call is currrently in ECBM, which would allow the call to go through to the primary user instead of failing. Note that MO non-emergency calls should still be rejected. The logic in InCallController where we determine the user to use in binding to the ICS needs to be modified to ensure we bind to the CURRENT_USER (aka primary user) when the work profile is disabled and we are in ECBM mode. Note that that MO emergency calls will never reach this line of logic as they would be rejected in the phone account selection phase so we can ensure that this is scoped to MT calls. Fixes: 279200068 Test: Manual with work profile enabled to ensure MT/MO emergency calls and non-emergency calls are routed to work profile dialer. Test: Manual with work profile disabled to ensure MT non-emergency calls are rejected when ECBM isn't enabled and allowed when it is enabled for the 5 minute time period. Test: Unit tests to ensure we reject the MT non-emergency calls when ECBM isn't enabled and accept when it is. Addded a test to ensure the binding to the ICS occurs on the CURRENT_USER. Change-Id: I48ef99e3a8ae35fcdee14364f54f18e54d16f45f --- core/java/android/provider/CallLog.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 77c00676878c4..ac6b2b23cdf56 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -1293,7 +1293,8 @@ public class CallLog { USER_MISSED_NO_VIBRATE, USER_MISSED_CALL_SCREENING_SERVICE_SILENCED, USER_MISSED_CALL_FILTERS_TIMEOUT, - USER_MISSED_NEVER_RANG + USER_MISSED_NEVER_RANG, + USER_MISSED_NOT_RUNNING }) @Retention(RetentionPolicy.SOURCE) public @interface MissedReason {} @@ -1390,6 +1391,13 @@ public class CallLog { */ public static final long USER_MISSED_NEVER_RANG = 1 << 23; + /** + * When {@link CallLog.Calls#TYPE} is {@link CallLog.Calls#MISSED_TYPE}, set this bit when + * the user receiving the call is not running (i.e. work profile paused). + * @hide + */ + public static final long USER_MISSED_NOT_RUNNING = 1 << 24; + /** * Where the {@link CallLog.Calls#TYPE} is {@link CallLog.Calls#MISSED_TYPE}, * indicates factors which may have lead the user to miss the call.