Skip to content

Commit

Permalink
Merge pull request #206 from pfmaggi/master
Browse files Browse the repository at this point in the history
Swap prebuild setupdesign library with the OSS version.
  • Loading branch information
pfmaggi authored Mar 26, 2024
2 parents ed8f4a8 + 7b5fdbf commit 6d9ecd8
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 104 deletions.
183 changes: 95 additions & 88 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
exports_files(["LICENSE"])
load("@rules_jvm_external//:defs.bzl", "artifact")

exports_files([
"LICENSE",
".blazeproject",
"WORKSPACE",
])

MANIFEST = "src/main/AndroidManifest.xml"

MANIFEST_DEBUG = "src/main/AndroidManifestDebug.xml"

PACKAGE = "com.afwsamples.testdpc"

aar_import(
name = "setupdesign",
aar = "lib/setupdesign.aar",
deps = [
":setupdesign_strings",
":setupcompat",
"@maven//:com_google_android_material_material",
],
)

aar_import(
name = "setupcompat",
aar = "lib/setupcompat.aar",
)

aar_import(
name = "setupdesign_strings",
aar = "lib/strings.aar",
)

android_library(
name = "setupdesign_deps",
exports = [
":setupdesign",
":setupcompat"
],
)

android_library(
name = "androidx_deps",
exports = [
"@maven//:androidx_annotation_annotation",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_collection_collection",
"@maven//:androidx_core_core",
"@maven//:androidx_enterprise_enterprise_feedback",
"@maven//:androidx_legacy_legacy_support_v13",
Expand All @@ -48,7 +27,6 @@ android_library(
"@maven//:androidx_localbroadcastmanager_localbroadcastmanager",
"@maven//:androidx_preference_preference",
"@maven//:androidx_recyclerview_recyclerview",
"@maven//:androidx_collection_collection"
],
)

Expand All @@ -70,7 +48,17 @@ android_library(
android_library(
name = "test_deps",
exports = [

artifact("com.google.testparameterinjector:test-parameter-injector"),
artifact("com.google.truth:truth"),
artifact("androidx.test:core"),
artifact("androidx.test:monitor"),
artifact("androidx.test:runner"),
artifact("junit:junit"),
artifact("org.hamcrest:java-hamcrest"),
artifact("org.robolectric:robolectric"),
artifact("org.robolectric:robolectric-annotations"),
artifact("org.robolectric:shadows-core"),
"@robolectric//bazel:android-all",
],
)

Expand Down Expand Up @@ -112,7 +100,8 @@ android_library(
":androidx_deps",
":bouncycastle_deps",
":guava_deps",
":setupdesign_deps",
"@setupdesign//:setupdesign",
"@setupcompat//:setupcompat",
],
)

Expand All @@ -130,55 +119,73 @@ java_library(
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/Utils.java"],
)

android_local_test(
name = "PermissionsHelperTest",
srcs = ["src/test/java/com/afwsamples/testdpc/common/PermissionsHelperTest.java"],
manifest = MANIFEST,
deps = [
":testdpc_lib",
":test_deps"
],
)

android_local_test(
name = "AppStatesServiceTest",
srcs = ["src/test/java/com/afwsamples/testdpc/feedback/AppStatesServiceTest.java"],
manifest = MANIFEST,
deps = [
":testdpc_lib",
":androidx_deps",
":test_deps"
],
)

android_local_test(
name = "WifiConfigUtilTest",
srcs = ["src/test/java/com/afwsamples/testdpc/policy/wifimanagement/WifiConfigUtilTest.java"],
manifest = MANIFEST,
deps = [
":testdpc_lib",
":test_deps"
],
)

android_local_test(
name = "GetProvisioningModeActivityTest",
srcs = ["src/test/java/com/afwsamples/testdpc/provision/GetProvisioningModeActivityTest.java"],
manifest = MANIFEST,
deps = [
":testdpc_lib",
":test_deps"
],
)
#
#android_local_test(
# name = "PermissionsHelperTest",
# srcs = ["src/test/java/com/afwsamples/testdpc/common/PermissionsHelperTest.java"],
# manifest = MANIFEST,
# deps = [
# ":test_deps",
# ":testdpc_lib",
# "@robolectric//bazel:android-all",
# ],
#)
#
#android_local_test(
# name = "AppStatesServiceTest",
# srcs = ["src/test/java/com/afwsamples/testdpc/feedback/AppStatesServiceTest.java"],
# manifest = MANIFEST,
# deps = [
# ":androidx_deps",
# ":test_deps",
# ":testdpc_lib",
# "@robolectric//bazel:android-all",
# ],
#)
#
#android_local_test(
# name = "WifiConfigUtilTest",
# srcs = ["src/test/java/com/afwsamples/testdpc/policy/wifimanagement/WifiConfigUtilTest.java"],
# manifest = MANIFEST,
# deps = [
# ":test_deps",
# ":testdpc_lib",
# "@robolectric//bazel:android-all",
# ],
#)
#
#android_local_test(
# name = "GetProvisioningModeActivityTest",
# srcs = ["src/test/java/com/afwsamples/testdpc/provision/GetProvisioningModeActivityTest.java"],
# manifest = MANIFEST,
# test_class = "com.afwsamples.testdpc.provision.GetProvisioningModeActivityTest",
# deps = [
# ":test_deps",
# ":testdpc_lib",
# ],
#)
#
#android_local_test(
# name = "GetProvisioningModeActivityTest",
# srcs = ["src/test/java/com/afwsamples/testdpc/provision/GetProvisioningModeActivityTest.java"],
# manifest = MANIFEST,
# test_class = "com.afwsamples.testdpc.provision.GetProvisioningModeActivityTest",
# deps = [
# ":test_deps",
# ":testdpc_lib",
# "@maven//:org_robolectric_robolectric",
# "@robolectric//bazel:android-all",
# ],
#)

java_test(
name = "BooleanParserTest",
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/BooleanParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -187,9 +194,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/ByteParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -198,9 +205,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/CharParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -209,9 +216,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/DoubleParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -220,9 +227,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/FloatParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -231,9 +238,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/IntParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -242,9 +249,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/LongParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -253,9 +260,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/ShortParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -264,9 +271,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/StringParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -275,9 +282,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/CustomParserTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -286,9 +293,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/CallbackTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -297,9 +304,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/HelpTextGenerationTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -308,9 +315,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/InvalidCallsTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -319,9 +326,9 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/ParamTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)

Expand All @@ -330,8 +337,8 @@ java_test(
size = "small",
srcs = ["src/test/java/com/afwsamples/testdpc/util/flags/RegistrationTest.java"],
deps = [
":test_deps",
":test_utils",
":testdpc_lib",
":test_deps"
],
)
)
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Provisioning

You 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.

#### QR code provisioing (Device Owner N+ only) ####
#### QR code provisioning (Device Owner N+ only) ####
1. Factory reset your device and tap the welcome screen in setup wizard 6 times.
2. The setup wizard prompts the user to connect to the Internet so the setup wizard can download a QR code reader.
3. Modify (if needed) and scan [this QR code] (http://down-box.appspot.com/qr/nQB0tw7b).
Expand Down Expand Up @@ -67,7 +67,7 @@ TestDPC v9.0.5+ can be setup as Device Management Role Holder.
Android Studio import
---------------------

To import this repository in Android Studio, you need to use the
To import this repository in Android Studio, you need to use the
[Bazel for IntelliJ](https://plugins.jetbrains.com/plugin/8609-bazel-for-intellij)
Plugin.

Expand All @@ -78,11 +78,20 @@ 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
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](https://android.googlesource.com/platform/external/setupdesign/+/refs/heads/main)
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.

Support
-------

Expand Down
Loading

0 comments on commit 6d9ecd8

Please sign in to comment.