CarrierService.onLoadConfig not being called even after gaining Carrier Privileges

368 Views Asked by At

I am working on a feature where i need to update some CarrierConfig for our subscriptions once the Sim is being installed and the app gains the Carrier Privileges. Now the app successfully gains the Carrier Prviliges but somehow CarrierService is not being executed. neither the onLoadConfig method is called.

Below is my service

class SampleCarrierConfigService : CarrierService() {
    override fun onLoadConfig(id: CarrierIdentifier?): PersistableBundle {
        val config = PersistableBundle()
        config.putBoolean(
            CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL, true
        )
        config.putBoolean(
            CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL, false
        )
        config.putInt(CarrierConfigManager.KEY_VOLTE_REPLACEMENT_RAT_INT, 6)
        // Check CarrierIdentifier and add more config if needed…
        return config
    }

    companion object {
        private const val TAG = "SampleCarrierConfig"
    }

    init {
        Log.d(TAG, "Service created")
    }
}

and here is how i have registered it in the manifest

<service
            android:name=".SampleCarrierConfigService"
            android:label="carrier_config_service"
            android:permission="android.permission.BIND_CARRIER_SERVICES">
            <intent-filter>
                <action android:name="android.service.carrier.CarrierService" />
            </intent-filter>
            <meta-data
                android:name="android.service.carrier.LONG_LIVED_BINDING"
                android:value="true" />
        </service>
1

There are 1 best solutions below

1
On

It's a privileged permission.

You can refer to the code below.

https://android.googlesource.com/platform/packages/apps/CarrierConfig/+/refs/heads/master/Android.bp

android_app { name: "CarrierConfig", srcs: ["src/**/*.java"], platform_apis: true, certificate: "platform", system_ext_specific: true, privileged: true, required: ["privapp_whitelist_com.android.carrierconfig"], optimize: { proguard_flags_files: ["proguard.flags"], }, aaptflags: ["--keep-raw-values"], }