summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2018-11-26 10:34:38 -0800
committerIgor Murashkin <iam@google.com>2019-01-07 13:45:51 -0800
commit202cb0a892690b490a263293633cc623b62ff946 (patch)
tree6986d69645abb3df65b829ef605da4b9d1efa3d4
parentaf46ec1ecefe2406ac6a6d0c606244a86e0f41bf (diff)
downloadiorap-202cb0a892690b490a263293633cc623b62ff946.tar.gz
binder: Add IIorap#onAppLaunchEvent AIDL method.
This consumes ActivityMetricsLaunchObserver callbacks from wm. We get app launch events (e.g. when an intent starts, an app launch begins/finishes, etc). Bug: 72170747 Change-Id: Ieb0312a851c75c39656183064e1dadbeae85cbe5
-rw-r--r--binder/com/google/android/startop/iorap/AppLaunchEvent.aidl20
-rw-r--r--binder/com/google/android/startop/iorap/IIorap.aidl2
-rw-r--r--include/binder/app_launch_event.h113
-rw-r--r--src/binder/iiorap_def.h2
4 files changed, 137 insertions, 0 deletions
diff --git a/binder/com/google/android/startop/iorap/AppLaunchEvent.aidl b/binder/com/google/android/startop/iorap/AppLaunchEvent.aidl
new file mode 100644
index 0000000..ea3f9f1
--- /dev/null
+++ b/binder/com/google/android/startop/iorap/AppLaunchEvent.aidl
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+package com.google.android.startop.iorap;
+
+/** @hide */
+parcelable AppLaunchEvent cpp_header "binder/app_launch_event.h";
diff --git a/binder/com/google/android/startop/iorap/IIorap.aidl b/binder/com/google/android/startop/iorap/IIorap.aidl
index 2b58905..fe91d15 100644
--- a/binder/com/google/android/startop/iorap/IIorap.aidl
+++ b/binder/com/google/android/startop/iorap/IIorap.aidl
@@ -19,6 +19,7 @@ package com.google.android.startop.iorap;
import com.google.android.startop.iorap.ITaskListener;
import com.google.android.startop.iorap.PackageEvent;
+import com.google.android.startop.iorap.AppLaunchEvent;
import com.google.android.startop.iorap.AppIntentEvent;
import com.google.android.startop.iorap.SystemServiceEvent;
import com.google.android.startop.iorap.SystemServiceUserEvent;
@@ -107,6 +108,7 @@ oneway interface IIorap {
// in frameworks/base/startop/src/com/google/android/startop/iorap/${Type}Event.java
// void onActivityHintEvent(in RequestId request, in ActivityHintEvent event);
+ void onAppLaunchEvent(in RequestId request, in AppLaunchEvent event);
void onPackageEvent(in RequestId request, in PackageEvent event);
void onAppIntentEvent(in RequestId request, in AppIntentEvent event);
void onSystemServiceEvent(in RequestId request, in SystemServiceEvent event);
diff --git a/include/binder/app_launch_event.h b/include/binder/app_launch_event.h
new file mode 100644
index 0000000..2221199
--- /dev/null
+++ b/include/binder/app_launch_event.h
@@ -0,0 +1,113 @@
+/*
+ * 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"
+
+namespace iorap {
+namespace binder {
+
+struct AppLaunchEvent : public ::android::Parcelable {
+ enum class Type : int32_t {
+ kIntentStarted = 0,
+ kIntentFailed = 1,
+ kActivityLaunched = 2,
+ kActivityLaunchCancelled = 3,
+ kActivityLaunchFinished = 4,
+ };
+
+ enum class Temperature : int32_t {
+ kCold = 1,
+ kWarm = 2,
+ kHot = 3,
+ };
+
+ Type type;
+ int64_t sequenceId;
+ std::string intent; // kIntentStarted only.
+ Temperature temperature; // kActivityLaunched only.
+ std::vector<uint8_t> activity_record_proto; // kActivityLaunch*
+
+ ::android::status_t readFromParcel(const android::Parcel* parcel) override {
+ ::android::status_t res = android::NO_ERROR;
+
+ type = static_cast<Type>(parcel->readInt32());
+ sequenceId = parcel->readInt64();
+
+ switch (type) {
+ case Type::kIntentStarted:
+ return readIntent(parcel);
+ case Type::kIntentFailed:
+ // No extra arguments.
+ break;
+ case Type::kActivityLaunched:
+ res = readActivityRecordProto(parcel);
+ if (res != android::NO_ERROR) {
+ return res;
+ }
+ temperature = static_cast<Temperature>(parcel->readInt32());
+ break;
+ case Type::kActivityLaunchFinished:
+ return readActivityRecordProto(parcel);
+ case Type::kActivityLaunchCancelled:
+ return readActivityRecordProtoNullable(parcel);
+ default:
+ return android::BAD_VALUE;
+ }
+ return res;
+
+ // TODO: std::variant + protobuf implementation in AutoParcelable.
+ }
+
+ ::android::status_t writeToParcel(android::Parcel* parcel) const override {
+ parcel->writeInt32(static_cast<int32_t>(type));
+ parcel->writeInt64(sequenceId);
+ // TODO rest.
+ return android::NO_ERROR;
+ }
+
+ private:
+ android::status_t readIntent(const android::Parcel* parcel) {
+ android::status_t res = parcel->readUtf8FromUtf16(/*out*/&intent);
+ if (res != android::NO_ERROR) return res;
+ // FIXME: This is a placeholder which only reads the 'action'. Replace with IntentProto.
+ return android::NO_ERROR;
+ }
+
+ android::status_t readActivityRecordProto(const android::Parcel* parcel) {
+ // TODO: replace with ActivityRecordProto instead of just reading the byte[].
+ return parcel->readByteVector(/*out*/&activity_record_proto);
+ }
+
+ android::status_t readActivityRecordProtoNullable(const android::Parcel* parcel) {
+ bool has_value = parcel->readBool();
+ if (has_value) {
+ return readActivityRecordProto(parcel);
+ }
+ return android::NO_ERROR;
+ }
+};
+
+IORAP_INTROSPECT_ADAPT_STRUCT(AppLaunchEvent, type, intent, activity_record_proto);
+
+}
+}
+IORAP_JAVA_NAMESPACE_BINDER_TYPEDEF(AppLaunchEvent)
+
+#endif // IORAP_BINDER_APP_LAUNCH_EVENT_H_
diff --git a/src/binder/iiorap_def.h b/src/binder/iiorap_def.h
index b88f873..0c1eac8 100644
--- a/src/binder/iiorap_def.h
+++ b/src/binder/iiorap_def.h
@@ -27,6 +27,8 @@
FN_BEGIN(::com::google::android::startup::iorap::,IIorap) \
/* name <see IORAP_BINDER_PARAM_JOIN> */ \
FN(setTaskListener, (const ::android::sp<::com::google::android::startop::iorap::,ITaskListener,>&,listener)) /*NOLINT*/ \
+FN(onAppLaunchEvent,(const ::com::google::android::startop::iorap::,RequestId,&,request), \
+ (const ::com::google::android::startop::iorap::,AppLaunchEvent,&,event)) \
FN(onPackageEvent, (const ::com::google::android::startop::iorap::,RequestId,&,request), \
(const ::com::google::android::startop::iorap::,PackageEvent,&,event)) \
FN(onAppIntentEvent,(const ::com::google::android::startop::iorap::,RequestId,&,request), \