Add generic atom definition for device policy events.

Bug: 119492678
Test: None
Change-Id: Ic6bee84b0c2ec0028c5078da74a7b32db1881638
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 3ee0a06..19c7adf 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -34,6 +34,8 @@
 import "frameworks/base/core/proto/android/telecomm/enums.proto";
 import "frameworks/base/core/proto/android/telephony/enums.proto";
 import "frameworks/base/core/proto/android/view/enums.proto";
+import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy_enums.proto";
+import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy.proto";
 
 /**
  * The master atom class. This message defines all of the available
@@ -156,6 +158,7 @@
         ServiceLaunchReported service_launch_reported = 100;
         PhenotypeFlagStateChanged phenotype_flag_state_changed = 101;
         BinaryPushStateChanged binary_push_state_changed = 102;
+        DevicePolicyEvent device_policy_event = 103;
     }
 
     // Pulled events will start at field 10000.
@@ -3389,3 +3392,25 @@
     // (i.e. roughly since device was last significantly charged).
     optional float power_milli_amp_hours = 2;
 }
+
+/**
+ * Logs device policy features.
+ *
+ * Logged from:
+ *   frameworks/base/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+ *   packages/apps/ManagedProvisioning/src/com/android/managedprovisioning/
+ */
+message DevicePolicyEvent {
+    // The event id - unique for each event.
+    optional android.stats.devicepolicy.EventId event_id = 1;
+    // The admin package name.
+    optional string admin_package_name = 2;
+    // A generic integer parameter.
+    optional int32 integer_value = 3;
+    // A generic boolean parameter.
+    optional bool boolean_value = 4;
+    // A parameter specifying a time period in milliseconds.
+    optional uint64 time_period_millis = 5;
+    // A parameter specifying a list of package names, bundle extras or string parameters.
+    optional android.stats.devicepolicy.StringList string_list_value = 6 [(log_mode) = MODE_BYTES];
+}
diff --git a/core/proto/android/stats/devicepolicy/Android.bp b/core/proto/android/stats/devicepolicy/Android.bp
new file mode 100644
index 0000000..6ae54e2
--- /dev/null
+++ b/core/proto/android/stats/devicepolicy/Android.bp
@@ -0,0 +1,33 @@
+// Copyright (C) 2018 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.
+
+java_library_static {
+    name: "devicepolicyprotosnano",
+    proto: {
+        type: "nano",
+    },
+    srcs: [
+        "*.proto",
+    ],
+    java_version: "1.8",
+    target: {
+        android: {
+            jarjar_rules: "jarjar-rules.txt",
+        },
+        host: {
+            static_libs: ["libprotobuf-java-nano"],
+        }
+    },
+    no_framework_libs: true,
+}
diff --git a/core/proto/android/stats/devicepolicy/device_policy.proto b/core/proto/android/stats/devicepolicy/device_policy.proto
new file mode 100644
index 0000000..af30cf3
--- /dev/null
+++ b/core/proto/android/stats/devicepolicy/device_policy.proto
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2018 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 android.stats.devicepolicy;
+option java_multiple_files = true;
+
+message StringList {
+  repeated string string_value = 1;
+}
diff --git a/core/proto/android/stats/devicepolicy/device_policy_enums.proto b/core/proto/android/stats/devicepolicy/device_policy_enums.proto
new file mode 100644
index 0000000..8fbea12
--- /dev/null
+++ b/core/proto/android/stats/devicepolicy/device_policy_enums.proto
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2018 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 android.stats.devicepolicy;
+option java_multiple_files = true;
+
+/**
+ * Id for device policy features.
+ */
+enum EventId {
+  SET_PASSWORD_QUALITY = 1;
+  SET_PASSWORD_MINIMUM_LENGTH = 2;
+  SET_PASSWORD_MINIMUM_NUMERIC = 3;
+  SET_PASSWORD_MINIMUM_NON_LETTER = 4;
+  SET_PASSWORD_MINIMUM_LETTERS = 5;
+  SET_PASSWORD_MINIMUM_LOWER_CASE = 6;
+  SET_PASSWORD_MINIMUM_UPPER_CASE = 7;
+  SET_PASSWORD_MINIMUM_SYMBOLS = 8;
+  SET_KEYGUARD_DISABLED_FEATURES = 9;
+  LOCK_NOW = 10;
+  WIPE_DATA_WITH_REASON = 11;
+  ADD_USER_RESTRICTION = 12;
+  REMOVE_USER_RESTRICTION = 13;
+  SET_SECURE_SETTING = 14;
+  SET_SECURITY_LOGGING_ENABLED = 15;
+  RETRIEVE_SECURITY_LOGS = 16;
+  RETRIEVE_PRE_REBOOT_SECURITY_LOGS = 17;
+  SET_PERMISSION_POLICY = 18;
+  SET_PERMISSION_GRANT_STATE = 19;
+  INSTALL_KEY_PAIR = 20;
+  INSTALL_CA_CERT = 21;
+  ON_CHOOSE_KEY_ALIAS = 22;
+  REMOVE_KEY_PAIR = 23;
+  UNINSTALL_CA_CERTS = 24;
+  SET_CERT_INSTALLER_PACKAGE = 25;
+  SET_ALWAYS_ON_VPN_PACKAGE = 26;
+  SET_PERMITTED_INPUT_METHODS = 27;
+  SET_PERMITTED_ACCESSIBILITY_SERVICES = 28;
+  SET_SCREEN_CAPTURE_DISABLE = 29;
+  SET_CAMERA_DISABLED = 30;
+  QUERY_SUMMARY_FOR_USER = 31;
+  QUERY_SUMMARY = 32;
+  QUERY_DETAILS = 33;
+  REBOOT = 34;
+  SET_MASTER_VOLUME_MUTED = 35;
+  SET_AUTO_TIME_REQUIRED = 36;
+  SET_KEYGUARD_DISABLED = 37;
+  SET_STATUS_BAR_DISABLED = 38;
+  SET_ORGANIZATION_COLOR = 39;
+  SET_PROFILE_NAME = 40;
+  SET_USER_ICON = 41;
+  SET_DEVICE_OWNER_LOCKSCREEN_INFO = 42;
+  SET_SHORT_SUPPORT_MESSAGE = 43;
+  SET_LONG_SUPPORT_MESSAGE = 44;
+  SET_CROSS_PROFILE_CONTACTS_SEARCH_DISABLED = 45;
+  SET_CROSS_PROFILE_CALLER_DISABLED = 46;
+  SET_BLUETOOTH_CONTACT_SHARING_DISABLED = 47;
+  ADD_CROSS_PROFILE_INTENT_FILTER = 48;
+  ADD_CROSS_PROFILE_WIDGET_PROVIDER = 49;
+  SET_SYSTEM_UPDATE_POLICY = 50;
+  SET_LOCKTASK_PACKAGES = 51;
+  ADD_PERSISTENT_PREFERRED_ACTIVITY = 52;
+  REQUEST_BUGREPORT = 53;
+  GET_WIFI_MAC_ADDRESS = 54;
+  REQUEST_QUIET_MODE_ENABLED = 55;
+  WORK_PROFILE_LOCATION_CHANGED = 56;
+  DO_USER_INFO_CLICKED = 57;
+  TRANSFER_OWNERSHIP = 58;
+  GENERATE_KEY_PAIR = 59;
+  SET_KEY_PAIR_CERTIFICATE = 60;
+  SET_KEEP_UNINSTALLED_PACKAGES = 61;
+  SET_APPLICATION_RESTRICTIONS = 62;
+  SET_APPLICATION_HIDDEN = 63;
+  ENABLE_SYSTEM_APP = 64;
+  ENABLE_SYSTEM_APP_WITH_INTENT = 65;
+  INSTALL_EXISTING_PACKAGE = 66;
+  SET_UNINSTALL_BLOCKED = 67;
+  SET_PACKAGES_SUSPENDED = 68;
+  ON_LOCK_TASK_MODE_ENTERING = 69;
+  ADD_CROSS_PROFILE_CALENDAR_PACKAGE = 70;
+  REMOVE_CROSS_PROFILE_CALENDAR_PACKAGE = 71;
+  GET_USER_PASSWORD_COMPLEXITY_LEVEL = 72;
+  INSTALL_SYSTEM_UPDATE = 73;
+  INSTALL_SYSTEM_UPDATE_ERROR = 74;
+  IS_MANAGED_KIOSK = 75;
+  IS_UNATTENDED_MANAGED_KIOSK = 76;
+  PROVISIONING_TO_COMP = 77;
+  PROVISIONING_FORCED_DO = 78;
+
+  // existing Tron logs to be migrated to WestWorld
+  PROVISIONING_ENTRY_POINT_NFC = 79;
+  PROVISIONING_ENTRY_POINT_QR_CODE = 80;
+  PROVISIONING_ENTRY_POINT_ZERO_TOUCH = 81;
+  PROVISIONING_ENTRY_POINT_ADB = 82;
+  PROVISIONING_ENTRY_POINT_TRUSTED_SOURCE = 83;
+  PROVISIONING_DPC_PACKAGE_NAME = 84;
+  PROVISIONING_DPC_INSTALLED_BY_PACKAGE = 85;
+  PROVISIONING_PROVISIONING_ACTIVITY_TIME_MS = 86;
+  PROVISIONING_PREPROVISIONING_ACTIVITY_TIME_MS = 87;
+  PROVISIONING_ENCRYPT_DEVICE_ACTIVITY_TIME_MS = 88;
+  PROVISIONING_WEB_ACTIVITY_TIME_MS = 89;
+  PROVISIONING_TRAMPOLINE_ACTIVITY_TIME_MS = 90;
+  PROVISIONING_POST_ENCRYPTION_ACTIVITY_TIME_MS = 91;
+  PROVISIONING_FINALIZATION_ACTIVITY_TIME_MS = 92;
+  PROVISIONING_NETWORK_TYPE = 93;
+  PROVISIONING_ACTION = 94;
+  PROVISIONING_EXTRAS = 95;
+  PROVISIONING_COPY_ACCOUNT_TASK_MS = 96;
+  PROVISIONING_CREATE_PROFILE_TASK_MS = 97;
+  PROVISIONING_START_PROFILE_TASK_MS = 98;
+  PROVISIONING_DOWNLOAD_PACKAGE_TASK_MS = 99;
+  PROVISIONING_INSTALL_PACKAGE_TASK_MS = 100;
+  PROVISIONING_CANCELLED = 101;
+  PROVISIONING_ERROR = 102;
+  PROVISIONING_COPY_ACCOUNT_STATUS = 103;
+  PROVISIONING_TOTAL_TASK_TIME_MS = 104;
+  PROVISIONING_SESSION_STARTED = 105;
+  PROVISIONING_SESSION_COMPLETED = 106;
+  PROVISIONING_TERMS_ACTIVITY_TIME_MS = 107;
+  PROVISIONING_TERMS_COUNT = 108;
+  PROVISIONING_TERMS_READ = 109;
+}
diff --git a/core/proto/android/stats/devicepolicy/jarjar-rules.txt b/core/proto/android/stats/devicepolicy/jarjar-rules.txt
new file mode 100644
index 0000000..40043a86
--- /dev/null
+++ b/core/proto/android/stats/devicepolicy/jarjar-rules.txt
@@ -0,0 +1 @@
+rule com.google.protobuf.nano.** com.android.framework.protobuf.nano.@1