Use EXTRA_CALLING_PACKAGE for legacy change default dialer/SMS intents.

So that RequestRoleActivity can always know the calling package. This
is required to keep supporting pre-Q apps calling with
startActivity().

Bug: 137054465
Test: manual
Change-Id: I10c758fcadde8157a2d360a192accea75550a1dd
(cherry picked from commit dc683d3001a13ac69f428960dd9ef052e33ae9f6)
diff --git a/src/com/android/packageinstaller/role/ui/RequestRoleActivity.java b/src/com/android/packageinstaller/role/ui/RequestRoleActivity.java
index 8b56a22..c57dfef 100644
--- a/src/com/android/packageinstaller/role/ui/RequestRoleActivity.java
+++ b/src/com/android/packageinstaller/role/ui/RequestRoleActivity.java
@@ -199,7 +199,9 @@
         mRoleName = RoleManager.ROLE_DIALER;
         mPackageName = null;
 
-        String callingPackageName = getCallingPackage();
+        // Intent.EXTRA_CALLING_PACKAGE is set in PermissionPolicyService.Internal
+        // .isActionRemovedForCallingPackage() and can be trusted.
+        String callingPackageName = intent.getStringExtra(Intent.EXTRA_CALLING_PACKAGE);
         String extraPackageName = intent.getStringExtra(
                 TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME);
         if (Objects.equals(extraPackageName, callingPackageName)) {
@@ -240,7 +242,9 @@
         mRoleName = RoleManager.ROLE_SMS;
         mPackageName = null;
 
-        String callingPackageName = getCallingPackage();
+        // Intent.EXTRA_CALLING_PACKAGE is set in PermissionPolicyService.Internal
+        // .isActionRemovedForCallingPackage() and can be trusted.
+        String callingPackageName = intent.getStringExtra(Intent.EXTRA_CALLING_PACKAGE);
         String extraPackageName = intent.getStringExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME);
         if (extraPackageName == null) {
             // Launch the settings activity to show the list.