[英]Android Management API: How to prevent the initial apps to be uninstalled during enrollment?
[英]How to keep system apps from being removed during device provisioning via Android Management API
我正在使用 Android 管理 API 生成 QR 注冊碼; 但是,在完全托管模式下注冊后,DPC 會刪除相機、計算器等系統應用程序。
其他帖子中提到必須將以下內容添加到由enrollmentTokens.create()方法生成的object中: "android.app.extra.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED" = true
我目前正在做的是:
androidmanagement = build(
"androidmanagement", "v1", credentials=credentials
)
enrollment_token = (
androidmanagement.enterprises()
.enrollmentTokens()
.create(
parent=f"enterprises/{enterprise_name}",
body={
"policyName": policy_name,
"user": {"accountIdentifier": f"{some_identifier}"},
"oneTimeOnly": "TRUE",
},
)
.execute()
)
enrollment_token
中res = json.loads(enrollment_token["qrCode"])
res["android.app.extra.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED"] = True
formatted_object_string = json.dumps(res)
enrollment_obj = formatted_object_string.replace(" ", "")
如果您打印enrollment_obj
,您將獲得:
{"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME":"com.google.android.apps.work.clouddpc/.receivers.CloudDeviceAdminReceiver","android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM":"SOME_CHECK_SUM","android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION":"https://play.google.com/managed/downloadManagingApp?identifier=setup","android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE":{"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN":"SOME_ENROLLMENT_TOKEN"},"android.app.extra.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED":true}
這個 object 用於創建如下所示的二維碼鏈接(當然沒有混淆數據):
https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl=%7B%22android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME%22%3A%22com.google.android.apps.work.clouddpc%2F.receivers.CloudDeviceAdminReceiver%22%2C%22android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM%22%3A%22<SOME_CHECKSUM>%22%2C%22android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION%22%3A%22https%3A%2F%2Fplay.google.com%2Fmanaged%2FdownloadManagingApp%3Fidentifier%3Dsetup%22%2C%22android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE%22%3A%7B%22com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN%22%3A%22<SOME_ENROLLMENT_TOKEN>%22%7D%2C%22android.app.extra.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED%22%3Atrue%7D
這將允許成功注冊; 但是,DPC 似乎並不尊重添加的屬性。 誰能看到我可能出錯的地方?
編輯:問題是我使用了錯誤的屬性鍵。 答案中提到的正確鍵是: android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED
看來您使用了不正確的密鑰,請嘗試改用android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED
。
res = json.loads(enrollment_token["qrCode"])
res["android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED"] = True
formatted_object_string = json.dumps(res)
enrollment_obj = formatted_object_string.replace(" ", "")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.