1/*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto3";
18
19package com.android.server.art.proto;
20option java_multiple_files = true;
21
22// Pre-reboot Dexopt metrics to persist on disk for being reported after reboot.
23// This proto is persisted on disk and forward and backward compatibility are considerations.
24message PreRebootStats {
25    // Overall status of the job right before the reboot.
26    // See `android.os.statsd.art.PreRebootDexoptJobEnded`.
27    enum Status {
28        STATUS_UNKNOWN = 0;
29        STATUS_SCHEDULED = 1;
30        STATUS_STARTED = 2;
31        STATUS_FAILED = 3;
32        STATUS_FINISHED = 4;
33        STATUS_CANCELLED = 5;
34        STATUS_ABORTED_SYSTEM_REQUIREMENTS = 6;
35        STATUS_NOT_SCHEDULED_DISABLED = 7;
36        STATUS_NOT_SCHEDULED_JOB_SCHEDULER = 8;
37    }
38    optional Status status = 1;
39
40    // Number of packages successfully optimized.
41    optional int32 optimized_package_count = 2;
42    // Number of packages failed to optimize.
43    optional int32 failed_package_count = 3;
44    // Number of packages skipped.
45    optional int32 skipped_package_count = 4;
46    // Total number of packages scanned.
47    optional int32 total_package_count = 5;
48
49    // When the job is scheduled, in milliseconds.
50    optional int64 job_scheduled_timestamp_millis = 6;
51
52    // Represents a job run.
53    message JobRun {
54        // When the job is started, in milliseconds.
55        optional int64 job_started_timestamp_millis = 1;
56        // When the job is ended (failed, finished, or cancelled), in milliseconds.
57        optional int64 job_ended_timestamp_millis = 2;
58    }
59
60    // All job runs. The job may be cancelled and rerun multiple times.
61    repeated JobRun job_runs = 7;
62
63    // Number of packages that have Pre-reboot Dexopt artifacts before the reboot. Note that this
64    // isn't necessarily equal to `optimized_package_count` because packages failed to be optimized
65    // may still have some splits successfully optimized.
66    optional int32 packages_with_artifacts_before_reboot_count = 8;
67
68    // The type of the job.
69    enum JobType {
70        JOB_TYPE_UNKNOWN = 0;
71        JOB_TYPE_OTA = 1;
72        JOB_TYPE_MAINLINE = 2;
73    }
74    optional JobType job_type = 9;
75}
76