I'm using the Android Mgmt. API to provision tablet devices. I have policies for each of these apps, and within the policies, I set a managedConfiguration for 'terminal,' which I was intending to be able to use this string value as the identifier for which 'terminal' I have setup. Here is the application policy:
"applications": [
{
"packageName": "packageName",
"installType": "KIOSK",
"defaultPermissionPolicy": "GRANT",
"managedConfiguration": {
"terminal": "2208"
}
},
My res > xml > app_restrictions.xml:
<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="facility"
android:title="@strings/facility_title"
android:restrictionType="string" />
<restriction
android:key="terminal"
android:title="@strings/terminal_title"
android:restrictionType="string" />
</restrictions>
A call to enterprises.applications.get shows that the managed config settings are recognized:
{
"key": "terminal",
"type": "STRING",
"title": "@strings/terminal_title"
}
Inside my app code(both following snippets are inside onCreate):
val config = this.getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
val identifier = TerminalIdentifier("")
val appRestrictions = config.applicationRestrictions
if (appRestrictions.containsKey("terminal")) {
identifier.id = appRestrictions.getString("terminal").toString()
}
// listener for changes while app is active
val restrictionsReceiver = this.setupRestrictionsReceiver(identifier, appRestrictions)
val restrictionsFilter = IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED)
registerReceiver(restrictionsReceiver, restrictionsFilter)
And here's the listener bit. Note, I will move this logic outside of onCreate. For now, with my main app, I just wanted to test if each app would receive the MC 'terminal' value that I setup in each policy.
private fun setupRestrictionsReceiver(identifier: IdentifierService, restrictions : Bundle) : BroadcastReceiver {
return object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (restrictions.containsKey("terminal")) {
identifier.id = restrictions.getString("terminal").toString()
}
}
}
}
My app isn't receiving the value. Am I missing something with this? Why isn't my identifier.id (a string field) receiving '2208'?