googlesamples/android-testdpc
googlesamples/android-testdpc has 1,088 GitHub stars and 424 forks. GitHot measured +2 stars in 24 hours, +10 in 7 days, and +19 in 15 days. Last checked 2026-11-23 12:37 UTC. Last push 2026-09-21.
实测星标增长
- 24小时
- +2
- 7天
- +10
- 15天
- +19
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
关于
Test DPC 是一个供 Android Enterprise 使用的设备策略控制器示例。开发者可以通过它了解自己的应用在受管环境中的表现,例如设备所有者模式或受管配置文件中。用户可以设置工作资料、启用工作应用、设置应用限制、管理安全策略等。该应用也可作为其他 DPC 的实现参考。
安全README.md
原文Test Device Policy Control (Test DPC) App
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.
Getting Started
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.
Provisioning
You can find various kinds of provisioning methods here. Let's take a few of them as an example.
AFW# code provisioning (Device Owner M+)
- Factory reset your device.
- Setup Wi-Fi
- When prompted to sign in, enter afw#testdpc
- Follow onscreen instructions
- Choose 'Use for work only' for fully managed setup.
QR code provisioning (Device Owner N+ only)
- Factory reset your device and tap the welcome screen in setup wizard 6 times.
- On Android O or older, the setup wizard prompts the user to connect to the Internet so the setup wizard can download a QR code reader. Android P and newer devices already have the QR code reader available.
- Generate a QR code with the content:
or use this pre-made QR code:{ "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" }
- Scan the QR code and follow onscreen instructions
Note
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.
ADB command
Device Owner (DO)
Run the
adbcommand:adb shell dpm set-device-owner com.afwsamples.testdpc/.DeviceAdminReceiver
Profile Owner - Personal device (PO - BYOD)
- Create a managed profile by launching the “Set up TestDPC” app
- Skip adding an account at the end of the flow
Profile Owner - Corporate-owned device (PO - COPE)
Create a managed profile by launching the “Set up TestDPC” app
Skip adding an account at the end of the flow
Run the
adbcommand:adb shell dpm mark-profile-owner-on-organization-owned-device --user 10 com.afwsamples.testdpc/.DeviceAdminReceiver`
TestDPC as DM role holder
TestDPC v9.0.5+ can be setup as Device Management Role Holder.
Running the following
adbcommands:adb shell cmd role set-bypassing-role-qualification true adb shell cmd role add-role-holder android.app.role.DEVICE_POLICY_MANAGEMENT com.afwsamples.testdpcNote: unlike DO/PO, this change is not persisted so TestDPC needs to be marked as role holder again if the device reboots.
Android Studio import
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.
Building with Bazel
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 setup
Bazel 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>
Support
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.
License
Licensed under the Apache 2.0 license. See the LICENSE file for details.
How to make contributions?
Please read and follow the steps in the CONTRIB file.
探索相关项目
加载中…