Managed configurations is null while creating work-profile

Shivam
Level 1.5: Cupcake

We are using Android management API to enroll managed devices. We have a custom app that is required for setup. For this app we also send managedConfigurations in the policy, some string data. To get the data are using RestrictionsManager in the app, so when the app is first opened from "required for setup" action, we create the RestrictionsManager's object to get the managedConfigurations but there is this issue that we face.

 

Scenarios:

When we create a fully managed device then their is not issue, custom app gets the managedConfigurations. But if we create a work-profile and set the custom app as required for setup and when the app try to get the  managedConfigurations then null is returned. 


This issue specifically rising in the Moto devices that we have for testing (Moto G32 devices). For some reason it works fine sometimes, so if we enroll the devices let's say for 15 times in work-profile, then it may work 3-5 times, this is not for sure, it may work and it may not work.

 

We also tried some of other manufacture's devices, OnePlus, Oppo, Realme, Redmi, etc and it seems to work fine in these devices, also tried in Genymotion emulators and it works fine there are well. However a Vivo device (Android 9) have the issue similar to Moto G32. 

 

Then to be sure, we also tried the Moto G32 with other MDM solution other than our own, and the Moto G32 enrolled fine there.

For some more context, we follow the documentation of Android and Management API to set the managementConfigurations and to get them in the app using RestrictionsManager. We are using the specified way to implement this feature.

 

So now, I am scratching my head to figure this out, what in the seven hells is going wrong. Please help out.

4 REPLIES 4

ReeceK
Google Community Team

Hey @Shivam.,

 

How's it going?

 

Mr. @jasonbayton , I wanted to loop you in to see if you have any insights or responses to this question. 😊

 

Thanks,

Reece

 

jasonbayton
Level 3.0: Honeycomb

I'd look at bug report & app logs to begin with, and compare it against that of a fully managed device. 

 

The behaviour should be identical and so I'm not sure why it'd return `null`.

 

@jeremy any thoughts?

mobisecte
Level 1.5: Cupcake

As of now, I am not able to pin-point the issue and still looking for some insight on the issue to resolve it.

 

I have uploaded the policy and bugreport of the a device that is enrolling in the work-profile without issue (Samsung) and of the particular device that is having the issue (Moto).

 

https://drive.google.com/drive/folders/1-iOVMhbCV5fC23yXIvyXB341eOqLJAoZ?usp=sharing

 

I used the same policy in both of the devices and in fully managed, along with the work-profile where we allow personal usage. Everywhere the policy works but in two of our new moto devices giving us the issue as I have explained in the post.

Here is the code that we use in the MainActivity of the app when it opens up to get the Restrictions.

fun setupRestrictions(){
        val restrictionManager = getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
        val appRestrictions = restrictionManager.applicationRestrictions

        if (appRestrictions != null){
            val id = appRestrictions.getString(AppDataStoreKey.id.key)
            val url = appRestrictions.getString(AppDataStoreKey.url.key)

            Log.d(TAG, "onCreate: Restrictions: ${Gson().toJson(appRestrictions)}")

            if (!id.isNullOrEmpty()){
                CoroutineScope(Dispatchers.IO).launch {
                    appDataStore.saveString(AppDataStoreKey.id, id)
                }
            }

            if (!url.isNullOrEmpty()){
                CoroutineScope(Dispatchers.IO).launch {
                    appDataStore.saveString(AppDataStoreKey.url, url)
                }
            }

            Log.d(TAG, "onCreate: Restrictions: \nID: $id \nURL: $url")
        }
    }



jeremy
Level 2.3: Gingerbread

I don't see why this is not working, just to clarify you're saying you've tested with another EMM, have you tested your app and managed configuration or only the enrolment ? I'm not sure if you're saying that the issue is with the managed configuration or with the enrolment itself ?

Best,