How to get `WRITE_EMBEDDED_SUBSCRIPTIONS `permission on android development

1.1k Views Asked by At

How do I get the permissions for WRITE_EMBEDDED_SUBSCRIPTIONS?

In android development, I'm developing a feature to download eSIM devices directly.

However, the WRITE_EMBEDDED_SUBSCRIPTIONS permission mentioned in the documentation always returns false. How can I resolve this?

I have added the following code to AndroidManifest.xml.

<uses-permission android:name="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"/>

This is how permission is called

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    if (requestCode == PERMISSION_REQUEST_CODE) {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
          Log.d("TAG", "Permitted")
        }
        { else {
          // Always returned false here
          Log.d("TAG", "Not Permitted")
        }
    }
  }
.
.
.


// Called permission request
checkSelfPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") == PackageManager.PERMISSION_GRANTED
requestPermissions(arrayOf("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"), PERMISSION_REQUEST_CODE)

The source document I'm looking at is here. https://source.android.com/devices/tech/connect/esim-euicc-api?hl=ja

2

There are 2 best solutions below

0
On

You can not get this permission, because it's only granted to system apps but you don't need this permission to install/delete/enable an eSIM, instead of this permission you should have the carrier privileges on the specific eSIM profile. So that you will be able to manage the eSIMs that you have the carrier privileges.

See more about the carrier privilege mechanism.

0
On

I answered a similar question here.

The app you want to give the WRITE_EMBEDDED_SUBSCRIPTIONS permission to can be indicated in the metadata that is sent from the SM-DP+ just prior to the installation. The app's signature is provided and this works in a similar way to how UICC Carrier Privileges are enabled for a physical SIM.