Google Play EMM API 支援下列發布方式,適用於公開和私人應用程式:
從管理版 Google Play 商店手動安裝應用程式
您可以定義使用者可在 Device
的 policy
中安裝哪些應用程式,並透過呼叫 Devices.update
進行設定。設定新裝置時,請先設定政策,再將受管理的 Google Play 帳戶新增至裝置,否則在將帳戶新增至裝置後,系統不會立即套用政策。
管理版 Play 商店行為是由 policy.productAvailabilityPolicy
的值定義:
all
:可使用 Play 商店中的所有公開應用程式。whitelist
:只有policy.productPolicy
中列出的應用程式可用。
無論是哪種情況,系統都會根據預設將 policy.productPolicy
中的所有應用程式新增至企業的商店版面配置。選取 whitelist
時,企業的商店版面配置會是管理版 Play 商店的首頁,選取 all
時則可在「工作應用程式」分頁中存取。您可以嵌入 Google Play 管理版 iframe,讓客戶自訂企業商店版面配置 (請參閱「使用 Google Play 管理版 iframe 整理應用程式」)。
從遠端安裝應用程式至使用者的裝置
如要在使用者的裝置上從遠端安裝 (又稱為推送安裝) 應用程式,請在 Device
的 policy
中設定 policy.productPolicy.autoInstallPolicy
。設定新裝置時,請先設定政策,再將受管理的 Google Play 帳戶新增至裝置,否則在將帳戶新增至裝置後,系統不會立即套用政策。
autoInstallMode
可設為:
doNotAutoInstall
:應用程式未自動安裝。autoInstallOnce
:應用程式會自動安裝一次,如果使用者解除安裝應用程式,系統就不會再次安裝。forceAutoInstall
:應用程式會自動安裝,如果使用者解除安裝應用程式,系統會重新安裝。在受管理的裝置上,DPC 應使用DevicePolicyManager.setUninstallBlocked
封鎖解除安裝作業。
如果發生失敗 (連線中斷、缺少儲存空間等) 的情況,系統會自動重試安裝作業,直到成功為止。系統會採用指數倒退重試策略,避免在發生無法復原的錯誤時浪費電池和資料。
安裝優先順序
您可以設定 autoInstallPriority
,選擇安裝順序。優先順序必須為無符號整數,預設值為 0。應用程式會依照升冪順序或優先順序安裝,也就是優先順序值較低的應用程式會先安裝。
安裝限制條件
您可以設定 autoInstallConstraint
,為每個應用程式設定安裝限制條件,藉此控管安裝期間裝置的必要狀態:
- 裝置是否應連上 Wi-Fi 網路。
- 裝置是否應充電。
- 以及裝置是否處於閒置狀態 (也就是沒有人使用)。
如果限制條件未立即達標,則受影響的下載作業會排入佇列,直到達到限制條件為止。
在 autoInstallConstraint
中,系統會在欄位之間套用 AND 規則。舉例來說,如果使用以下 autoInstallConstraint
,裝置必須同時處於充電狀態並連上非計量付費網路 (例如 Wi-Fi),才能安裝應用程式:
"autoInstallConstraint": [
"chargingStateConstraint" : "chargingRequired",
"networkTypeConstraint" : "unmeteredNetwork"
]
在新提供的裝置上自動安裝應用程式
裝置首次佈建時,Google Play EMM API 會傳送 NewDeviceEvent
通知。如要自動將應用程式推送至新配置的裝置,請監聽 NewDeviceEvent
通知。從每個 NewDeviceEvent
擷取 userId
和 deviceId
,然後呼叫 Devices.update
來設定該裝置的政策。
如要瞭解如何訂閱 EMM 通知,請參閱「設定 EMM 通知」。
應用程式自動安裝錯誤意見回饋
與應用程式安裝相關的錯誤會透過 應用程式意見回饋回報,而 DPC 可以監控透過 KeyedAppStatesService
傳送的 EnterprisePolicyStatus
訊息。
如要解碼 Base64 編碼資料,DPC 必須根據 EnterprisePolicyStatus
的 proto 定義產生類別。如要瞭解如何產生 Proto 類別,請參閱 通訊協定緩衝區說明文件。
有了產生的類別,DPC 就能解碼 EnterprisePolicyStatus
物件:
EnterprisePolicyStatus enterprisePolicyStatus = EnterprisePolicyStatus.parseFrom(
BaseEncoding.base64().decode(base64EncodedString)
);
裝置政策現在包含新的選用欄位 PolicyId
。建立或更新政策時,EMM 可以將 PolicyId
設為任何字串值,以便識別特定的裝置政策版本。
如果可用,應用程式安裝意見回饋會回報 PolicyId
,以便 DPC 將收到的錯誤與特定政策進行比對。
EnterprisePolicyStatus
message EnterprisePolicyStatus {
// Individual status for an app in the policy
repeated ApplicationStatus app_status = 1;
// Version of the policy for which this status applies.
PolicyVersion version = 2;
}
ApplicationStatus
// Individual status for an app.
message ApplicationStatus {
// The package name for the app.
string package_name = 1;
// The install status for the app. Only includes status for apps scheduled
// to be auto-installed via the policy resource.
AutoInstallStatus install_status = 2;
}
AutoInstallStatus
// Auto-install status for an app.
message AutoInstallStatus {
// The error causing the install to fail if state is INSTALL_ERROR.
EnterpriseAutoInstallError error = 1;
// The current install state of the app.
EnterpriseAutoInstallState state = 2;
}
PolicyVersion
// The version of the policy which these install states apply to.
message PolicyVersion {
// A policy id which may be optionally set by the EMM.
string policy_id = 1;
}
EnterpriseAutoInstallError
// Install errors resulting in failure to install an app.
enum EnterpriseAutoInstallError {
// Catch-all for unrecognized enum values.
ENTERPRISE_AUTO_INSTALL_ERROR_UNKNOWN = 0;
// The app could not be found.
ENTERPRISE_AUTO_INSTALL_ERROR_NOT_FOUND = 1;
// The app is not available in the user's country.
ENTERPRISE_AUTO_INSTALL_ERROR_UNAVAILABLE_COUNTRY = 2;
// The app is not compatible with the device hardware.
ENTERPRISE_AUTO_INSTALL_ERROR_NOT_COMPATIBLE_WITH_DEVICE = 3;
// No license remained to grant ownership of the app, and the user did not
// already own the app.
ENTERPRISE_AUTO_INSTALL_ERROR_NO_LICENSES_REMAINING = 4;
// Required permissions for the app have not been accepted.
ENTERPRISE_AUTO_INSTALL_ERROR_MISSING_PERMISSION = 5;
// The app is not available based on the enterprise availability policy.
ENTERPRISE_AUTO_INSTALL_ERROR_NOT_APPROVED_OR_UNAVAILABLE = 6;
// The app is not available to the user or device.
ENTERPRISE_AUTO_INSTALL_ERROR_APP_UNAVAILABLE = 7;
// Failed to grant license because the user already has ownership.
ENTERPRISE_AUTO_INSTALL_ERROR_INCOMPATIBLE_OWNERSHIP = 8;
// The admin has not accepted the terms of service.
ENTERPRISE_AUTO_INSTALL_ERROR_TOS_NOT_ACCEPTED = 9;
// The device does not have enough RAM.
ENTERPRISE_AUTO_INSTALL_ERROR_INSUFFICIENT_RAM = 10;
// The app is incompatible with the device carrier.
ENTERPRISE_AUTO_INSTALL_ERROR_NOT_COMPATIBLE_WITH_DEVICE_CARRIER = 11;
// The app is incompatible with the country or carrier.
ENTERPRISE_AUTO_INSTALL_ERROR_NOT_COMPATIBLE_WITH_DEVICE_COUNTRY_OR_CARRIER = 12;
// The app is incompatible with the safe search level.
ENTERPRISE_AUTO_INSTALL_ERROR_NOT_COMPATIBLE_WITH_DEVICE_SAFE_SEARCH_LEVEL = 13;
// The app could not be installed due to an installer error.
ENTERPRISE_AUTO_INSTALL_ERROR_INSTALL_FAILED = 14;
// The app could not be installed due to network errors.
ENTERPRISE_AUTO_INSTALL_ERROR_NETWORK_FAILED = 15;
// The device does not have enough storage.
ENTERPRISE_AUTO_INSTALL_ERROR_INSUFFICIENT_STORAGE = 16;
}
EnterpriseAutoInstallState
// The current install state for an app.
enum EnterpriseAutoInstallState {
// Catch-all for unrecognized enum values.
INSTALL_STATE_UNKNOWN = 0;
// The app has been received by Play but an install attempt has not completed
// yet.
INSTALL_STATE_PENDING = 1;
// The latest install attempt failed and will be retried automatically.
INSTALL_STATE_ERROR = 2;
// The app has been installed.
INSTALL_STATE_INSTALLED = 3;
}
發布應用程式以進行封閉測試
封閉測試可讓應用程式開發人員向信任的使用者取得應用程式早期版本的意見回饋。開發人員可以在 Google Play 管理中心設定封閉式測試。您可以使用 Play EMM API,讓 IT 管理員將封閉式版本 (又稱為測試群組) 發布給特定使用者。您的企業客戶不僅可以使用這項功能測試第三方應用程式,還能測試自行開發的私人應用程式。
符合資格的應用程式
開發人員在將企業新增至應用程式的封閉測試人員名單前,應用程式應符合下列條件:
- 應用程式的正式版已在 Google Play 上發布。
- 在 Google Play 管理中心,您可以在應用程式的「進階設定」頁面中啟用「Google Play 受管理」。
- 所有封閉版本的應用程式都符合版本代碼規定。
將企業新增至封閉測試
應用程式開發人員可以將企業加入使用 封閉 Alpha 版測試或使用 Google 網路論壇執行 Alpha 版測試的測試中。如需操作說明,請參閱設定公開、封閉或內部測試的指南。開發人員必須輸入每家參與企業的機構 ID (也稱為企業 ID)。IT 管理員可以按照下列步驟,向第三方應用程式開發人員提供機構 ID:
- 登入 Google Play 管理版商店。
- 按一下 [管理設定]。
- 複製機構資訊方塊中的機構 ID 字串,然後將機構 ID 提供給開發人員。
私人應用程式的其他規定
如果是私人應用程式,開發人員還必須在應用程式的「進階設定」頁面中,於「Google Play 管理版」分頁中新增每家參與企業的機構 ID。如需操作說明,請參閱「發布私人應用程式」。
將封閉式音軌發布給使用者
如要擷取企業可用於特定應用程式的曲目清單,請呼叫 Products.get
。回應中包含的 appTracks[]
清單包含每個應用程式可用的測試群組。appTracks[].trackAlias
是測試群組的使用者可讀名稱,可在 EMM 控制台中顯示;appTracks[].trackId
則是測試群組的機器可讀 ID。
如要讓使用者查看應用程式的封閉測試群組,請在 Device
的 policy
中設定 policy.productPolicy[].trackIds[]
。如果裝置可使用多個測試群組,系統會安裝版本代碼最高的可用版本。
在某些情況下,系統會自動從 Products.get
呼叫中移除 trackId,例如:
- 測試群組的應用程式版本已升級至其他測試群組或正式版。
- 正式版更新至高於測試群組的版本。
- 開發人員停止追蹤。
追蹤付費應用程式授權
對於付費應用程式,Grouplicenses
物件會追蹤企業擁有的授權數量,以及正在使用的授權數量。您可以呼叫 Grouplicenses.get
取得應用程式的授權詳細資料。
企業必須先取得付費應用程式的授權,才能在裝置上安裝該應用程式。如果有可用的授權,系統就會在裝置上安裝應用程式,並建立 Entitlements
物件。Entitlements
物件會將授權連結至使用者,並減少應用程式可用的授權數量。如果沒有可用的授權,應用程式安裝作業就會失敗,且不會建立 Entitlements
物件。
免費發布的應用程式不會使用 Grouplicenses
和 Entitlements
物件。