Loading repository data…
Loading repository data…
googlesamples / repository
Test DPC is a sample device policy controller for use with Android Enterprise. It gives developers the ability to see how their app will behave in a managed context such as device owner or within a managed profile. Users can set up a work profile, enable work apps, set applications restrictions, manage security polices, and much more. The app also serves as a implementation reference for other DPCs
Test DPC is an app designed to help EMMs, ISVs, and OEMs to test their applications and platforms in a Android enterprise managed profile (i.e. work profile). It serves as both a sample Device Policy Controller and a testing application to flex the APIs available for Android enterprise. It supports devices running Android 5.0 Lollipop or later.
See the documentation to learn more about Android in the enterprise.
This sample uses the Bazel build system. To build this project, use the "bazel build testdpc" command.
This app can also be found on the Play store.
You can find various kinds of provisioning methods here. Let's take a few of them as an example.
{
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.afwsamples.testdpc/com.afwsamples.testdpc.DeviceAdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "gJD2YwtOiWJHkSMkkIfLRlj-quNqG1fb6v100QmzM9w=",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://testdpc-latest-apk.appspot.com"
}
or use this pre-made QR code:If using this QR code your device is stuck on the configuring screen, it may due to a problem connecting to the appspot.com domain.
In these cases you can use the latest release available on github. You can also upload this version on your own server and use that as your download location.
Replace the link used for PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION with a link to your APK. After that, regenerate the QR code.
Run the adb command:
adb shell dpm set-device-owner com.afwsamples.testdpc/.DeviceAdminReceiver
Create a managed profile by launching the “Set up TestDPC” app
Skip adding an account at the end of the flow
Run the adb command:
adb shell dpm mark-profile-owner-on-organization-owned-device --user 10 com.afwsamples.testdpc/.DeviceAdminReceiver`
TestDPC v9.0.5+ can be setup as Device Management Role Holder.
Running the following adb commands:
adb shell cmd role set-bypassing-role-qualification true
adb shell cmd role add-role-holder android.app.role.DEVICE_POLICY_MANAGEMENT com.afwsamples.testdpc
Note: unlike DO/PO, this change is not persisted so TestDPC needs to be marked as role holder again if the device reboots.
To import this repository in Android Studio, you need to use the Bazel for Android Studio Plugin.
When importing the project you have to select the folder containing the Bazel's
BUILD file. When prompted to select a "project view", you can choose the
option "Copy external" and choose the scripts/ij.bazelproject available in
this repository.
Once Bazel has complete the import operation and the first sync of the
project, you can create a "Run Configuration".
Select "Bazel Command" as Configuration type and add //:testdpc as
"target expression".
You can now run the project from inside Android Studio.
The repository includes a build.sh script to build the application. The required
setupdesign library
is now imported and patched dynamically using the command line utility ed. This needs to be
available on the path to successfully build the project.
ANDROID_HOME environment setupBazel requires that you set the ANDROID_HOME environment variable to the path of your Android SDK.
As an example, you can add to your .bashrc on linux:
export ANDROID_HOME=<Path to the Android SDK>
If you've found an error in this sample, please file an issue: https://github.com/googlesamples/android-testdpc/issues
Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.
Licensed under the Apache 2.0 license. See the LICENSE file for details.
Please read and follow the steps in the CONTRIB file.