diff options
author | Xin Li <delphij@google.com> | 2020-09-08 16:57:37 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2020-09-08 16:57:37 -0700 |
commit | d1299a41b4bdd9bdfd7d339fedde7fb433569f5e (patch) | |
tree | 72379b91ee508a91522937d7a2fa6640e1e4d2f6 /include | |
parent | 806a07b868ac808bbd7ef09c37d6bd180e15de36 (diff) | |
parent | d3905c2fcaeda7eecdea063d5351d7009f62cbe0 (diff) | |
download | platform_system_iorap-master.tar.gz platform_system_iorap-master.tar.bz2 platform_system_iorap-master.zip |
Bug: 168057903
Merged-In: I3c77335b908d1ae9b675ef482589858ed27a9b97
Change-Id: I36f1c71de91f477257efed4c541bea519457b918
Diffstat (limited to 'include')
-rw-r--r-- | include/binder/app_launch_event.h | 54 | ||||
-rw-r--r-- | include/binder/dexopt_event.h | 42 | ||||
-rw-r--r-- | include/binder/job_scheduled_event.h | 59 | ||||
-rw-r--r-- | include/binder/request_id.h | 8 | ||||
-rw-r--r-- | include/binder/task_result.h | 11 |
5 files changed, 171 insertions, 3 deletions
diff --git a/include/binder/app_launch_event.h b/include/binder/app_launch_event.h index 784db16..0127e09 100644 --- a/include/binder/app_launch_event.h +++ b/include/binder/app_launch_event.h @@ -31,7 +31,7 @@ namespace binder { // These protos are part of the iorapd binder ABI, alias them for easier usage. using IntentProto = ::android::content::IntentProto; -using ActivityRecordProto = ::com::android::server::am::ActivityRecordProto; +using ActivityRecordProto = ::com::android::server::wm::ActivityRecordProto; struct AppLaunchEvent : public ::android::Parcelable { // Index position matters: Keep up-to-date with AppLaunchEvent.java sTypes field. @@ -42,6 +42,7 @@ struct AppLaunchEvent : public ::android::Parcelable { kActivityLaunched = 2, kActivityLaunchFinished = 3, kActivityLaunchCancelled = 4, + kReportFullyDrawn = 5, }; enum class Temperature : int32_t { @@ -59,18 +60,45 @@ struct AppLaunchEvent : public ::android::Parcelable { Temperature temperature{Temperature::kUninitialized}; // kActivityLaunch*. Can be null in kActivityLaunchCancelled. std::unique_ptr<ActivityRecordProto> activity_record_proto; + // kIntentStarted, kActivityLaunchFinished and kReportFullyDrawn only. + int64_t timestamp_nanos{-1}; AppLaunchEvent() = default; AppLaunchEvent(Type type, int64_t sequence_id, std::unique_ptr<IntentProto> intent_proto = nullptr, Temperature temperature = Temperature::kUninitialized, - std::unique_ptr<ActivityRecordProto> activity_record_proto = nullptr) + std::unique_ptr<ActivityRecordProto> activity_record_proto = nullptr, + int64_t timestamp_nanos = -1) : type(type), sequence_id(sequence_id), intent_proto(std::move(intent_proto)), temperature(temperature), - activity_record_proto(std::move(activity_record_proto)) { + activity_record_proto(std::move(activity_record_proto)), + timestamp_nanos(timestamp_nanos) { + } + + AppLaunchEvent(const AppLaunchEvent& other) { + *this = other; + } + + AppLaunchEvent& operator=(const AppLaunchEvent& other) { + if (&other == this) { + return *this; + } + + type = other.type; + sequence_id = other.sequence_id; + if (other.intent_proto != nullptr) { + intent_proto.reset(new IntentProto(*other.intent_proto)); + } + temperature = other.temperature; + if (other.activity_record_proto != nullptr) { + activity_record_proto.reset(new ActivityRecordProto(*other.activity_record_proto)); + } + timestamp_nanos = other.timestamp_nanos; + + return *this; } ::android::status_t readFromParcel(const android::Parcel* parcel) override { @@ -92,6 +120,7 @@ struct AppLaunchEvent : public ::android::Parcelable { switch (type) { case Type::kIntentStarted: PARCEL_READ_OR_RETURN(readIntent, parcel); + PARCEL_READ_OR_RETURN(parcel->readInt64, ×tamp_nanos); break; case Type::kIntentFailed: // No extra arguments. @@ -105,10 +134,15 @@ struct AppLaunchEvent : public ::android::Parcelable { } case Type::kActivityLaunchFinished: PARCEL_READ_OR_RETURN(readActivityRecordProto, parcel); + PARCEL_READ_OR_RETURN(parcel->readInt64, ×tamp_nanos); break; case Type::kActivityLaunchCancelled: PARCEL_READ_OR_RETURN(readActivityRecordProtoNullable, parcel); break; + case Type::kReportFullyDrawn: + PARCEL_READ_OR_RETURN(readActivityRecordProto, parcel); + PARCEL_READ_OR_RETURN(parcel->readInt64, ×tamp_nanos); + break; default: return android::BAD_VALUE; } @@ -131,6 +165,7 @@ struct AppLaunchEvent : public ::android::Parcelable { switch (type) { case Type::kIntentStarted: PARCEL_WRITE_OR_RETURN(writeIntent, parcel); + PARCEL_WRITE_OR_RETURN(parcel->writeInt64, timestamp_nanos); break; case Type::kIntentFailed: // No extra arguments. @@ -141,10 +176,15 @@ struct AppLaunchEvent : public ::android::Parcelable { break; case Type::kActivityLaunchFinished: PARCEL_WRITE_OR_RETURN(writeActivityRecordProto, parcel); + PARCEL_WRITE_OR_RETURN(parcel->writeInt64, timestamp_nanos); break; case Type::kActivityLaunchCancelled: PARCEL_WRITE_OR_RETURN(writeActivityRecordProtoNullable, parcel); break; + case Type::kReportFullyDrawn: + PARCEL_WRITE_OR_RETURN(writeActivityRecordProtoNullable, parcel); + PARCEL_WRITE_OR_RETURN(parcel->writeInt64, timestamp_nanos); + break; default: DCHECK(false) << "attempted to write an uninitialized AppLaunchEvent to Parcel"; return android::BAD_VALUE; @@ -320,6 +360,9 @@ inline std::ostream& operator<<(std::ostream& os, const AppLaunchEvent::Type& ty case AppLaunchEvent::Type::kActivityLaunchFinished: os << "kActivityLaunchFinished"; break; + case AppLaunchEvent::Type::kReportFullyDrawn: + os << "kReportFullyDrawn"; + break; default: os << "(unknown)"; } @@ -378,6 +421,11 @@ inline std::ostream& operator<<(std::ostream& os, const AppLaunchEvent& e) { // title or component name. os << "'" << e.activity_record_proto->identifier().title() << "'"; } + os << ","; + + os << "timestamp_nanos=" << e.timestamp_nanos << ","; + os << ","; + os << "}"; return os; diff --git a/include/binder/dexopt_event.h b/include/binder/dexopt_event.h new file mode 100644 index 0000000..cb506f4 --- /dev/null +++ b/include/binder/dexopt_event.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 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. + */ + +#ifndef IORAP_BINDER_DEXOPT_EVENT_H_ +#define IORAP_BINDER_DEXOPT_EVENT_H_ + +#include "binder/common.h" +#include "binder/auto_parcelable.h" +#include "common/introspection.h" + +namespace iorap { +namespace binder { + +struct DexOptEvent : public AutoParcelable<DexOptEvent> { + enum class Type : int32_t { + kPackageUpdate = 0, + }; + + Type type; + std::string package_name; +}; + +IORAP_INTROSPECT_ADAPT_STRUCT(DexOptEvent, type, package_name); + +} +} +IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(DexOptEvent) + +#endif // IORAP_BINDER_DEXOPT_EVENT_H_ diff --git a/include/binder/job_scheduled_event.h b/include/binder/job_scheduled_event.h new file mode 100644 index 0000000..f85f39b --- /dev/null +++ b/include/binder/job_scheduled_event.h @@ -0,0 +1,59 @@ +/* + * 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. + */ + +#ifndef IORAP_BINDER_JOB_SCHEDULED_EVENT_H_ +#define IORAP_BINDER_JOB_SCHEDULED_EVENT_H_ + +#include "binder/common.h" +#include "binder/auto_parcelable.h" +#include "common/introspection.h" + +namespace iorap { +namespace binder { + +struct JobScheduledEvent : public AutoParcelable<JobScheduledEvent> { + enum class Type : int32_t { + kStartJob = 0, + kStopJob = 1, + }; + + Type type; + int32_t job_id; + + enum class Sort : int32_t { + kIdleMaintenance = 0, + }; + + Sort sort; + + constexpr bool operator==(const JobScheduledEvent& other) const { + return type == other.type + && job_id == other.job_id + && sort == other.sort; + } + + constexpr bool operator!=(const JobScheduledEvent& other) const { + return !(*this == other); + } +}; + +IORAP_INTROSPECT_ADAPT_STRUCT(JobScheduledEvent, type, job_id, sort); + +} +} +IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(JobScheduledEvent) + +#endif // IORAP_BINDER_JOB_SCHEDULED_EVENT_H_ diff --git a/include/binder/request_id.h b/include/binder/request_id.h index c41ff3c..71a2edd 100644 --- a/include/binder/request_id.h +++ b/include/binder/request_id.h @@ -25,6 +25,14 @@ namespace binder { struct RequestId : public AutoParcelable<RequestId> { int64_t request_id; + + constexpr bool operator==(const RequestId& other) const { + return request_id == other.request_id; + } + + constexpr bool operator!=(const RequestId& other) const { + return !(*this == other); + } }; IORAP_INTROSPECT_ADAPT_STRUCT(RequestId, request_id); diff --git a/include/binder/task_result.h b/include/binder/task_result.h index 3fc3ff9..b060f3f 100644 --- a/include/binder/task_result.h +++ b/include/binder/task_result.h @@ -34,6 +34,17 @@ struct TaskResult : public AutoParcelable<TaskResult> { }; State state; + + TaskResult() = default; + explicit TaskResult(State state) : state(state) {} + + constexpr bool operator==(const TaskResult& other) const { + return state == other.state; + } + + constexpr bool operator!=(const TaskResult& other) const { + return !(*this == other); + } }; IORAP_INTROSPECT_ADAPT_STRUCT(TaskResult, state); |