Delete References to Statsd in StatsManager
Test: adb shell cmd stats pull-source 10000 (chosen randomly) Change-Id: I9578f84213e6c2787da60ae7e2c20157087d5b6a
This commit is contained in:
@@ -23,7 +23,6 @@ filegroup {
|
||||
"android/os/IPullAtomResultReceiver.aidl",
|
||||
"android/os/IStatsCompanionService.aidl",
|
||||
"android/os/IStatsd.aidl",
|
||||
"android/os/IStatsPullerCallback.aidl",
|
||||
"android/util/StatsEventParcel.aidl",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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 @@ interface IStatsd {
|
||||
*/
|
||||
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 @@ interface IStatsd {
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,6 @@ cc_defaults {
|
||||
"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",
|
||||
|
||||
@@ -1265,16 +1265,6 @@ Status StatsService::sendAppBreadcrumbAtom(int32_t label, int32_t state) {
|
||||
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 @@ Status StatsService::registerNativePullAtomCallback(int32_t atomTag, int64_t coo
|
||||
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.");
|
||||
|
||||
@@ -170,14 +170,6 @@ public:
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@@ -192,11 +184,6 @@ public:
|
||||
int64_t timeoutNs, const std::vector<int32_t>& additiveFields,
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
27
cmds/statsd/src/external/StatsPullerManager.cpp
vendored
27
cmds/statsd/src/external/StatsPullerManager.cpp
vendored
@@ -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 @@ int StatsPullerManager::ClearPullerCacheIfNecessary(int64_t timestampNs) {
|
||||
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::RegisterPullAtomCallback(const int uid, const int32_t a
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -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 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@@ -164,9 +164,6 @@ public:
|
||||
// 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;
|
||||
|
||||
|
||||
@@ -25,11 +25,9 @@ import android.annotation.RequiresPermission;
|
||||
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;
|
||||
@@ -475,42 +473,6 @@ public final class StatsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -734,32 +696,6 @@ public final class StatsManager {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user