blob: dbb0578aac0e99c02b890647ed85262736cf2e3f [file] [log] [blame]
Todd Poynor694553d2015-12-03 11:05:45 -08001/*
2 * Copyright (C) 2015 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
17#include "metrics_collector_service_impl.h"
18
19#include <binder/IServiceManager.h>
20#include <binder/Status.h>
21#include <brillo/binder_watcher.h>
22#include <utils/Errors.h>
23
24#include "metrics_collector_service_trampoline.h"
25
26using namespace android;
27
28BnMetricsCollectorServiceImpl::BnMetricsCollectorServiceImpl(
29 MetricsCollectorServiceTrampoline* metrics_collector_service_trampoline) {
30 metrics_collector_service_trampoline_ = metrics_collector_service_trampoline;
31}
32
33void BnMetricsCollectorServiceImpl::Run() {
34 status_t status =
35 defaultServiceManager()->addService(getInterfaceDescriptor(), this);
36 CHECK(status == OK) << "libmetricscollectorservice: failed to add service";
37 binder_watcher_.reset(new ::brillo::BinderWatcher);
38 CHECK(binder_watcher_->Init()) << "Binder FD watcher init failed";
39}
40
41android::binder::Status BnMetricsCollectorServiceImpl::notifyUserCrash() {
42 metrics_collector_service_trampoline_->ProcessUserCrash();
43 return android::binder::Status::ok();
44}