{"id":13711626,"url":"https://github.com/googlesamples/android-testdpc","last_synced_at":"2025-05-14T17:05:17.500Z","repository":{"id":32468819,"uuid":"36048718","full_name":"googlesamples/android-testdpc","owner":"googlesamples","description":"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","archived":false,"fork":false,"pushed_at":"2025-01-08T17:12:37.000Z","size":9316,"stargazers_count":825,"open_issues_count":22,"forks_count":350,"subscribers_count":85,"default_branch":"master","last_synced_at":"2025-04-13T04:57:04.730Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://play.google.com/store/apps/details?id=com.afwsamples.testdpc","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googlesamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-22T02:46:28.000Z","updated_at":"2025-04-12T06:48:06.000Z","dependencies_parsed_at":"2022-07-14T08:17:14.437Z","dependency_job_id":"f12d5ba3-d1e6-4bd5-94e0-5dbd6716e46f","html_url":"https://github.com/googlesamples/android-testdpc","commit_stats":{"total_commits":997,"total_committers":67,"mean_commits":"14.880597014925373","dds":0.8294884653961886,"last_synced_commit":"7a8957beb7c2e01a1bf5776898542e24f6f288fb"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fandroid-testdpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fandroid-testdpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fandroid-testdpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fandroid-testdpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googlesamples","download_url":"https://codeload.github.com/googlesamples/android-testdpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254190397,"owners_count":22029632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:10.065Z","updated_at":"2025-05-14T17:05:17.446Z","avatar_url":"https://github.com/googlesamples.png","language":"Java","funding_links":[],"categories":["Tools :hammer_and_wrench:"],"sub_categories":[],"readme":"Test Device Policy Control (Test DPC) App\n=========================================\n\nTest 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.\n\nSee the [documentation](https://developer.android.com/work/index.html) to learn more about Android in the enterprise.\n\n## Getting Started\n\nThis sample uses the Bazel build system. To build this project, use the \"bazel build testdpc\" command.\n\nThis app can also be found [on the Play store](https://play.google.com/store/apps/details?id=com.afwsamples.testdpc).\n\n## Provisioning\n\nYou can find various kinds of provisioning methods [here](https://developers.google.com/android/work/prov-devices#Key_provisioning_differences_across_android_releases). Let's take a few of them as an example.\n\n### AFW# code provisioning (Device Owner M+)\n1. Factory reset your device and tap the welcome screen in setup wizard 6 times.\n2. When prompted to sign in, enter **afw#testdpc**\n3. Follow onscreen instructions\n\n### QR code provisioning (Device Owner N+ only)\n1. Factory reset your device and tap the welcome screen in setup wizard 6 times.\n1. 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.\n   Android P and newer devices already have the QR code reader available.\n1. Generate a QR code with the content:\n   ```\n    {\n    \t\"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME\": \"com.afwsamples.testdpc/com.afwsamples.testdpc.DeviceAdminReceiver\",\n    \t\"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM\": \"gJD2YwtOiWJHkSMkkIfLRlj-quNqG1fb6v100QmzM9w=\",\n    \t\"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION\": \"https://testdpc-latest-apk.appspot.com\"\n    }\n   ```\n   or use this pre-made QR code:  \n   ![testdpc_provisioning](qrcode.png)\n1. Scan the QR code and follow onscreen instructions\n\n#### Note\n\nIf using this QR code your device is stuck on the configuring screen, it may due to a problem connecting to the `appspot.com` domain.\n\nIn these cases you can use the [latest release](https://github.com/googlesamples/android-testdpc/releases/latest) available on github.\nYou can also upload this version on your own server and use that as your download location.\n\nReplace the link used for `PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION` with a link to your APK. After that, regenerate the QR code.\n\n### ADB command\n\n#### Device Owner (DO)\n\n*   Run the `adb` command:\n\n    ```console\n    adb shell dpm set-device-owner com.afwsamples.testdpc/.DeviceAdminReceiver\n    ```\n\n#### Profile Owner - Personal device (PO - BYOD)\n\n*   Create a managed profile by launching the “Set up TestDPC” app\n*   Skip adding an account at the end of the flow\n\n#### Profile Owner - Corporate-owned device (PO - COPE)\n\n*   Create a managed profile by launching the “Set up TestDPC” app\n*   Skip adding an account at the end of the flow\n*   Run the `adb` command:\n\n    ```console\n    adb shell dpm mark-profile-owner-on-organization-owned-device --user 10 com.afwsamples.testdpc/.DeviceAdminReceiver`\n    ```\n\n#### TestDPC as DM role holder\n\nTestDPC v9.0.5+ can be setup as Device Management Role Holder.\n\n*   Running the following `adb` commands:\n\n    ```console\n    adb shell cmd role set-bypassing-role-qualification true\n    adb shell cmd role add-role-holder android.app.role.DEVICE_POLICY_MANAGEMENT com.afwsamples.testdpc\n    ```\n\n    Note: unlike DO/PO, this change is not persisted so TestDPC needs to be\n    marked as role holder again if the device reboots.\n\n## Android Studio import\n\nTo import this repository in Android Studio, you need to use the \n[Bazel for Android Studio](https://plugins.jetbrains.com/plugin/9185-bazel-for-android-studio)\nPlugin.\n\nWhen importing the project you have to select the folder containing the Bazel's\n`BUILD` file. When prompted to select a \"project view\", you can choose the\noption \"Copy external\" and choose the `scripts/ij.bazelproject` available in\nthis repository.\n\nOnce Bazel has complete the import operation and the first sync of the\nproject, you can create a \"Run Configuration\".\nSelect \"Bazel Command\" as Configuration type and add `//:testdpc` as\n\"target expression\".\n\nYou can now run the project from inside Android Studio.\n\n## Building with Bazel\n\nThe repository includes a `build.sh` script to build the application. The required\n[setupdesign library](https://android.googlesource.com/platform/external/setupdesign/+/refs/heads/main)\nis now imported and patched dynamically using the command line utility `ed`. This needs to be\navailable on the path to successfully build the project.\n\n### `ANDROID_HOME` environment setup\n\nBazel requires that you set the `ANDROID_HOME` environment variable to the path of your Android SDK.\nAs an example, you can add to your `.bashrc` on linux:\n```\nexport ANDROID_HOME=\u003cPath to the Android SDK\u003e\n```\n\n## Support\n\nIf you've found an error in this sample, please file an issue:\nhttps://github.com/googlesamples/android-testdpc/issues\n\nPatches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.\n\n## License\n\nLicensed under the Apache 2.0 license. See the LICENSE file for details.\n\n## How to make contributions?\n\nPlease read and follow the steps in the CONTRIB file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglesamples%2Fandroid-testdpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglesamples%2Fandroid-testdpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglesamples%2Fandroid-testdpc/lists"}