ここでは、デバイス管理機能を有効にして検証する方法を説明します。デバイス管理機能はデバイスを準備して管理対象プロファイルを設定するために必要です。また、企業環境に不可欠なデバイス所有者のユースケースについても説明します。
デバイスで管理対象プロファイルが機能するためには、AOSP コードの他に次のコンポーネントがデバイスで必要になります。
全般的な要件
デバイス管理をサポートするデバイスでは、次の全般的な要件を満たす必要があります。
サーマル HAL の値
Android 7.0 以降では HardwarePropertiesManager API がサポートされています。デバイス モニタリングおよびヘルスレポート用のこの API は、デバイスのハードウェアの状態をアプリケーションがクエリできるようにします。この API は、android.os.HardwarePropertiesManager
から公開されていて、HardwarePropertiesManagerService
を通じてハードウェア サーマル HAL(hardware/libhardware/include/hardware/thermal.h
)を呼び出します。保護された API であり、デバイス所有者およびプロファイル所有者の Device Policy Controller(DPC)アプリケーションと現在の VrListenerService
のみが呼び出すことができます。
HardwarePropertiesManager API をサポートするには、実装したデバイス サーマル HAL で次の値をレポートできる必要があります。
値 | レポート スケール | 機能 |
---|---|---|
[CPU | GPU | 電池 | デバイスのスキン] の温度 | コンポーネントの温度(摂氏) | アプリがデバイスの温度とコンポーネントのスロットル / シャットダウン温度を確認できるようになります |
CPU のアクティブ時間と合計有効時間 | 時間(ミリ秒) | アプリがコアごとの CPU 使用状況を確認できるようになります |
ファンの速度 | RPM | アプリがファンの速度を確認できるようになります |
実装したデバイス サーマル HAL では、コア(GPU、バッテリー、ファン)がオフラインになったときや、電源が接続された、または接続が解除されたときのレポート値を正しく処理できる必要があります。
デバイス管理を有効にする
デバイス管理を有効にするには、次の uses-features
が宣言されていることを確認します。
android.software.device_admin
android.software.managed_users
(デバイスのメモリが 2 GB 以上の場合にのみ、機能が宣言されます)
デバイスで uses-feature
の値が宣言されていることを確認するには、adb shell pm list features
を実行します。
必須アプリのみ
デフォルトで、管理対象デバイスのプロビジョニングでは、プロファイルを正しく動作させるために必要なアプリケーションのみを有効にする必要があります。以下の _managed_profile.xml
ファイルのサンプル インスタンスはすべて、android.software.managed_users
が宣言されている場合にのみ使用します。OEM は、以下を変更して、管理対象プロファイルまたはデバイスに必須のアプリケーションがすべて揃っているようにしなければなりません。
vendor_required_apps_managed_profile.xml vendor_required_apps_managed_device.xml vendor_disallowed_apps_managed_profile.xml vendor_disallowed_apps_managed_device.xml /* * The following are for Android 9 and higher only */ vendor_required_apps_managed_user.xml vendor_disallowed_apps_managed_user.xml
管理対象ユーザーの必須アプリと不許可アプリは、DevicePolicyManager#createAndManageUser
で作成されたセカンダリ ユーザーに適用されます。
Nexus デバイスの例
Android 8.x 以前
pacakages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_device.xml
Android 9 以降
frameworks/base/core/res/res/values/vendor_required_apps_managed_device.xml
<resources> <!-- A list of apps to be retained on the managed device --> <string-array name="vendor_required_apps_managed_device"> <item>com.android.vending</item> <!--Google Play --> <item>com.google.android.gms</item> <!--Required by Play --> <item>com.google.android.contacts</item> <!--Google or OEM Contacts--> <item>com.google.android.googlequicksearchbox</item> <!--Google Launcher --> <item>com.google.android.launcher</item> <!--Google Launcher or OEM Launcher --> <item>com.google.android.dialer</item> <!--Google or OEM dialer to enable making phone calls --> </string-array> </resources>
Android 8.x 以前
packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_profile.xml
Android 9 以降
frameworks/base/core/res/res/values/vendor_required_apps_managed_profile.xml
<resources> <!-- A list of apps to be retained in the managed profile. This includes any Google experience apps required. --> <string-array name="vendor_required_apps_managed_profile"> <item>com.android.vending</item> <!-- Google Play --> <item>com.google.android.gms</item> <!-- Required by Play --> <item>com.google.android.contacts</item> <!-- Google or OEM Contacts --> </string-array> </resources>
ランチャーの要件
バッジ アプリケーションや、アイコンバッジ(管理対象アプリケーションを表すために AOSP で提供される)およびその他のバッジ ユーザー インターフェース要素(履歴や通知など)をサポートするには、ランチャーを更新する必要があります。AOSP の launcher3 を変更せずに使用している場合は、このバッジ機能はすでにサポートされている可能性があります。
NFC の要件
NFC が搭載されたデバイスでは、使用開始までの準備作業(セットアップ ウィザードが表示されている)間に NFC を有効にして、管理対象プロビジョニング インテントを受け入れるように構成する必要があります。
packages/apps/Nfc/res/values/provisioning.xml
<bool name="enable_nfc_provisioning">true</bool> <item>application/com.android.managedprovisioning</item>
セットアップの要件
セットアップ ウィザードなど、OOBE(Out Of Box Experience)を含むデバイスは、デバイス所有者のプロビジョニングを実装する必要があります。OOBE を開くと、デバイス所有者のプロビジョニングなどの別のプロセスがすでにユーザー セットアップを完了しているかどうかを確認し、完了している場合は、ホーム インテントを起動してセットアップを完了します。このインテントはプロビジョニング アプリケーションによって捕捉され、プロビジョニング アプリケーションは新しく設定されたデバイス所有者に制御を渡します。
セットアップの要件を満たすには、デバイス設定のメイン アクティビティに次のコードを追加します。
@Override protected void onStart() { super.onStart(); // When returning to a setup wizard activity, check to see if another setup process // has intervened and, if so, complete an orderly exit boolean completed = Settings.Secure.getInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0) != 0; if (completed) { startActivity(new Intent(Intent.ACTION_MAIN, null) .addCategory(Intent.CATEGORY_HOME) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)); finish(); } ... }