Add grpc proto files for checkin

These files are cloned from server side.

Bug: 262270778
Test: Build successfully
Change-Id: I3892a7fe72ae100168f4005892b5d6d48aa33a7c
diff --git a/DeviceLockController/Android.bp b/DeviceLockController/Android.bp
index 904e639..248f674 100644
--- a/DeviceLockController/Android.bp
+++ b/DeviceLockController/Android.bp
@@ -160,6 +160,7 @@
         "androidx.work_work-runtime",
         "devicelockcontroller-activities-lib",
         "devicelockcontroller-grpclib",
+        "devicelockcontroller-protos-lite",
         "devicelockcontroller-interface",
         "devicelockcontroller-res-lib",
         "devicelockcontroller-util-lib",
diff --git a/DeviceLockController/proto/Android.bp b/DeviceLockController/proto/Android.bp
new file mode 100644
index 0000000..373b080
--- /dev/null
+++ b/DeviceLockController/proto/Android.bp
@@ -0,0 +1,69 @@
+//
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package {
+    default_applicable_licenses: [
+        "packages_modules_DeviceLock_DeviceLockController_license",
+    ],
+}
+
+// Generate gRPC client code
+LITE_PROTO_CMD = "$(location aprotoc) " +
+    "--plugin=protoc-gen-grpc-java=$(location protoc-gen-grpc-java-plugin) " +
+    "--grpc-java_out=lite:$(genDir) $(in) && " +
+    "$(location soong_zip) -o $(out) -C $(genDir) -D $(genDir)"
+
+genrule {
+    name: "checkIn-service-stub-lite",
+    tools: [
+        "aprotoc",
+        "protoc-gen-grpc-java-plugin",
+        "soong_zip",
+    ],
+    cmd: LITE_PROTO_CMD,
+    srcs: [
+        "*.proto",
+    ],
+    out: [
+        "protos.srcjar",
+    ],
+}
+
+java_library {
+    name: "devicelockcontroller-protos-lite",
+    host_supported: true,
+    proto: {
+        type: "lite",
+        include_dirs: [
+            "external/protobuf/src",
+            "external/protobuf/java",
+        ],
+    },
+    srcs: [
+        ":checkIn-service-stub-lite",
+        "*.proto",
+    ],
+    libs: ["javax_annotation-api_1.3.2"],
+    static_libs: [
+        "libprotobuf-java-lite",
+        "guava",
+        "grpc-java-core-android",
+        "grpc-java-okhttp-client-lite",
+    ],
+    apex_available: ["com.android.devicelock"],
+    sdk_version: "module_current",
+    min_sdk_version: "UpsideDownCake",
+}
diff --git a/DeviceLockController/proto/configuration_info.proto b/DeviceLockController/proto/configuration_info.proto
new file mode 100644
index 0000000..6c74d1b
--- /dev/null
+++ b/DeviceLockController/proto/configuration_info.proto
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package devicelock;
+
+option java_package = "com.android.devicelockcontroller.proto";
+option java_multiple_files = true;
+
+enum ConfigurationType {
+  CONFIGURATION_TYPE_UNSPECIFIED = 0;
+  CONFIGURATION_TYPE_FINANCED = 1;
+}
+
+enum ConfigurationStatus {
+  CONFIGURATION_STATUS_UNSPECIFIED = 0;
+  // The configuration created by a user passed all validation checks and was
+  // successfully inserted into the database.
+  CONFIGURATION_STATUS_ACTIVE = 1;
+  // The configuration was initially active but the user decided to archive the
+  // configuration. In order to archive the configuration, there has to be no
+  // device assigned to this configuration. Also, a device cannot be assigned an
+  // archived configuration.
+  CONFIGURATION_STATUS_ARCHIVED = 2;
+}
+
+message ConfigurationInfo {
+  // The URL to download the kiosk app for non-GMS devices.
+  optional string kiosk_app_download_url = 1;
+
+  // The name of the provider of the kiosk app, e.g. "Foo Bar Inc".
+  optional string kiosk_app_provider_name = 2;
+
+  // The package name of the kiosk app, e.g. "com.foo.bar".
+  optional string kiosk_app_package = 3;
+
+  // The checksum used to sign the kiosk app.
+  //
+  // This is for verifying the validity of the kiosk app.
+  optional string kiosk_app_signature_checksum = 4;
+
+  // The package component of the activity of the kiosk app that the user
+  // would interact when the device is locked (i.e. this activity allows the
+  // user to make a payment), e.g. "com.foo.bar/com.foo.bar.MainActivity".
+  optional string kiosk_app_main_activity = 5;
+
+  // The list of apps that a user can use when the device is locked.
+  repeated string kiosk_app_allowlist_packages = 6;
+
+  // Whether the user can make phone calls when the device is locked.
+  optional bool kiosk_app_enable_outgoing_calls = 7;
+
+  // Whether notifications are shown to the user when the device is locked.
+  optional bool kiosk_app_enable_notifications = 8;
+}
diff --git a/DeviceLockController/proto/date.proto b/DeviceLockController/proto/date.proto
new file mode 100644
index 0000000..7748d89
--- /dev/null
+++ b/DeviceLockController/proto/date.proto
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package devicelock;
+
+option java_package = "com.android.devicelockcontroller.proto";
+option java_outer_classname = "DateProto";
+
+// Represents a whole or partial calendar date, such as a birthday. The time of
+// day and time zone are either specified elsewhere or are insignificant. The
+// date is relative to the Gregorian Calendar. This can represent one of the
+// following:
+//
+// * A full date, with non-zero year, month, and day values.
+// * A month and day, with a zero year (for example, an anniversary).
+// * A year on its own, with a zero month and a zero day.
+// * A year and month, with a zero day (for example, a credit card expiration
+//   date).
+//
+message Date {
+  // Year of the date. Must be from 1 to 9999, or 0 to specify a date without
+  // a year.
+  required int32 year = 1;
+  // Month of a year. Must be from 1 to 12, or 0 to specify a year without a
+  // month and day.
+  required int32 month = 2;
+  // Day of a month. Must be from 1 to 31 and valid for the year and month, or 0
+  // to specify a year by itself or a year and month where the day isn't
+  // significant.
+  required int32 day = 3;
+}
\ No newline at end of file
diff --git a/DeviceLockController/proto/device_checkin_info.proto b/DeviceLockController/proto/device_checkin_info.proto
new file mode 100644
index 0000000..e0dda46
--- /dev/null
+++ b/DeviceLockController/proto/device_checkin_info.proto
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package devicelock;
+
+option java_package = "com.android.devicelockcontroller.proto";
+option java_multiple_files = true;
+
+// The different states a device that did a check-in with the Device Lock
+// server can be in.
+enum DeviceCheckinStatus {
+  DEVICE_CHECKIN_STATUS_UNSPECIFIED = 0;
+  // The device is not ready for provisioning.
+  DEVICE_CHECKIN_STATUS_PROVISION_NOT_READY = 1;
+  // The device is ready for provisioning.
+  DEVICE_CHECKIN_STATUS_PROVISION_READY = 2;
+  // The device completed the locking program.
+  DEVICE_CHECKIN_STATUS_COMPLETE = 3;
+  // The device did not get enrolled within the registration window.
+  DEVICE_CHECKIN_STATUS_PROVISION_NOT_REQUIRED = 4;
+  // The device is in a country where Device Lock is not approved.
+  DEVICE_CHECKIN_STATUS_GEOLOCATION_UNAVAILABLE = 5;
+  // Device identifiers provided by the client that are not registered
+  // on the Device Lock portal. The client provides a list of device identifiers
+  // and if one of them is found that is registered on the Device Lock portal,
+  // then the rest of the device identifiers are set to this check-in status.
+  DEVICE_CHECKIN_STATUS_TO_BE_PURGE = 6;
+}
+
+// The different provisioning methods the Device Lock Android client can
+// provision the device.
+enum DeviceProvisionType {
+  DEVICE_PROVISION_TYPE_UNSPECIFIED = 0;
+  // The device provision should be after the SUW.
+  DEVICE_PROVISION_TYPE_DEFERRED = 1;
+  // The device provision should be during the SUW.
+  DEVICE_PROVISION_TYPE_MANDATORY = 2;
+}
+
+message DeviceCheckinInfo {}
diff --git a/DeviceLockController/proto/device_info.proto b/DeviceLockController/proto/device_info.proto
new file mode 100644
index 0000000..78c1ede
--- /dev/null
+++ b/DeviceLockController/proto/device_info.proto
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package devicelock;
+
+option java_package = "com.android.devicelockcontroller.proto";
+option java_multiple_files = true;
+
+enum DeviceIdentifierType {
+  DEVICE_IDENTIFIER_TYPE_UNSPECIFIED = 0;
+  // International Mobile Equipment Identity (IMEI).
+  DEVICE_IDENTIFIER_TYPE_IMEI = 1;
+  // Mobile Equipment Identity (MEID).
+  DEVICE_IDENTIFIER_TYPE_MEID = 2;
+  // Some devices (e.g. tablets) don’t have an IMEI but do have a serial number.
+  DEVICE_IDENTIFIER_TYPE_SERIAL = 3;
+}
+
+message DeviceInfo {
+  // This comes from android.os.Build.VERSION.SDK_INT.
+  optional int32 android_sdk_version = 1;
+}
diff --git a/DeviceLockController/proto/service.proto b/DeviceLockController/proto/service.proto
new file mode 100644
index 0000000..acc1a78
--- /dev/null
+++ b/DeviceLockController/proto/service.proto
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package devicelock;
+
+import "packages/modules/DeviceLock/DeviceLockController/proto/configuration_info.proto";
+import "packages/modules/DeviceLock/DeviceLockController/proto/date.proto";
+import "packages/modules/DeviceLock/DeviceLockController/proto/device_checkin_info.proto";
+import "packages/modules/DeviceLock/DeviceLockController/proto/device_info.proto";
+
+option java_package = "com.android.devicelockcontroller.proto";
+option java_multiple_files = true;
+
+// This service is used by the Device Lock Android client to facilitate device
+// provisioning of an eligible device into a Device Lock locking program.
+service DeviceLockCheckinService {
+  // Fetches the check-in status of the device.
+  rpc GetDeviceCheckinStatus(GetDeviceCheckinStatusRequest)
+      returns (GetDeviceCheckinStatusResponse) { }
+
+  // Pauses the provisioning of the device.
+  rpc PauseDeviceProvisioning(PauseDeviceProvisioningRequest)
+      returns (PauseDeviceProvisioningResponse) { }
+
+  // Reports that device provisioning was completed/a success.
+  rpc ReportDeviceProvisionComplete(ReportDeviceProvisionCompleteRequest)
+      returns (ReportDeviceProvisionCompleteResponse) { }
+}
+
+// Request to retrieve the check-in status of the device.
+message GetDeviceCheckinStatusRequest {
+  // The device identifiers associated with the device provided by Device Lock
+  // Android client. The Device Lock Android client would provide only one
+  // device identifier once the Device Lock Check-in service determines which
+  // of the device identifiers is registered with a locking program.
+  repeated string device_identifiers = 1;
+  optional DeviceIdentifierType device_identifier_type = 2;
+  // The Mobile Network Code for the carrier, the Device Lock Android client
+  // would fetch it from TelephonyManager#getSimOperator().
+  optional string carrier_mccmnc = 3;
+  // The Firebase Cloud Messaging (FCM) registration token associated with the
+  // device provided by the Device Lock Android client. The token is only used
+  // for GMS devices.
+  optional string fcm_registration_token = 4;
+}
+
+// The different check-in status the Device Lock Android client can be in.
+enum ClientCheckinStatus {
+  CLIENT_CHECKIN_STATUS_UNSPECIFIED = 0;
+  // The device is not ready for provision. The Device Lock Android client
+  // would need to do another check-in.
+  CLIENT_CHECKIN_STATUS_RETRY_CHECKIN = 1;
+  // The device is ready for provision. The Device Lock Android client can use
+  // the device provisioning information provided by the Device Lock server to
+  // provision the device.
+  CLIENT_CHECKIN_STATUS_READY_FOR_PROVISION = 2;
+  // The device no longer needs to be provisioned. The Device Lock Android
+  // client can stop future check-ins.
+  CLIENT_CHECKIN_STATUS_STOP_CHECKIN = 3;
+}
+
+// Response to a request to retrieve the check-in status of a given device.
+message GetDeviceCheckinStatusResponse {
+  // The Device Lock Android client check-in status determined by the Device
+  // Lock server.
+  optional ClientCheckinStatus client_checkin_status = 1;
+  // Set by the Device Lock server when the Device Lock Android client provides
+  // multiple device identifiers and one of the multiple device identifiers is
+  // registered with the Device Lock server. The client should use the device
+  // identifier that was found for any future communications with the Device
+  // Lock server.
+  optional string registered_device_identifier = 2;
+  // One of the following fields will get populated based on the device
+  // check-in status. But if the Device Lock server determines that the Device
+  // Lock Android client no longer needs to do a check-in, then none of the
+  // fields will be populated.
+  oneof next_steps {
+    // The Device Lock server determined that the Device Lock Android client
+    // needs to perform another device check-in.
+    NextCheckinInformation next_checkin_information = 3;
+    // The Device Lock server determined that the Device Lock Android client
+    // can now provision the device.
+    DeviceProvisioningInformation device_provisioning_information = 4;
+  }
+}
+
+// Information needed by the Device Lock Android client for the next check-in.
+message NextCheckinInformation {
+  // Set by the Device Lock server which tells the Device Lock Android client
+  // the date when the next check-in should happen.
+  optional Date next_checkin_date = 1;
+}
+
+// Information needed by the Device Lock Android client for device provisioning.
+message DeviceProvisioningInformation {
+  // The configuration information assigned to the device.
+  optional ConfigurationInfo configuration_information = 1;
+  // The type of configuration assigned to the device. This is used by the
+  // Device Lock Android client to determine what type of strings should be
+  // shown to the user.
+  optional ConfigurationType configuration_type = 2;
+  // The provision type selected when enrolling the device into a locking
+  // program. The Device Lock Android client would use this to determine which
+  // provision approach should be used to provision the device.
+  optional DeviceProvisionType device_provision_type = 3;
+  // Whether the Device Lock Android client should force the provisioning. If
+  // true, then the user cannot stop device provisioning. Otherwise, if false,
+  // then the user can optionally pause device provisioning.
+  optional bool force_provisioning = 4;
+}
+
+// The different reasons device provisioning can be paused.
+enum PauseDeviceProvisioningReason {
+  PAUSE_DEVICE_PROVISIONING_REASON_UNSPECIFIED = 0;
+  // If given as an option to the user, the user can pause device provisioning.
+  // For example, the user is currently driving and the Device Lock Android
+  // client is prompting the user to proceed with device provisioning.
+  PAUSE_DEVICE_PROVISIONING_REASON_USER_DEFERRED_DEVICE_PROVISIONING = 1;
+}
+
+// Request to pause device provisioning of an eligible device.
+message PauseDeviceProvisioningRequest {
+  // The device identifier that is registered with the Device Lock server that
+  // is requesting to pause device provisioning.
+  optional string registered_device_identifier = 1;
+  // The reason for pausing device provisioning.
+  optional PauseDeviceProvisioningReason pause_device_provisioning_reason = 2;
+}
+
+// Response to a request to pause device provisioning of an eligible device.
+message PauseDeviceProvisioningResponse {
+  // The Device Lock server decision as to whether or not to force device
+  // provisioning after receiving the pause device provisioning request. If
+  // true, then device provisioning would be forced. Otherwise, if false, then
+  // the device provisioning can still be paused.
+  optional bool force_provisioning = 1;
+}
+
+// Request to report that device provisioning of an eligible device is complete.
+message ReportDeviceProvisionCompleteRequest {
+  // The device identifier that is registered with the Device Lock server that
+  // was provisioned.
+  optional string registered_device_identifier = 1;
+}
+
+// Response to a request reporting that device provisioning of an eligible
+// device is complete.
+message ReportDeviceProvisionCompleteResponse {
+  // Ids the client can send back for faster look-ups for reporting device
+  // events throughout the locking program.
+  optional int64 company_id = 1;
+  optional int64 device_id = 2;
+  optional int64 configuration_id = 3;
+}