Loading src/com/android/server/telecom/TelecomServiceImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -1813,7 +1813,7 @@ public class TelecomServiceImpl { } mUserCallIntentProcessorFactory.create(mContext, userHandle) .processIntent( intent, callingPackage, isSelfManaged || intent, callingPackage, isSelfManaged, (hasCallAppOp && hasCallPermission), true /* isLocalInvocation */); } finally { Loading src/com/android/server/telecom/components/UserCallActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,8 @@ public class UserCallActivity extends Activity implements TelecomSystem.Componen // ActivityThread.ActivityClientRecord#intent directly. // Modifying directly may be a potential risk when relaunching this activity. new UserCallIntentProcessor(this, userHandle).processIntent(new Intent(intent), getCallingPackage(), true /* hasCallAppOp*/, false /* isLocalInvocation */); getCallingPackage(), false, true /* hasCallAppOp*/, false /* isLocalInvocation */); } finally { Log.endSession(); wakelock.release(); Loading src/com/android/server/telecom/components/UserCallIntentProcessor.java +36 −31 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ public class UserCallIntentProcessor { * * @param intent The intent. * @param callingPackageName The package name of the calling app. * @param isSelfManaged {@code true} if SelfManaged profile enabled. * @param canCallNonEmergency {@code true} if the caller is permitted to call non-emergency * numbers. * @param isLocalInvocation {@code true} if the caller is within the system service (i.e. the Loading @@ -79,19 +80,21 @@ public class UserCallIntentProcessor { * service resides. */ public void processIntent(Intent intent, String callingPackageName, boolean canCallNonEmergency, boolean isLocalInvocation) { boolean isSelfManaged, boolean canCallNonEmergency, boolean isLocalInvocation) { String action = intent.getAction(); if (Intent.ACTION_CALL.equals(action) || Intent.ACTION_CALL_PRIVILEGED.equals(action) || Intent.ACTION_CALL_EMERGENCY.equals(action)) { processOutgoingCallIntent(intent, callingPackageName, canCallNonEmergency, isLocalInvocation); processOutgoingCallIntent(intent, callingPackageName, isSelfManaged, canCallNonEmergency, isLocalInvocation); } } private void processOutgoingCallIntent(Intent intent, String callingPackageName, boolean canCallNonEmergency, boolean isLocalInvocation) { boolean isSelfManaged, boolean canCallNonEmergency, boolean isLocalInvocation) { Uri handle = intent.getData(); if (handle == null) return; String scheme = handle.getScheme(); Loading @@ -102,21 +105,22 @@ public class UserCallIntentProcessor { handle = Uri.fromParts(PhoneAccount.SCHEME_SIP, uriString, null); } // Check DISALLOW_OUTGOING_CALLS restriction. Note: We are skipping this check in a managed // profile user because this check can always be bypassed by copying and pasting the phone // number into the personal dialer. if(!isSelfManaged && !isLocalInvocation) { // Check DISALLOW_OUTGOING_CALLS restriction. Note: We are skipping this // check in a managed profile user because this check can always be bypassed // by copying and pasting the phone number into the personal dialer. if (!UserUtil.isManagedProfile(mContext, mUserHandle)) { // Only emergency calls are allowed for users with the DISALLOW_OUTGOING_CALLS // restriction. if (!TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) { final UserManager userManager = (UserManager) mContext.getSystemService( Context.USER_SERVICE); final UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (userManager.hasBaseUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, mUserHandle)) { showErrorDialogForRestrictedOutgoingCall(mContext, R.string.outgoing_call_not_allowed_user_restriction); Log.w(this, "Rejecting non-emergency phone call due to DISALLOW_OUTGOING_CALLS " + "restriction"); Log.w(this, "Rejecting non-emergency phone call " + "due to DISALLOW_OUTGOING_CALLS restriction"); return; } else if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, mUserHandle)) { Loading @@ -134,6 +138,7 @@ public class UserCallIntentProcessor { } } } } if (!canCallNonEmergency && !TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) { showErrorDialogForRestrictedOutgoingCall(mContext, Loading tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -1125,7 +1125,7 @@ public class TelecomServiceImplTest extends TelecomTestCase { boolean shouldNonEmergencyBeAllowed) { ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mUserCallIntentProcessor).processIntent(intentCaptor.capture(), anyString(), eq(shouldNonEmergencyBeAllowed), eq(true)); eq(false), eq(shouldNonEmergencyBeAllowed), eq(true)); Intent capturedIntent = intentCaptor.getValue(); assertEquals(Intent.ACTION_CALL, capturedIntent.getAction()); assertEquals(expectedHandle, capturedIntent.getData()); Loading @@ -1148,7 +1148,7 @@ public class TelecomServiceImplTest extends TelecomTestCase { } verify(mUserCallIntentProcessor, never()) .processIntent(any(Intent.class), anyString(), anyBoolean(), eq(true)); .processIntent(any(Intent.class), anyString(), eq(false), anyBoolean(), eq(true)); } @SmallTest Loading tests/src/com/android/server/telecom/tests/TelecomSystemTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -761,7 +761,7 @@ public class TelecomSystemTest extends TelecomTestCase { final UserHandle userHandle = initiatingUser; Context localAppContext = mComponentContextFixture.getTestDouble().getApplicationContext(); new UserCallIntentProcessor(localAppContext, userHandle).processIntent( actionCallIntent, null, true /* hasCallAppOp*/, false /* isLocal */); actionCallIntent, null, false, true /* hasCallAppOp*/, false /* isLocal */); // Wait for handler to start CallerInfo lookup. waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT); // Send the CallerInfo lookup reply. Loading Loading
src/com/android/server/telecom/TelecomServiceImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -1813,7 +1813,7 @@ public class TelecomServiceImpl { } mUserCallIntentProcessorFactory.create(mContext, userHandle) .processIntent( intent, callingPackage, isSelfManaged || intent, callingPackage, isSelfManaged, (hasCallAppOp && hasCallPermission), true /* isLocalInvocation */); } finally { Loading
src/com/android/server/telecom/components/UserCallActivity.java +2 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,8 @@ public class UserCallActivity extends Activity implements TelecomSystem.Componen // ActivityThread.ActivityClientRecord#intent directly. // Modifying directly may be a potential risk when relaunching this activity. new UserCallIntentProcessor(this, userHandle).processIntent(new Intent(intent), getCallingPackage(), true /* hasCallAppOp*/, false /* isLocalInvocation */); getCallingPackage(), false, true /* hasCallAppOp*/, false /* isLocalInvocation */); } finally { Log.endSession(); wakelock.release(); Loading
src/com/android/server/telecom/components/UserCallIntentProcessor.java +36 −31 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ public class UserCallIntentProcessor { * * @param intent The intent. * @param callingPackageName The package name of the calling app. * @param isSelfManaged {@code true} if SelfManaged profile enabled. * @param canCallNonEmergency {@code true} if the caller is permitted to call non-emergency * numbers. * @param isLocalInvocation {@code true} if the caller is within the system service (i.e. the Loading @@ -79,19 +80,21 @@ public class UserCallIntentProcessor { * service resides. */ public void processIntent(Intent intent, String callingPackageName, boolean canCallNonEmergency, boolean isLocalInvocation) { boolean isSelfManaged, boolean canCallNonEmergency, boolean isLocalInvocation) { String action = intent.getAction(); if (Intent.ACTION_CALL.equals(action) || Intent.ACTION_CALL_PRIVILEGED.equals(action) || Intent.ACTION_CALL_EMERGENCY.equals(action)) { processOutgoingCallIntent(intent, callingPackageName, canCallNonEmergency, isLocalInvocation); processOutgoingCallIntent(intent, callingPackageName, isSelfManaged, canCallNonEmergency, isLocalInvocation); } } private void processOutgoingCallIntent(Intent intent, String callingPackageName, boolean canCallNonEmergency, boolean isLocalInvocation) { boolean isSelfManaged, boolean canCallNonEmergency, boolean isLocalInvocation) { Uri handle = intent.getData(); if (handle == null) return; String scheme = handle.getScheme(); Loading @@ -102,21 +105,22 @@ public class UserCallIntentProcessor { handle = Uri.fromParts(PhoneAccount.SCHEME_SIP, uriString, null); } // Check DISALLOW_OUTGOING_CALLS restriction. Note: We are skipping this check in a managed // profile user because this check can always be bypassed by copying and pasting the phone // number into the personal dialer. if(!isSelfManaged && !isLocalInvocation) { // Check DISALLOW_OUTGOING_CALLS restriction. Note: We are skipping this // check in a managed profile user because this check can always be bypassed // by copying and pasting the phone number into the personal dialer. if (!UserUtil.isManagedProfile(mContext, mUserHandle)) { // Only emergency calls are allowed for users with the DISALLOW_OUTGOING_CALLS // restriction. if (!TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) { final UserManager userManager = (UserManager) mContext.getSystemService( Context.USER_SERVICE); final UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (userManager.hasBaseUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, mUserHandle)) { showErrorDialogForRestrictedOutgoingCall(mContext, R.string.outgoing_call_not_allowed_user_restriction); Log.w(this, "Rejecting non-emergency phone call due to DISALLOW_OUTGOING_CALLS " + "restriction"); Log.w(this, "Rejecting non-emergency phone call " + "due to DISALLOW_OUTGOING_CALLS restriction"); return; } else if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, mUserHandle)) { Loading @@ -134,6 +138,7 @@ public class UserCallIntentProcessor { } } } } if (!canCallNonEmergency && !TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) { showErrorDialogForRestrictedOutgoingCall(mContext, Loading
tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -1125,7 +1125,7 @@ public class TelecomServiceImplTest extends TelecomTestCase { boolean shouldNonEmergencyBeAllowed) { ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mUserCallIntentProcessor).processIntent(intentCaptor.capture(), anyString(), eq(shouldNonEmergencyBeAllowed), eq(true)); eq(false), eq(shouldNonEmergencyBeAllowed), eq(true)); Intent capturedIntent = intentCaptor.getValue(); assertEquals(Intent.ACTION_CALL, capturedIntent.getAction()); assertEquals(expectedHandle, capturedIntent.getData()); Loading @@ -1148,7 +1148,7 @@ public class TelecomServiceImplTest extends TelecomTestCase { } verify(mUserCallIntentProcessor, never()) .processIntent(any(Intent.class), anyString(), anyBoolean(), eq(true)); .processIntent(any(Intent.class), anyString(), eq(false), anyBoolean(), eq(true)); } @SmallTest Loading
tests/src/com/android/server/telecom/tests/TelecomSystemTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -761,7 +761,7 @@ public class TelecomSystemTest extends TelecomTestCase { final UserHandle userHandle = initiatingUser; Context localAppContext = mComponentContextFixture.getTestDouble().getApplicationContext(); new UserCallIntentProcessor(localAppContext, userHandle).processIntent( actionCallIntent, null, true /* hasCallAppOp*/, false /* isLocal */); actionCallIntent, null, false, true /* hasCallAppOp*/, false /* isLocal */); // Wait for handler to start CallerInfo lookup. waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT); // Send the CallerInfo lookup reply. Loading