Remove IStatsd reference from StatsLog.java
Also remove sendAppBreadcrumb binder api because it's no longer used. Bug: 154264326 Test: atest com.google.android.statsd.gts.StatsdHostTestCases Change-Id: Ic51a057bb01a89a24337521a49c54a52e2073cd1
This commit is contained in:
@@ -181,12 +181,6 @@ interface IStatsd {
|
||||
*/
|
||||
void unsetBroadcastSubscriber(long configId, long subscriberId, int callingUid);
|
||||
|
||||
/**
|
||||
* Apps can send an atom via this application breadcrumb with the specified label and state for
|
||||
* this label. This allows building custom metrics and predicates.
|
||||
*/
|
||||
void sendAppBreadcrumbAtom(int label, int state);
|
||||
|
||||
/**
|
||||
* Tell the stats daemon that all the pullers registered during boot have been sent.
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,7 @@ import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.Context;
|
||||
import android.os.IStatsd;
|
||||
import android.os.RemoteException;
|
||||
import android.os.StatsFrameworkInitializer;
|
||||
import android.os.Process;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import com.android.internal.util.StatsdStatsLog;
|
||||
@@ -45,10 +44,6 @@ public final class StatsLog {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final int EXPERIMENT_IDS_FIELD_ID = 1;
|
||||
|
||||
private static IStatsd sService;
|
||||
|
||||
private static Object sLogLock = new Object();
|
||||
|
||||
private StatsLog() {
|
||||
}
|
||||
|
||||
@@ -59,26 +54,13 @@ public final class StatsLog {
|
||||
* @return True if the log request was sent to statsd.
|
||||
*/
|
||||
public static boolean logStart(int label) {
|
||||
synchronized (sLogLock) {
|
||||
try {
|
||||
IStatsd service = getIStatsdLocked();
|
||||
if (service == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Failed to find statsd when logging start");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
service.sendAppBreadcrumbAtom(label,
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__START);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
sService = null;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Failed to connect to statsd when logging start");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int callingUid = Process.myUid();
|
||||
StatsdStatsLog.write(
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED,
|
||||
callingUid,
|
||||
label,
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__START);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,26 +70,13 @@ public final class StatsLog {
|
||||
* @return True if the log request was sent to statsd.
|
||||
*/
|
||||
public static boolean logStop(int label) {
|
||||
synchronized (sLogLock) {
|
||||
try {
|
||||
IStatsd service = getIStatsdLocked();
|
||||
if (service == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Failed to find statsd when logging stop");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
service.sendAppBreadcrumbAtom(
|
||||
label, StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__STOP);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
sService = null;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Failed to connect to statsd when logging stop");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int callingUid = Process.myUid();
|
||||
StatsdStatsLog.write(
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED,
|
||||
callingUid,
|
||||
label,
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__STOP);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,26 +86,13 @@ public final class StatsLog {
|
||||
* @return True if the log request was sent to statsd.
|
||||
*/
|
||||
public static boolean logEvent(int label) {
|
||||
synchronized (sLogLock) {
|
||||
try {
|
||||
IStatsd service = getIStatsdLocked();
|
||||
if (service == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Failed to find statsd when logging event");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
service.sendAppBreadcrumbAtom(
|
||||
label, StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__UNSPECIFIED);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
sService = null;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Failed to connect to statsd when logging event");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int callingUid = Process.myUid();
|
||||
StatsdStatsLog.write(
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED,
|
||||
callingUid,
|
||||
label,
|
||||
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__UNSPECIFIED);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,17 +137,6 @@ public final class StatsLog {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IStatsd getIStatsdLocked() throws RemoteException {
|
||||
if (sService != null) {
|
||||
return sService;
|
||||
}
|
||||
sService = IStatsd.Stub.asInterface(StatsFrameworkInitializer
|
||||
.getStatsServiceManager()
|
||||
.getStatsdServiceRegisterer()
|
||||
.get());
|
||||
return sService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an event to stats log using the raw format.
|
||||
*
|
||||
|
||||
@@ -1222,15 +1222,6 @@ Status StatsService::unsetBroadcastSubscriber(int64_t configId,
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
Status StatsService::sendAppBreadcrumbAtom(int32_t label, int32_t state) {
|
||||
// Permission check not necessary as it's meant for applications to write to
|
||||
// statsd.
|
||||
android::os::statsd::util::stats_write(android::os::statsd::util::APP_BREADCRUMB_REPORTED,
|
||||
(int32_t) AIBinder_getCallingUid(), label,
|
||||
state);
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
Status StatsService::allPullersFromBootRegistered() {
|
||||
ENFORCE_UID(AID_SYSTEM);
|
||||
|
||||
|
||||
@@ -161,11 +161,6 @@ public:
|
||||
/** Inform statsCompanion that statsd is ready. */
|
||||
virtual void sayHiToStatsCompanion();
|
||||
|
||||
/**
|
||||
* Binder call to get AppBreadcrumbReported atom.
|
||||
*/
|
||||
virtual Status sendAppBreadcrumbAtom(int32_t label, int32_t state) override;
|
||||
|
||||
/**
|
||||
* Binder call to notify statsd that all pullers from boot have been registered.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user