Implementing Device Administration
Implementing Device Administration
This page walks you through the many features in Android 5.0 and higher platform release that need to be enabled and validated on devices to make them ready for managed profile and device owner user cases that are essential to using them in a corporate environment. In addition to the related Android Open Source Project (AOSP) code, there are a number of additional components required for a device to function with managed profiles.
Requirements
The following uses-feature need to be defined:
android.software.managed_users
android.software.device_admin
Confirm with: adb shell pm list features
It should not be a low-RAM device, meaning ro.config.low_ram should not be defined. The framework automatically limits the number of users to 1 when the low_ram flag is defined.
By default, only applications that are essential for correct operation of the profile should be enabled as part of provisioning a managed device.
OEMs must ensure the managed profile or device has all required applications by modifying:
vendor_required_apps_managed_profile.xml
vendor_required_apps_managed_device.xml
Here are examples from a Nexus device:
packages/apps/ManagedProvisioning/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>
packages/apps/ManagedProvisioning/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>
Launcher
The launcher must support badging applications with the icon badge provided in the Android Open Source Project (AOSP) to represent the managed applications and other badge user interface elements such as recents and notifications.
Update the Launcher to support badging. If you use launcher3 in AOSP as-is, then you likely already support this badging feature.
NFC
On devices with NFC, NFC must be enabled in the Android Setup Wizard and configured to accept managed provisioning intents:
packages/apps/Nfc/res/values/provisioning.xml
<bool name="enable_nfc_provisioning">true</bool>
<item>application/com.android.managedprovisioning</item>
Setup Wizard
The Android Setup Wizard needs to support device owner provisioning. When it opens, it needs to check if another process (such as device owner provisioning) has already finished the user setup. If this is the case, it needs to fire a home intent and finish the setup wizard.
This intent will be caught by the provisioning application, which will then hand over control to the newly set device owner. This can be achieved by adding the following to your setup wizard’s main activity:
@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();
}
...
}
本文来自博客园,作者:dolinux,未经同意,禁止转载

浙公网安备 33010602011771号