Merge "Remove IStatsd reference from StatsLog.java" into rvc-dev am: 64c55e7e8a
Change-Id: I9b8bdbe67fb2d4fbdd4166244973c5bec087fd99
This commit is contained in:
@@ -181,12 +181,6 @@ interface IStatsd {
|
|||||||
*/
|
*/
|
||||||
void unsetBroadcastSubscriber(long configId, long subscriberId, int callingUid);
|
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.
|
* 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.annotation.SystemApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.IStatsd;
|
import android.os.IStatsd;
|
||||||
import android.os.RemoteException;
|
import android.os.Process;
|
||||||
import android.os.StatsFrameworkInitializer;
|
|
||||||
import android.util.proto.ProtoOutputStream;
|
import android.util.proto.ProtoOutputStream;
|
||||||
|
|
||||||
import com.android.internal.util.StatsdStatsLog;
|
import com.android.internal.util.StatsdStatsLog;
|
||||||
@@ -45,10 +44,6 @@ public final class StatsLog {
|
|||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final int EXPERIMENT_IDS_FIELD_ID = 1;
|
private static final int EXPERIMENT_IDS_FIELD_ID = 1;
|
||||||
|
|
||||||
private static IStatsd sService;
|
|
||||||
|
|
||||||
private static Object sLogLock = new Object();
|
|
||||||
|
|
||||||
private StatsLog() {
|
private StatsLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,26 +54,13 @@ public final class StatsLog {
|
|||||||
* @return True if the log request was sent to statsd.
|
* @return True if the log request was sent to statsd.
|
||||||
*/
|
*/
|
||||||
public static boolean logStart(int label) {
|
public static boolean logStart(int label) {
|
||||||
synchronized (sLogLock) {
|
int callingUid = Process.myUid();
|
||||||
try {
|
StatsdStatsLog.write(
|
||||||
IStatsd service = getIStatsdLocked();
|
StatsdStatsLog.APP_BREADCRUMB_REPORTED,
|
||||||
if (service == null) {
|
callingUid,
|
||||||
if (DEBUG) {
|
label,
|
||||||
Log.d(TAG, "Failed to find statsd when logging start");
|
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__START);
|
||||||
}
|
return true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,26 +70,13 @@ public final class StatsLog {
|
|||||||
* @return True if the log request was sent to statsd.
|
* @return True if the log request was sent to statsd.
|
||||||
*/
|
*/
|
||||||
public static boolean logStop(int label) {
|
public static boolean logStop(int label) {
|
||||||
synchronized (sLogLock) {
|
int callingUid = Process.myUid();
|
||||||
try {
|
StatsdStatsLog.write(
|
||||||
IStatsd service = getIStatsdLocked();
|
StatsdStatsLog.APP_BREADCRUMB_REPORTED,
|
||||||
if (service == null) {
|
callingUid,
|
||||||
if (DEBUG) {
|
label,
|
||||||
Log.d(TAG, "Failed to find statsd when logging stop");
|
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__STOP);
|
||||||
}
|
return true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,26 +86,13 @@ public final class StatsLog {
|
|||||||
* @return True if the log request was sent to statsd.
|
* @return True if the log request was sent to statsd.
|
||||||
*/
|
*/
|
||||||
public static boolean logEvent(int label) {
|
public static boolean logEvent(int label) {
|
||||||
synchronized (sLogLock) {
|
int callingUid = Process.myUid();
|
||||||
try {
|
StatsdStatsLog.write(
|
||||||
IStatsd service = getIStatsdLocked();
|
StatsdStatsLog.APP_BREADCRUMB_REPORTED,
|
||||||
if (service == null) {
|
callingUid,
|
||||||
if (DEBUG) {
|
label,
|
||||||
Log.d(TAG, "Failed to find statsd when logging event");
|
StatsdStatsLog.APP_BREADCRUMB_REPORTED__STATE__UNSPECIFIED);
|
||||||
}
|
return true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,17 +137,6 @@ public final class StatsLog {
|
|||||||
return true;
|
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.
|
* Write an event to stats log using the raw format.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1222,15 +1222,6 @@ Status StatsService::unsetBroadcastSubscriber(int64_t configId,
|
|||||||
return Status::ok();
|
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() {
|
Status StatsService::allPullersFromBootRegistered() {
|
||||||
ENFORCE_UID(AID_SYSTEM);
|
ENFORCE_UID(AID_SYSTEM);
|
||||||
|
|
||||||
|
|||||||
@@ -161,11 +161,6 @@ public:
|
|||||||
/** Inform statsCompanion that statsd is ready. */
|
/** Inform statsCompanion that statsd is ready. */
|
||||||
virtual void sayHiToStatsCompanion();
|
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.
|
* Binder call to notify statsd that all pullers from boot have been registered.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user