From f9aa8d04bd2da3e34c3dac5dd0d95d2e98e004d6 Mon Sep 17 00:00:00 2001 From: Ruchir Rastogi Date: Tue, 21 Jan 2020 16:57:48 -0800 Subject: [PATCH] Delete StatsCompanionServicePuller Since pulls now go through StatsPullAtomService, instead of StatsCompanionService, we no longer need the StatsCompanionServicePuller class. Test: m -j Change-Id: Id7050fbda1118808aade0754747248b21c11b814 --- .../android/os/IStatsCompanionService.aidl | 6 -- .../server/stats/StatsCompanionService.java | 21 ----- cmds/statsd/Android.bp | 1 - .../external/StatsCompanionServicePuller.cpp | 78 ------------------- .../external/StatsCompanionServicePuller.h | 40 ---------- .../src/external/StatsPullerManager.cpp | 1 - 6 files changed, 147 deletions(-) delete mode 100644 cmds/statsd/src/external/StatsCompanionServicePuller.cpp delete mode 100644 cmds/statsd/src/external/StatsCompanionServicePuller.h diff --git a/apex/statsd/aidl/android/os/IStatsCompanionService.aidl b/apex/statsd/aidl/android/os/IStatsCompanionService.aidl index 99b9d398e30cc..bdd1da7bf3d39 100644 --- a/apex/statsd/aidl/android/os/IStatsCompanionService.aidl +++ b/apex/statsd/aidl/android/os/IStatsCompanionService.aidl @@ -16,9 +16,6 @@ package android.os; -import android.os.IPullAtomCallback; -import android.os.StatsLogEventWrapper; - /** * Binder interface to communicate with the Java-based statistics service helper. * {@hide} @@ -62,9 +59,6 @@ interface IStatsCompanionService { /** Cancel any alarm for the purpose of subscriber triggering. */ oneway void cancelAlarmForSubscriberTriggering(); - /** Pull the specified data. Results will be sent to statsd when complete. */ - StatsLogEventWrapper[] pullData(int pullCode); - /** Tells StatsCompaionService to grab the uid map snapshot and send it to statsd. */ oneway void triggerUidSnapshot(); } diff --git a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java index 6db9e7b5e3e0b..bcbb5a1407f62 100644 --- a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java +++ b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java @@ -714,27 +714,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } - /** - * Pulls various data. - */ - @Override // Binder call - public StatsLogEventWrapper[] pullData(int tagId) { - StatsCompanion.enforceStatsCompanionPermission(mContext); - if (DEBUG) { - Slog.d(TAG, "Pulling " + tagId); - } - List ret = new ArrayList<>(); - long elapsedNanos = SystemClock.elapsedRealtimeNanos(); - long wallClockNanos = SystemClock.currentTimeMicro() * 1000L; - switch (tagId) { - - default: - Slog.w(TAG, "No such tagId data as " + tagId); - return null; - } - return ret.toArray(new StatsLogEventWrapper[ret.size()]); - } - @Override // Binder call public void statsdReady() { StatsCompanion.enforceStatsCompanionPermission(mContext); diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp index 6eafbd8bb3f16..080b1af350596 100644 --- a/cmds/statsd/Android.bp +++ b/cmds/statsd/Android.bp @@ -73,7 +73,6 @@ cc_defaults { "src/external/puller_util.cpp", "src/external/ResourceHealthManagerPuller.cpp", "src/external/StatsCallbackPuller.cpp", - "src/external/StatsCompanionServicePuller.cpp", "src/external/StatsPuller.cpp", "src/external/StatsPullerManager.cpp", "src/external/SubsystemSleepStatePuller.cpp", diff --git a/cmds/statsd/src/external/StatsCompanionServicePuller.cpp b/cmds/statsd/src/external/StatsCompanionServicePuller.cpp deleted file mode 100644 index f37d2bedf8c26..0000000000000 --- a/cmds/statsd/src/external/StatsCompanionServicePuller.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#define DEBUG false -#include "Log.h" - -#include -#include -#include -#include "../stats_log_util.h" -#include "../statscompanion_util.h" -#include "StatsCompanionServicePuller.h" - -using namespace android; -using namespace android::base; -using namespace android::binder; -using namespace android::os; -using std::make_shared; -using std::shared_ptr; -using std::vector; - -namespace android { -namespace os { -namespace statsd { - -// The reading and parsing are implemented in Java. It is not difficult to port over. But for now -// let StatsCompanionService handle that and send the data back. -StatsCompanionServicePuller::StatsCompanionServicePuller(int tagId) : StatsPuller(tagId) { -} - -void StatsCompanionServicePuller::SetStatsCompanionService( - sp statsCompanionService) { - AutoMutex _l(mStatsCompanionServiceLock); - sp tmpForLock = mStatsCompanionService; - mStatsCompanionService = statsCompanionService; -} - -bool StatsCompanionServicePuller::PullInternal(vector >* data) { - sp statsCompanionServiceCopy = mStatsCompanionService; - if (statsCompanionServiceCopy != nullptr) { - vector returned_value; - Status status = statsCompanionServiceCopy->pullData(mTagId, &returned_value); - if (!status.isOk()) { - ALOGW("StatsCompanionServicePuller::pull failed for %d", mTagId); - StatsdStats::getInstance().noteStatsCompanionPullFailed(mTagId); - if (status.exceptionCode() == Status::Exception::EX_TRANSACTION_FAILED) { - StatsdStats::getInstance().noteStatsCompanionPullBinderTransactionFailed(mTagId); - } - return false; - } - data->clear(); - for (const StatsLogEventWrapper& it : returned_value) { - LogEvent::createLogEvents(it, *data); - } - VLOG("StatsCompanionServicePuller::pull succeeded for %d", mTagId); - return true; - } else { - ALOGW("statsCompanion not found!"); - return false; - } -} - -} // namespace statsd -} // namespace os -} // namespace android diff --git a/cmds/statsd/src/external/StatsCompanionServicePuller.h b/cmds/statsd/src/external/StatsCompanionServicePuller.h deleted file mode 100644 index 2e133207f01d4..0000000000000 --- a/cmds/statsd/src/external/StatsCompanionServicePuller.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#pragma once - -#include -#include "StatsPuller.h" - -namespace android { -namespace os { -namespace statsd { - -class StatsCompanionServicePuller : public StatsPuller { -public: - explicit StatsCompanionServicePuller(int tagId); - - void SetStatsCompanionService(sp statsCompanionService) override; - -private: - Mutex mStatsCompanionServiceLock; - sp mStatsCompanionService = nullptr; - bool PullInternal(vector >* data) override; -}; - -} // namespace statsd -} // namespace os -} // namespace android diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp index 56ad192dd60f9..8d67b5c169f54 100644 --- a/cmds/statsd/src/external/StatsPullerManager.cpp +++ b/cmds/statsd/src/external/StatsPullerManager.cpp @@ -37,7 +37,6 @@ #include "PowerStatsPuller.h" #include "ResourceHealthManagerPuller.h" #include "StatsCallbackPuller.h" -#include "StatsCompanionServicePuller.h" #include "SubsystemSleepStatePuller.h" #include "TrainInfoPuller.h" #include "statslog.h"