Restrict access to the resolution PendingIntent created by
EuiccController to EuiccResolutionUiDispatcherActivity

Bug: 156097472
Bug: 155094269
Fix: 156097472
Test: Local, with jpd@'s PoC app
Change-Id: I76a9eb55d8321ea695594693580be468522e4de8
Merged-In: I76a9eb55d8321ea695594693580be468522e4de8
(cherry picked from commit 0126084de146b51a842d7604cddb3303f46cade7)
diff --git a/src/java/com/android/internal/telephony/euicc/EuiccController.java b/src/java/com/android/internal/telephony/euicc/EuiccController.java
index ca36cf0..c972afd 100644
--- a/src/java/com/android/internal/telephony/euicc/EuiccController.java
+++ b/src/java/com/android/internal/telephony/euicc/EuiccController.java
@@ -22,6 +22,7 @@
 import android.annotation.Nullable;
 import android.app.AppOpsManager;
 import android.app.PendingIntent;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ComponentInfo;
@@ -73,6 +74,11 @@
     private static final String EXTRA_EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTION =
             EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTION;
 
+    /** Restrictions limiting access to the PendingIntent */
+    private static final String RESOLUTION_ACTIVITY_PACKAGE_NAME = "com.android.phone";
+    private static final String RESOLUTION_ACTIVITY_CLASS_NAME =
+            "com.android.phone.euicc.EuiccResolutionUiDispatcherActivity";
+
     private static EuiccController sInstance;
 
     private final Context mContext;
@@ -955,6 +961,9 @@
     public void addResolutionIntent(Intent extrasIntent, String resolutionAction,
             String callingPackage, boolean confirmationCodeRetried, EuiccOperation op) {
         Intent intent = new Intent(EuiccManager.ACTION_RESOLVE_ERROR);
+        intent.setPackage(RESOLUTION_ACTIVITY_PACKAGE_NAME);
+        intent.setComponent(new ComponentName(
+                        RESOLUTION_ACTIVITY_PACKAGE_NAME, RESOLUTION_ACTIVITY_CLASS_NAME));
         intent.putExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_ACTION,
                 resolutionAction);
         intent.putExtra(EuiccService.EXTRA_RESOLUTION_CALLING_PACKAGE, callingPackage);