Delete References to Statsd in StatsManager
Test: adb shell cmd stats pull-source 10000 (chosen randomly)
Change-Id: I9578f84213e6c2787da60ae7e2c20157087d5b6a
diff --git a/apex/statsd/aidl/Android.bp b/apex/statsd/aidl/Android.bp
index f8325d4..cc5172c6 100644
--- a/apex/statsd/aidl/Android.bp
+++ b/apex/statsd/aidl/Android.bp
@@ -23,7 +23,6 @@
"android/os/IPullAtomResultReceiver.aidl",
"android/os/IStatsCompanionService.aidl",
"android/os/IStatsd.aidl",
- "android/os/IStatsPullerCallback.aidl",
"android/util/StatsEventParcel.aidl",
],
}
diff --git a/apex/statsd/aidl/android/os/IStatsPullerCallback.aidl b/apex/statsd/aidl/android/os/IStatsPullerCallback.aidl
deleted file mode 100644
index c3e1e55..0000000
--- a/apex/statsd/aidl/android/os/IStatsPullerCallback.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2019 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 android.os;
-
-import android.os.StatsLogEventWrapper;
-
-/**
- * DEPRECATED
- * Binder interface to pull atoms for the stats service.
- * {@hide}
- */
-interface IStatsPullerCallback {
- /**
- * Pull data for the specified atom tag. Returns an array of StatsLogEventWrapper containing
- * the data.
- *
- * Note: These pulled atoms should not have uid/attribution chain. Additionally, the event
- * timestamps will be truncated to the nearest 5 minutes.
- */
- StatsLogEventWrapper[] pullData(int atomTag, long elapsedNanos, long wallClocknanos);
-
-}
diff --git a/apex/statsd/aidl/android/os/IStatsd.aidl b/apex/statsd/aidl/android/os/IStatsd.aidl
index 0ecf2f0..a2564212 100644
--- a/apex/statsd/aidl/android/os/IStatsd.aidl
+++ b/apex/statsd/aidl/android/os/IStatsd.aidl
@@ -16,7 +16,6 @@
package android.os;
-import android.os.IStatsPullerCallback;
import android.os.IPendingIntentRef;
import android.os.IPullAtomCallback;
import android.os.ParcelFileDescriptor;
@@ -183,16 +182,6 @@
*/
void sendAppBreadcrumbAtom(int label, int state);
- /**
- * Registers a puller callback function that, when invoked, pulls the data
- * for the specified vendor atom tag.
- *
- * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS
- * @deprecated please use registerPullAtomCallback.
- */
- oneway void registerPullerCallback(int atomTag, IStatsPullerCallback pullerCallback,
- String packageName);
-
/**
* Registers a puller callback function that, when invoked, pulls the data
* for the specified atom tag.
@@ -207,13 +196,6 @@
oneway void registerNativePullAtomCallback(int atomTag, long coolDownNs, long timeoutNs,
in int[] additiveFields, IPullAtomCallback pullerCallback);
- /**
- * Unregisters a puller callback function for the given vendor atom.
- *
- * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS
- */
- oneway void unregisterPullerCallback(int atomTag, String packageName);
-
/**
* Unregisters any pullAtomCallback for the given uid/atom.
*/
diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp
index 1c6867c3..6eafbd8 100644
--- a/cmds/statsd/Android.bp
+++ b/cmds/statsd/Android.bp
@@ -73,7 +73,6 @@
"src/external/puller_util.cpp",
"src/external/ResourceHealthManagerPuller.cpp",
"src/external/StatsCallbackPuller.cpp",
- "src/external/StatsCallbackPullerDeprecated.cpp",
"src/external/StatsCompanionServicePuller.cpp",
"src/external/StatsPuller.cpp",
"src/external/StatsPullerManager.cpp",
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index ada2f2d..c1a8d69 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -1265,16 +1265,6 @@
return Status::ok();
}
-Status StatsService::registerPullerCallback(int32_t atomTag,
- const sp<android::os::IStatsPullerCallback>& pullerCallback,
- const String16& packageName) {
- ENFORCE_DUMP_AND_USAGE_STATS(packageName);
-
- VLOG("StatsService::registerPullerCallback called.");
- mPullerManager->RegisterPullerCallback(atomTag, pullerCallback);
- return Status::ok();
-}
-
Status StatsService::registerPullAtomCallback(int32_t uid, int32_t atomTag, int64_t coolDownNs,
int64_t timeoutNs, const std::vector<int32_t>& additiveFields,
const sp<android::os::IPullAtomCallback>& pullerCallback) {
@@ -1297,14 +1287,6 @@
return Status::ok();
}
-Status StatsService::unregisterPullerCallback(int32_t atomTag, const String16& packageName) {
- ENFORCE_DUMP_AND_USAGE_STATS(packageName);
-
- VLOG("StatsService::unregisterPullerCallback called.");
- mPullerManager->UnregisterPullerCallback(atomTag);
- return Status::ok();
-}
-
Status StatsService::unregisterPullAtomCallback(int32_t uid, int32_t atomTag) {
ENFORCE_UID(AID_SYSTEM);
VLOG("StatsService::unregisterPullAtomCallback called.");
diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h
index 7990e5e..f2079d9 100644
--- a/cmds/statsd/src/StatsService.h
+++ b/cmds/statsd/src/StatsService.h
@@ -171,14 +171,6 @@
virtual Status sendAppBreadcrumbAtom(int32_t label, int32_t state) override;
/**
- * Binder call to register a callback function for a vendor pulled atom.
- * Note: this atom must NOT have uid as a field.
- */
- virtual Status registerPullerCallback(int32_t atomTag,
- const sp<android::os::IStatsPullerCallback>& pullerCallback,
- const String16& packageName) override;
-
- /**
* Binder call to register a callback function for a pulled atom.
*/
virtual Status registerPullAtomCallback(int32_t uid, int32_t atomTag, int64_t coolDownNs,
@@ -193,11 +185,6 @@
const sp<android::os::IPullAtomCallback>& pullerCallback) override;
/**
- * Binder call to unregister any existing callback function for a vendor pulled atom.
- */
- virtual Status unregisterPullerCallback(int32_t atomTag, const String16& packageName) override;
-
- /**
* Binder call to unregister any existing callback for the given uid and atom.
*/
virtual Status unregisterPullAtomCallback(int32_t uid, int32_t atomTag) override;
diff --git a/cmds/statsd/src/external/StatsCallbackPullerDeprecated.cpp b/cmds/statsd/src/external/StatsCallbackPullerDeprecated.cpp
deleted file mode 100644
index 4f88a91..0000000
--- a/cmds/statsd/src/external/StatsCallbackPullerDeprecated.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2019 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 // STOPSHIP if true
-#include "Log.h"
-
-#include "StatsCallbackPullerDeprecated.h"
-
-#include <android/os/IStatsPullerCallback.h>
-
-#include "logd/LogEvent.h"
-#include "stats_log_util.h"
-
-using namespace android::binder;
-
-namespace android {
-namespace os {
-namespace statsd {
-
-StatsCallbackPullerDeprecated::StatsCallbackPullerDeprecated(
- int tagId, const sp<IStatsPullerCallback>& callback)
- : StatsPuller(tagId), mCallback(callback) {
- VLOG("StatsCallbackPuller created for tag %d", tagId);
-}
-
-bool StatsCallbackPullerDeprecated::PullInternal(vector<shared_ptr<LogEvent>>* data) {
- VLOG("StatsCallbackPuller called for tag %d", mTagId)
- if (mCallback == nullptr) {
- ALOGW("No callback registered");
- return false;
- }
- int64_t wallClockTimeNs = getWallClockNs();
- int64_t elapsedTimeNs = getElapsedRealtimeNs();
- vector<StatsLogEventWrapper> returned_value;
- Status status = mCallback->pullData(mTagId, elapsedTimeNs, wallClockTimeNs, &returned_value);
- if (!status.isOk()) {
- ALOGW("StatsCallbackPuller::pull failed for %d", mTagId);
- return false;
- }
- data->clear();
- for (const StatsLogEventWrapper& it : returned_value) {
- LogEvent::createLogEvents(it, *data);
- }
- VLOG("StatsCallbackPuller::pull succeeded for %d", mTagId);
- return true;
-}
-
-} // namespace statsd
-} // namespace os
-} // namespace android
diff --git a/cmds/statsd/src/external/StatsCallbackPullerDeprecated.h b/cmds/statsd/src/external/StatsCallbackPullerDeprecated.h
deleted file mode 100644
index 0289029..0000000
--- a/cmds/statsd/src/external/StatsCallbackPullerDeprecated.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2019 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 <android/os/IStatsPullerCallback.h>
-#include <utils/String16.h>
-
-#include "StatsPuller.h"
-
-namespace android {
-namespace os {
-namespace statsd {
-
-class StatsCallbackPullerDeprecated : public StatsPuller {
-public:
- explicit StatsCallbackPullerDeprecated(int tagId, const sp<IStatsPullerCallback>& callback);
-
-private:
- bool PullInternal(vector<std::shared_ptr<LogEvent> >* data) override;
- const sp<IStatsPullerCallback> mCallback;
-};
-
-} // namespace statsd
-} // namespace os
-} // namespace android
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index d5cda85..daab129 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -21,7 +21,6 @@
#include <android/os/IPullAtomCallback.h>
#include <android/os/IStatsCompanionService.h>
-#include <android/os/IStatsPullerCallback.h>
#include <cutils/log.h>
#include <math.h>
#include <stdint.h>
@@ -38,7 +37,6 @@
#include "PowerStatsPuller.h"
#include "ResourceHealthManagerPuller.h"
#include "StatsCallbackPuller.h"
-#include "StatsCallbackPullerDeprecated.h"
#include "StatsCompanionServicePuller.h"
#include "SubsystemSleepStatePuller.h"
#include "TrainInfoPuller.h"
@@ -406,21 +404,6 @@
return totalCleared;
}
-// Deprecated, remove after puller API is complete.
-void StatsPullerManager::RegisterPullerCallback(int32_t atomTag,
- const sp<IStatsPullerCallback>& callback) {
- AutoMutex _l(mLock);
- // Platform pullers cannot be changed.
- if (!isVendorPulledAtom(atomTag)) {
- VLOG("RegisterPullerCallback: atom tag %d is not vendor pulled", atomTag);
- return;
- }
- VLOG("RegisterPullerCallback: adding puller for tag %d", atomTag);
- StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/true);
- kAllPullAtomInfo[{.atomTag = atomTag}] = {
- .puller = new StatsCallbackPullerDeprecated(atomTag, callback)};
-}
-
void StatsPullerManager::RegisterPullAtomCallback(const int uid, const int32_t atomTag,
const int64_t coolDownNs, const int64_t timeoutNs,
const vector<int32_t>& additiveFields,
@@ -437,16 +420,6 @@
};
}
-void StatsPullerManager::UnregisterPullerCallback(int32_t atomTag) {
- AutoMutex _l(mLock);
- // Platform pullers cannot be changed.
- if (!isVendorPulledAtom(atomTag)) {
- return;
- }
- StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/false);
- kAllPullAtomInfo.erase({.atomTag = atomTag});
-}
-
void StatsPullerManager::UnregisterPullAtomCallback(const int uid, const int32_t atomTag) {
AutoMutex _l(mLock);
StatsdStats::getInstance().notePullerCallbackRegistrationChanged(atomTag, /*registered=*/false);
diff --git a/cmds/statsd/src/external/StatsPullerManager.h b/cmds/statsd/src/external/StatsPullerManager.h
index 349fd47..4b6ab57 100644
--- a/cmds/statsd/src/external/StatsPullerManager.h
+++ b/cmds/statsd/src/external/StatsPullerManager.h
@@ -18,7 +18,6 @@
#include <android/os/IPullAtomCallback.h>
#include <android/os/IStatsCompanionService.h>
-#include <android/os/IStatsPullerCallback.h>
#include <binder/IServiceManager.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
@@ -116,15 +115,10 @@
void SetStatsCompanionService(sp<IStatsCompanionService> statsCompanionService);
- // Deprecated, remove after puller API is complete.
- void RegisterPullerCallback(int32_t atomTag, const sp<IStatsPullerCallback>& callback);
-
void RegisterPullAtomCallback(const int uid, const int32_t atomTag, const int64_t coolDownNs,
const int64_t timeoutNs, const vector<int32_t>& additiveFields,
const sp<IPullAtomCallback>& callback);
- void UnregisterPullerCallback(int32_t atomTag);
-
void UnregisterPullAtomCallback(const int uid, const int32_t atomTag);
static std::map<PullerKey, PullAtomInfo> kAllPullAtomInfo;
diff --git a/cmds/statsd/src/guardrail/StatsdStats.h b/cmds/statsd/src/guardrail/StatsdStats.h
index 692d91e..3282785 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.h
+++ b/cmds/statsd/src/guardrail/StatsdStats.h
@@ -164,9 +164,6 @@
// Maximum number of pushed atoms statsd stats will track above kMaxPushedAtomId.
static const int kMaxNonPlatformPushedAtoms = 100;
- // Max platform atom tag number.
- static const int32_t kMaxPlatformAtomTag = 100000;
-
// Vendor pulled atom start id.
static const int32_t kVendorPulledAtomStartTag = 150000;
diff --git a/core/java/android/app/StatsManager.java b/core/java/android/app/StatsManager.java
index 0beceb0..0ea05d8 100644
--- a/core/java/android/app/StatsManager.java
+++ b/core/java/android/app/StatsManager.java
@@ -25,11 +25,9 @@
import android.annotation.SystemApi;
import android.content.Context;
import android.os.Binder;
-import android.os.IBinder;
import android.os.IPullAtomCallback;
import android.os.IPullAtomResultReceiver;
import android.os.IStatsManagerService;
-import android.os.IStatsPullerCallback;
import android.os.IStatsd;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -476,42 +474,6 @@
}
/**
- * Registers a callback for an atom when that atom is to be pulled. The stats service will
- * invoke pullData in the callback when the stats service determines that this atom needs to be
- * pulled. Currently, this only works for atoms with tags above 100,000 that do not have a uid.
- *
- * @param atomTag The tag of the atom for this puller callback. Must be at least 100000.
- * @param callback The callback to be invoked when the stats service pulls the atom.
- * @throws StatsUnavailableException if unsuccessful due to failing to connect to stats service
- *
- * @hide
- * @deprecated Please use registerPullAtomCallback
- */
- @Deprecated
- @RequiresPermission(allOf = { DUMP, PACKAGE_USAGE_STATS })
- public void setPullerCallback(int atomTag, IStatsPullerCallback callback)
- throws StatsUnavailableException {
- synchronized (sLock) {
- try {
- IStatsd service = getIStatsdLocked();
- if (callback == null) {
- service.unregisterPullerCallback(atomTag, mContext.getOpPackageName());
- } else {
- service.registerPullerCallback(atomTag, callback,
- mContext.getOpPackageName());
- }
-
- } catch (RemoteException e) {
- Slog.e(TAG, "Failed to connect to statsd when registering data listener.");
- throw new StatsUnavailableException("could not connect", e);
- } catch (SecurityException e) {
- throw new StatsUnavailableException(e.getMessage(), e);
- }
- }
- }
-
-
- /**
* Temp registration for while the migration is in progress.
*
* @hide
@@ -734,32 +696,6 @@
int onPullAtom(int atomTag, @NonNull List<StatsEvent> data);
}
- private class StatsdDeathRecipient implements IBinder.DeathRecipient {
- @Override
- public void binderDied() {
- synchronized (sLock) {
- mService = null;
- }
- }
- }
-
- @GuardedBy("sLock")
- private IStatsd getIStatsdLocked() throws StatsUnavailableException {
- if (mService != null) {
- return mService;
- }
- mService = IStatsd.Stub.asInterface(ServiceManager.getService("stats"));
- if (mService == null) {
- throw new StatsUnavailableException("could not be found");
- }
- try {
- mService.asBinder().linkToDeath(new StatsdDeathRecipient(), 0);
- } catch (RemoteException e) {
- throw new StatsUnavailableException("could not connect when linkToDeath", e);
- }
- return mService;
- }
-
@GuardedBy("sLock")
private IStatsManagerService getIStatsManagerServiceLocked() {
if (mStatsManagerService != null) {