summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/Android.bp14
-rw-r--r--framework/java/android/app/StatsManager.java10
-rw-r--r--framework/java/android/util/StatsEvent.java20
-rw-r--r--framework/java/android/util/StatsLog.java9
-rw-r--r--framework/test/src/android/os/StatsDimensionsValueTest.java8
-rw-r--r--lib/libstatspull/Android.bp4
-rw-r--r--service/Android.bp1
-rw-r--r--service/java/com/android/server/stats/StatsCompanionService.java91
-rw-r--r--statsd/src/FieldValue.cpp37
-rw-r--r--statsd/src/FieldValue.h14
-rw-r--r--statsd/src/HashableDimensionKey.cpp2
-rw-r--r--statsd/src/Log.h4
-rw-r--r--statsd/src/StatsLogProcessor.cpp2
-rw-r--r--statsd/src/StatsService.cpp2
-rw-r--r--statsd/src/anomaly/AlarmMonitor.cpp2
-rw-r--r--statsd/src/anomaly/AlarmTracker.cpp2
-rw-r--r--statsd/src/anomaly/AnomalyTracker.cpp2
-rw-r--r--statsd/src/anomaly/DurationAnomalyTracker.cpp2
-rw-r--r--statsd/src/anomaly/subscriber_util.cpp2
-rw-r--r--statsd/src/condition/CombinationConditionTracker.cpp2
-rw-r--r--statsd/src/condition/SimpleConditionTracker.cpp4
-rw-r--r--statsd/src/config/ConfigManager.cpp2
-rw-r--r--statsd/src/external/Perfetto.cpp2
-rw-r--r--statsd/src/external/StatsCallbackPuller.cpp2
-rw-r--r--statsd/src/external/StatsPuller.cpp2
-rw-r--r--statsd/src/external/StatsPullerManager.cpp2
-rw-r--r--statsd/src/external/TrainInfoPuller.cpp2
-rw-r--r--statsd/src/external/puller_util.cpp2
-rw-r--r--statsd/src/guardrail/StatsdStats.cpp2
-rw-r--r--statsd/src/logd/LogEvent.cpp2
-rw-r--r--statsd/src/logd/LogEventQueue.cpp2
-rw-r--r--statsd/src/main.cpp2
-rw-r--r--statsd/src/matchers/SimpleAtomMatchingTracker.cpp2
-rw-r--r--statsd/src/matchers/matcher_util.cpp2
-rw-r--r--statsd/src/metrics/CountMetricProducer.cpp2
-rw-r--r--statsd/src/metrics/DurationMetricProducer.cpp2
-rw-r--r--statsd/src/metrics/EventMetricProducer.cpp17
-rw-r--r--statsd/src/metrics/EventMetricProducer.h1
-rw-r--r--statsd/src/metrics/GaugeMetricProducer.cpp2
-rw-r--r--statsd/src/metrics/KllMetricProducer.cpp2
-rw-r--r--statsd/src/metrics/MetricProducer.cpp2
-rw-r--r--statsd/src/metrics/MetricsManager.cpp4
-rw-r--r--statsd/src/metrics/NumericValueMetricProducer.cpp2
-rw-r--r--statsd/src/metrics/ValueMetricProducer.cpp2
-rw-r--r--statsd/src/metrics/duration_helper/MaxDurationTracker.cpp2
-rw-r--r--statsd/src/metrics/duration_helper/OringDurationTracker.cpp2
-rw-r--r--statsd/src/metrics/parsing_utils/config_update_utils.cpp2
-rw-r--r--statsd/src/metrics/parsing_utils/metrics_manager_util.cpp2
-rw-r--r--statsd/src/packages/UidMap.cpp2
-rw-r--r--statsd/src/shell/ShellSubscriber.cpp2
-rwxr-xr-xstatsd/src/socket/StatsSocketListener.cpp2
-rw-r--r--statsd/src/state/StateManager.cpp2
-rw-r--r--statsd/src/state/StateTracker.cpp2
-rw-r--r--statsd/src/statscompanion_util.cpp2
-rw-r--r--statsd/src/storage/StorageManager.cpp2
-rw-r--r--statsd/src/subscriber/IncidentdReporter.cpp2
-rw-r--r--statsd/src/subscriber/SubscriberReporter.cpp2
-rw-r--r--statsd/src/utils/MultiConditionTrigger.cpp2
-rw-r--r--statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java1
-rw-r--r--tests/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java54
-rw-r--r--tests/apps/statsdapp/src/com/android/server/cts/device/statsd/StatsFrameworkInitializerTests.java34
-rw-r--r--tests/src/android/cts/statsd/validation/StatsFrameworkInitializerTest.java29
62 files changed, 229 insertions, 213 deletions
diff --git a/apex/Android.bp b/apex/Android.bp
index bbf613ff..4bb7657e 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -24,6 +24,7 @@ apex {
apex_defaults {
bootclasspath_fragments: ["com.android.os.statsd-bootclasspath-fragment"],
+ systemserverclasspath_fragments: ["com.android.os.statsd-systemserverclasspath-fragment"],
jni_libs: [
"libstats_jni",
],
@@ -32,17 +33,13 @@ apex_defaults {
"libstatssocket",
],
binaries: ["statsd"],
- java_libs: [
- "service-statsd",
- ],
compile_multilib: "both",
prebuilts: [
"com.android.os.statsd.init.rc",
"current_sdkinfo",
],
name: "com.android.os.statsd-defaults",
- updatable: true,
- min_sdk_version: "30",
+ defaults: ["r-launched-apex-module"],
key: "com.android.os.statsd.key",
certificate: ":com.android.os.statsd.certificate",
}
@@ -73,6 +70,7 @@ prebuilt_etc {
sdk {
name: "statsd-module-sdk",
bootclasspath_fragments: ["com.android.os.statsd-bootclasspath-fragment"],
+ systemserverclasspath_fragments: ["com.android.os.statsd-systemserverclasspath-fragment"],
native_shared_libs: [
"libstatssocket",
],
@@ -102,3 +100,9 @@ bootclasspath_fragment {
max_target_o_low_priority: ["hiddenapi/hiddenapi-max-target-o-low-priority.txt"],
},
}
+
+systemserverclasspath_fragment {
+ name: "com.android.os.statsd-systemserverclasspath-fragment",
+ standalone_contents: ["service-statsd"],
+ apex_available: ["com.android.os.statsd"],
+}
diff --git a/framework/java/android/app/StatsManager.java b/framework/java/android/app/StatsManager.java
index 41803cfd..ee5ea68b 100644
--- a/framework/java/android/app/StatsManager.java
+++ b/framework/java/android/app/StatsManager.java
@@ -134,6 +134,7 @@ public final class StatsManager {
/**
* Adds the given configuration and associates it with the given configKey. If a config with the
* given configKey already exists for the caller's uid, it is replaced with the new one.
+ * This call can block on statsd.
*
* @param configKey An arbitrary integer that allows clients to track the configuration.
* @param config Wire-encoded StatsdConfig proto that specifies metrics (and all
@@ -178,6 +179,8 @@ public final class StatsManager {
/**
* Remove a configuration from logging.
*
+ * This call can block on statsd.
+ *
* @param configKey Configuration key to remove.
* @throws StatsUnavailableException if unsuccessful due to failing to connect to stats service
*/
@@ -235,6 +238,7 @@ public final class StatsManager {
* <p>
* This function can only be called by the owner (uid) of the config. It must be called each
* time statsd starts. The config must have been added first (via {@link #addConfig}).
+ * This call can block on statsd.
*
* @param pendingIntent the PendingIntent to use when broadcasting info to the subscriber
* associated with the given subscriberId. May be null, in which case
@@ -290,6 +294,7 @@ public final class StatsManager {
* statsd to send metrics data whenever statsd determines that the metrics in memory are
* approaching the memory limits. The fetch operation should call {@link #getReports} to fetch
* the data, which also deletes the retrieved metrics from statsd's memory.
+ * This call can block on statsd.
*
* @param pendingIntent the PendingIntent to use when broadcasting info to the subscriber
* associated with the given subscriberId. May be null, in which case
@@ -325,6 +330,7 @@ public final class StatsManager {
* statsd to inform clients that they should pull data of the configs that are currently
* active. The activeConfigsChangedOperation should set periodic alarms to pull data of configs
* that are active and stop pulling data of configs that are no longer active.
+ * This call can block on statsd.
*
* @param pendingIntent the PendingIntent to use when broadcasting info to the subscriber
* associated with the given subscriberId. May be null, in which case
@@ -375,6 +381,7 @@ public final class StatsManager {
/**
* Request the data collected for the given configKey.
* This getter is destructive - it also clears the retrieved metrics from statsd's memory.
+ * This call can block on statsd.
*
* @param configKey Configuration key to retrieve data from.
* @return Serialized ConfigMetricsReportList proto.
@@ -416,6 +423,7 @@ public final class StatsManager {
* Clients can request metadata for statsd. Will contain stats across all configurations but not
* the actual metrics themselves (metrics must be collected via {@link #getReports(long)}.
* This getter is not destructive and will not reset any metrics/counters.
+ * This call can block on statsd.
*
* @return Serialized StatsdStatsReport proto.
* @throws StatsUnavailableException if unsuccessful due to failing to connect to stats service
@@ -455,6 +463,8 @@ public final class StatsManager {
/**
* Returns the experiments IDs registered with statsd, or an empty array if there aren't any.
*
+ * This call can block on statsd.
+ *
* @throws StatsUnavailableException if unsuccessful due to failing to connect to stats service
*/
@RequiresPermission(allOf = {DUMP, PACKAGE_USAGE_STATS})
diff --git a/framework/java/android/util/StatsEvent.java b/framework/java/android/util/StatsEvent.java
index a1988b8c..51676f95 100644
--- a/framework/java/android/util/StatsEvent.java
+++ b/framework/java/android/util/StatsEvent.java
@@ -586,7 +586,9 @@ public final class StatsEvent {
/**
* Write a repeated boolean field to this StatsEvent.
*
- * The list size must not exceed 127.
+ * The list size must not exceed 127. Otherwise, the array isn't written
+ * to the StatsEvent and ERROR_LIST_TOO_LONG is appended to the
+ * StatsEvent errors field.
*
* @param elements array of booleans.
**/
@@ -607,7 +609,9 @@ public final class StatsEvent {
/**
* Write a repeated int field to this StatsEvent.
*
- * The list size must not exceed 127.
+ * The list size must not exceed 127. Otherwise, the array isn't written
+ * to the StatsEvent and ERROR_LIST_TOO_LONG is appended to the
+ * StatsEvent errors field.
*
* @param elements array of ints.
**/
@@ -628,7 +632,9 @@ public final class StatsEvent {
/**
* Write a repeated long field to this StatsEvent.
*
- * The list size must not exceed 127.
+ * The list size must not exceed 127. Otherwise, the array isn't written
+ * to the StatsEvent and ERROR_LIST_TOO_LONG is appended to the
+ * StatsEvent errors field.
*
* @param elements array of longs.
**/
@@ -649,7 +655,9 @@ public final class StatsEvent {
/**
* Write a repeated float field to this StatsEvent.
*
- * The list size must not exceed 127.
+ * The list size must not exceed 127. Otherwise, the array isn't written
+ * to the StatsEvent and ERROR_LIST_TOO_LONG is appended to the
+ * StatsEvent errors field.
*
* @param elements array of floats.
**/
@@ -670,7 +678,9 @@ public final class StatsEvent {
/**
* Write a repeated string field to this StatsEvent.
*
- * The list size must not exceed 127.
+ * The list size must not exceed 127. Otherwise, the array isn't written
+ * to the StatsEvent and ERROR_LIST_TOO_LONG is appended to the
+ * StatsEvent errors field.
*
* @param elements array of strings.
**/
diff --git a/framework/java/android/util/StatsLog.java b/framework/java/android/util/StatsLog.java
index 80c027b3..28884c16 100644
--- a/framework/java/android/util/StatsLog.java
+++ b/framework/java/android/util/StatsLog.java
@@ -250,13 +250,4 @@ public final class StatsLog {
writeImpl(statsEvent.getBytes(), statsEvent.getNumBytes(), statsEvent.getAtomId());
statsEvent.release();
}
-
- private static void enforceDumpCallingPermission(Context context) {
- context.enforceCallingPermission(android.Manifest.permission.DUMP, "Need DUMP permission.");
- }
-
- private static void enforcesageStatsCallingPermission(Context context) {
- context.enforceCallingPermission(Manifest.permission.PACKAGE_USAGE_STATS,
- "Need PACKAGE_USAGE_STATS permission.");
- }
}
diff --git a/framework/test/src/android/os/StatsDimensionsValueTest.java b/framework/test/src/android/os/StatsDimensionsValueTest.java
index db25911e..8b956a61 100644
--- a/framework/test/src/android/os/StatsDimensionsValueTest.java
+++ b/framework/test/src/android/os/StatsDimensionsValueTest.java
@@ -88,6 +88,14 @@ public final class StatsDimensionsValueTest {
assertThat(sdvChildren.get(3).getFloatValue()).isEqualTo(floatValue);
assertThat(sdvChildren.get(4).getBooleanValue()).isEqualTo(boolValue);
+ // Try to get wrong types, ensure that the default values are returned
+ assertThat(sdvChildren.get(0).getIntValue()).isEqualTo(0);
+ assertThat(sdvChildren.get(0).getLongValue()).isEqualTo(0);
+ assertThat(sdvChildren.get(0).getBooleanValue()).isEqualTo(false);
+ assertThat(sdvChildren.get(0).getFloatValue()).isEqualTo(0F);
+ assertThat(sdvChildren.get(0).getTupleValueList()).isNull();
+ assertThat(sdvChildren.get(1).getTupleValueList()).isNull();
+
// Ensure that StatsDimensionsValue and StatsDimensionsValueParcel are
// parceled equivalently
Parcel sdvpParcel = Parcel.obtain();
diff --git a/lib/libstatspull/Android.bp b/lib/libstatspull/Android.bp
index bf00942e..c0bc46d7 100644
--- a/lib/libstatspull/Android.bp
+++ b/lib/libstatspull/Android.bp
@@ -52,7 +52,6 @@ cc_library {
name: "libstatspull",
defaults: [
"libstatspull_defaults",
- "libbinder_ndk_host_user",
],
host_supported: true,
target: {
@@ -66,6 +65,9 @@ cc_library {
enabled: false,
},
},
+ darwin: {
+ enabled: false,
+ },
},
// enumerate stable entry points for APEX use
stubs: {
diff --git a/service/Android.bp b/service/Android.bp
index 21338b28..bad74ce7 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -45,4 +45,5 @@ java_library {
"test_com.android.os.statsd",
],
min_sdk_version: "30",
+ installable: true,
}
diff --git a/service/java/com/android/server/stats/StatsCompanionService.java b/service/java/com/android/server/stats/StatsCompanionService.java
index e55742b9..83847d81 100644
--- a/service/java/com/android/server/stats/StatsCompanionService.java
+++ b/service/java/com/android/server/stats/StatsCompanionService.java
@@ -103,7 +103,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
private static IStatsd sStatsd;
private static final Object sStatsdLock = new Object();
- private final OnAlarmListener mAnomalyAlarmListener;
private final OnAlarmListener mPullingAlarmListener;
private final OnAlarmListener mPeriodicAlarmListener;
@@ -127,27 +126,10 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
handlerThread.start();
mHandler = new CompanionHandler(handlerThread.getLooper());
- mAnomalyAlarmListener = new AnomalyAlarmListener(context);
mPullingAlarmListener = new PullingAlarmListener(context);
mPeriodicAlarmListener = new PeriodicAlarmListener(context);
}
- private final static int[] toIntArray(List<Integer> list) {
- int[] ret = new int[list.size()];
- for (int i = 0; i < ret.length; i++) {
- ret[i] = list.get(i);
- }
- return ret;
- }
-
- private final static long[] toLongArray(List<Long> list) {
- long[] ret = new long[list.size()];
- for (int i = 0; i < ret.length; i++) {
- ret[i] = list.get(i);
- }
- return ret;
- }
-
/**
* Non-blocking call to retrieve a reference to statsd
*
@@ -357,41 +339,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
}
}
- public static final class AnomalyAlarmListener implements OnAlarmListener {
- private final Context mContext;
-
- AnomalyAlarmListener(Context context) {
- mContext = context;
- }
-
- @Override
- public void onAlarm() {
- if (DEBUG) {
- Log.i(TAG, "StatsCompanionService believes an anomaly has occurred at time "
- + System.currentTimeMillis() + "ms.");
- }
- IStatsd statsd = getStatsdNonblocking();
- if (statsd == null) {
- Log.w(TAG, "Could not access statsd to inform it of anomaly alarm firing");
- return;
- }
-
- // Wakelock needs to be retained while calling statsd.
- Thread thread = new WakelockThread(mContext,
- AnomalyAlarmListener.class.getCanonicalName(), new Runnable() {
- @Override
- public void run() {
- try {
- statsd.informAnomalyAlarmFired();
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to inform statsd of anomaly alarm firing", e);
- }
- }
- });
- thread.start();
- }
- }
-
public final static class PullingAlarmListener implements OnAlarmListener {
private final Context mContext;
@@ -490,32 +437,12 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
}
@Override // Binder call
- public void setAnomalyAlarm(long timestampMs) {
- StatsCompanion.enforceStatsdCallingUid();
- if (DEBUG) Log.d(TAG, "Setting anomaly alarm for " + timestampMs);
- final long callingToken = Binder.clearCallingIdentity();
- try {
- // using ELAPSED_REALTIME, not ELAPSED_REALTIME_WAKEUP, so if device is asleep, will
- // only fire when it awakens.
- // AlarmManager will automatically cancel any previous mAnomalyAlarmListener alarm.
- mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME, timestampMs, TAG + ".anomaly",
- mAnomalyAlarmListener, mHandler);
- } finally {
- Binder.restoreCallingIdentity(callingToken);
- }
- }
+ // Unused, but keep the IPC due to the bootstrap apex issue on R.
+ public void setAnomalyAlarm(long timestampMs) {}
@Override // Binder call
- public void cancelAnomalyAlarm() {
- StatsCompanion.enforceStatsdCallingUid();
- if (DEBUG) Log.d(TAG, "Cancelling anomaly alarm");
- final long callingToken = Binder.clearCallingIdentity();
- try {
- mAlarmManager.cancel(mAnomalyAlarmListener);
- } finally {
- Binder.restoreCallingIdentity(callingToken);
- }
- }
+ // Unused, but keep the IPC due to the bootstrap apex issue on R.
+ public void cancelAnomalyAlarm() {}
@Override // Binder call
public void setAlarmForSubscriberTriggering(long timestampMs) {
@@ -697,11 +624,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
return;
}
- // Cleann up from previous statsd - cancel any alarms that had been set. Do this here
- // instead of in binder death because statsd can come back and set different alarms, or not
- // want to set an alarm when it had been set. This guarantees that when we get a new statsd,
- // we cancel any alarms before it is able to set them.
- cancelAnomalyAlarm();
+ // Cleann up from previous statsd - cancel any alarms that had been set.
+ // Do this here instead of in binder death because statsd can come back
+ // and set different alarms, or not want to set an alarm when it had
+ // been set. This guarantees that when we get a new statsd, we cancel
+ // any alarms before it is able to set them.
cancelPullingAlarm();
cancelAlarmForSubscriberTriggering();
diff --git a/statsd/src/FieldValue.cpp b/statsd/src/FieldValue.cpp
index c9ccfb93..9e4e4504 100644
--- a/statsd/src/FieldValue.cpp
+++ b/statsd/src/FieldValue.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
#include "FieldValue.h"
#include "HashableDimensionKey.h"
@@ -415,6 +415,33 @@ double Value::getDouble() const {
}
}
+size_t Value::getSize() const {
+ size_t size = 0;
+ switch (type) {
+ case INT:
+ size = sizeof(int32_t);
+ break;
+ case LONG:
+ size = sizeof(int64_t);
+ break;
+ case FLOAT:
+ size = sizeof(float);
+ break;
+ case DOUBLE:
+ size = sizeof(double);
+ break;
+ case STRING:
+ size = sizeof(char) * str_value.length();
+ break;
+ case STORAGE:
+ size = sizeof(uint8_t) * storage_value.size();
+ break;
+ default:
+ break;
+ }
+ return size;
+}
+
bool equalDimensions(const std::vector<Matcher>& dimension_a,
const std::vector<Matcher>& dimension_b) {
bool eq = dimension_a.size() == dimension_b.size();
@@ -469,6 +496,14 @@ bool HasPositionALL(const FieldMatcher& matcher) {
return false;
}
+size_t getSize(const std::vector<FieldValue>& fieldValues) {
+ size_t totalSize = 0;
+ for (const FieldValue& fieldValue : fieldValues) {
+ totalSize += fieldValue.getSize();
+ }
+ return totalSize;
+}
+
} // namespace statsd
} // namespace os
} // namespace android
diff --git a/statsd/src/FieldValue.h b/statsd/src/FieldValue.h
index 538d7428..81fe28c5 100644
--- a/statsd/src/FieldValue.h
+++ b/statsd/src/FieldValue.h
@@ -161,6 +161,10 @@ public:
return getDepth() >= depth && getRawPosAtDepth(depth) == kLastBitMask;
}
+ inline size_t getSize() const {
+ return sizeof(mField) + sizeof(mTag);
+ }
+
inline bool operator==(const Field& that) const {
return mTag == that.getTag() && mField == that.getField();
};
@@ -345,6 +349,8 @@ struct Value {
double getDouble() const;
+ size_t getSize() const;
+
Value(const Value& from);
bool operator==(const Value& that) const;
@@ -433,6 +439,10 @@ struct FieldValue {
return false;
}
+ size_t getSize() const {
+ return mField.getSize() + mValue.getSize();
+ }
+
Field mField;
Value mValue;
Annotations mAnnotations;
@@ -457,6 +467,10 @@ bool equalDimensions(const std::vector<Matcher>& dimension_a,
// Returns true if dimension_a is a subset of dimension_b.
bool subsetDimensions(const std::vector<Matcher>& dimension_a,
const std::vector<Matcher>& dimension_b);
+
+// Estimate the memory size of the FieldValues. This is different from sizeof(FieldValue) because
+// the size is computed at runtime using the actual contents stored in the FieldValue.
+size_t getSize(const std::vector<FieldValue>& fieldValues);
} // namespace statsd
} // namespace os
} // namespace android
diff --git a/statsd/src/HashableDimensionKey.cpp b/statsd/src/HashableDimensionKey.cpp
index bceaf9d2..c1b250a1 100644
--- a/statsd/src/HashableDimensionKey.cpp
+++ b/statsd/src/HashableDimensionKey.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "HashableDimensionKey.h"
diff --git a/statsd/src/Log.h b/statsd/src/Log.h
index 87f4cbaf..c00dc07f 100644
--- a/statsd/src/Log.h
+++ b/statsd/src/Log.h
@@ -28,6 +28,6 @@
// Use the local value to turn on/off debug logs instead of using log.tag. properties.
// The advantage is that in production compiler can remove the logging code if the local
-// DEBUG/VERBOSE is false.
+// STATSD_DEBUG/VERBOSE is false.
#define VLOG(...) \
- if (DEBUG) ALOGD(__VA_ARGS__);
+ if (STATSD_DEBUG) ALOGD(__VA_ARGS__);
diff --git a/statsd/src/StatsLogProcessor.cpp b/statsd/src/StatsLogProcessor.cpp
index d5ee388a..10d21121 100644
--- a/statsd/src/StatsLogProcessor.cpp
+++ b/statsd/src/StatsLogProcessor.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StatsLogProcessor.h"
diff --git a/statsd/src/StatsService.cpp b/statsd/src/StatsService.cpp
index 4770a539..00370577 100644
--- a/statsd/src/StatsService.cpp
+++ b/statsd/src/StatsService.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StatsService.h"
diff --git a/statsd/src/anomaly/AlarmMonitor.cpp b/statsd/src/anomaly/AlarmMonitor.cpp
index b632d040..4822b541 100644
--- a/statsd/src/anomaly/AlarmMonitor.cpp
+++ b/statsd/src/anomaly/AlarmMonitor.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
#include "anomaly/AlarmMonitor.h"
diff --git a/statsd/src/anomaly/AlarmTracker.cpp b/statsd/src/anomaly/AlarmTracker.cpp
index 6d9beb8f..e8c70fa5 100644
--- a/statsd/src/anomaly/AlarmTracker.cpp
+++ b/statsd/src/anomaly/AlarmTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "anomaly/AlarmTracker.h"
diff --git a/statsd/src/anomaly/AnomalyTracker.cpp b/statsd/src/anomaly/AnomalyTracker.cpp
index 6aa410b1..68dc0aa0 100644
--- a/statsd/src/anomaly/AnomalyTracker.cpp
+++ b/statsd/src/anomaly/AnomalyTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "AnomalyTracker.h"
diff --git a/statsd/src/anomaly/DurationAnomalyTracker.cpp b/statsd/src/anomaly/DurationAnomalyTracker.cpp
index 2b568101..66c71ad5 100644
--- a/statsd/src/anomaly/DurationAnomalyTracker.cpp
+++ b/statsd/src/anomaly/DurationAnomalyTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "DurationAnomalyTracker.h"
diff --git a/statsd/src/anomaly/subscriber_util.cpp b/statsd/src/anomaly/subscriber_util.cpp
index 5a4a41d0..34f33205 100644
--- a/statsd/src/anomaly/subscriber_util.cpp
+++ b/statsd/src/anomaly/subscriber_util.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "external/Perfetto.h"
diff --git a/statsd/src/condition/CombinationConditionTracker.cpp b/statsd/src/condition/CombinationConditionTracker.cpp
index 4574b2e3..7a97ab39 100644
--- a/statsd/src/condition/CombinationConditionTracker.cpp
+++ b/statsd/src/condition/CombinationConditionTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "CombinationConditionTracker.h"
diff --git a/statsd/src/condition/SimpleConditionTracker.cpp b/statsd/src/condition/SimpleConditionTracker.cpp
index 1398c3eb..66ce961f 100644
--- a/statsd/src/condition/SimpleConditionTracker.cpp
+++ b/statsd/src/condition/SimpleConditionTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "SimpleConditionTracker.h"
@@ -249,7 +249,7 @@ void SimpleConditionTracker::handleConditionEvent(const HashableDimensionKey& ou
}
// dump all dimensions for debugging
- if (DEBUG) {
+ if (STATSD_DEBUG) {
dumpState();
}
diff --git a/statsd/src/config/ConfigManager.cpp b/statsd/src/config/ConfigManager.cpp
index d839e024..1a76cb88 100644
--- a/statsd/src/config/ConfigManager.cpp
+++ b/statsd/src/config/ConfigManager.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "config/ConfigManager.h"
diff --git a/statsd/src/external/Perfetto.cpp b/statsd/src/external/Perfetto.cpp
index b9ccfd2b..86c8d7a8 100644
--- a/statsd/src/external/Perfetto.cpp
+++ b/statsd/src/external/Perfetto.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "config/ConfigKey.h"
#include "Log.h"
diff --git a/statsd/src/external/StatsCallbackPuller.cpp b/statsd/src/external/StatsCallbackPuller.cpp
index 49864710..7d5d04b1 100644
--- a/statsd/src/external/StatsCallbackPuller.cpp
+++ b/statsd/src/external/StatsCallbackPuller.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StatsCallbackPuller.h"
diff --git a/statsd/src/external/StatsPuller.cpp b/statsd/src/external/StatsPuller.cpp
index b8e4abc7..395e660e 100644
--- a/statsd/src/external/StatsPuller.cpp
+++ b/statsd/src/external/StatsPuller.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StatsPuller.h"
diff --git a/statsd/src/external/StatsPullerManager.cpp b/statsd/src/external/StatsPullerManager.cpp
index c8c09b42..90e1cd0e 100644
--- a/statsd/src/external/StatsPullerManager.cpp
+++ b/statsd/src/external/StatsPullerManager.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
#include "StatsPullerManager.h"
diff --git a/statsd/src/external/TrainInfoPuller.cpp b/statsd/src/external/TrainInfoPuller.cpp
index 9273788d..f2a55d9b 100644
--- a/statsd/src/external/TrainInfoPuller.cpp
+++ b/statsd/src/external/TrainInfoPuller.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "external/StatsPuller.h"
diff --git a/statsd/src/external/puller_util.cpp b/statsd/src/external/puller_util.cpp
index 3076ce36..dc7cdce9 100644
--- a/statsd/src/external/puller_util.cpp
+++ b/statsd/src/external/puller_util.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "puller_util.h"
diff --git a/statsd/src/guardrail/StatsdStats.cpp b/statsd/src/guardrail/StatsdStats.cpp
index 000ac81d..0e660190 100644
--- a/statsd/src/guardrail/StatsdStats.cpp
+++ b/statsd/src/guardrail/StatsdStats.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StatsdStats.h"
diff --git a/statsd/src/logd/LogEvent.cpp b/statsd/src/logd/LogEvent.cpp
index c4f15ad6..e89d067b 100644
--- a/statsd/src/logd/LogEvent.cpp
+++ b/statsd/src/logd/LogEvent.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "logd/LogEvent.h"
#include <android-base/stringprintf.h>
diff --git a/statsd/src/logd/LogEventQueue.cpp b/statsd/src/logd/LogEventQueue.cpp
index 146464bb..96b7f015 100644
--- a/statsd/src/logd/LogEventQueue.cpp
+++ b/statsd/src/logd/LogEventQueue.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "LogEventQueue.h"
diff --git a/statsd/src/main.cpp b/statsd/src/main.cpp
index df723c64..01e1e924 100644
--- a/statsd/src/main.cpp
+++ b/statsd/src/main.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StatsService.h"
diff --git a/statsd/src/matchers/SimpleAtomMatchingTracker.cpp b/statsd/src/matchers/SimpleAtomMatchingTracker.cpp
index 423da5bd..76bd4761 100644
--- a/statsd/src/matchers/SimpleAtomMatchingTracker.cpp
+++ b/statsd/src/matchers/SimpleAtomMatchingTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "SimpleAtomMatchingTracker.h"
diff --git a/statsd/src/matchers/matcher_util.cpp b/statsd/src/matchers/matcher_util.cpp
index 4ea117fa..68c11592 100644
--- a/statsd/src/matchers/matcher_util.cpp
+++ b/statsd/src/matchers/matcher_util.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "src/statsd_config.pb.h"
diff --git a/statsd/src/metrics/CountMetricProducer.cpp b/statsd/src/metrics/CountMetricProducer.cpp
index 5896754f..434bba70 100644
--- a/statsd/src/metrics/CountMetricProducer.cpp
+++ b/statsd/src/metrics/CountMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "CountMetricProducer.h"
diff --git a/statsd/src/metrics/DurationMetricProducer.cpp b/statsd/src/metrics/DurationMetricProducer.cpp
index 569618cd..add5fa43 100644
--- a/statsd/src/metrics/DurationMetricProducer.cpp
+++ b/statsd/src/metrics/DurationMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
diff --git a/statsd/src/metrics/EventMetricProducer.cpp b/statsd/src/metrics/EventMetricProducer.cpp
index cf994f46..502ea8ad 100644
--- a/statsd/src/metrics/EventMetricProducer.cpp
+++ b/statsd/src/metrics/EventMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "EventMetricProducer.h"
@@ -77,6 +77,7 @@ EventMetricProducer::EventMetricProducer(
}
mConditionSliced = true;
}
+ mTotalSize = 0;
VLOG("metric %lld created. bucket size %lld start_time: %lld", (long long)metric.id(),
(long long)mBucketSizeNs, (long long)mTimeBaseNs);
}
@@ -128,6 +129,7 @@ bool EventMetricProducer::onConfigUpdatedLocked(
void EventMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
mAggregatedAtoms.clear();
+ mTotalSize = 0;
StatsdStats::getInstance().noteBucketDropped(mMetricId);
}
@@ -154,6 +156,7 @@ std::unique_ptr<std::vector<uint8_t>> serializeProtoLocked(ProtoOutputStream& pr
void EventMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) {
mAggregatedAtoms.clear();
+ mTotalSize = 0;
}
void EventMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
@@ -186,6 +189,7 @@ void EventMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
protoOutput->end(protoToken);
if (erase_data) {
mAggregatedAtoms.clear();
+ mTotalSize = 0;
}
}
@@ -207,16 +211,15 @@ void EventMetricProducer::onMatchedLogEventInternalLocked(
AtomDimensionKey key(event.GetTagId(), HashableDimensionKey(event.getValues()));
std::vector<int64_t>& aggregatedTimestampsNs = mAggregatedAtoms[key];
+ if (aggregatedTimestampsNs.empty()) {
+ mTotalSize += getSize(key.getAtomFieldValues().getValues());
+ }
aggregatedTimestampsNs.push_back(elapsedTimeNs);
+ mTotalSize += sizeof(int64_t); // Add the size of the event timestamp
}
size_t EventMetricProducer::byteSizeLocked() const {
- size_t totalSize = 0;
- for (const auto& [atomDimensionKey, elapsedTimestampsNs] : mAggregatedAtoms) {
- totalSize += sizeof(FieldValue) * atomDimensionKey.getAtomFieldValues().getValues().size();
- totalSize += sizeof(int64_t) * elapsedTimestampsNs.size();
- }
- return totalSize;
+ return mTotalSize;
}
} // namespace statsd
diff --git a/statsd/src/metrics/EventMetricProducer.h b/statsd/src/metrics/EventMetricProducer.h
index 2e3b2e63..76747b67 100644
--- a/statsd/src/metrics/EventMetricProducer.h
+++ b/statsd/src/metrics/EventMetricProducer.h
@@ -96,6 +96,7 @@ private:
// Maps the field/value pairs of an atom to a list of timestamps used to deduplicate atoms.
std::unordered_map<AtomDimensionKey, std::vector<int64_t>> mAggregatedAtoms;
+ size_t mTotalSize;
};
} // namespace statsd
diff --git a/statsd/src/metrics/GaugeMetricProducer.cpp b/statsd/src/metrics/GaugeMetricProducer.cpp
index da54a9e6..b4fbe172 100644
--- a/statsd/src/metrics/GaugeMetricProducer.cpp
+++ b/statsd/src/metrics/GaugeMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "GaugeMetricProducer.h"
diff --git a/statsd/src/metrics/KllMetricProducer.cpp b/statsd/src/metrics/KllMetricProducer.cpp
index 8897c51b..5fe08fc7 100644
--- a/statsd/src/metrics/KllMetricProducer.cpp
+++ b/statsd/src/metrics/KllMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "KllMetricProducer.h"
diff --git a/statsd/src/metrics/MetricProducer.cpp b/statsd/src/metrics/MetricProducer.cpp
index 6c7b8d5c..9a00c87f 100644
--- a/statsd/src/metrics/MetricProducer.cpp
+++ b/statsd/src/metrics/MetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "MetricProducer.h"
diff --git a/statsd/src/metrics/MetricsManager.cpp b/statsd/src/metrics/MetricsManager.cpp
index 53eab968..7c8d9b79 100644
--- a/statsd/src/metrics/MetricsManager.cpp
+++ b/statsd/src/metrics/MetricsManager.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "MetricsManager.h"
@@ -281,7 +281,7 @@ void MetricsManager::initAllowedLogSources() {
auto uids = mUidMap->getAppUid(pkg);
mAllowedLogSources.insert(uids.begin(), uids.end());
}
- if (DEBUG) {
+ if (STATSD_DEBUG) {
for (const auto& uid : mAllowedLogSources) {
VLOG("Allowed uid %d", uid);
}
diff --git a/statsd/src/metrics/NumericValueMetricProducer.cpp b/statsd/src/metrics/NumericValueMetricProducer.cpp
index 2660c0c0..fd2e207a 100644
--- a/statsd/src/metrics/NumericValueMetricProducer.cpp
+++ b/statsd/src/metrics/NumericValueMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "NumericValueMetricProducer.h"
diff --git a/statsd/src/metrics/ValueMetricProducer.cpp b/statsd/src/metrics/ValueMetricProducer.cpp
index ba2e88e2..530de931 100644
--- a/statsd/src/metrics/ValueMetricProducer.cpp
+++ b/statsd/src/metrics/ValueMetricProducer.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "ValueMetricProducer.h"
diff --git a/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp b/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp
index 0ee5e46d..0e93c283 100644
--- a/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp
+++ b/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
#include "MaxDurationTracker.h"
diff --git a/statsd/src/metrics/duration_helper/OringDurationTracker.cpp b/statsd/src/metrics/duration_helper/OringDurationTracker.cpp
index b67e25c4..b9dafda3 100644
--- a/statsd/src/metrics/duration_helper/OringDurationTracker.cpp
+++ b/statsd/src/metrics/duration_helper/OringDurationTracker.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
#include "OringDurationTracker.h"
#include "guardrail/StatsdStats.h"
diff --git a/statsd/src/metrics/parsing_utils/config_update_utils.cpp b/statsd/src/metrics/parsing_utils/config_update_utils.cpp
index 9fd30b62..f1361244 100644
--- a/statsd/src/metrics/parsing_utils/config_update_utils.cpp
+++ b/statsd/src/metrics/parsing_utils/config_update_utils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "config_update_utils.h"
diff --git a/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp b/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp
index efb456df..cde81015 100644
--- a/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp
+++ b/statsd/src/metrics/parsing_utils/metrics_manager_util.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "metrics_manager_util.h"
diff --git a/statsd/src/packages/UidMap.cpp b/statsd/src/packages/UidMap.cpp
index 121c7a0f..69584b58 100644
--- a/statsd/src/packages/UidMap.cpp
+++ b/statsd/src/packages/UidMap.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "hash.h"
diff --git a/statsd/src/shell/ShellSubscriber.cpp b/statsd/src/shell/ShellSubscriber.cpp
index 9d8f0c24..35e64e47 100644
--- a/statsd/src/shell/ShellSubscriber.cpp
+++ b/statsd/src/shell/ShellSubscriber.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "ShellSubscriber.h"
diff --git a/statsd/src/socket/StatsSocketListener.cpp b/statsd/src/socket/StatsSocketListener.cpp
index b877cc9c..7b465735 100755
--- a/statsd/src/socket/StatsSocketListener.cpp
+++ b/statsd/src/socket/StatsSocketListener.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include <ctype.h>
diff --git a/statsd/src/state/StateManager.cpp b/statsd/src/state/StateManager.cpp
index 367f3d86..c488d044 100644
--- a/statsd/src/state/StateManager.cpp
+++ b/statsd/src/state/StateManager.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "StateManager.h"
diff --git a/statsd/src/state/StateTracker.cpp b/statsd/src/state/StateTracker.cpp
index 60726947..719ff3f2 100644
--- a/statsd/src/state/StateTracker.cpp
+++ b/statsd/src/state/StateTracker.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG true // STOPSHIP if true
+#define STATSD_DEBUG true // STOPSHIP if true
#include "Log.h"
#include "stats_util.h"
diff --git a/statsd/src/statscompanion_util.cpp b/statsd/src/statscompanion_util.cpp
index ce07ec0e..75de24f5 100644
--- a/statsd/src/statscompanion_util.cpp
+++ b/statsd/src/statscompanion_util.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "statscompanion_util.h"
diff --git a/statsd/src/storage/StorageManager.cpp b/statsd/src/storage/StorageManager.cpp
index 782b020b..b3e8d8a1 100644
--- a/statsd/src/storage/StorageManager.cpp
+++ b/statsd/src/storage/StorageManager.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "android-base/stringprintf.h"
diff --git a/statsd/src/subscriber/IncidentdReporter.cpp b/statsd/src/subscriber/IncidentdReporter.cpp
index 1d77513d..09ef325f 100644
--- a/statsd/src/subscriber/IncidentdReporter.cpp
+++ b/statsd/src/subscriber/IncidentdReporter.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false
+#define STATSD_DEBUG false
#include "Log.h"
#include "FieldValue.h"
diff --git a/statsd/src/subscriber/SubscriberReporter.cpp b/statsd/src/subscriber/SubscriberReporter.cpp
index c6bdc3fe..2fb5c761 100644
--- a/statsd/src/subscriber/SubscriberReporter.cpp
+++ b/statsd/src/subscriber/SubscriberReporter.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "Log.h"
#include "SubscriberReporter.h"
diff --git a/statsd/src/utils/MultiConditionTrigger.cpp b/statsd/src/utils/MultiConditionTrigger.cpp
index 43a69337..5ef50ee0 100644
--- a/statsd/src/utils/MultiConditionTrigger.cpp
+++ b/statsd/src/utils/MultiConditionTrigger.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#define DEBUG false // STOPSHIP if true
+#define STATSD_DEBUG false // STOPSHIP if true
#include "MultiConditionTrigger.h"
diff --git a/statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java b/statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java
index 1fe788e5..ba2d452e 100644
--- a/statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java
+++ b/statsd/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java
@@ -75,6 +75,7 @@ public class TestDrive {
"com.google.android.cellbroadcastreceiver",
"com.google.android.apps.nexuslauncher",
"AID_KEYSTORE",
+ "AID_VIRTUALIZATIONSERVICE",
};
private static final String[] DEFAULT_PULL_SOURCES = {
"AID_KEYSTORE",
diff --git a/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java b/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
index ffcf99bc..41481392 100644
--- a/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
+++ b/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/AtomTests.java
@@ -465,26 +465,6 @@ public class AtomTests {
}
@Test
- public void testScreenBrightness() {
- Context context = InstrumentationRegistry.getContext();
- PowerManager pm = context.getSystemService(PowerManager.class);
- PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
- PowerManager.ACQUIRE_CAUSES_WAKEUP, "StatsdBrightnessTest");
- wl.acquire();
- sleep(500);
-
- setScreenBrightness(47);
- sleep(500);
- setScreenBrightness(100);
- sleep(500);
- setScreenBrightness(198);
- sleep(500);
-
-
- wl.release();
- }
-
- @Test
public void testSyncState() throws Exception {
Context context = InstrumentationRegistry.getContext();
@@ -680,40 +660,6 @@ public class AtomTests {
Log.i(TAG, "The answer is " + timestamp);
}
- @Test
- public void testWriteRawTestAtom() throws Exception {
- Context context = InstrumentationRegistry.getTargetContext();
- ApplicationInfo appInfo = context.getPackageManager()
- .getApplicationInfo(context.getPackageName(), 0);
- int[] uids = {1234, appInfo.uid};
- String[] tags = {"tag1", "tag2"};
- byte[] experimentIds = {8, 1, 8, 2, 8, 3}; // Corresponds to 1, 2, 3.
- StatsLogStatsdCts.write(StatsLogStatsdCts.TEST_ATOM_REPORTED, uids, tags, 42,
- Long.MAX_VALUE, 3.14f, "This is a basic test!", false,
- StatsLogStatsdCts.TEST_ATOM_REPORTED__STATE__ON, experimentIds);
-
- // All nulls. Should get dropped since cts app is not in the attribution chain.
- StatsLogStatsdCts.write(StatsLogStatsdCts.TEST_ATOM_REPORTED, null, null, 0, 0,
- 0f, null, false, StatsLogStatsdCts.TEST_ATOM_REPORTED__STATE__ON, null);
-
- // Null tag in attribution chain.
- int[] uids2 = {9999, appInfo.uid};
- String[] tags2 = {"tag9999", null};
- StatsLogStatsdCts.write(StatsLogStatsdCts.TEST_ATOM_REPORTED, uids2, tags2, 100,
- Long.MIN_VALUE, -2.5f, "Test null uid", true,
- StatsLogStatsdCts.TEST_ATOM_REPORTED__STATE__UNKNOWN, experimentIds);
-
- // Non chained non-null
- StatsLogStatsdCts.write_non_chained(StatsLogStatsdCts.TEST_ATOM_REPORTED,
- appInfo.uid, "tag1", -256, -1234567890L, 42.01f, "Test non chained", true,
- StatsLogStatsdCts.TEST_ATOM_REPORTED__STATE__OFF, experimentIds);
-
- // Non chained all null
- StatsLogStatsdCts.write_non_chained(StatsLogStatsdCts.TEST_ATOM_REPORTED, appInfo.uid, null,
- 0, 0, 0f, null, true, StatsLogStatsdCts.TEST_ATOM_REPORTED__STATE__OFF, null);
-
- }
-
/**
* Bring up and generate some traffic on cellular data connection.
*/
diff --git a/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/StatsFrameworkInitializerTests.java b/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/StatsFrameworkInitializerTests.java
new file mode 100644
index 00000000..317e8ac8
--- /dev/null
+++ b/tests/apps/statsdapp/src/com/android/server/cts/device/statsd/StatsFrameworkInitializerTests.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2022 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 com.android.server.cts.device.statsd;
+
+import android.os.StatsFrameworkInitializer;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+public class StatsFrameworkInitializerTests {
+ @Test
+ public void testRegisterServiceWrappers_expectFail() {
+ try {
+ StatsFrameworkInitializer.registerServiceWrappers();
+ fail("Expected exception when calling "
+ + "StatsFrameworkInitializer.registerServiceWrappers() outside of "
+ + "SystemServiceRegistry!");
+ } catch (IllegalStateException expected) {}
+ }
+}
diff --git a/tests/src/android/cts/statsd/validation/StatsFrameworkInitializerTest.java b/tests/src/android/cts/statsd/validation/StatsFrameworkInitializerTest.java
new file mode 100644
index 00000000..0ea332e2
--- /dev/null
+++ b/tests/src/android/cts/statsd/validation/StatsFrameworkInitializerTest.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2022 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.cts.statsd.validation;
+
+import android.cts.statsd.atom.DeviceAtomTestCase;
+
+public class StatsFrameworkInitializerTest extends DeviceAtomTestCase {
+
+ public void testStatsFrameworkInitializer_failsWhenCalledOutsideOfSystemServiceRegistry()
+ throws Exception {
+ runDeviceTests(DEVICE_SIDE_TEST_PACKAGE,
+ ".StatsFrameworkInitializerTests", "testRegisterServiceWrappers_expectFail");
+ }
+
+}