Loading src/com/android/server/telecom/InCallController.java +29 −9 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ public class InCallController extends CallsManagerListenerBase implements public static final String SET_IN_CALL_ADAPTER_ERROR_MSG = "Exception thrown while setting the in-call adapter."; private final com.android.internal.telephony.flags.FeatureFlags mTelephonyFeatureFlags; @VisibleForTesting public void setAnomalyReporterAdapter(AnomalyReporterAdapter mAnomalyReporterAdapter){ mAnomalyReporter = mAnomalyReporterAdapter; Loading Loading @@ -1246,6 +1248,16 @@ public class InCallController extends CallsManagerListenerBase implements SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper, CarModeTracker carModeTracker, ClockProxy clockProxy, FeatureFlags featureFlags) { this(context, lock, callsManager, systemStateHelper, defaultDialerCache, timeoutsAdapter, emergencyCallHelper, carModeTracker, clockProxy, featureFlags, null); } @VisibleForTesting public InCallController(Context context, TelecomSystem.SyncRoot lock, CallsManager callsManager, SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper, CarModeTracker carModeTracker, ClockProxy clockProxy, FeatureFlags featureFlags, com.android.internal.telephony.flags.FeatureFlags telephonyFeatureFlags) { mContext = context; mAppOpsManager = context.getSystemService(AppOpsManager.class); mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class); Loading @@ -1263,6 +1275,12 @@ public class InCallController extends CallsManagerListenerBase implements userAddedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mContext.registerReceiver(mUserAddedReceiver, userAddedFilter); mFeatureFlags = featureFlags; if (telephonyFeatureFlags != null) { mTelephonyFeatureFlags = telephonyFeatureFlags; } else { mTelephonyFeatureFlags = new com.android.internal.telephony.flags.FeatureFlagsImpl(); } } private void restrictPhoneCallOps() { Loading Loading @@ -1875,13 +1893,14 @@ public class InCallController extends CallsManagerListenerBase implements @VisibleForTesting public void bindToServices(Call call) { UserHandle userFromCall = getUserFromCall(call); UserHandle parentUser = null; UserManager um = mContext.getSystemService(UserManager.class); if (um.isManagedProfile(userFromCall.getIdentifier())) { UserHandle parentUser = mTelephonyFeatureFlags.workProfileApiSplit() ? um.getProfileParent(userFromCall) : null; if (!mTelephonyFeatureFlags.workProfileApiSplit() && um.isManagedProfile(userFromCall.getIdentifier())) { parentUser = um.getProfileParent(userFromCall); Log.i(this, "child:%s parent:%s", userFromCall, parentUser); } Log.i(this, "child:%s parent:%s", userFromCall, parentUser); if (!mInCallServiceConnections.containsKey(userFromCall)) { InCallServiceConnection dialerInCall = null; Loading Loading @@ -1954,19 +1973,20 @@ public class InCallController extends CallsManagerListenerBase implements private void updateNonUiInCallServices(Call call) { UserHandle userFromCall = getUserFromCall(call); UserHandle parentUser = null; UserManager um = mContext.getSystemService(UserManager.class); if(um.isManagedProfile(userFromCall.getIdentifier())) { UserHandle parentUser = mTelephonyFeatureFlags.workProfileApiSplit() ? um.getProfileParent(userFromCall) : null; if (!mTelephonyFeatureFlags.workProfileApiSplit() && um.isManagedProfile(userFromCall.getIdentifier())) { parentUser = um.getProfileParent(userFromCall); } List<InCallServiceInfo> nonUIInCallComponents = getInCallServiceComponents(userFromCall, IN_CALL_SERVICE_TYPE_NON_UI); List<InCallServiceInfo> nonUIInCallComponentsForParent = new ArrayList<>(); if(parentUser != null) { if(parentUser != null) { //also get Non-UI services using parent handle. nonUIInCallComponentsForParent = getInCallServiceComponents(parentUser, IN_CALL_SERVICE_TYPE_NON_UI); Loading tests/src/com/android/server/telecom/tests/InCallControllerTests.java +11 −8 Original line number Diff line number Diff line Loading @@ -206,6 +206,7 @@ public class InCallControllerTests extends TelecomTestCase { private UserHandle mChildUserHandle = UserHandle.of(10); private @Mock Call mMockChildUserCall; private UserHandle mParentUserHandle = UserHandle.of(1); private @Mock com.android.internal.telephony.flags.FeatureFlags mTelephonyFeatureFlags; @Override @Before Loading Loading @@ -235,9 +236,11 @@ public class InCallControllerTests extends TelecomTestCase { mMockPermissionInfo); when(mMockContext.getAttributionSource()).thenReturn(new AttributionSource(Process.myUid(), "com.android.server.telecom.tests", null)); when(mTelephonyFeatureFlags.workProfileApiSplit()).thenReturn(false); mInCallController = new InCallController(mMockContext, mLock, mMockCallsManager, mMockSystemStateHelper, mDefaultDialerCache, mTimeoutsAdapter, mEmergencyCallHelper, mCarModeTracker, mClockProxy, mFeatureFlags); mEmergencyCallHelper, mCarModeTracker, mClockProxy, mFeatureFlags, mTelephonyFeatureFlags); // Capture the broadcast receiver registered. doAnswer(invocation -> { mRegisteredReceiver = invocation.getArgument(0); Loading Loading @@ -1904,7 +1907,7 @@ public class InCallControllerTests extends TelecomTestCase { when(call.getId()).thenReturn("TC@" + id); } private void setupMocksForWorkProfileTest() { private void setupMocksForProfileTest() { when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); when(mMockCallsManager.isInEmergencyCall()).thenReturn(false); when(mMockChildUserCall.isIncoming()).thenReturn(false); Loading @@ -1920,9 +1923,9 @@ public class InCallControllerTests extends TelecomTestCase { when(mMockUserInfo.getUserHandle()).thenReturn(mParentUserHandle); when(mMockChildUserInfo.getUserHandle()).thenReturn(mChildUserHandle); when(mMockUserInfo.isManagedProfile()).thenReturn(false); when(mMockChildUserInfo.isManagedProfile()).thenReturn(true); when(mMockChildUserInfo.isManagedProfile()).thenReturn(false); when(mMockChildUserCall.getAssociatedUser()).thenReturn(mChildUserHandle); when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mChildUserHandle); when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mParentUserHandle); when(mMockUserManager.getProfileParent(mChildUserHandle.getIdentifier())).thenReturn( mMockUserInfo); when(mMockUserManager.getProfileParent(mChildUserHandle)).thenReturn(mParentUserHandle); Loading @@ -1930,14 +1933,14 @@ public class InCallControllerTests extends TelecomTestCase { mMockUserInfo); when(mMockUserManager.getUserInfo(eq(mChildUserHandle.getIdentifier()))).thenReturn( mMockChildUserInfo); when(mMockUserManager.isManagedProfile(mChildUserHandle.getIdentifier())).thenReturn(true); when(mMockUserManager.isManagedProfile(mParentUserHandle.getIdentifier())).thenReturn( false); when(mTelephonyFeatureFlags.workProfileApiSplit()).thenReturn(true); } @Test public void testManagedProfileCallQueriesIcsUsingParentUserToo() throws Exception { setupMocksForWorkProfileTest(); public void testProfileCallQueriesIcsUsingParentUserToo() throws Exception { setupMocksForProfileTest(); setupMockPackageManager(true /* default */, true /* system */, false /* external calls */); setupMockPackageManager(true /* default */, true /*useNonUiInCalls*/, true /*useAppOpNonUiInCalls*/, Loading @@ -1946,7 +1949,7 @@ public class InCallControllerTests extends TelecomTestCase { true /*includeSelfManagedCallsInCarModeDialer*/, true /*includeSelfManagedCallsInNonUi*/); //pass in call by child/work-profileuser //pass in call by child/profile user mInCallController.bindToServices(mMockChildUserCall); // Verify that queryIntentServicesAsUser is also called with parent handle Loading Loading
src/com/android/server/telecom/InCallController.java +29 −9 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ public class InCallController extends CallsManagerListenerBase implements public static final String SET_IN_CALL_ADAPTER_ERROR_MSG = "Exception thrown while setting the in-call adapter."; private final com.android.internal.telephony.flags.FeatureFlags mTelephonyFeatureFlags; @VisibleForTesting public void setAnomalyReporterAdapter(AnomalyReporterAdapter mAnomalyReporterAdapter){ mAnomalyReporter = mAnomalyReporterAdapter; Loading Loading @@ -1246,6 +1248,16 @@ public class InCallController extends CallsManagerListenerBase implements SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper, CarModeTracker carModeTracker, ClockProxy clockProxy, FeatureFlags featureFlags) { this(context, lock, callsManager, systemStateHelper, defaultDialerCache, timeoutsAdapter, emergencyCallHelper, carModeTracker, clockProxy, featureFlags, null); } @VisibleForTesting public InCallController(Context context, TelecomSystem.SyncRoot lock, CallsManager callsManager, SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache, Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper, CarModeTracker carModeTracker, ClockProxy clockProxy, FeatureFlags featureFlags, com.android.internal.telephony.flags.FeatureFlags telephonyFeatureFlags) { mContext = context; mAppOpsManager = context.getSystemService(AppOpsManager.class); mSensorPrivacyManager = context.getSystemService(SensorPrivacyManager.class); Loading @@ -1263,6 +1275,12 @@ public class InCallController extends CallsManagerListenerBase implements userAddedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mContext.registerReceiver(mUserAddedReceiver, userAddedFilter); mFeatureFlags = featureFlags; if (telephonyFeatureFlags != null) { mTelephonyFeatureFlags = telephonyFeatureFlags; } else { mTelephonyFeatureFlags = new com.android.internal.telephony.flags.FeatureFlagsImpl(); } } private void restrictPhoneCallOps() { Loading Loading @@ -1875,13 +1893,14 @@ public class InCallController extends CallsManagerListenerBase implements @VisibleForTesting public void bindToServices(Call call) { UserHandle userFromCall = getUserFromCall(call); UserHandle parentUser = null; UserManager um = mContext.getSystemService(UserManager.class); if (um.isManagedProfile(userFromCall.getIdentifier())) { UserHandle parentUser = mTelephonyFeatureFlags.workProfileApiSplit() ? um.getProfileParent(userFromCall) : null; if (!mTelephonyFeatureFlags.workProfileApiSplit() && um.isManagedProfile(userFromCall.getIdentifier())) { parentUser = um.getProfileParent(userFromCall); Log.i(this, "child:%s parent:%s", userFromCall, parentUser); } Log.i(this, "child:%s parent:%s", userFromCall, parentUser); if (!mInCallServiceConnections.containsKey(userFromCall)) { InCallServiceConnection dialerInCall = null; Loading Loading @@ -1954,19 +1973,20 @@ public class InCallController extends CallsManagerListenerBase implements private void updateNonUiInCallServices(Call call) { UserHandle userFromCall = getUserFromCall(call); UserHandle parentUser = null; UserManager um = mContext.getSystemService(UserManager.class); if(um.isManagedProfile(userFromCall.getIdentifier())) { UserHandle parentUser = mTelephonyFeatureFlags.workProfileApiSplit() ? um.getProfileParent(userFromCall) : null; if (!mTelephonyFeatureFlags.workProfileApiSplit() && um.isManagedProfile(userFromCall.getIdentifier())) { parentUser = um.getProfileParent(userFromCall); } List<InCallServiceInfo> nonUIInCallComponents = getInCallServiceComponents(userFromCall, IN_CALL_SERVICE_TYPE_NON_UI); List<InCallServiceInfo> nonUIInCallComponentsForParent = new ArrayList<>(); if(parentUser != null) { if(parentUser != null) { //also get Non-UI services using parent handle. nonUIInCallComponentsForParent = getInCallServiceComponents(parentUser, IN_CALL_SERVICE_TYPE_NON_UI); Loading
tests/src/com/android/server/telecom/tests/InCallControllerTests.java +11 −8 Original line number Diff line number Diff line Loading @@ -206,6 +206,7 @@ public class InCallControllerTests extends TelecomTestCase { private UserHandle mChildUserHandle = UserHandle.of(10); private @Mock Call mMockChildUserCall; private UserHandle mParentUserHandle = UserHandle.of(1); private @Mock com.android.internal.telephony.flags.FeatureFlags mTelephonyFeatureFlags; @Override @Before Loading Loading @@ -235,9 +236,11 @@ public class InCallControllerTests extends TelecomTestCase { mMockPermissionInfo); when(mMockContext.getAttributionSource()).thenReturn(new AttributionSource(Process.myUid(), "com.android.server.telecom.tests", null)); when(mTelephonyFeatureFlags.workProfileApiSplit()).thenReturn(false); mInCallController = new InCallController(mMockContext, mLock, mMockCallsManager, mMockSystemStateHelper, mDefaultDialerCache, mTimeoutsAdapter, mEmergencyCallHelper, mCarModeTracker, mClockProxy, mFeatureFlags); mEmergencyCallHelper, mCarModeTracker, mClockProxy, mFeatureFlags, mTelephonyFeatureFlags); // Capture the broadcast receiver registered. doAnswer(invocation -> { mRegisteredReceiver = invocation.getArgument(0); Loading Loading @@ -1904,7 +1907,7 @@ public class InCallControllerTests extends TelecomTestCase { when(call.getId()).thenReturn("TC@" + id); } private void setupMocksForWorkProfileTest() { private void setupMocksForProfileTest() { when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager); when(mMockCallsManager.isInEmergencyCall()).thenReturn(false); when(mMockChildUserCall.isIncoming()).thenReturn(false); Loading @@ -1920,9 +1923,9 @@ public class InCallControllerTests extends TelecomTestCase { when(mMockUserInfo.getUserHandle()).thenReturn(mParentUserHandle); when(mMockChildUserInfo.getUserHandle()).thenReturn(mChildUserHandle); when(mMockUserInfo.isManagedProfile()).thenReturn(false); when(mMockChildUserInfo.isManagedProfile()).thenReturn(true); when(mMockChildUserInfo.isManagedProfile()).thenReturn(false); when(mMockChildUserCall.getAssociatedUser()).thenReturn(mChildUserHandle); when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mChildUserHandle); when(mMockCallsManager.getCurrentUserHandle()).thenReturn(mParentUserHandle); when(mMockUserManager.getProfileParent(mChildUserHandle.getIdentifier())).thenReturn( mMockUserInfo); when(mMockUserManager.getProfileParent(mChildUserHandle)).thenReturn(mParentUserHandle); Loading @@ -1930,14 +1933,14 @@ public class InCallControllerTests extends TelecomTestCase { mMockUserInfo); when(mMockUserManager.getUserInfo(eq(mChildUserHandle.getIdentifier()))).thenReturn( mMockChildUserInfo); when(mMockUserManager.isManagedProfile(mChildUserHandle.getIdentifier())).thenReturn(true); when(mMockUserManager.isManagedProfile(mParentUserHandle.getIdentifier())).thenReturn( false); when(mTelephonyFeatureFlags.workProfileApiSplit()).thenReturn(true); } @Test public void testManagedProfileCallQueriesIcsUsingParentUserToo() throws Exception { setupMocksForWorkProfileTest(); public void testProfileCallQueriesIcsUsingParentUserToo() throws Exception { setupMocksForProfileTest(); setupMockPackageManager(true /* default */, true /* system */, false /* external calls */); setupMockPackageManager(true /* default */, true /*useNonUiInCalls*/, true /*useAppOpNonUiInCalls*/, Loading @@ -1946,7 +1949,7 @@ public class InCallControllerTests extends TelecomTestCase { true /*includeSelfManagedCallsInCarModeDialer*/, true /*includeSelfManagedCallsInNonUi*/); //pass in call by child/work-profileuser //pass in call by child/profile user mInCallController.bindToServices(mMockChildUserCall); // Verify that queryIntentServicesAsUser is also called with parent handle Loading