blob: 13c6f67dd37d81c73f9988e4a0a192b6095d7fec [file] [log] [blame]
Joe Onorato5dcbc6c2017-08-29 15:13:58 -07001/*
2 * Copyright (C) 2016 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#define LOG_TAG "statsd"
18
19#include "StatsService.h"
20
21#include <binder/IPCThreadState.h>
22#include <binder/IServiceManager.h>
23#include <cutils/log.h>
24#include <private/android_filesystem_config.h>
25#include <utils/Looper.h>
26
27#include <unistd.h>
28#include <stdio.h>
29
30using namespace android;
31
32// ================================================================================
33StatsService::StatsService(const sp<Looper>& handlerLooper)
34{
35 ALOGD("stats service constructed");
36}
37
38StatsService::~StatsService()
39{
40}
41
42status_t
43StatsService::dump(int fd, const Vector<String16>& args)
44{
45 FILE* out = fdopen(fd, "w");
46 if (out == NULL) {
47 return NO_MEMORY; // the fd is already open
48 }
49
50 fprintf(out, "StatsService::dump:");
51 ALOGD("StatsService::dump:");
52 const int N = args.size();
53 for (int i=0; i<N; i++) {
54 fprintf(out, " %s", String8(args[i]).string());
55 ALOGD(" %s", String8(args[i]).string());
56 }
57 fprintf(out, "\n");
58
59 fclose(out);
60 return NO_ERROR;
61}
62
63Status
64StatsService::systemRunning()
65{
66 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
67 return Status::fromExceptionCode(Status::EX_SECURITY,
68 "Only system uid can call systemRunning");
69 }
70
71 // When system_server is up and running, schedule the dropbox task to run.
72 ALOGD("StatsService::systemRunning");
73
74 return Status::ok();
75}
76