2

I'm trying to write a test example of code for implementing eSim on a device using examples from the documentation https://source.android.com/devices/tech/connect/esim-overview?hl=en . The device supports eSim and the verification method mgr.isEnabled() returns true. But when I try to call the public load method downloadSubscription nothing happens, the onReceive method is not called.

static final String ACTION_DOWNLOAD_SUBSCRIPTION = "download_subscription";
static final String LPA_DECLARED_PERMISSION
    = "com.your.company.lpa.permission.BROADCAST";
BroadcastReceiver receiver =
        new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (!action.equals(intent.getAction())) {
                    return;
                }
                resultCode = getResultCode();
                detailedCode = intent.getIntExtra(
                    EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE,
                    0 /* defaultValue*/);
                resultIntent = intent;
            }
        };
context.registerReceiver(receiver,
        new IntentFilter(ACTION_DOWNLOAD_SUBSCRIPTION),
        LPA_DECLARED_PERMISSION /* broadcastPermission*/,
        null /* handler */);

// Download subscription asynchronously.
DownloadableSubscription sub = DownloadableSubscription
        .forActivationCode(code /* encodedActivationCode*/);
Intent intent = new Intent(action);
PendingIntent callbackIntent = PendingIntent.getBroadcast(
        getContext(), 0 /* requestCode */, intent,
        PendingIntent.FLAG_UPDATE_CURRENT);
mgr.downloadSubscription(sub, true /* switchAfterDownload */,
        callbackIntent);

And I don't quite understand what exactly needs to be specified here "com.your.company.lpa.permission.BROADCAST" I tried changing "com.your.company" to my package name but it doesn't work

Franck
  • 1,340
  • 2
  • 3
  • 15
Mad Ben
  • 21
  • 2
  • You need a rooted phone to implement this. You may try building an LPA app using AOSP and executing code there. Besides, if this is the only code you have got, there is a long way to go. – Farhan A. Rafi Dec 09 '21 at 13:34
  • "com.your.company.lpa.permission.BROADCAST" is the permission that the sender must hold to provide you the callback. Since the code you provided is from the Carrier app, the other app must be the LPA app. This is why there is lpa in the package name. – Farhan A. Rafi Jan 04 '22 at 08:59
  • 1
    Hi, have you found the solution? I am also experiencing the same thing. – Kyaw Soe Hein Jul 07 '22 at 03:07

1 Answers1

0

I was facing the same problem as you, what actually fix the problem was:

When you create a new intent like this, to pass as parameter to PendingIntent:

Intent intent = new Intent(action);

the action value should be the same as ACTION_DOWNLOAD_SUBSCRIPTION, I was passing different values on them, and you do not need to set up the LPA_DECLARED_PERMISSION, you can pass null, to the registerBroadcast.