diff options
Diffstat (limited to 'include/binder')
-rw-r--r-- | include/binder/activity_info.h | 40 | ||||
-rw-r--r-- | include/binder/app_intent_event.h | 45 | ||||
-rw-r--r-- | include/binder/app_launch_event.h | 448 | ||||
-rw-r--r-- | include/binder/auto_parcelable.h | 188 | ||||
-rw-r--r-- | include/binder/common.h | 28 | ||||
-rw-r--r-- | include/binder/dexopt_event.h | 42 | ||||
-rw-r--r-- | include/binder/job_scheduled_event.h | 64 | ||||
-rw-r--r-- | include/binder/package_event.h | 43 | ||||
-rw-r--r-- | include/binder/request_id.h | 44 | ||||
-rw-r--r-- | include/binder/system_service_event.h | 42 | ||||
-rw-r--r-- | include/binder/system_service_user_event.h | 46 | ||||
-rw-r--r-- | include/binder/task_result.h | 56 |
12 files changed, 0 insertions, 1086 deletions
diff --git a/include/binder/activity_info.h b/include/binder/activity_info.h deleted file mode 100644 index 0712f18..0000000 --- a/include/binder/activity_info.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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_ACTIVITY_INFO_H_ -#define IORAP_BINDER_ACTIVITY_INFO_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" -#include "common/introspection.h" - -#include <string> - -namespace iorap { -namespace binder { - -struct ActivityInfo : public AutoParcelable<ActivityInfo> { - std::string package_name; - std::string activity_name; -}; - -IORAP_INTROSPECT_ADAPT_STRUCT(ActivityInfo, package_name, activity_name); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(ActivityInfo) - -#endif // IORAP_BINDER_ACTIVITY_INFO_H_ diff --git a/include/binder/app_intent_event.h b/include/binder/app_intent_event.h deleted file mode 100644 index bbd19ee..0000000 --- a/include/binder/app_intent_event.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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_APP_INTENT_EVENT_H_ -#define IORAP_BINDER_APP_INTENT_EVENT_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" -#include "common/introspection.h" - -#include "binder/activity_info.h" - -namespace iorap { -namespace binder { - -struct AppIntentEvent : public AutoParcelable<AppIntentEvent> { - enum class Type : int32_t { - kDefaultIntentChanged = 0, - }; - - Type type; - ActivityInfo old_activity_info; - ActivityInfo new_activity_info; -}; - -IORAP_INTROSPECT_ADAPT_STRUCT(AppIntentEvent, type, old_activity_info, new_activity_info); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(AppIntentEvent) - -#endif // IORAP_BINDER_APP_INTENT_EVENT_H_ diff --git a/include/binder/app_launch_event.h b/include/binder/app_launch_event.h deleted file mode 100644 index 0127e09..0000000 --- a/include/binder/app_launch_event.h +++ /dev/null @@ -1,448 +0,0 @@ -/* - * 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_APP_LAUNCH_EVENT_H_ -#define IORAP_BINDER_APP_LAUNCH_EVENT_H_ - -#include "binder/common.h" -#include "common/introspection.h" -#include "common/expected.h" - -#include <binder/Parcel.h> -#include <binder/Parcelable.h> -#include <frameworks/base/core/proto/android/content/intent.pb.h> // IntentProto -#include <frameworks/base/core/proto/android/server/activitymanagerservice.pb.h> // ActivityRecord - -namespace iorap { -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::wm::ActivityRecordProto; - -struct AppLaunchEvent : public ::android::Parcelable { - // Index position matters: Keep up-to-date with AppLaunchEvent.java sTypes field. - enum class Type : int32_t { - kUninitialized = -1, - kIntentStarted = 0, - kIntentFailed = 1, - kActivityLaunched = 2, - kActivityLaunchFinished = 3, - kActivityLaunchCancelled = 4, - kReportFullyDrawn = 5, - }; - - enum class Temperature : int32_t { - kUninitialized = -1, - kCold = 1, - kWarm = 2, - kHot = 3, - }; - - Type type{Type::kUninitialized}; - int64_t sequence_id{-1}; - // kIntentStarted only. - std::unique_ptr<IntentProto> intent_proto; - // kActivityLaunched only. - 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, - 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)), - 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 { - -# define PARCEL_READ_OR_RETURN(function, ...) \ - if (::android::status_t res = function(__VA_ARGS__); res != ::android::NO_ERROR) { \ - LOG(ERROR) << "AppLaunchEvent::readFromParcel failed"; \ - return res; \ - } - - int32_t type_int; - PARCEL_READ_OR_RETURN(parcel->readInt32, &type_int); - type = static_cast<Type>(type_int); - - LOG(VERBOSE) << "AppLaunchEvent::readFromParcel (type=" << type_int << ")"; - - PARCEL_READ_OR_RETURN(parcel->readInt64, &sequence_id); - - 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. - break; - case Type::kActivityLaunched: { - PARCEL_READ_OR_RETURN(readActivityRecordProto, parcel); - int32_t temperature_int; - PARCEL_READ_OR_RETURN(parcel->readInt32, &temperature_int); - temperature = static_cast<Temperature>(temperature_int); - break; - } - 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; - } -# undef PARCEL_READ_OR_RETURN - - return ::android::NO_ERROR; - - // TODO: std::variant + protobuf implementation in AutoParcelable. - } - -#define PARCEL_WRITE_OR_RETURN(function, ...) \ - if (::android::status_t res = function(__VA_ARGS__); res != ::android::NO_ERROR) { \ - return res; \ - } - - ::android::status_t writeToParcel(android::Parcel* parcel) const override { - PARCEL_WRITE_OR_RETURN(parcel->writeInt32, static_cast<int32_t>(type)); - PARCEL_WRITE_OR_RETURN(parcel->writeInt64, sequence_id); - - 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. - break; - case Type::kActivityLaunched: - PARCEL_WRITE_OR_RETURN(writeActivityRecordProto, parcel); - PARCEL_WRITE_OR_RETURN(parcel->writeInt32, static_cast<int32_t>(temperature)); - 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; - } - -#undef PARCEL_WRITE_OR_RETURN - - return android::NO_ERROR; - } - - private: - // Using 'unique_ptr' here because protobufs don't have a move constructor. Is there - // a better way that is cheap to pass them around? - template <typename T> - static expected<std::unique_ptr<T>, ::android::status_t> - ReadProto(const android::Parcel* parcel) { - DCHECK(parcel != nullptr); - - ::android::status_t res; - - std::vector<uint8_t> byte_vector; - if ((res = parcel->readByteVector(/*out*/&byte_vector)) != ::android::NO_ERROR) { - return unexpected(res); - } - // TODO: we may want to do this without an extra copy, by parsing - // the protobuf directly out of the parcel. - - const uint8_t* data = byte_vector.data(); - const size_t size = byte_vector.size(); - - std::unique_ptr<T> proto_ptr{new T{}}; - - if (!proto_ptr) { - return unexpected(::android::NO_MEMORY); - } - - if (!proto_ptr->ParseFromArray(data, size)) { - return unexpected(::android::BAD_VALUE); - } - - return proto_ptr; - } - - template <typename T> - static expected<std::unique_ptr<T>, ::android::status_t> - ReadNullableProto(const android::Parcel* parcel) { - DCHECK(parcel != nullptr); - - bool value; - - ::android::status_t res; - res = parcel->readBool(/*out*/&value); - - if (res != ::android::NO_ERROR) { - return unexpected(res); - } - - if (!value) { - return std::unique_ptr<T>{nullptr}; - } - - return ReadProto<T>(parcel); - } - - template <typename T> - static ::android::status_t - WriteProto(android::Parcel* parcel, const std::unique_ptr<T>& proto) { - DCHECK(parcel != nullptr); - DCHECK(proto != nullptr); - - std::vector<uint8_t> byte_vector; - { - const int serialized_size = proto->ByteSize(); - byte_vector.resize(serialized_size); - if (!proto->SerializeToArray(byte_vector.data(), serialized_size)) { - return ::android::BAD_VALUE; - } - } - - ::android::status_t res; - if ((res = parcel->writeByteVector(/*in*/byte_vector)) != ::android::NO_ERROR) { - return res; - } - - return ::android::NO_ERROR; - } - - template <typename T> - static ::android::status_t - WriteNullableProto(android::Parcel* parcel, const std::unique_ptr<T>& maybe_proto) { - bool value = (maybe_proto != nullptr); - - ::android::status_t res; - res = parcel->writeBool(value); - - if (res != ::android::NO_ERROR) { - return res; - } - - if (!value) { - return ::android::NO_ERROR; - } - - return WriteProto<T>(parcel, maybe_proto); - } - - android::status_t readIntent(const android::Parcel* parcel) { - expected<std::unique_ptr<IntentProto>, ::android::status_t> maybe_intent = - ReadProto<IntentProto>(parcel); - - if (maybe_intent) { - intent_proto = std::move(maybe_intent.value()); - return ::android::NO_ERROR; - } else { - return maybe_intent.error(); - } - } - - android::status_t readActivityRecordProto(const android::Parcel* parcel) { - expected<std::unique_ptr<ActivityRecordProto>, ::android::status_t> maybe_record = - ReadProto<ActivityRecordProto>(parcel); - - if (maybe_record) { - activity_record_proto = std::move(maybe_record.value()); - return ::android::NO_ERROR; - } else { - return maybe_record.error(); - } - } - - android::status_t readActivityRecordProtoNullable(const android::Parcel* parcel) { - expected<std::unique_ptr<ActivityRecordProto>, ::android::status_t> maybe_record = - ReadNullableProto<ActivityRecordProto>(parcel); - - if (maybe_record) { - activity_record_proto = std::move(maybe_record.value()); - return ::android::NO_ERROR; - } else { - return maybe_record.error(); - } - } - - android::status_t writeIntent(android::Parcel* parcel) const { - return WriteProto<IntentProto>(parcel, intent_proto); - } - - android::status_t writeActivityRecordProto(android::Parcel* parcel) const { - return WriteProto<ActivityRecordProto>(parcel, activity_record_proto); - } - - android::status_t writeActivityRecordProtoNullable(android::Parcel* parcel) const { - return WriteNullableProto<ActivityRecordProto>(parcel, activity_record_proto); - } -}; - -inline std::ostream& operator<<(std::ostream& os, const AppLaunchEvent::Type& type) { - switch (type) { - case AppLaunchEvent::Type::kUninitialized: - os << "kUninitialized"; - break; - case AppLaunchEvent::Type::kIntentStarted: - os << "kIntentStarted"; - break; - case AppLaunchEvent::Type::kIntentFailed: - os << "kIntentFailed"; - break; - case AppLaunchEvent::Type::kActivityLaunched: - os << "kActivityLaunched"; - break; - case AppLaunchEvent::Type::kActivityLaunchCancelled: - os << "kActivityLaunchCancelled"; - break; - case AppLaunchEvent::Type::kActivityLaunchFinished: - os << "kActivityLaunchFinished"; - break; - case AppLaunchEvent::Type::kReportFullyDrawn: - os << "kReportFullyDrawn"; - break; - default: - os << "(unknown)"; - } - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const AppLaunchEvent::Temperature& type) { - switch (type) { - case AppLaunchEvent::Temperature::kUninitialized: - os << "kUninitialized"; - break; - case AppLaunchEvent::Temperature::kCold: - os << "kCold"; - break; - case AppLaunchEvent::Temperature::kWarm: - os << "kWarm"; - break; - case AppLaunchEvent::Temperature::kHot: - os << "kHot"; - break; - default: - os << "(unknown)"; - } - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const AppLaunchEvent& e) { - os << "AppLaunchEvent{"; - os << "type=" << e.type << ","; - os << "sequence_id=" << e.sequence_id << ","; - - os << "intent_proto="; - if (e.intent_proto == nullptr) { - os << "(nullptr)"; - } else { - os << "(action=" << e.intent_proto->action() << ","; - os << "component="; - if (e.intent_proto->has_component()) { - // $package/$class_name - os << e.intent_proto->component().package_name() << "/" - << e.intent_proto->component().class_name(); - } else { - os << "(no component)"; - } - os << ")"; - } - os << ","; - - os << "temperature=" << e.temperature << ","; - os << ","; - - os << "activity_record_proto="; - if (e.activity_record_proto == nullptr) { - os << "(nullptr)"; - } else { - // title or component name. - os << "'" << e.activity_record_proto->identifier().title() << "'"; - } - os << ","; - - os << "timestamp_nanos=" << e.timestamp_nanos << ","; - os << ","; - - os << "}"; - - return os; -} - -/* -IORAP_INTROSPECT_ADAPT_STRUCT(AppLaunchEvent, - type, - sequence_id, - intent_proto, - temperature, - activity_record_proto); -*/ - -} // namespace binder -} // namespace iorap - -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(AppLaunchEvent) - -#endif // IORAP_BINDER_APP_LAUNCH_EVENT_H_ diff --git a/include/binder/auto_parcelable.h b/include/binder/auto_parcelable.h deleted file mode 100644 index 357615c..0000000 --- a/include/binder/auto_parcelable.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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_AUTO_PARCELABLE_H_ -#define IORAP_BINDER_AUTO_PARCELABLE_H_ - -#include "binder/Parcelable.h" -#include "binder/Parcel.h" -#include "binder/Status.h" - -#include "common/introspection.h" - -namespace iorap { -namespace binder { - -// -// Implements the android::Parcelable interface (readFromParcel, writeToParcel) -// automatically by using compile-time introspection on T. -// -// Requires that 'T' implements introspection by using the IORAP_INTROSPECT_ADAPT_STRUCT macro. -// -template <typename T> -struct AutoParcelable : public ::android::Parcelable { - private: - using Status = android::binder::Status; - using Parcel = android::Parcel; - using Parcelable = android::Parcelable; - using status_t = android::status_t; - - public: - // Write every (introspected) field to the parcel by automatically inferring the correct - // write method to invoke on the parcel from the member type. - status_t writeToParcel(Parcel* parcel) const override { - if (parcel == nullptr) { - return ::android::UNEXPECTED_NULL; - } - - status_t result = android::NO_ERROR; - ::iorap::introspect::for_each_member_field_value(*Self(), [&](auto&& value) { - if (result == android::NO_ERROR) { - result = writeAnyToParcel(/*inout*/parcel, value); - } - }); - - return result; - } - - // Read every (introspected) field to the parcel by automatically inferring the correct - // read method to invoke on the parcel from the member type. - // - // Resilient to partial read failures: A return code other than NO_ERROR means that - // the current value is left unmodified. - status_t readFromParcel(const Parcel* parcel) override { - if (parcel == nullptr) { - return ::android::UNEXPECTED_NULL; - } - - T tmp{*Self()}; - - // Unpack all the parcelable data into a temporary copy. - // Parceling could fail halfway through, in which case - // the original object is unaffected. - - status_t result = android::NO_ERROR; - ::iorap::introspect::for_each_member_field_set_value(tmp, [&](auto field_type) { - // type<?> field_type - - using ValueT = typename decltype(field_type)::type; - - if (result == android::NO_ERROR) { - auto&& [res, read_value] = readAnyFromParcel<ValueT>(/*inout*/parcel); - result = res; - return ::iorap::introspect::aliasing_forward<ValueT>(read_value); - } else { - // TODO: nice-to-have fold over members to early-out on failure. - return ValueT{}; - } - }); - - if (result != android::NO_ERROR) { - return result; - } - - // Success! Now we can copy all the data in a single step. - *Self() = std::move(tmp); - - // TODO: nice-to-have some kind of invariants-checking after reading the parcel data. - - return ::android::NO_ERROR; - } - - private: -#define AUTO_PARCELABLE_BINDER_MAPPING(FN) \ -FN(Byte,int8_t)\ -FN(Int32,int32_t)\ -FN(Uint32,uint32_t)\ -FN(Int64,int64_t)\ -FN(Uint64,uint64_t)\ -FN(Float,float)\ -FN(Double,double)\ -FN(Bool,bool)\ -FN(CString,const char*)\ -FN(String16,const String16&)\ -FN(String16,const std::unique_ptr<String16>&)\ -FN(StrongBinder,const sp<IBinder>&)\ - - template <typename F> - static status_t writeAnyToParcel(Parcel* parcel, const F& value) { - using namespace android; // NOLINT - - // 'F' is the original type of the field here, so it's safe to use it undecayed. - // However, to make matching easier we almost always want to match against the decayed type. - using D = std::decay_t<F>; // [const] [volatile] X[&][&] -> X - - if constexpr (std::is_base_of_v<Parcelable, D>) { - return value.writeToParcel(parcel); - } else if constexpr (std::is_enum_v<D>) { - return writeAnyToParcel(parcel, static_cast<std::underlying_type_t<F>>(value)); -#define AUTO_PARCELABLE_WRITE_TO_PARCEL(fn_name, type_name) \ - } else if constexpr (std::is_same_v<D, std::decay_t<type_name>>) { \ - return parcel->write ## fn_name (value); -AUTO_PARCELABLE_BINDER_MAPPING(AUTO_PARCELABLE_WRITE_TO_PARCEL) - } else if constexpr (std::is_same_v<D, std::string>) { - return parcel->writeUtf8AsUtf16(value); - } else { - STATIC_FAIL(D, "Unsupported type: Add more manual type conversions above^^^"); - } - -#undef AUTO_PARCELABLE_WRITE_TO_PARCEL - } - - template <typename F> - static auto readAnyFromParcel(const Parcel* parcel) { - // returns pair(status_t, ~F~) - using namespace android; - - // Since 'F' is almost always an lvalue reference (due to F=decltype(auto&&), - // we should lose the references, and also any consts. - using D = std::decay_t<F>; - - D value; - status_t result; - - if constexpr (std::is_base_of_v<Parcelable, D>) { - status_t result = value.readFromParcel(/*in*/parcel); - } else if constexpr (std::is_enum_v<D>) { - auto&& [res, val] = readAnyFromParcel<std::underlying_type_t<D>>(parcel); - result = res; - value = static_cast<D>(val); -#define AUTO_PARCELABLE_READ_FROM_PARCEL(fn_name, type_name) \ - } else if constexpr (std::is_same_v<D, std::decay_t<type_name>>) { \ - result = parcel->read ## fn_name (/*out*/&value); -AUTO_PARCELABLE_BINDER_MAPPING(AUTO_PARCELABLE_READ_FROM_PARCEL) - } else if constexpr (std::is_same_v<D, std::string>) { - result = parcel->readUtf8FromUtf16(/*out*/&value); - } else { - STATIC_FAIL(D, "Unsupported type: Add more manual type conversions above^^^"); - } -#undef AUTO_PARCELABLE_READ_FROM_PARCEL - - return std::make_pair(result, std::move(value)); - } - - T* Self() { - return static_cast<T*>(this); - } - const T* Self() const { - return static_cast<const T*>(this); - } -}; - -} // namespace binder -} // namespace iorap - -#endif // IORAP_BINDER_AUTO_PARCELABLE_H_ diff --git a/include/binder/common.h b/include/binder/common.h deleted file mode 100644 index f31e1e9..0000000 --- a/include/binder/common.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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_COMMON_H_ -#define IORAP_BINDER_COMMON_H_ - -// AIDL has no way to specify a custom C++ namespace for parcelables. -// -// We want our parcelables to live in the ::iorap::binder namespace, -// not in com.google.android.startop.iorap -// So this macro is just a short-hand for doing an alias across namespaces. -#define IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(what) \ -namespace com { namespace google { namespace android { namespace startop { namespace iorap { using what = ::iorap::binder::what; } } } } } - -#endif // IORAP_BINDER_COMMON_H_ diff --git a/include/binder/dexopt_event.h b/include/binder/dexopt_event.h deleted file mode 100644 index cb506f4..0000000 --- a/include/binder/dexopt_event.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6b067d7..0000000 --- a/include/binder/job_scheduled_event.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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; - std::string package_name; - bool should_update_versions; - - 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 - && package_name == other.package_name - && should_update_versions == other.should_update_versions; - } - - constexpr bool operator!=(const JobScheduledEvent& other) const { - return !(*this == other); - } -}; - -IORAP_INTROSPECT_ADAPT_STRUCT( - JobScheduledEvent, type, job_id, sort, package_name, should_update_versions); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(JobScheduledEvent) - -#endif // IORAP_BINDER_JOB_SCHEDULED_EVENT_H_ diff --git a/include/binder/package_event.h b/include/binder/package_event.h deleted file mode 100644 index d8d7933..0000000 --- a/include/binder/package_event.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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_PACKAGE_EVENT_H_ -#define IORAP_BINDER_PACKAGE_EVENT_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" -#include "common/introspection.h" - -namespace iorap { -namespace binder { - -struct PackageEvent : public AutoParcelable<PackageEvent> { - enum class Type : int32_t { - kReplaced = 0, - }; - - Type type; - std::string package_uri; - std::string package_name; -}; - -IORAP_INTROSPECT_ADAPT_STRUCT(PackageEvent, type, package_uri, package_name); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(PackageEvent) - -#endif // IORAP_BINDER_PACKAGE_EVENT_H_ diff --git a/include/binder/request_id.h b/include/binder/request_id.h deleted file mode 100644 index 71a2edd..0000000 --- a/include/binder/request_id.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_REQUEST_ID_H_ -#define IORAP_BINDER_REQUEST_ID_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" - -namespace iorap { -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); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(RequestId) - -#endif // IORAP_BINDER_REQUEST_ID_H_ diff --git a/include/binder/system_service_event.h b/include/binder/system_service_event.h deleted file mode 100644 index a82c200..0000000 --- a/include/binder/system_service_event.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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_SYSTEM_SERVICE_EVENT_H_ -#define IORAP_BINDER_SYSTEM_SERVICE_EVENT_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" -#include "common/introspection.h" - -namespace iorap { -namespace binder { - -struct SystemServiceEvent : public AutoParcelable<SystemServiceEvent> { - enum class Type : int32_t { - kBootPhase = 0, - kStart = 1, - }; - - Type type; -}; - -IORAP_INTROSPECT_ADAPT_STRUCT(SystemServiceEvent, type); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(SystemServiceEvent) - -#endif // IORAP_BINDER_SYSTEM_SERVICE_EVENT_H_ diff --git a/include/binder/system_service_user_event.h b/include/binder/system_service_user_event.h deleted file mode 100644 index 43f92ea..0000000 --- a/include/binder/system_service_user_event.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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_SYSTEM_SERVICE_USER_EVENT_H_ -#define IORAP_BINDER_SYSTEM_SERVICE_USER_EVENT_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" -#include "common/introspection.h" - -namespace iorap { -namespace binder { - -struct SystemServiceUserEvent : public AutoParcelable<SystemServiceUserEvent> { - enum class Type : int32_t { - kStartUser = 0, - kUnlockUser, - kSwitchUser, - kStopUser, - kCleanupUser, - }; - - Type type; - int32_t user_handle; -}; - -IORAP_INTROSPECT_ADAPT_STRUCT(SystemServiceUserEvent, type, user_handle); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(SystemServiceUserEvent) - -#endif // IORAP_BINDER_SYSTEM_SERVICE_USER_EVENT_H_ diff --git a/include/binder/task_result.h b/include/binder/task_result.h deleted file mode 100644 index b060f3f..0000000 --- a/include/binder/task_result.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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_TASK_RESULT_H_ -#define IORAP_BINDER_TASK_RESULT_H_ - -#include "binder/common.h" -#include "binder/auto_parcelable.h" -#include "common/introspection.h" - -namespace iorap { -namespace binder { - -struct TaskResult : public AutoParcelable<TaskResult> { - enum class State : int32_t { - kBegan = 0, - kOngoing = 1, - kCompleted = 2, - kError = 3, - kMax = kError, - }; - - 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); - -} -} -IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(TaskResult) - -#endif // IORAP_BINDER_TASK_RESULT_H_ |