一些专为企业设计的应用包含称为“托管配置”的内置设置,IT 管理员可以远程配置这些设置。例如,应用或许可以选择仅在设备连接到 Wi-Fi 时才同步数据。对于所有解决方案集,都要求 IT 管理员能够指定托管配置并将其应用于设备。
下图说明了托管配置管理的一些关键阶段,并简要介绍了 Google Play EMM API 提供的选项。
检查应用是否支持托管配置
使用 Products.getAppRestrictionsSchema
确定应用是否支持托管配置。下例使用 Java 版 Google Play EMM API 客户端库。
public AppRestrictionsSchema getAppRestrictionsSchema(String enterpriseId,
String productId, String language) throws IOException {
return androidEnterprise
.product()
.getAppRestrictionsSchema(enterpriseId, productId, language)
.execute();
}
所有应用均返回应用限制(托管配置)架构。如果调用返回空架构,则表示应用不支持管理配置。如果调用返回的架构包含一组限制,则应用支持托管配置。例如,如果应用具有通过 VPN 启用远程打印的属性,则可能会对 Products.getAppRestrictionsSchema
返回以下响应。
{
"kind": "androidenterprise#appRestrictionsSchema",
"restrictions": [
{
"key": "printing_enabled",
"title": "Enable printing",
"restrictionType": "bool",
"description": "Allow user to print from the app",
"defaultValue": {
"type": "bool",
"valueBool": true,
}
},
{
"key": "vpn_configurations",
"title": "VPN configurations",
"restrictionType": "bundle_array",
"description": "List of VPN configurations",
"nestedRestriction": [
{
"key": "vpn_configuration",
"title": "VPN configuration",
"restrictionType": "bundle",
"nestedRestrictions": [
{
"key": "server",
"title": "VPN server host",
"restrictionType": "string"
},
{
"key": "username",
"title": "VPN account username",
"restrictionType": "string"
}
]
}
]
}
]
}
指定托管配置
对于支持托管配置的应用,您可以让 IT 管理员通过嵌入托管配置 iframe 或通过开发自己的界面,在 EMM 控制台中设置这些应用。
方法 1:嵌入托管配置 iframe
要支持托管配置,最简单的方法是将托管配置 iframe 嵌入到 EMM 控制台中。iframe 会检索指定应用的托管配置架构,并允许 IT 管理员保存、修改和删除自定义配置文件。您可以使用 Play EMM API 将自定义资料应用于用户的设备。如需详细了解该 iframe 以及如何将其添加到您的控制台,请参阅托管配置 iframe。
方法 2:创建您自己的界面
您可以使用从 Products.getAppRestrictionsSchema
返回的配置创建自己的界面,以便 IT 管理员管理应用配置。
应用托管配置
如需将托管配置应用于设备,您的 DPC 必须与 DPC 支持库集成(如构建设备政策控制器中所述)。DPC 支持库会以透明方式处理对 Google Play 的委托,以应用托管配置。
您可以通过在 Device
的 policy
中设置 policy.productPolicy.managedConfiguration
来将托管配置应用于设备。
使用 mcmId
每当 IT 管理员从托管配置 iframe 保存新的配置文件时,iframe 都会返回一个名为 mcmId
的唯一标识符。mcmId
对可以应用它的设备数量没有限制,也没有到期时间。
如需将配置文件应用于设备,请在 Device
的 policy
中设置 policy.productPolicy.managedConfiguration.configurationVariables.mcmId
。
如果您希望允许 IT 管理员在托管配置 iframe 中使用变量(例如 $FirstName、$LastName),则需要使用 policy.productPolicy[].managedConfiguration.configurationVariables.mcmId.variableSet[]
定义配置文件中包含的任何变量。
使用受管理的资源列表
您还可以通过在 Device
的 policy
中设置 policy.productPolicy.managedConfiguration.managedProperty[]
来添加一组代管式属性。
以下示例展示了如何定义配置。此配置包含一个 bundle_array
(列表),它由两个软件包属性(在本例中为 VPN 的一组相关属性)组成。
ManagedConfiguration managedConfiguration = new ManagedConfiguration()
.setManagedProperty(
ImmutableList.of(
new ManagedProperty()
.setKey("printing_enabled")
.setValueBool(true),
new ManagedProperty()
.setKey("vpn_configurations")
.setValueBundleArray(
ImmutableList.of(
new ManagedPropertyBundle().setManagedProperty(
ImmutableList.of(
new ManagedProperty()
.setKey("server")
.setValueString("vpn1.example.com"),
new ManagedProperty()
.setKey("username")
.setValueString("john.doe"))),
new ManagedPropertyBundle().setManagedProperty(
ImmutableList.of(
new ManagedProperty()
.setKey("server")
.setValueString("vpn2.example.com"),
new ManagedProperty()
.setKey("username")
.setValueString("jane.doe")))))));
如需详细了解应用可以支持的不同配置属性,请参阅定义托管配置。
列出应用的配置文件
根据您设计解决方案的方式,您可能需要显示为应用保存的配置配置文件的列表。如需检索此列表,请调用 Managedconfigurationssettings.list
。