summaryrefslogtreecommitdiff
path: root/perfprofd
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2017-12-28 12:02:12 -0800
committerAndreas Gampe <agampe@google.com>2018-01-18 14:48:17 -0800
commit83476bead4e8ee6cb4dd1669c11e29be6b4afecc (patch)
treeba28c94bd8e932dcf12d44eeff93b3f5ba096e01 /perfprofd
parentd2c99752e774c73f28cf0cef4cdf902e3b5e4781 (diff)
downloadextras-83476bead4e8ee6cb4dd1669c11e29be6b4afecc.tar.gz
Perfprofd: Dropbox support
Use libservices to support sending an encoded proto to dropbox. In the binder frontend, send the encoded proto to dropbox if enabled in the current configuration. Test: mmma system/extras/perfprofd Test: collect profile, check /data/system/dropbox Change-Id: I9830f42ff111eacc685bd13efd6008a8c9c6d6ab
Diffstat (limited to 'perfprofd')
-rw-r--r--perfprofd/Android.bp1
-rw-r--r--perfprofd/binder_interface/Android.bp3
-rw-r--r--perfprofd/binder_interface/perfprofd_binder.cc28
-rw-r--r--perfprofd/binder_interface/perfprofd_config.proto3
-rw-r--r--perfprofd/scripts/perf_config_proto.py1
5 files changed, 35 insertions, 1 deletions
diff --git a/perfprofd/Android.bp b/perfprofd/Android.bp
index 4a7f2f66..3f255448 100644
--- a/perfprofd/Android.bp
+++ b/perfprofd/Android.bp
@@ -156,6 +156,7 @@ cc_binary {
"libprotobuf-cpp-lite",
"libbase",
"libbinder",
+ "libservices",
"libutils",
],
diff --git a/perfprofd/binder_interface/Android.bp b/perfprofd/binder_interface/Android.bp
index c40036bd..d7bff41b 100644
--- a/perfprofd/binder_interface/Android.bp
+++ b/perfprofd/binder_interface/Android.bp
@@ -30,6 +30,9 @@ cc_library_static {
"libperfprofdcore",
"libprotobuf-cpp-lite",
],
+ shared_libs: [
+ "libservices",
+ ],
srcs: [
"perfprofd_binder.cc",
":perfprofd_aidl",
diff --git a/perfprofd/binder_interface/perfprofd_binder.cc b/perfprofd/binder_interface/perfprofd_binder.cc
index 34d6a038..388dea61 100644
--- a/perfprofd/binder_interface/perfprofd_binder.cc
+++ b/perfprofd/binder_interface/perfprofd_binder.cc
@@ -32,6 +32,7 @@
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
+#include <android/os/DropBoxManager.h>
#include <binder/BinderService.h>
#include <binder/IResultReceiver.h>
#include <binder/Status.h>
@@ -55,6 +56,8 @@ using Status = ::android::binder::Status;
class BinderConfig : public Config {
public:
+ bool send_to_dropbox = true;
+
bool is_profiling = false;
void Sleep(size_t seconds) override {
@@ -90,6 +93,8 @@ class BinderConfig : public Config {
// Copy base fields.
*static_cast<Config*>(this) = static_cast<const Config&>(rhs);
+ send_to_dropbox = rhs.send_to_dropbox;
+
return *this;
}
@@ -143,7 +148,27 @@ class PerfProfdNativeService : public BinderService<PerfProfdNativeService>,
};
bool PerfProfdNativeService::BinderHandler(
- wireless_android_play_playlog::AndroidPerfProfile* encodedProfile, Config* config) {
+ wireless_android_play_playlog::AndroidPerfProfile* encodedProfile,
+ Config* config) {
+ CHECK(config != nullptr);
+ if (static_cast<BinderConfig*>(config)->send_to_dropbox) {
+ size_t size = encodedProfile->ByteSize();
+ std::unique_ptr<uint8_t[]> data(new uint8_t[size]);
+ encodedProfile->SerializeWithCachedSizesToArray(data.get());
+
+ using DropBoxManager = android::os::DropBoxManager;
+ sp<DropBoxManager> dropbox(new DropBoxManager());
+ Status status = dropbox->addData(String16("perfprofd"),
+ data.get(),
+ size,
+ 0);
+ if (!status.isOk()) {
+ LOG(WARNING) << "Failed dropbox submission: " << status.exceptionCode()
+ << " " << status.exceptionMessage().c_str();
+ }
+ return status.isOk();
+ }
+
if (encodedProfile == nullptr) {
return false;
}
@@ -264,6 +289,7 @@ Status PerfProfdNativeService::StartProfilingProtobuf(ProtoLoaderFn fn) {
CHECK_AND_COPY_FROM_PROTO(collect_camera_active)
CHECK_AND_COPY_FROM_PROTO(process)
CHECK_AND_COPY_FROM_PROTO(use_elf_symbolizer)
+ CHECK_AND_COPY_FROM_PROTO(send_to_dropbox)
#undef CHECK_AND_COPY_FROM_PROTO
};
return StartProfiling(config_fn);
diff --git a/perfprofd/binder_interface/perfprofd_config.proto b/perfprofd/binder_interface/perfprofd_config.proto
index ae3aee9f..bb7b52d8 100644
--- a/perfprofd/binder_interface/perfprofd_config.proto
+++ b/perfprofd/binder_interface/perfprofd_config.proto
@@ -73,4 +73,7 @@ message ProfilingConfig {
// Whether to use a symbolizer on-device.
optional bool use_elf_symbolizer = 19;
+
+ // Whether to send the result to dropbox.
+ optional bool send_to_dropbox = 20;
};
diff --git a/perfprofd/scripts/perf_config_proto.py b/perfprofd/scripts/perf_config_proto.py
index 13eef959..461f17f5 100644
--- a/perfprofd/scripts/perf_config_proto.py
+++ b/perfprofd/scripts/perf_config_proto.py
@@ -43,6 +43,7 @@ config_options = [
('collect_camera_active', 'b'),
('process', 'i'),
('use_elf_symbolizer', 'b'),
+ ('send_to_dropbox', 'b'),
]
def collect_and_write(filename):